diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-08-03 15:41:18 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-08-04 10:03:57 -0500 |
commit | 6d7a275edafb3ae0f3cff94d66503a82dafb71f7 (patch) | |
tree | fae8f75e2cd1d7b179b0ed93e15625d68ba7c441 /src/burn/engine/core.cpp | |
parent | ed57d171f6fb6bb4e180696cc12caa568599566a (diff) | |
download | wix-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/core.cpp')
-rw-r--r-- | src/burn/engine/core.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp index 0468d406..8985ab27 100644 --- a/src/burn/engine/core.cpp +++ b/src/burn/engine/core.cpp | |||
@@ -32,6 +32,7 @@ static HRESULT DetectPackage( | |||
32 | __in BURN_PACKAGE* pPackage | 32 | __in BURN_PACKAGE* pPackage |
33 | ); | 33 | ); |
34 | static HRESULT DetectPackagePayloadsCached( | 34 | static HRESULT DetectPackagePayloadsCached( |
35 | __in BURN_CACHE* pCache, | ||
35 | __in BURN_PACKAGE* pPackage | 36 | __in BURN_PACKAGE* pPackage |
36 | ); | 37 | ); |
37 | static DWORD WINAPI CacheThreadProc( | 38 | static DWORD WINAPI CacheThreadProc( |
@@ -65,7 +66,6 @@ extern "C" HRESULT CoreInitialize( | |||
65 | BYTE* pbBuffer = NULL; | 66 | BYTE* pbBuffer = NULL; |
66 | SIZE_T cbBuffer = 0; | 67 | SIZE_T cbBuffer = 0; |
67 | BURN_CONTAINER_CONTEXT containerContext = { }; | 68 | BURN_CONTAINER_CONTEXT containerContext = { }; |
68 | BOOL fElevated = FALSE; | ||
69 | LPWSTR sczSourceProcessFolder = NULL; | 69 | LPWSTR sczSourceProcessFolder = NULL; |
70 | 70 | ||
71 | // Initialize variables. | 71 | // Initialize variables. |
@@ -105,10 +105,7 @@ extern "C" HRESULT CoreInitialize( | |||
105 | hr = CoreInitializeConstants(pEngineState); | 105 | hr = CoreInitializeConstants(pEngineState); |
106 | ExitOnFailure(hr, "Failed to initialize contants."); | 106 | ExitOnFailure(hr, "Failed to initialize contants."); |
107 | 107 | ||
108 | // Retain whether bundle was initially run elevated. | 108 | hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, pEngineState->internalCommand.fInitiallyElevated, TRUE); |
109 | ProcElevated(::GetCurrentProcess(), &fElevated); | ||
110 | |||
111 | hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, fElevated, TRUE); | ||
112 | ExitOnFailure(hr, "Failed to overwrite the %ls built-in variable.", BURN_BUNDLE_ELEVATED); | 109 | ExitOnFailure(hr, "Failed to overwrite the %ls built-in variable.", BURN_BUNDLE_ELEVATED); |
113 | 110 | ||
114 | hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_UILEVEL, pEngineState->command.display, TRUE); | 111 | hr = VariableSetNumeric(&pEngineState->variables, BURN_BUNDLE_UILEVEL, pEngineState->command.display, TRUE); |
@@ -136,8 +133,8 @@ extern "C" HRESULT CoreInitialize( | |||
136 | 133 | ||
137 | if (BURN_MODE_UNTRUSTED == pEngineState->mode || BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) | 134 | if (BURN_MODE_UNTRUSTED == pEngineState->mode || BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) |
138 | { | 135 | { |
139 | hr = CacheInitialize(&pEngineState->registration, &pEngineState->variables, pEngineState->internalCommand.sczSourceProcessPath); | 136 | hr = CacheInitializeSources(&pEngineState->cache, &pEngineState->registration, &pEngineState->variables, &pEngineState->internalCommand); |
140 | ExitOnFailure(hr, "Failed to initialize internal cache functionality."); | 137 | ExitOnFailure(hr, "Failed to initialize internal cache source functionality."); |
141 | } | 138 | } |
142 | 139 | ||
143 | // If we're not elevated then we'll be loading the bootstrapper application, so extract | 140 | // If we're not elevated then we'll be loading the bootstrapper application, so extract |
@@ -145,7 +142,7 @@ extern "C" HRESULT CoreInitialize( | |||
145 | if (BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) | 142 | if (BURN_MODE_NORMAL == pEngineState->mode || BURN_MODE_EMBEDDED == pEngineState->mode) |
146 | { | 143 | { |
147 | // Extract all UX payloads to working folder. | 144 | // Extract all UX payloads to working folder. |
148 | hr = UserExperienceEnsureWorkingFolder(pEngineState->registration.sczId, &pEngineState->userExperience.sczTempDirectory); | 145 | hr = UserExperienceEnsureWorkingFolder(&pEngineState->cache, &pEngineState->userExperience.sczTempDirectory); |
149 | ExitOnFailure(hr, "Failed to get unique temporary folder for bootstrapper application."); | 146 | ExitOnFailure(hr, "Failed to get unique temporary folder for bootstrapper application."); |
150 | 147 | ||
151 | hr = PayloadExtractUXContainer(&pEngineState->userExperience.payloads, &containerContext, pEngineState->userExperience.sczTempDirectory); | 148 | hr = PayloadExtractUXContainer(&pEngineState->userExperience.payloads, &containerContext, pEngineState->userExperience.sczTempDirectory); |
@@ -455,6 +452,7 @@ extern "C" HRESULT CorePlan( | |||
455 | // Remember the overall action state in the plan since it shapes the changes | 452 | // Remember the overall action state in the plan since it shapes the changes |
456 | // we make everywhere. | 453 | // we make everywhere. |
457 | pEngineState->plan.action = action; | 454 | pEngineState->plan.action = action; |
455 | pEngineState->plan.pCache = &pEngineState->cache; | ||
458 | pEngineState->plan.pPayloads = &pEngineState->payloads; | 456 | pEngineState->plan.pPayloads = &pEngineState->payloads; |
459 | pEngineState->plan.wzBundleId = pEngineState->registration.sczId; | 457 | pEngineState->plan.wzBundleId = pEngineState->registration.sczId; |
460 | pEngineState->plan.wzBundleProviderKey = pEngineState->registration.sczId; | 458 | pEngineState->plan.wzBundleProviderKey = pEngineState->registration.sczId; |
@@ -571,7 +569,7 @@ extern "C" HRESULT CoreElevate( | |||
571 | // If the elevated companion pipe isn't created yet, let's make that happen. | 569 | // If the elevated companion pipe isn't created yet, let's make that happen. |
572 | if (!pEngineState->sczBundleEngineWorkingPath) | 570 | if (!pEngineState->sczBundleEngineWorkingPath) |
573 | { | 571 | { |
574 | hr = CacheBundleToWorkingDirectory(pEngineState->registration.sczId, pEngineState->registration.sczExecutableName, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath); | 572 | hr = CacheBundleToWorkingDirectory(&pEngineState->cache, pEngineState->registration.sczExecutableName, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath); |
575 | ExitOnFailure(hr, "Failed to cache engine to working directory."); | 573 | ExitOnFailure(hr, "Failed to cache engine to working directory."); |
576 | } | 574 | } |
577 | 575 | ||
@@ -673,7 +671,7 @@ extern "C" HRESULT CoreApply( | |||
673 | // Ensure the engine is cached to the working path. | 671 | // Ensure the engine is cached to the working path. |
674 | if (!pEngineState->sczBundleEngineWorkingPath) | 672 | if (!pEngineState->sczBundleEngineWorkingPath) |
675 | { | 673 | { |
676 | hr = CacheBundleToWorkingDirectory(pEngineState->registration.sczId, pEngineState->registration.sczExecutableName, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath); | 674 | hr = CacheBundleToWorkingDirectory(&pEngineState->cache, pEngineState->registration.sczExecutableName, &pEngineState->section, &pEngineState->sczBundleEngineWorkingPath); |
677 | ExitOnFailure(hr, "Failed to cache engine to working directory."); | 675 | ExitOnFailure(hr, "Failed to cache engine to working directory."); |
678 | } | 676 | } |
679 | 677 | ||
@@ -1740,7 +1738,7 @@ static HRESULT DetectPackage( | |||
1740 | ExitOnRootFailure(hr, "BA aborted detect package begin."); | 1738 | ExitOnRootFailure(hr, "BA aborted detect package begin."); |
1741 | 1739 | ||
1742 | // Detect the cache state of the package. | 1740 | // Detect the cache state of the package. |
1743 | hr = DetectPackagePayloadsCached(pPackage); | 1741 | hr = DetectPackagePayloadsCached(&pEngineState->cache, pPackage); |
1744 | ExitOnFailure(hr, "Failed to detect if payloads are all cached for package: %ls", pPackage->sczId); | 1742 | ExitOnFailure(hr, "Failed to detect if payloads are all cached for package: %ls", pPackage->sczId); |
1745 | 1743 | ||
1746 | // Use the correct engine to detect the package. | 1744 | // Use the correct engine to detect the package. |
@@ -1782,6 +1780,7 @@ LExit: | |||
1782 | } | 1780 | } |
1783 | 1781 | ||
1784 | static HRESULT DetectPackagePayloadsCached( | 1782 | static HRESULT DetectPackagePayloadsCached( |
1783 | __in BURN_CACHE* pCache, | ||
1785 | __in BURN_PACKAGE* pPackage | 1784 | __in BURN_PACKAGE* pPackage |
1786 | ) | 1785 | ) |
1787 | { | 1786 | { |
@@ -1792,7 +1791,7 @@ static HRESULT DetectPackagePayloadsCached( | |||
1792 | 1791 | ||
1793 | if (pPackage->sczCacheId && *pPackage->sczCacheId) | 1792 | if (pPackage->sczCacheId && *pPackage->sczCacheId) |
1794 | { | 1793 | { |
1795 | hr = CacheGetCompletedPath(pPackage->fPerMachine, pPackage->sczCacheId, &sczCachePath); | 1794 | hr = CacheGetCompletedPath(pCache, pPackage->fPerMachine, pPackage->sczCacheId, &sczCachePath); |
1796 | ExitOnFailure(hr, "Failed to get completed cache path."); | 1795 | ExitOnFailure(hr, "Failed to get completed cache path."); |
1797 | 1796 | ||
1798 | // If the cached directory exists, we have something. | 1797 | // If the cached directory exists, we have something. |