main
h 354 lines 11.4 KB
Raw
1 #pragma once
2 // 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.
3
4
5 #if defined(__cplusplus)
6 extern "C" {
7 #endif
8
9
10 // constants
11
12 const LPCWSTR BURN_POLICY_REGISTRY_PATH = L"WiX\\Burn";
13
14 const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT = L"parent";
15 const LPCWSTR BURN_COMMANDLINE_SWITCH_PARENT_NONE = L"parent:none";
16 const LPCWSTR BURN_COMMANDLINE_SWITCH_WORKING_DIRECTORY = L"burn.engine.working.directory";
17 const LPCWSTR BURN_COMMANDLINE_SWITCH_ELEVATED = L"burn.elevated";
18 const LPCWSTR BURN_COMMANDLINE_SWITCH_EMBEDDED = L"burn.embedded";
19 const LPCWSTR BURN_COMMANDLINE_SWITCH_RUNONCE = L"burn.runonce";
20 const LPCWSTR BURN_COMMANDLINE_SWITCH_LOG_APPEND = L"burn.log.append";
21 const LPCWSTR BURN_COMMANDLINE_SWITCH_LOG_MODE = L"burn.log.mode";
22 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_DETECT = L"burn.related.detect";
23 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_UPGRADE = L"burn.related.upgrade";
24 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_ADDON = L"burn.related.addon";
25 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_DEPENDENT_ADDON = L"burn.related.dependent.addon";
26 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_PATCH = L"burn.related.patch";
27 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_DEPENDENT_PATCH = L"burn.related.dependent.patch";
28 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_UPDATE = L"burn.related.update";
29 const LPCWSTR BURN_COMMANDLINE_SWITCH_RELATED_CHAIN_PACKAGE = L"burn.related.chain.package";
30 const LPCWSTR BURN_COMMANDLINE_SWITCH_PASSTHROUGH = L"burn.passthrough";
31 const LPCWSTR BURN_COMMANDLINE_SWITCH_DISABLE_UNELEVATE = L"burn.disable.unelevate";
32 const LPCWSTR BURN_COMMANDLINE_SWITCH_IGNOREDEPENDENCIES = L"burn.ignoredependencies";
33 const LPCWSTR BURN_COMMANDLINE_SWITCH_ANCESTORS = L"burn.ancestors";
34 const LPCWSTR BURN_COMMANDLINE_SWITCH_FILEHANDLE_ATTACHED = L"burn.filehandle.attached";
35 const LPCWSTR BURN_COMMANDLINE_SWITCH_FILEHANDLE_SELF = L"burn.filehandle.self";
36 const LPCWSTR BURN_COMMANDLINE_SWITCH_SPLASH_SCREEN = L"burn.splash.screen";
37 const LPCWSTR BURN_COMMANDLINE_SWITCH_SYSTEM_COMPONENT = L"burn.system.component";
38 const LPCWSTR BURN_COMMANDLINE_SWITCH_PREFIX = L"burn.";
39
40 const LPCWSTR BURN_BUNDLE_ACTION = L"WixBundleAction";
41 const LPCWSTR BURN_BUNDLE_ACTIVE_PARENT = L"WixBundleActiveParent";
42 const LPCWSTR BURN_BUNDLE_COMMAND_LINE_ACTION = L"WixBundleCommandLineAction";
43 const LPCWSTR BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER = L"WixBundleExecutePackageCacheFolder";
44 const LPCWSTR BURN_BUNDLE_EXECUTE_PACKAGE_ACTION = L"WixBundleExecutePackageAction";
45 const LPCWSTR BURN_BUNDLE_FORCED_RESTART_PACKAGE = L"WixBundleForcedRestartPackage";
46 const LPCWSTR BURN_BUNDLE_INSTALLED = L"WixBundleInstalled";
47 const LPCWSTR BURN_BUNDLE_ELEVATED = L"WixBundleElevated";
48 const LPCWSTR BURN_BUNDLE_PROVIDER_KEY = L"WixBundleProviderKey";
49 const LPCWSTR BURN_BUNDLE_TAG = L"WixBundleTag";
50 const LPCWSTR BURN_BUNDLE_UILEVEL = L"WixBundleUILevel";
51 const LPCWSTR BURN_BUNDLE_VERSION = L"WixBundleVersion";
52
53 // The following well-known variables are settable by the BA.
54 const LPCWSTR BURN_BUNDLE_LAYOUT_DIRECTORY = L"WixBundleLayoutDirectory";
55 const LPCWSTR BURN_BUNDLE_NAME = L"WixBundleName";
56 const LPCWSTR BURN_BUNDLE_INPROGRESS_NAME = L"WixBundleInProgressName";
57 const LPCWSTR BURN_BUNDLE_MANUFACTURER = L"WixBundleManufacturer";
58 const LPCWSTR BURN_BUNDLE_ORIGINAL_SOURCE = L"WixBundleOriginalSource";
59 const LPCWSTR BURN_BUNDLE_ORIGINAL_SOURCE_FOLDER = L"WixBundleOriginalSourceFolder";
60 const LPCWSTR BURN_BUNDLE_LAST_USED_SOURCE = L"WixBundleLastUsedSource";
61
62
63 // enums
64
65 enum BURN_MODE
66 {
67 BURN_MODE_UNKNOWN,
68 BURN_MODE_NORMAL,
69 BURN_MODE_ELEVATED,
70 BURN_MODE_EMBEDDED,
71 BURN_MODE_RUNONCE,
72 };
73
74 enum BURN_AU_PAUSE_ACTION
75 {
76 BURN_AU_PAUSE_ACTION_NONE,
77 BURN_AU_PAUSE_ACTION_IFELEVATED,
78 BURN_AU_PAUSE_ACTION_IFELEVATED_NORESUME,
79 };
80
81 enum BURN_RESTART_STATE
82 {
83 BURN_RESTART_STATE_NONE,
84 BURN_RESTART_STATE_REQUESTING,
85 BURN_RESTART_STATE_REQUESTED,
86 BURN_RESTART_STATE_INITIATING,
87 BURN_RESTART_STATE_INITIATED,
88 BURN_RESTART_STATE_BLOCKED,
89 };
90
91
92 // structs
93
94 typedef struct _BURN_ENGINE_COMMAND
95 {
96 int argc;
97 LPWSTR* argv;
98 DWORD cSecretArgs;
99 int* rgSecretArgs;
100 DWORD cUnknownArgs;
101 int* rgUnknownArgs;
102 BOOL fInvalidCommandLine;
103
104 BURN_MODE mode;
105 BURN_AU_PAUSE_ACTION automaticUpdates;
106 BOOL fArpSystemComponent;
107 BOOL fDisableSystemRestore;
108 BOOL fInitiallyElevated;
109
110 LPWSTR sczActiveParent;
111 LPWSTR sczAncestors;
112 LPWSTR sczIgnoreDependencies;
113
114 LPWSTR sczOriginalSource;
115 LPWSTR sczEngineWorkingDirectory;
116
117 DWORD dwLoggingAttributes;
118 LPWSTR sczLogFile;
119 } BURN_ENGINE_COMMAND;
120
121 typedef struct _BURN_REDIRECTED_LOGGING_CONTEXT
122 {
123 CRITICAL_SECTION csBuffer;
124 LPSTR sczBuffer;
125 HANDLE hPipe;
126 HANDLE hLogEvent;
127 HANDLE hFinishedEvent;
128 HANDLE hThread;
129 } BURN_REDIRECTED_LOGGING_CONTEXT;
130
131 typedef struct _BURN_ENGINE_STATE
132 {
133 // UX flow control
134 BOOL fDetected;
135 BOOL fPlanned;
136 BOOL fQuit;
137 //BOOL fSuspend; // Is TRUE when UX made Suspend() call on core.
138 //BOOL fForcedReboot; // Is TRUE when UX made Reboot() call on core.
139 //BOOL fCancelled; // Is TRUE when UX return cancel on UX OnXXX() methods.
140 //BOOL fReboot; // Is TRUE when UX confirms OnRestartRequried().
141 BOOL fRestart; // Set TRUE when UX returns IDRESTART during Apply().
142
143 // engine data
144 BOOTSTRAPPER_COMMAND command;
145 BURN_SECTION section;
146 BURN_VARIABLES variables;
147 BURN_CONDITION condition;
148 BURN_SEARCHES searches;
149 BURN_USER_EXPERIENCE userExperience;
150 BURN_REGISTRATION registration;
151 BURN_CONTAINERS containers;
152 BURN_PAYLOADS payloads;
153 BURN_PACKAGES packages;
154 BURN_UPDATE update;
155 BURN_APPROVED_EXES approvedExes;
156 BURN_CACHE cache;
157 BURN_DEPENDENCIES dependencies;
158 BURN_EXTENSIONS extensions;
159
160 HWND hMessageWindow;
161 HANDLE hMessageWindowThread;
162
163 BOOL fDisableRollback;
164 BOOL fParallelCacheAndExecute;
165
166 BURN_LOGGING log;
167
168 BURN_PAYLOAD_GROUP layoutPayloads;
169
170 BURN_PLAN plan;
171
172 BURN_REDIRECTED_LOGGING_CONTEXT elevatedLoggingContext;
173 HANDLE hUnelevatedLoggingThread;
174
175 LPWSTR sczBundleEngineWorkingPath;
176 BURN_PIPE_CONNECTION companionConnection;
177 BURN_PIPE_CONNECTION embeddedConnection;
178
179 CRITICAL_SECTION csRestartState;
180 BOOL fRestarting;
181 BURN_RESTART_STATE restartState;
182
183 BOOL fCriticalShutdownInitiated;
184 BURN_RESUME_MODE resumeMode;
185 LPCWSTR wzRestartInitiatedPackageId;
186
187 BURN_ENGINE_COMMAND internalCommand;
188 } BURN_ENGINE_STATE;
189
190 typedef struct _BURN_APPLY_CONTEXT
191 {
192 CRITICAL_SECTION csApply;
193 DWORD cOverallProgressTicks;
194 HANDLE hCacheThread;
195 DWORD dwCacheCheckpoint;
196 } BURN_APPLY_CONTEXT;
197
198 typedef BOOL (STDAPICALLTYPE *PFN_CREATEPROCESSW)(
199 __in_opt LPCWSTR lpApplicationName,
200 __inout_opt LPWSTR lpCommandLine,
201 __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
202 __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
203 __in BOOL bInheritHandles,
204 __in DWORD dwCreationFlags,
205 __in_opt LPVOID lpEnvironment,
206 __in_opt LPCWSTR lpCurrentDirectory,
207 __in LPSTARTUPINFOW lpStartupInfo,
208 __out LPPROCESS_INFORMATION lpProcessInformation
209 );
210
211 typedef HRESULT (DAPI *PFN_PROCWAITFORCOMPLETION)(
212 __in HANDLE hProcess,
213 __in DWORD dwTimeout,
214 __out DWORD* pReturnCode
215 );
216
217
218 // function declarations
219
220 HRESULT CoreInitialize(
221 __in BURN_ENGINE_STATE* pEngineState
222 );
223 HRESULT CoreInitializeConstants(
224 __in BURN_ENGINE_STATE* pEngineState
225 );
226 HRESULT CoreSerializeEngineState(
227 __in BURN_ENGINE_STATE* pEngineState,
228 __inout BYTE** ppbBuffer,
229 __inout SIZE_T* piBuffer
230 );
231 HRESULT CoreQueryRegistration(
232 __in BURN_ENGINE_STATE* pEngineState
233 );
234 //HRESULT CoreDeserializeEngineState(
235 // __in BURN_ENGINE_STATE* pEngineState,
236 // __in_bcount(cbBuffer) BYTE* pbBuffer,
237 // __in SIZE_T cbBuffer
238 // );
239 HRESULT CoreDetect(
240 __in BURN_ENGINE_STATE* pEngineState,
241 __in_opt HWND hwndParent
242 );
243 HRESULT CorePlan(
244 __in BURN_ENGINE_STATE* pEngineState,
245 __in BOOTSTRAPPER_ACTION action
246 );
247 HRESULT CoreElevate(
248 __in BURN_ENGINE_STATE* pEngineState,
249 __in WM_BURN reason,
250 __in_opt HWND hwndParent
251 );
252 HRESULT CoreApply(
253 __in BURN_ENGINE_STATE* pEngineState,
254 __in_opt HWND hwndParent
255 );
256 HRESULT CoreLaunchApprovedExe(
257 __in BURN_ENGINE_STATE* pEngineState,
258 __in BURN_LAUNCH_APPROVED_EXE* pLaunchApprovedExe
259 );
260 void CoreQuit(
261 __in BAENGINE_CONTEXT* pEngineContext,
262 __in DWORD dwExitCode
263 );
264 HRESULT CoreSaveEngineState(
265 __in BURN_ENGINE_STATE* pEngineState
266 );
267 LPCWSTR CoreRelationTypeToCommandLineString(
268 __in BOOTSTRAPPER_RELATION_TYPE relationType
269 );
270 HRESULT CoreCreatePassthroughBundleCommandLine(
271 __deref_inout_z LPWSTR* psczCommandLine,
272 __in BURN_ENGINE_COMMAND* pInternalCommand,
273 __in BOOTSTRAPPER_COMMAND* pCommand
274 );
275 HRESULT CoreCreateResumeCommandLine(
276 __deref_inout_z LPWSTR* psczCommandLine,
277 __in BURN_PLAN* pPlan,
278 __in BURN_LOGGING* pLog
279 );
280 HRESULT CoreCreateUpdateBundleCommandLine(
281 __deref_inout_z LPWSTR* psczCommandLine,
282 __in BURN_ENGINE_COMMAND* pInternalCommand,
283 __in BOOTSTRAPPER_COMMAND* pCommand
284 );
285 HRESULT CoreAppendFileHandleAttachedToCommandLine(
286 __in HANDLE hFileWithAttachedContainer,
287 __out HANDLE* phExecutableFile,
288 __deref_inout_z LPWSTR* psczCommandLine
289 );
290 HRESULT CoreAppendFileHandleSelfToCommandLine(
291 __in LPCWSTR wzExecutablePath,
292 __out HANDLE* phExecutableFile,
293 __deref_inout_z LPWSTR* psczCommandLine,
294 __deref_inout_z_opt LPWSTR* psczObfuscatedCommandLine
295 );
296 HRESULT CoreAppendLogToCommandLine(
297 __deref_inout_z LPWSTR* psczCommandLine,
298 __deref_inout_z_opt LPWSTR* psczObfuscatedCommandLine,
299 __in BOOL fRollback,
300 __in BURN_VARIABLES* pVariables,
301 __in BURN_PACKAGE *pPackage
302 );
303 HRESULT CoreAppendSplashScreenWindowToCommandLine(
304 __in_opt HWND hwndSplashScreen,
305 __deref_inout_z LPWSTR* psczCommandLine
306 );
307 HRESULT CoreAppendEngineWorkingDirectoryToCommandLine(
308 __in_z_opt LPCWSTR wzEngineWorkingDirectory,
309 __deref_inout_z LPWSTR* psczCommandLine,
310 __deref_inout_z_opt LPWSTR* psczObfuscatedCommandLine
311 );
312 void CoreCleanup(
313 __in BURN_ENGINE_STATE* pEngineState
314 );
315 HRESULT CoreParseCommandLine(
316 __in BURN_ENGINE_COMMAND* pInternalCommand,
317 __in BOOTSTRAPPER_COMMAND* pCommand,
318 __in BURN_PIPE_CONNECTION* pCompanionConnection,
319 __in BURN_PIPE_CONNECTION* pEmbeddedConnection,
320 __inout HANDLE* phSectionFile,
321 __inout HANDLE* phSourceEngineFile
322 );
323 void CoreUpdateRestartState(
324 __in BURN_ENGINE_STATE* pEngineState,
325 __in BURN_RESTART_STATE restartState
326 );
327 void CoreFunctionOverride(
328 __in_opt PFN_CREATEPROCESSW pfnCreateProcessW,
329 __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion
330 );
331 HRESULT CoreCreateProcess(
332 __in_opt LPCWSTR wzApplicationName,
333 __inout_opt LPWSTR sczCommandLine,
334 __in BOOL fInheritHandles,
335 __in DWORD dwCreationFlags,
336 __in_opt LPCWSTR wzCurrentDirectory,
337 __in WORD wShowWindow,
338 __out LPPROCESS_INFORMATION pProcessInformation
339 );
340 HRESULT DAPI CoreWaitForProcCompletion(
341 __in HANDLE hProcess,
342 __in DWORD dwTimeout,
343 __out_opt DWORD* pdwReturnCode
344 );
345 HRESULT DAPI CoreCloseElevatedLoggingThread(
346 __in BURN_ENGINE_STATE* pEngineState
347 );
348 HRESULT DAPI CoreWaitForUnelevatedLoggingThread(
349 __in HANDLE hUnelevatedLoggingThread
350 );
351
352 #if defined(__cplusplus)
353 }
354 #endif