| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.BootstrapperApplicationApi |
| 4 | { |
| 5 | using System; |
| 6 | using System.CodeDom.Compiler; |
| 7 | using System.Runtime.InteropServices; |
| 8 | using System.Text; |
| 9 | |
| 10 | /// <summary> |
| 11 | /// Allows calls into the bootstrapper engine. |
| 12 | /// </summary> |
| 13 | [ComImport] |
| 14 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] |
| 15 | [Guid("6480D616-27A0-44D7-905B-81512C29C2FB")] |
| 16 | [GeneratedCodeAttribute("WixToolset.Bootstrapper.InteropCodeGenerator", "1.0.0.0")] |
| 17 | public interface IBootstrapperEngine |
| 18 | { |
| 19 | /// <summary> |
| 20 | /// See <see cref="IEngine.PackageCount"/>. |
| 21 | /// </summary> |
| 22 | void GetPackageCount( |
| 23 | [MarshalAs(UnmanagedType.U4)] out int pcPackages |
| 24 | ); |
| 25 | |
| 26 | /// <summary> |
| 27 | /// See <see cref="IEngine.GetVariableNumeric(string)"/>. |
| 28 | /// </summary> |
| 29 | [PreserveSig] |
| 30 | int GetVariableNumeric( |
| 31 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 32 | out long pllValue |
| 33 | ); |
| 34 | |
| 35 | /// <summary> |
| 36 | /// See <see cref="IEngine.GetVariableString(string)"/>. |
| 37 | /// </summary> |
| 38 | [PreserveSig] |
| 39 | int GetVariableString( |
| 40 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 41 | IntPtr wzValue, |
| 42 | ref IntPtr pcchValue |
| 43 | ); |
| 44 | |
| 45 | /// <summary> |
| 46 | /// See <see cref="IEngine.GetVariableVersion(string)"/>. |
| 47 | /// </summary> |
| 48 | [PreserveSig] |
| 49 | int GetVariableVersion( |
| 50 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 51 | IntPtr wzValue, |
| 52 | ref IntPtr pcchValue |
| 53 | ); |
| 54 | |
| 55 | /// <summary> |
| 56 | /// See <see cref="IEngine.FormatString(string)"/>. |
| 57 | /// </summary> |
| 58 | [PreserveSig] |
| 59 | int FormatString( |
| 60 | [MarshalAs(UnmanagedType.LPWStr)] string wzIn, |
| 61 | [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, |
| 62 | ref IntPtr pcchOut |
| 63 | ); |
| 64 | |
| 65 | /// <summary> |
| 66 | /// See <see cref="IEngine.EscapeString(string)"/>. |
| 67 | /// </summary> |
| 68 | [PreserveSig] |
| 69 | int EscapeString( |
| 70 | [MarshalAs(UnmanagedType.LPWStr)] string wzIn, |
| 71 | [MarshalAs(UnmanagedType.LPWStr), Out] StringBuilder wzOut, |
| 72 | ref IntPtr pcchOut |
| 73 | ); |
| 74 | |
| 75 | /// <summary> |
| 76 | /// See <see cref="IEngine.EvaluateCondition(string)"/>. |
| 77 | /// </summary> |
| 78 | void EvaluateCondition( |
| 79 | [MarshalAs(UnmanagedType.LPWStr)] string wzCondition, |
| 80 | [MarshalAs(UnmanagedType.Bool)] out bool pf |
| 81 | ); |
| 82 | |
| 83 | /// <summary> |
| 84 | /// See <see cref="IEngine.Log(LogLevel, string)"/>. |
| 85 | /// </summary> |
| 86 | void Log( |
| 87 | [MarshalAs(UnmanagedType.U4)] LogLevel level, |
| 88 | [MarshalAs(UnmanagedType.LPWStr)] string wzMessage |
| 89 | ); |
| 90 | |
| 91 | /// <summary> |
| 92 | /// See <see cref="IEngine.SendEmbeddedError(int, string, int)"/>. |
| 93 | /// </summary> |
| 94 | void SendEmbeddedError( |
| 95 | [MarshalAs(UnmanagedType.U4)] int dwErrorCode, |
| 96 | [MarshalAs(UnmanagedType.LPWStr)] string wzMessage, |
| 97 | [MarshalAs(UnmanagedType.U4)] int dwUIHint, |
| 98 | [MarshalAs(UnmanagedType.I4)] out int pnResult |
| 99 | ); |
| 100 | |
| 101 | /// <summary> |
| 102 | /// See <see cref="IEngine.SendEmbeddedProgress(int, int)"/>. |
| 103 | /// </summary> |
| 104 | void SendEmbeddedProgress( |
| 105 | [MarshalAs(UnmanagedType.U4)] int dwProgressPercentage, |
| 106 | [MarshalAs(UnmanagedType.U4)] int dwOverallProgressPercentage, |
| 107 | [MarshalAs(UnmanagedType.I4)] out int pnResult |
| 108 | ); |
| 109 | |
| 110 | /// <summary> |
| 111 | /// See <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/>. |
| 112 | /// </summary> |
| 113 | void SetUpdate( |
| 114 | [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, |
| 115 | [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, |
| 116 | [MarshalAs(UnmanagedType.U8)] long qwValue, |
| 117 | [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, |
| 118 | [MarshalAs(UnmanagedType.LPWStr)] string wzHash, |
| 119 | [MarshalAs(UnmanagedType.LPWStr)] string wzUpdatePackageId |
| 120 | ); |
| 121 | |
| 122 | /// <summary> |
| 123 | /// See <see cref="IEngine.SetLocalSource(string, string, string)"/>. |
| 124 | /// </summary> |
| 125 | void SetLocalSource( |
| 126 | [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, |
| 127 | [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, |
| 128 | [MarshalAs(UnmanagedType.LPWStr)] string wzPath |
| 129 | ); |
| 130 | |
| 131 | /// <summary> |
| 132 | /// See <see cref="IEngine.SetDownloadSource(string, string, string, string, string)"/>. |
| 133 | /// </summary> |
| 134 | void SetDownloadSource( |
| 135 | [MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId, |
| 136 | [MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId, |
| 137 | [MarshalAs(UnmanagedType.LPWStr)] string wzUrl, |
| 138 | [MarshalAs(UnmanagedType.LPWStr)] string wzUser, |
| 139 | [MarshalAs(UnmanagedType.LPWStr)] string wzPassword |
| 140 | ); |
| 141 | |
| 142 | /// <summary> |
| 143 | /// See <see cref="IEngine.SetVariableNumeric(string, long)"/>. |
| 144 | /// </summary> |
| 145 | void SetVariableNumeric( |
| 146 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 147 | long llValue |
| 148 | ); |
| 149 | |
| 150 | /// <summary> |
| 151 | /// See <see cref="IEngine.SetVariableString(string, string, bool)"/>. |
| 152 | /// </summary> |
| 153 | void SetVariableString( |
| 154 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 155 | IntPtr wzValue, |
| 156 | [MarshalAs(UnmanagedType.Bool)] bool fFormatted |
| 157 | ); |
| 158 | |
| 159 | /// <summary> |
| 160 | /// See <see cref="IEngine.SetVariableVersion(string, string)"/>. |
| 161 | /// </summary> |
| 162 | void SetVariableVersion( |
| 163 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 164 | IntPtr wzValue |
| 165 | ); |
| 166 | |
| 167 | /// <summary> |
| 168 | /// See <see cref="IEngine.CloseSplashScreen"/>. |
| 169 | /// </summary> |
| 170 | void CloseSplashScreen(); |
| 171 | |
| 172 | /// <summary> |
| 173 | /// See <see cref="IEngine.Detect(IntPtr)"/>. |
| 174 | /// </summary> |
| 175 | void Detect( |
| 176 | IntPtr hwndParent |
| 177 | ); |
| 178 | |
| 179 | /// <summary> |
| 180 | /// See <see cref="IEngine.Plan(LaunchAction)"/>. |
| 181 | /// </summary> |
| 182 | void Plan( |
| 183 | [MarshalAs(UnmanagedType.U4)] LaunchAction action |
| 184 | ); |
| 185 | |
| 186 | /// <summary> |
| 187 | /// See <see cref="IEngine.Elevate(IntPtr)"/>. |
| 188 | /// </summary> |
| 189 | [PreserveSig] |
| 190 | int Elevate( |
| 191 | IntPtr hwndParent |
| 192 | ); |
| 193 | |
| 194 | /// <summary> |
| 195 | /// See <see cref="IEngine.Apply(IntPtr)"/>. |
| 196 | /// </summary> |
| 197 | void Apply( |
| 198 | IntPtr hwndParent |
| 199 | ); |
| 200 | |
| 201 | /// <summary> |
| 202 | /// See <see cref="IEngine.Quit(int)"/>. |
| 203 | /// </summary> |
| 204 | void Quit( |
| 205 | [MarshalAs(UnmanagedType.U4)] int dwExitCode |
| 206 | ); |
| 207 | |
| 208 | /// <summary> |
| 209 | /// See <see cref="IEngine.LaunchApprovedExe(IntPtr, string, string, int)"/>. |
| 210 | /// </summary> |
| 211 | void LaunchApprovedExe( |
| 212 | IntPtr hwndParent, |
| 213 | [MarshalAs(UnmanagedType.LPWStr)] string wzApprovedExeForElevationId, |
| 214 | [MarshalAs(UnmanagedType.LPWStr)] string wzArguments, |
| 215 | [MarshalAs(UnmanagedType.U4)] int dwWaitForInputIdleTimeout |
| 216 | ); |
| 217 | |
| 218 | /// <summary> |
| 219 | /// Sets the URL to the update feed. |
| 220 | /// </summary> |
| 221 | void SetUpdateSource( |
| 222 | [MarshalAs(UnmanagedType.LPWStr)] string url |
| 223 | ); |
| 224 | |
| 225 | /// <summary> |
| 226 | /// See <see cref="IEngine.CompareVersions(string, string)"/>. |
| 227 | /// </summary> |
| 228 | void CompareVersions( |
| 229 | [MarshalAs(UnmanagedType.LPWStr)] string wzVersion1, |
| 230 | [MarshalAs(UnmanagedType.LPWStr)] string wzVersion2, |
| 231 | [MarshalAs(UnmanagedType.I4)] out int pnResult |
| 232 | ); |
| 233 | |
| 234 | /// <summary> |
| 235 | /// See <see cref="IEngine.GetRelatedBundleVariable(string, string)"/>. |
| 236 | /// </summary> |
| 237 | [PreserveSig] |
| 238 | int GetRelatedBundleVariable( |
| 239 | [MarshalAs(UnmanagedType.LPWStr)] string wzBundleId, |
| 240 | [MarshalAs(UnmanagedType.LPWStr)] string wzVariable, |
| 241 | IntPtr wzValue, |
| 242 | ref IntPtr pcchValue |
| 243 | ); |
| 244 | } |
| 245 | |
| 246 | /// <summary> |
| 247 | /// The installation action for the bundle or current package. |
| 248 | /// </summary> |
| 249 | public enum ActionState |
| 250 | { |
| 251 | /// <summary> |
| 252 | /// No action. |
| 253 | /// </summary> |
| 254 | None, |
| 255 | |
| 256 | /// <summary> |
| 257 | /// Uninstall action. |
| 258 | /// </summary> |
| 259 | Uninstall, |
| 260 | |
| 261 | /// <summary> |
| 262 | /// Install action. |
| 263 | /// </summary> |
| 264 | Install, |
| 265 | |
| 266 | /// <summary> |
| 267 | /// Modify action. |
| 268 | /// </summary> |
| 269 | Modify, |
| 270 | |
| 271 | /// <summary> |
| 272 | /// Repair action. |
| 273 | /// </summary> |
| 274 | Repair, |
| 275 | |
| 276 | /// <summary> |
| 277 | /// Minor upgrade action. |
| 278 | /// </summary> |
| 279 | MinorUpgrade, |
| 280 | } |
| 281 | |
| 282 | /// <summary> |
| 283 | /// The action for the bundle to perform. |
| 284 | /// </summary> |
| 285 | public enum LaunchAction |
| 286 | { |
| 287 | /// <summary> |
| 288 | /// Invalid action. |
| 289 | /// </summary> |
| 290 | Unknown, |
| 291 | |
| 292 | /// <summary> |
| 293 | /// Provide help information. |
| 294 | /// </summary> |
| 295 | Help, |
| 296 | |
| 297 | /// <summary> |
| 298 | /// Layout the bundle on disk, normally to prepare for offline installation. |
| 299 | /// </summary> |
| 300 | Layout, |
| 301 | |
| 302 | /// <summary> |
| 303 | /// Same as Uninstall, except it will always remove itself from the package cache and Add/Remove Programs. |
| 304 | /// This should only be used to remove corrupt bundles since it might not properly clean up its packages. |
| 305 | /// </summary> |
| 306 | UnsafeUninstall, |
| 307 | |
| 308 | /// <summary> |
| 309 | /// Uninstall the bundle. |
| 310 | /// </summary> |
| 311 | Uninstall, |
| 312 | |
| 313 | /// <summary> |
| 314 | /// Cache the bundle and its packages. |
| 315 | /// </summary> |
| 316 | Cache, |
| 317 | |
| 318 | /// <summary> |
| 319 | /// Install the bundle. |
| 320 | /// </summary> |
| 321 | Install, |
| 322 | |
| 323 | /// <summary> |
| 324 | /// Modify the bundle. |
| 325 | /// </summary> |
| 326 | Modify, |
| 327 | |
| 328 | /// <summary> |
| 329 | /// Repair the bundle |
| 330 | /// </summary> |
| 331 | Repair, |
| 332 | |
| 333 | /// <summary> |
| 334 | /// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/> and then exit without waiting for it to complete. |
| 335 | /// </summary> |
| 336 | UpdateReplace, |
| 337 | |
| 338 | /// <summary> |
| 339 | /// Launch the update registered with <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string, string)"/> as an embedded bundle. |
| 340 | /// </summary> |
| 341 | UpdateReplaceEmbedded, |
| 342 | } |
| 343 | |
| 344 | /// <summary> |
| 345 | /// The message log level. |
| 346 | /// </summary> |
| 347 | public enum LogLevel |
| 348 | { |
| 349 | /// <summary> |
| 350 | /// No logging level (generic). |
| 351 | /// </summary> |
| 352 | None, |
| 353 | |
| 354 | /// <summary> |
| 355 | /// User messages. |
| 356 | /// </summary> |
| 357 | Standard, |
| 358 | |
| 359 | /// <summary> |
| 360 | /// Verbose messages. |
| 361 | /// </summary> |
| 362 | Verbose, |
| 363 | |
| 364 | /// <summary> |
| 365 | /// Messages for debugging. |
| 366 | /// </summary> |
| 367 | Debug, |
| 368 | |
| 369 | /// <summary> |
| 370 | /// Error messages. |
| 371 | /// </summary> |
| 372 | Error, |
| 373 | } |
| 374 | |
| 375 | /// <summary> |
| 376 | /// Type of hash used for update bundle. |
| 377 | /// </summary> |
| 378 | public enum UpdateHashType |
| 379 | { |
| 380 | /// <summary> |
| 381 | /// No hash provided. |
| 382 | /// </summary> |
| 383 | None, |
| 384 | |
| 385 | /// <summary> |
| 386 | /// SHA-512 based hash provided. |
| 387 | /// </summary> |
| 388 | Sha512, |
| 389 | } |
| 390 | |
| 391 | /// <summary> |
| 392 | /// Describes the state of an installation package. |
| 393 | /// </summary> |
| 394 | public enum PackageState |
| 395 | { |
| 396 | /// <summary> |
| 397 | /// Invalid state. |
| 398 | /// </summary> |
| 399 | Unknown, |
| 400 | |
| 401 | /// <summary> |
| 402 | /// The package is not on the machine (except possibly MspPackage) and should not be installed. |
| 403 | /// </summary> |
| 404 | Obsolete, |
| 405 | |
| 406 | /// <summary> |
| 407 | /// The package is not installed. |
| 408 | /// </summary> |
| 409 | Absent, |
| 410 | |
| 411 | /// <summary> |
| 412 | /// The package is installed. |
| 413 | /// </summary> |
| 414 | Present, |
| 415 | |
| 416 | /// <summary> |
| 417 | /// The package is on the machine but not active, so only uninstall operations are allowed. |
| 418 | /// </summary> |
| 419 | Superseded, |
| 420 | |
| 421 | /// <summary> |
| 422 | /// This value is no longer used. See the DetectPackageCompleteEventArgs.Cached value instead. |
| 423 | /// </summary> |
| 424 | [Obsolete("Use DetectPackageCompleteEventArgs.Cached instead.")] |
| 425 | Cached = Present, |
| 426 | } |
| 427 | |
| 428 | /// <summary> |
| 429 | /// Indicates the state desired for an installation package. |
| 430 | /// </summary> |
| 431 | public enum RequestState |
| 432 | { |
| 433 | /// <summary> |
| 434 | /// No change requested. |
| 435 | /// </summary> |
| 436 | None, |
| 437 | |
| 438 | /// <summary> |
| 439 | /// As long as there are no dependents, the package will be uninstalled. |
| 440 | /// There are some packages that can't be uninstalled, such as an ExePackage without an UninstallCommand. |
| 441 | /// </summary> |
| 442 | ForceAbsent, |
| 443 | |
| 444 | /// <summary> |
| 445 | /// Request the package to not be installed on the machine. |
| 446 | /// </summary> |
| 447 | Absent, |
| 448 | |
| 449 | /// <summary> |
| 450 | /// Request the package to be cached and not be installed on the machine. |
| 451 | /// </summary> |
| 452 | Cache, |
| 453 | |
| 454 | /// <summary> |
| 455 | /// Request the package to be installed on the machine. |
| 456 | /// </summary> |
| 457 | Present, |
| 458 | |
| 459 | /// <summary> |
| 460 | /// Force the bundle to install the package. |
| 461 | /// </summary> |
| 462 | ForcePresent, |
| 463 | |
| 464 | /// <summary> |
| 465 | /// Request the package to be repaired. |
| 466 | /// </summary> |
| 467 | Repair, |
| 468 | } |
| 469 | |
| 470 | /// <summary> |
| 471 | /// Indicates the state of a feature. |
| 472 | /// See https://learn.microsoft.com/en-us/windows/win32/api/msi/nf-msi-msiqueryfeaturestatew. |
| 473 | /// </summary> |
| 474 | public enum FeatureState |
| 475 | { |
| 476 | /// <summary> |
| 477 | /// Invalid state. |
| 478 | /// </summary> |
| 479 | Unknown, |
| 480 | |
| 481 | /// <summary> |
| 482 | /// INSTALLSTATE_ABSENT |
| 483 | /// </summary> |
| 484 | Absent, |
| 485 | |
| 486 | /// <summary> |
| 487 | /// INSTALLSTATE_ADVERTISED |
| 488 | /// </summary> |
| 489 | Advertised, |
| 490 | |
| 491 | /// <summary> |
| 492 | /// INSTALLSTATE_LOCAL |
| 493 | /// </summary> |
| 494 | Local, |
| 495 | |
| 496 | /// <summary> |
| 497 | /// INSTALLSTATE_SOURCE |
| 498 | /// </summary> |
| 499 | Source, |
| 500 | } |
| 501 | } |