aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/engine.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-08-03 15:41:18 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-08-04 10:03:57 -0500
commit6d7a275edafb3ae0f3cff94d66503a82dafb71f7 (patch)
treefae8f75e2cd1d7b179b0ed93e15625d68ba7c441 /src/burn/engine/engine.cpp
parented57d171f6fb6bb4e180696cc12caa568599566a (diff)
downloadwix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.tar.gz
wix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.tar.bz2
wix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.zip
Replace static cache internals with a struct.
Initialize them explicitly to make it clearer when that happens.
Diffstat (limited to 'src/burn/engine/engine.cpp')
-rw-r--r--src/burn/engine/engine.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp
index e6cb1708..0c2c8dc5 100644
--- a/src/burn/engine/engine.cpp
+++ b/src/burn/engine/engine.cpp
@@ -244,8 +244,8 @@ LExit:
244 244
245 UserExperienceRemove(&engineState.userExperience); 245 UserExperienceRemove(&engineState.userExperience);
246 246
247 CacheRemoveWorkingFolder(engineState.registration.sczId); 247 CacheRemoveWorkingFolder(&engineState.cache);
248 CacheUninitialize(); 248 CacheUninitialize(&engineState.cache);
249 249
250 // If this is a related bundle (but not an update) suppress restart and return the standard restart error code. 250 // If this is a related bundle (but not an update) suppress restart and return the standard restart error code.
251 if (fRestart && BOOTSTRAPPER_RELATION_NONE != engineState.command.relationType && BOOTSTRAPPER_RELATION_UPDATE != engineState.command.relationType) 251 if (fRestart && BOOTSTRAPPER_RELATION_NONE != engineState.command.relationType && BOOTSTRAPPER_RELATION_UPDATE != engineState.command.relationType)
@@ -334,6 +334,9 @@ static HRESULT InitializeEngineState(
334 PipeConnectionInitialize(&pEngineState->companionConnection); 334 PipeConnectionInitialize(&pEngineState->companionConnection);
335 PipeConnectionInitialize(&pEngineState->embeddedConnection); 335 PipeConnectionInitialize(&pEngineState->embeddedConnection);
336 336
337 // Retain whether bundle was initially run elevated.
338 ProcElevated(::GetCurrentProcess(), &pEngineState->internalCommand.fInitiallyElevated);
339
337 // Parse command line. 340 // Parse command line.
338 hr = CoreParseCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &pEngineState->mode, &pEngineState->automaticUpdates, &pEngineState->fDisableSystemRestore, &pEngineState->internalCommand.sczSourceProcessPath, &pEngineState->internalCommand.sczOriginalSource, &hSectionFile, &hSourceEngineFile, &pEngineState->fDisableUnelevate, &pEngineState->log.dwAttributes, &pEngineState->log.sczPath, &pEngineState->registration.sczActiveParent, &pEngineState->sczIgnoreDependencies, &pEngineState->registration.sczAncestors, &pEngineState->fInvalidCommandLine, &pEngineState->cUnknownArgs, &pEngineState->rgUnknownArgs); 341 hr = CoreParseCommandLine(pEngineState->argc, pEngineState->argv, &pEngineState->command, &pEngineState->companionConnection, &pEngineState->embeddedConnection, &pEngineState->mode, &pEngineState->automaticUpdates, &pEngineState->fDisableSystemRestore, &pEngineState->internalCommand.sczSourceProcessPath, &pEngineState->internalCommand.sczOriginalSource, &hSectionFile, &hSourceEngineFile, &pEngineState->fDisableUnelevate, &pEngineState->log.dwAttributes, &pEngineState->log.sczPath, &pEngineState->registration.sczActiveParent, &pEngineState->sczIgnoreDependencies, &pEngineState->registration.sczAncestors, &pEngineState->fInvalidCommandLine, &pEngineState->cUnknownArgs, &pEngineState->rgUnknownArgs);
339 ExitOnFailure(hr, "Fatal error while parsing command line."); 342 ExitOnFailure(hr, "Fatal error while parsing command line.");
@@ -341,6 +344,9 @@ static HRESULT InitializeEngineState(
341 hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile); 344 hr = SectionInitialize(&pEngineState->section, hSectionFile, hSourceEngineFile);
342 ExitOnFailure(hr, "Failed to initialize engine section."); 345 ExitOnFailure(hr, "Failed to initialize engine section.");
343 346
347 hr = CacheInitialize(&pEngineState->cache, &pEngineState->internalCommand);
348 ExitOnFailure(hr, "Failed to initialize internal cache functionality.");
349
344LExit: 350LExit:
345 return hr; 351 return hr;
346} 352}
@@ -421,8 +427,6 @@ static HRESULT RunUntrusted(
421 hr = PathForCurrentProcess(&sczCurrentProcessPath, NULL); 427 hr = PathForCurrentProcess(&sczCurrentProcessPath, NULL);
422 ExitOnFailure(hr, "Failed to get path for current process."); 428 ExitOnFailure(hr, "Failed to get path for current process.");
423 429
424 BOOL fRunningFromCache = CacheBundleRunningFromCache();
425
426 // If we're running from the package cache, we're in a secure 430 // If we're running from the package cache, we're in a secure
427 // folder (DLLs cannot be inserted here for hijacking purposes) 431 // folder (DLLs cannot be inserted here for hijacking purposes)
428 // so just launch the current process's path as the clean room 432 // so just launch the current process's path as the clean room
@@ -431,13 +435,13 @@ static HRESULT RunUntrusted(
431 // a secure folder) but it makes the code that only wants to run 435 // a secure folder) but it makes the code that only wants to run
432 // in clean room more complicated if we don't launch an explicit 436 // in clean room more complicated if we don't launch an explicit
433 // clean room process. 437 // clean room process.
434 if (fRunningFromCache) 438 if (CacheBundleRunningFromCache(&pEngineState->cache))
435 { 439 {
436 wzCleanRoomBundlePath = sczCurrentProcessPath; 440 wzCleanRoomBundlePath = sczCurrentProcessPath;
437 } 441 }
438 else 442 else
439 { 443 {
440 hr = CacheBundleToCleanRoom(&pEngineState->section, &sczCachedCleanRoomBundlePath); 444 hr = CacheBundleToCleanRoom(&pEngineState->cache, &pEngineState->section, &sczCachedCleanRoomBundlePath);
441 ExitOnFailure(hr, "Failed to cache to clean room."); 445 ExitOnFailure(hr, "Failed to cache to clean room.");
442 446
443 wzCleanRoomBundlePath = sczCachedCleanRoomBundlePath; 447 wzCleanRoomBundlePath = sczCachedCleanRoomBundlePath;
@@ -658,7 +662,7 @@ static HRESULT RunElevated(
658 SrpInitialize(TRUE); 662 SrpInitialize(TRUE);
659 663
660 // Pump messages from parent process. 664 // Pump messages from parent process.
661 hr = ElevationChildPumpMessages(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe, pEngineState->companionConnection.hCachePipe, &pEngineState->approvedExes, &pEngineState->containers, &pEngineState->packages, &pEngineState->payloads, &pEngineState->variables, &pEngineState->registration, &pEngineState->userExperience, &hLock, &fDisabledAutomaticUpdates, &pEngineState->userExperience.dwExitCode, &pEngineState->fRestart); 665 hr = ElevationChildPumpMessages(pEngineState->dwElevatedLoggingTlsId, pEngineState->companionConnection.hPipe, pEngineState->companionConnection.hCachePipe, &pEngineState->approvedExes, &pEngineState->cache, &pEngineState->containers, &pEngineState->packages, &pEngineState->payloads, &pEngineState->variables, &pEngineState->registration, &pEngineState->userExperience, &hLock, &fDisabledAutomaticUpdates, &pEngineState->userExperience.dwExitCode, &pEngineState->fRestart);
662 LogRedirect(NULL, NULL); // reset logging so the next failure gets written to "log buffer" for the failure log. 666 LogRedirect(NULL, NULL); // reset logging so the next failure gets written to "log buffer" for the failure log.
663 ExitOnFailure(hr, "Failed to pump messages from parent process."); 667 ExitOnFailure(hr, "Failed to pump messages from parent process.");
664 668