aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-16 09:42:01 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-19 23:12:55 -0500
commitc88806b89293f5bb92c42e90230e48be6b79b7f4 (patch)
treeaf9fb6fdbe68d0e208115a7d7bd73d183aff880f
parent941c47e5a3f57ce9626b447a95740b1444e69343 (diff)
downloadwix-c88806b89293f5bb92c42e90230e48be6b79b7f4.tar.gz
wix-c88806b89293f5bb92c42e90230e48be6b79b7f4.tar.bz2
wix-c88806b89293f5bb92c42e90230e48be6b79b7f4.zip
Detect whether the bundle is cached.
-rw-r--r--src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h1
-rw-r--r--src/engine/cache.cpp1
-rw-r--r--src/engine/core.cpp8
-rw-r--r--src/engine/detect.cpp2
-rw-r--r--src/engine/engine.mc2
-rw-r--r--src/engine/registration.cpp7
-rw-r--r--src/engine/registration.h4
-rw-r--r--src/engine/userexperience.cpp2
-rw-r--r--src/engine/userexperience.h1
9 files changed, 17 insertions, 11 deletions
diff --git a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
index fb4b6ea3..2d086f38 100644
--- a/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
+++ b/src/WixToolset.BootstrapperCore.Native/inc/BootstrapperApplication.h
@@ -463,6 +463,7 @@ struct BA_ONDETECTBEGIN_ARGS
463 DWORD cbSize; 463 DWORD cbSize;
464 BOOL fInstalled; 464 BOOL fInstalled;
465 DWORD cPackages; 465 DWORD cPackages;
466 BOOL fCached;
466}; 467};
467 468
468struct BA_ONDETECTBEGIN_RESULTS 469struct BA_ONDETECTBEGIN_RESULTS
diff --git a/src/engine/cache.cpp b/src/engine/cache.cpp
index 667ca9e0..46c2650a 100644
--- a/src/engine/cache.cpp
+++ b/src/engine/cache.cpp
@@ -733,6 +733,7 @@ extern "C" HRESULT CacheCompleteBundle(
733 hr = PathConcat(sczTargetDirectory, wzExecutableName, &sczTargetPath); 733 hr = PathConcat(sczTargetDirectory, wzExecutableName, &sczTargetPath);
734 ExitOnFailure(hr, "Failed to combine completed path with engine file name."); 734 ExitOnFailure(hr, "Failed to combine completed path with engine file name.");
735 735
736 // We can't just use wzExecutablePath because we needed to call CreateCompletedPath to ensure that the destination was secured.
736 Assert(CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, wzExecutablePath, -1, sczTargetPath, -1)); 737 Assert(CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, wzExecutablePath, -1, sczTargetPath, -1));
737 738
738 // If the bundle is running out of the package cache then we don't need to copy it there 739 // If the bundle is running out of the package cache then we don't need to copy it there
diff --git a/src/engine/core.cpp b/src/engine/core.cpp
index 7341e4b8..42759d3f 100644
--- a/src/engine/core.cpp
+++ b/src/engine/core.cpp
@@ -239,7 +239,7 @@ extern "C" HRESULT CoreQueryRegistration(
239 SIZE_T iBuffer = 0; 239 SIZE_T iBuffer = 0;
240 240
241 // Detect if bundle is already installed. 241 // Detect if bundle is already installed.
242 hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->registration.fInstalled); 242 hr = RegistrationDetectInstalled(&pEngineState->registration);
243 ExitOnFailure(hr, "Failed to detect bundle install state."); 243 ExitOnFailure(hr, "Failed to detect bundle install state.");
244 244
245 // detect resume type 245 // detect resume type
@@ -293,7 +293,7 @@ extern "C" HRESULT CoreDetect(
293 // only happens if Apply() changed the state of bundle (installed or 293 // only happens if Apply() changed the state of bundle (installed or
294 // uninstalled). In that case, Detect() can be used here to reset 294 // uninstalled). In that case, Detect() can be used here to reset
295 // the installed state. 295 // the installed state.
296 hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->registration.fInstalled); 296 hr = RegistrationDetectInstalled(&pEngineState->registration);
297 ExitOnFailure(hr, "Failed to detect bundle install state."); 297 ExitOnFailure(hr, "Failed to detect bundle install state.");
298 298
299 if (pEngineState->registration.fInstalled) 299 if (pEngineState->registration.fInstalled)
@@ -308,7 +308,7 @@ extern "C" HRESULT CoreDetect(
308 } 308 }
309 309
310 fDetectBegan = TRUE; 310 fDetectBegan = TRUE;
311 hr = UserExperienceOnDetectBegin(&pEngineState->userExperience, pEngineState->registration.fInstalled, pEngineState->packages.cPackages); 311 hr = UserExperienceOnDetectBegin(&pEngineState->userExperience, pEngineState->registration.fCached, pEngineState->registration.fInstalled, pEngineState->packages.cPackages);
312 ExitOnRootFailure(hr, "UX aborted detect begin."); 312 ExitOnRootFailure(hr, "UX aborted detect begin.");
313 313
314 pEngineState->userExperience.hwndDetect = hwndParent; 314 pEngineState->userExperience.hwndDetect = hwndParent;
@@ -426,7 +426,7 @@ LExit:
426 426
427 pEngineState->userExperience.hwndDetect = NULL; 427 pEngineState->userExperience.hwndDetect = NULL;
428 428
429 LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr, !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fInstalled), FAILED(hr) ? "(failed)" : LoggingBoolToString(pEngineState->registration.fEligibleForCleanup)); 429 LogId(REPORT_STANDARD, MSG_DETECT_COMPLETE, hr, !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fInstalled), !fDetectBegan ? "(failed)" : LoggingBoolToString(pEngineState->registration.fCached), FAILED(hr) ? "(failed)" : LoggingBoolToString(pEngineState->registration.fEligibleForCleanup));
430 430
431 return hr; 431 return hr;
432} 432}
diff --git a/src/engine/detect.cpp b/src/engine/detect.cpp
index 355b49f5..844816ba 100644
--- a/src/engine/detect.cpp
+++ b/src/engine/detect.cpp
@@ -173,7 +173,7 @@ extern "C" HRESULT DetectReportRelatedBundles(
173 HRESULT hr = S_OK; 173 HRESULT hr = S_OK;
174 int nCompareResult = 0; 174 int nCompareResult = 0;
175 BOOTSTRAPPER_REQUEST_STATE uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE; 175 BOOTSTRAPPER_REQUEST_STATE uninstallRequestState = BOOTSTRAPPER_REQUEST_STATE_NONE;
176 *pfEligibleForCleanup = pRegistration->fInstalled || CacheBundleRunningFromCache(); 176 *pfEligibleForCleanup = pRegistration->fInstalled || pRegistration->fCached;
177 177
178 for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle) 178 for (DWORD iRelatedBundle = 0; iRelatedBundle < pRegistration->relatedBundles.cRelatedBundles; ++iRelatedBundle)
179 { 179 {
diff --git a/src/engine/engine.mc b/src/engine/engine.mc
index 365da1d9..71c27cad 100644
--- a/src/engine/engine.mc
+++ b/src/engine/engine.mc
@@ -300,7 +300,7 @@ MessageId=199
300Severity=Success 300Severity=Success
301SymbolicName=MSG_DETECT_COMPLETE 301SymbolicName=MSG_DETECT_COMPLETE
302Language=English 302Language=English
303Detect complete, result: 0x%1!x!, installed: %2!hs!, eligible for cleanup: %3!hs! 303Detect complete, result: 0x%1!x!, installed: %2!hs!, cached: %3!hs!, eligible for cleanup: %4!hs!
304. 304.
305 305
306MessageId=200 306MessageId=200
diff --git a/src/engine/registration.cpp b/src/engine/registration.cpp
index 9e27b177..7435f292 100644
--- a/src/engine/registration.cpp
+++ b/src/engine/registration.cpp
@@ -463,14 +463,15 @@ LExit:
463} 463}
464 464
465extern "C" HRESULT RegistrationDetectInstalled( 465extern "C" HRESULT RegistrationDetectInstalled(
466 __in BURN_REGISTRATION* pRegistration, 466 __in BURN_REGISTRATION* pRegistration
467 __out BOOL* pfInstalled
468 ) 467 )
469{ 468{
470 HRESULT hr = S_OK; 469 HRESULT hr = S_OK;
471 HKEY hkRegistration = NULL; 470 HKEY hkRegistration = NULL;
472 DWORD dwInstalled = 0; 471 DWORD dwInstalled = 0;
473 472
473 pRegistration->fCached = FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);
474
474 // open registration key 475 // open registration key
475 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); 476 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration);
476 if (SUCCEEDED(hr)) 477 if (SUCCEEDED(hr))
@@ -484,7 +485,7 @@ extern "C" HRESULT RegistrationDetectInstalled(
484 hr = S_OK; 485 hr = S_OK;
485 } 486 }
486 487
487 *pfInstalled = (1 == dwInstalled); 488 pRegistration->fInstalled = (1 == dwInstalled);
488 489
489 ReleaseRegKey(hkRegistration); 490 ReleaseRegKey(hkRegistration);
490 return hr; 491 return hr;
diff --git a/src/engine/registration.h b/src/engine/registration.h
index ed0641eb..af1b42e4 100644
--- a/src/engine/registration.h
+++ b/src/engine/registration.h
@@ -92,6 +92,7 @@ typedef struct _BURN_REGISTRATION
92 BOOL fPerMachine; 92 BOOL fPerMachine;
93 BOOL fRegisterArp; 93 BOOL fRegisterArp;
94 BOOL fDisableResume; 94 BOOL fDisableResume;
95 BOOL fCached;
95 BOOL fInstalled; 96 BOOL fInstalled;
96 LPWSTR sczId; 97 LPWSTR sczId;
97 LPWSTR sczTag; 98 LPWSTR sczTag;
@@ -174,8 +175,7 @@ HRESULT RegistrationSetVariables(
174 __in BURN_VARIABLES* pVariables 175 __in BURN_VARIABLES* pVariables
175 ); 176 );
176HRESULT RegistrationDetectInstalled( 177HRESULT RegistrationDetectInstalled(
177 __in BURN_REGISTRATION* pRegistration, 178 __in BURN_REGISTRATION* pRegistration
178 __out BOOL* pfInstalled
179 ); 179 );
180HRESULT RegistrationDetectResumeType( 180HRESULT RegistrationDetectResumeType(
181 __in BURN_REGISTRATION* pRegistration, 181 __in BURN_REGISTRATION* pRegistration,
diff --git a/src/engine/userexperience.cpp b/src/engine/userexperience.cpp
index b81dbfb2..c1641675 100644
--- a/src/engine/userexperience.cpp
+++ b/src/engine/userexperience.cpp
@@ -708,6 +708,7 @@ LExit:
708 708
709EXTERN_C BAAPI UserExperienceOnDetectBegin( 709EXTERN_C BAAPI UserExperienceOnDetectBegin(
710 __in BURN_USER_EXPERIENCE* pUserExperience, 710 __in BURN_USER_EXPERIENCE* pUserExperience,
711 __in BOOL fCached,
711 __in BOOL fInstalled, 712 __in BOOL fInstalled,
712 __in DWORD cPackages 713 __in DWORD cPackages
713 ) 714 )
@@ -719,6 +720,7 @@ EXTERN_C BAAPI UserExperienceOnDetectBegin(
719 args.cbSize = sizeof(args); 720 args.cbSize = sizeof(args);
720 args.cPackages = cPackages; 721 args.cPackages = cPackages;
721 args.fInstalled = fInstalled; 722 args.fInstalled = fInstalled;
723 args.fCached = fCached;
722 724
723 results.cbSize = sizeof(results); 725 results.cbSize = sizeof(results);
724 726
diff --git a/src/engine/userexperience.h b/src/engine/userexperience.h
index cef9d769..a1fb67a0 100644
--- a/src/engine/userexperience.h
+++ b/src/engine/userexperience.h
@@ -186,6 +186,7 @@ BAAPI UserExperienceOnCommitMsiTransactionComplete(
186 ); 186 );
187BAAPI UserExperienceOnDetectBegin( 187BAAPI UserExperienceOnDetectBegin(
188 __in BURN_USER_EXPERIENCE* pUserExperience, 188 __in BURN_USER_EXPERIENCE* pUserExperience,
189 __in BOOL fCached,
189 __in BOOL fInstalled, 190 __in BOOL fInstalled,
190 __in DWORD cPackages 191 __in DWORD cPackages
191 ); 192 );