aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-08-08 18:02:15 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-08-09 09:57:02 -0500
commit240b663ad5fc94ed6d19c966b5c9105a176ecf40 (patch)
treed194e242ccb5bb69f0dbbc388ede87cef65c700f /src/burn
parent8e1cbe8d7b468553d76c20452561e89726de5c47 (diff)
downloadwix-240b663ad5fc94ed6d19c966b5c9105a176ecf40.tar.gz
wix-240b663ad5fc94ed6d19c966b5c9105a176ecf40.tar.bz2
wix-240b663ad5fc94ed6d19c966b5c9105a176ecf40.zip
Skip logging errors in some places when they are due to missing files or registry keys or values.
Related to 6696
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/apply.cpp16
-rw-r--r--src/burn/engine/bundlepackageengine.cpp14
-rw-r--r--src/burn/engine/cache.cpp3
-rw-r--r--src/burn/engine/dependency.cpp44
-rw-r--r--src/burn/engine/exeengine.cpp21
-rw-r--r--src/burn/engine/registration.cpp32
-rw-r--r--src/burn/engine/relatedbundle.cpp17
-rw-r--r--src/burn/engine/search.cpp89
8 files changed, 100 insertions, 136 deletions
diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp
index 31d756a8..e67208b4 100644
--- a/src/burn/engine/apply.cpp
+++ b/src/burn/engine/apply.cpp
@@ -611,7 +611,7 @@ extern "C" HRESULT ApplyCache(
611 ExitOnFailure(hr, "Failed cache action: %ls", L"layout bundle"); 611 ExitOnFailure(hr, "Failed cache action: %ls", L"layout bundle");
612 612
613 hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext); 613 hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext);
614 LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"layout bundle"); 614 LogExitOnRootFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"layout bundle");
615 615
616 break; 616 break;
617 617
@@ -637,7 +637,7 @@ extern "C" HRESULT ApplyCache(
637 ExitOnFailure(hr, "Failed cache action: %ls", L"cache package"); 637 ExitOnFailure(hr, "Failed cache action: %ls", L"cache package");
638 638
639 hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext); 639 hr = ReportOverallProgressTicks(pUX, FALSE, pPlan->cOverallProgressTicksTotal, pContext);
640 LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"cache package"); 640 LogExitOnRootFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls", L"cache package");
641 641
642 break; 642 break;
643 643
@@ -1038,7 +1038,7 @@ static HRESULT ApplyCachePackage(
1038 } 1038 }
1039 else if (fCanceledBegin) 1039 else if (fCanceledBegin)
1040 { 1040 {
1041 LogExitOnFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls: %ls", L"begin cache package", pPackage->sczId); 1041 LogExitOnRootFailure(hr, MSG_USER_CANCELED, "Cancel during cache: %ls: %ls", L"begin cache package", pPackage->sczId);
1042 } 1042 }
1043 1043
1044 break; 1044 break;
@@ -1796,8 +1796,7 @@ static HRESULT AcquireContainerOrPayload(
1796 1796
1797 break; 1797 break;
1798 default: 1798 default:
1799 hr = E_FILENOTFOUND; 1799 LogExitWithRootFailure(hr, E_FILENOTFOUND, MSG_RESOLVE_SOURCE_FAILED, "Failed to resolve source, payload: %ls, package: %ls, container: %ls", wzPayloadId, pPackage ? pPackage->sczId : NULL, pContainer ? pContainer->sczId : NULL);
1800 LogExitOnFailure(hr, MSG_RESOLVE_SOURCE_FAILED, "Failed to resolve source, payload: %ls, package: %ls, container: %ls", wzPayloadId, pPackage ? pPackage->sczId : NULL, pContainer ? pContainer->sczId : NULL);
1801 } 1800 }
1802 1801
1803 // Send 100% complete here. This is sometimes the only progress sent to the BA. 1802 // Send 100% complete here. This is sometimes the only progress sent to the BA.
@@ -1965,17 +1964,12 @@ static HRESULT PreparePayloadDestinationPath(
1965 dwFileAttributes &= ~FILE_ATTRIBUTE_READONLY; 1964 dwFileAttributes &= ~FILE_ATTRIBUTE_READONLY;
1966 if (!::SetFileAttributes(wzDestinationPath, dwFileAttributes)) 1965 if (!::SetFileAttributes(wzDestinationPath, dwFileAttributes))
1967 { 1966 {
1968 ExitWithLastError(hr, "Failed to clear readonly bit on payload destination path: %ls", wzDestinationPath); 1967 ExitWithPathLastError(hr, "Failed to clear readonly bit on payload destination path: %ls", wzDestinationPath);
1969 } 1968 }
1970 } 1969 }
1971 } 1970 }
1972 1971
1973LExit: 1972LExit:
1974 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
1975 {
1976 hr = S_OK;
1977 }
1978
1979 return hr; 1973 return hr;
1980} 1974}
1981 1975
diff --git a/src/burn/engine/bundlepackageengine.cpp b/src/burn/engine/bundlepackageengine.cpp
index dafe1967..8896fdd0 100644
--- a/src/burn/engine/bundlepackageengine.cpp
+++ b/src/burn/engine/bundlepackageengine.cpp
@@ -1049,6 +1049,7 @@ static HRESULT DetectArpEntry(
1049{ 1049{
1050 HRESULT hr = S_OK; 1050 HRESULT hr = S_OK;
1051 HKEY hKey = NULL; 1051 HKEY hKey = NULL;
1052 BOOL fExists = FALSE;
1052 HKEY hkRoot = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 1053 HKEY hkRoot = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
1053 REG_KEY_BITNESS keyBitness = pPackage->Bundle.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT; 1054 REG_KEY_BITNESS keyBitness = pPackage->Bundle.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT;
1054 1055
@@ -1065,20 +1066,17 @@ static HRESULT DetectArpEntry(
1065 } 1066 }
1066 1067
1067 hr = RegOpenEx(hkRoot, pPackage->Bundle.sczArpKeyPath, KEY_READ, keyBitness, &hKey); 1068 hr = RegOpenEx(hkRoot, pPackage->Bundle.sczArpKeyPath, KEY_READ, keyBitness, &hKey);
1068 if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 1069 ExitOnPathFailure(hr, fExists, "Failed to open registry key: %ls.", pPackage->Bundle.sczArpKeyPath);
1070
1071 if (!fExists)
1069 { 1072 {
1070 ExitFunction1(hr = S_OK); 1073 ExitFunction();
1071 } 1074 }
1072 ExitOnFailure(hr, "Failed to open registry key: %ls.", pPackage->Bundle.sczArpKeyPath);
1073 1075
1074 *pfRegistered = TRUE; 1076 *pfRegistered = TRUE;
1075 1077
1076 hr = RegReadString(hKey, L"QuietUninstallString", psczQuietUninstallString); 1078 hr = RegReadString(hKey, L"QuietUninstallString", psczQuietUninstallString);
1077 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 1079 ExitOnPathFailure(hr, fExists, "Failed to read QuietUninstallString.");
1078 {
1079 hr = S_OK;
1080 }
1081 ExitOnFailure(hr, "Failed to read QuietUninstallString.");
1082 1080
1083LExit: 1081LExit:
1084 ReleaseRegKey(hKey); 1082 ReleaseRegKey(hKey);
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp
index a23ce9ed..01237162 100644
--- a/src/burn/engine/cache.cpp
+++ b/src/burn/engine/cache.cpp
@@ -1144,8 +1144,7 @@ extern "C" HRESULT CacheCompletePayload(
1144 } 1144 }
1145 else // if the working path and unverified path do not exist, nothing we can do. 1145 else // if the working path and unverified path do not exist, nothing we can do.
1146 { 1146 {
1147 hr = E_FILENOTFOUND; 1147 ExitWithRootFailure(hr, E_FILENOTFOUND, "Failed to find payload: %ls in working path: %ls and unverified path: %ls", pPayload->sczKey, wzWorkingPayloadPath, sczUnverifiedPayloadPath);
1148 ExitOnFailure(hr, "Failed to find payload: %ls in working path: %ls and unverified path: %ls", pPayload->sczKey, wzWorkingPayloadPath, sczUnverifiedPayloadPath);
1149 } 1148 }
1150 1149
1151 hr = ResetPathPermissions(fPerMachine, sczUnverifiedPayloadPath); 1150 hr = ResetPathPermissions(fPerMachine, sczUnverifiedPayloadPath);
diff --git a/src/burn/engine/dependency.cpp b/src/burn/engine/dependency.cpp
index 221c7bbf..d6698680 100644
--- a/src/burn/engine/dependency.cpp
+++ b/src/burn/engine/dependency.cpp
@@ -279,19 +279,13 @@ extern "C" HRESULT DependencyDetectBundle(
279 ) 279 )
280{ 280{
281 HRESULT hr = S_OK; 281 HRESULT hr = S_OK;
282 BOOL fExists = FALSE;
282 283
283 hr = DependencyDetectProviderKeyBundleId(pRegistration); 284 hr = DependencyDetectProviderKeyBundleId(pRegistration);
284 ExitOnFailure(hr, "Failed to detect provider key bundle id."); 285 ExitOnFailure(hr, "Failed to detect provider key bundle id.");
285 286
286 hr = DepCheckDependents(pRegistration->hkRoot, pRegistration->sczProviderKey, 0, NULL, &pRegistration->rgDependents, &pRegistration->cDependents); 287 hr = DepCheckDependents(pRegistration->hkRoot, pRegistration->sczProviderKey, 0, NULL, &pRegistration->rgDependents, &pRegistration->cDependents);
287 if (E_FILENOTFOUND != hr) 288 ExitOnPathFailure(hr, fExists, "Failed dependents check on bundle.");
288 {
289 ExitOnFailure(hr, "Failed dependents check on bundle.");
290 }
291 else
292 {
293 hr = S_OK;
294 }
295 289
296 if (pDependencies->fSelfDependent || pDependencies->fActiveParent) 290 if (pDependencies->fSelfDependent || pDependencies->fActiveParent)
297 { 291 {
@@ -813,6 +807,7 @@ extern "C" HRESULT DependencyProcessDependentRegistration(
813 ) 807 )
814{ 808{
815 HRESULT hr = S_OK; 809 HRESULT hr = S_OK;
810 BOOL fDeleted = FALSE;
816 811
817 switch (pAction->type) 812 switch (pAction->type)
818 { 813 {
@@ -823,12 +818,11 @@ extern "C" HRESULT DependencyProcessDependentRegistration(
823 818
824 case BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER: 819 case BURN_DEPENDENT_REGISTRATION_ACTION_TYPE_UNREGISTER:
825 hr = DepUnregisterDependent(pRegistration->hkRoot, pRegistration->sczProviderKey, pAction->sczDependentProviderKey); 820 hr = DepUnregisterDependent(pRegistration->hkRoot, pRegistration->sczProviderKey, pAction->sczDependentProviderKey);
826 ExitOnFailure(hr, "Failed to unregister dependent: %ls", pAction->sczDependentProviderKey); 821 ExitOnPathFailure(hr, fDeleted, "Failed to unregister dependent: %ls", pAction->sczDependentProviderKey);
827 break; 822 break;
828 823
829 default: 824 default:
830 hr = E_INVALIDARG; 825 ExitWithRootFailure(hr, E_INVALIDARG, "Unrecognized registration action type: %d", pAction->type);
831 ExitOnRootFailure(hr, "Unrecognized registration action type: %d", pAction->type);
832 } 826 }
833 827
834LExit: 828LExit:
@@ -848,11 +842,11 @@ extern "C" void DependencyUnregisterBundle(
848 { 842 {
849 // Remove the bundle provider key. 843 // Remove the bundle provider key.
850 hr = DepUnregisterDependency(pRegistration->hkRoot, pRegistration->sczProviderKey); 844 hr = DepUnregisterDependency(pRegistration->hkRoot, pRegistration->sczProviderKey);
851 if (SUCCEEDED(hr)) 845 if (SUCCEEDED(hr) || E_FILENOTFOUND == hr)
852 { 846 {
853 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED, pRegistration->sczProviderKey); 847 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED, pRegistration->sczProviderKey);
854 } 848 }
855 else if (FAILED(hr) && E_FILENOTFOUND != hr) 849 else
856 { 850 {
857 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED_FAILED, pRegistration->sczProviderKey, hr); 851 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_BUNDLE_UNREGISTERED_FAILED, pRegistration->sczProviderKey, hr);
858 } 852 }
@@ -961,13 +955,10 @@ static HRESULT DetectPackageDependents(
961 for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i) 955 for (DWORD i = 0; i < pPackage->cDependencyProviders; ++i)
962 { 956 {
963 BURN_DEPENDENCY_PROVIDER* pProvider = &pPackage->rgDependencyProviders[i]; 957 BURN_DEPENDENCY_PROVIDER* pProvider = &pPackage->rgDependencyProviders[i];
958 BOOL fExists = FALSE;
964 959
965 hr = DepCheckDependents(hkHive, pProvider->sczKey, 0, NULL, &pProvider->rgDependents, &pProvider->cDependents); 960 hr = DepCheckDependents(hkHive, pProvider->sczKey, 0, NULL, &pProvider->rgDependents, &pProvider->cDependents);
966 if (E_FILENOTFOUND == hr) 961 ExitOnPathFailure(hr, fExists, "Failed dependents check on package provider: %ls", pProvider->sczKey);
967 {
968 hr = S_OK;
969 }
970 ExitOnFailure(hr, "Failed dependents check on package provider: %ls", pProvider->sczKey);
971 962
972 if (0 < pProvider->cDependents || GetProviderExists(hkHive, pProvider->sczKey)) 963 if (0 < pProvider->cDependents || GetProviderExists(hkHive, pProvider->sczKey))
973 { 964 {
@@ -1366,11 +1357,11 @@ static void UnregisterPackageProvider(
1366 HRESULT hr = S_OK; 1357 HRESULT hr = S_OK;
1367 1358
1368 hr = DepUnregisterDependency(hkRoot, pProvider->sczKey); 1359 hr = DepUnregisterDependency(hkRoot, pProvider->sczKey);
1369 if (SUCCEEDED(hr)) 1360 if (SUCCEEDED(hr) || E_FILENOTFOUND == hr)
1370 { 1361 {
1371 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED, pProvider->sczKey, wzPackageId); 1362 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED, pProvider->sczKey, wzPackageId);
1372 } 1363 }
1373 else if (FAILED(hr) && E_FILENOTFOUND != hr) 1364 else
1374 { 1365 {
1375 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_FAILED, pProvider->sczKey, wzPackageId, hr); 1366 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_FAILED, pProvider->sczKey, wzPackageId, hr);
1376 } 1367 }
@@ -1390,15 +1381,14 @@ static HRESULT RegisterPackageProviderDependent(
1390 ) 1381 )
1391{ 1382{
1392 HRESULT hr = S_OK; 1383 HRESULT hr = S_OK;
1384 BOOL fExists = FALSE;
1393 1385
1394 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_REGISTER_DEPENDENCY, wzDependentProviderKey, pProvider->sczKey, wzPackageId); 1386 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_REGISTER_DEPENDENCY, wzDependentProviderKey, pProvider->sczKey, wzPackageId);
1395 1387
1396 hr = DepRegisterDependent(hkRoot, pProvider->sczKey, wzDependentProviderKey, NULL, NULL, 0); 1388 hr = DepRegisterDependent(hkRoot, pProvider->sczKey, wzDependentProviderKey, NULL, NULL, 0);
1397 if (E_FILENOTFOUND != hr) 1389 ExitOnPathFailure(hr, fExists, "Failed to register the dependency on package dependency provider: %ls", pProvider->sczKey);
1398 { 1390
1399 ExitOnFailure(hr, "Failed to register the dependency on package dependency provider: %ls", pProvider->sczKey); 1391 if (!fExists)
1400 }
1401 else
1402 { 1392 {
1403 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_SKIP_MISSING, pProvider->sczKey, wzPackageId); 1393 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_SKIP_MISSING, pProvider->sczKey, wzPackageId);
1404 } 1394 }
@@ -1454,11 +1444,11 @@ static void UnregisterPackageProviderDependent(
1454 HRESULT hr = S_OK; 1444 HRESULT hr = S_OK;
1455 1445
1456 hr = DepUnregisterDependent(hkRoot, pProvider->sczKey, wzDependentProviderKey); 1446 hr = DepUnregisterDependent(hkRoot, pProvider->sczKey, wzDependentProviderKey);
1457 if (SUCCEEDED(hr)) 1447 if (SUCCEEDED(hr) || E_FILENOTFOUND == hr)
1458 { 1448 {
1459 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_DEPENDENCY, wzDependentProviderKey, pProvider->sczKey, wzPackageId); 1449 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_DEPENDENCY, wzDependentProviderKey, pProvider->sczKey, wzPackageId);
1460 } 1450 }
1461 else if (FAILED(hr) && E_FILENOTFOUND != hr) 1451 else
1462 { 1452 {
1463 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_DEPENDENCY_FAILED, wzDependentProviderKey, pProvider->sczKey, wzPackageId, hr); 1453 LogId(REPORT_VERBOSE, MSG_DEPENDENCY_PACKAGE_UNREGISTERED_DEPENDENCY_FAILED, wzDependentProviderKey, pProvider->sczKey, wzPackageId, hr);
1464 } 1454 }
diff --git a/src/burn/engine/exeengine.cpp b/src/burn/engine/exeengine.cpp
index ef0015ac..b4898d42 100644
--- a/src/burn/engine/exeengine.cpp
+++ b/src/burn/engine/exeengine.cpp
@@ -1040,6 +1040,7 @@ static HRESULT DetectArpEntry(
1040{ 1040{
1041 HRESULT hr = S_OK; 1041 HRESULT hr = S_OK;
1042 HKEY hKey = NULL; 1042 HKEY hKey = NULL;
1043 BOOL fExists = FALSE;
1043 VERUTIL_VERSION* pVersion = NULL; 1044 VERUTIL_VERSION* pVersion = NULL;
1044 int nCompareResult = 0; 1045 int nCompareResult = 0;
1045 HKEY hkRoot = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 1046 HKEY hkRoot = pPackage->fPerMachine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
@@ -1052,18 +1053,20 @@ static HRESULT DetectArpEntry(
1052 } 1053 }
1053 1054
1054 hr = RegOpenEx(hkRoot, pPackage->Exe.sczArpKeyPath, KEY_READ, keyBitness, &hKey); 1055 hr = RegOpenEx(hkRoot, pPackage->Exe.sczArpKeyPath, KEY_READ, keyBitness, &hKey);
1055 if (HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr || HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 1056 ExitOnPathFailure(hr, fExists, "Failed to open registry key: %ls.", pPackage->Exe.sczArpKeyPath);
1057
1058 if (!fExists)
1056 { 1059 {
1057 ExitFunction1(hr = S_OK); 1060 ExitFunction();
1058 } 1061 }
1059 ExitOnFailure(hr, "Failed to open registry key: %ls.", pPackage->Exe.sczArpKeyPath);
1060 1062
1061 hr = RegReadWixVersion(hKey, L"DisplayVersion", &pVersion); 1063 hr = RegReadWixVersion(hKey, L"DisplayVersion", &pVersion);
1062 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 1064 ExitOnPathFailure(hr, fExists, "Failed to read DisplayVersion.");
1065
1066 if (!fExists)
1063 { 1067 {
1064 ExitFunction1(hr = S_OK); 1068 ExitFunction();
1065 } 1069 }
1066 ExitOnFailure(hr, "Failed to read DisplayVersion.");
1067 1070
1068 if (pVersion->fInvalid) 1071 if (pVersion->fInvalid)
1069 { 1072 {
@@ -1089,11 +1092,7 @@ static HRESULT DetectArpEntry(
1089 if (psczQuietUninstallString) 1092 if (psczQuietUninstallString)
1090 { 1093 {
1091 hr = RegReadString(hKey, L"QuietUninstallString", psczQuietUninstallString); 1094 hr = RegReadString(hKey, L"QuietUninstallString", psczQuietUninstallString);
1092 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 1095 ExitOnPathFailure(hr, fExists, "Failed to read QuietUninstallString.");
1093 {
1094 hr = S_OK;
1095 }
1096 ExitOnFailure(hr, "Failed to read QuietUninstallString.");
1097 } 1096 }
1098 1097
1099LExit: 1098LExit:
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp
index 484c08ac..35100336 100644
--- a/src/burn/engine/registration.cpp
+++ b/src/burn/engine/registration.cpp
@@ -492,25 +492,28 @@ extern "C" HRESULT RegistrationDetectResumeType(
492{ 492{
493 HRESULT hr = S_OK; 493 HRESULT hr = S_OK;
494 HKEY hkRegistration = NULL; 494 HKEY hkRegistration = NULL;
495 BOOL fExists = FALSE;
495 DWORD dwResume = 0; 496 DWORD dwResume = 0;
496 497
497 // open registration key 498 // open registration key
498 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration); 499 hr = RegOpen(pRegistration->hkRoot, pRegistration->sczRegistrationKey, KEY_QUERY_VALUE, &hkRegistration);
499 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 500 ExitOnPathFailure(hr, fExists, "Failed to open registration key.");
501
502 if (!fExists)
500 { 503 {
501 *pResumeType = BOOTSTRAPPER_RESUME_TYPE_NONE; 504 *pResumeType = BOOTSTRAPPER_RESUME_TYPE_NONE;
502 ExitFunction1(hr = S_OK); 505 ExitFunction();
503 } 506 }
504 ExitOnFailure(hr, "Failed to open registration key.");
505 507
506 // read Resume value 508 // read Resume value
507 hr = RegReadNumber(hkRegistration, L"Resume", &dwResume); 509 hr = RegReadNumber(hkRegistration, L"Resume", &dwResume);
508 if (E_FILENOTFOUND == hr) 510 ExitOnPathFailure(hr, fExists, "Failed to read Resume value.");
511
512 if (!fExists)
509 { 513 {
510 *pResumeType = BOOTSTRAPPER_RESUME_TYPE_INVALID; 514 *pResumeType = BOOTSTRAPPER_RESUME_TYPE_INVALID;
511 ExitFunction1(hr = S_OK); 515 ExitFunction();
512 } 516 }
513 ExitOnFailure(hr, "Failed to read Resume value.");
514 517
515 switch (dwResume) 518 switch (dwResume)
516 { 519 {
@@ -855,6 +858,7 @@ extern "C" HRESULT RegistrationSessionEnd(
855{ 858{
856 HRESULT hr = S_OK; 859 HRESULT hr = S_OK;
857 HKEY hkRegistration = NULL; 860 HKEY hkRegistration = NULL;
861 BOOL fDeleted = FALSE;
858 862
859 // If no resume mode, then remove the bundle registration. 863 // If no resume mode, then remove the bundle registration.
860 if (BURN_RESUME_MODE_NONE == resumeMode) 864 if (BURN_RESUME_MODE_NONE == resumeMode)
@@ -874,10 +878,7 @@ extern "C" HRESULT RegistrationSessionEnd(
874 878
875 // Delete registration key. 879 // Delete registration key.
876 hr = RegDelete(pRegistration->hkRoot, pRegistration->sczRegistrationKey, REG_KEY_DEFAULT, TRUE); 880 hr = RegDelete(pRegistration->hkRoot, pRegistration->sczRegistrationKey, REG_KEY_DEFAULT, TRUE);
877 if (E_FILENOTFOUND != hr) 881 ExitOnPathFailure(hr, fDeleted, "Failed to delete registration key: %ls", pRegistration->sczRegistrationKey);
878 {
879 ExitOnFailure(hr, "Failed to delete registration key: %ls", pRegistration->sczRegistrationKey);
880 }
881 882
882 CacheRemoveBundle(pCache, pRegistration->fPerMachine, pRegistration->sczId); 883 CacheRemoveBundle(pCache, pRegistration->fPerMachine, pRegistration->sczId);
883 } 884 }
@@ -967,7 +968,10 @@ extern "C" HRESULT RegistrationSaveState(
967 ExitOnFailure(hr, "Failed to enumerate value %u", i); 968 ExitOnFailure(hr, "Failed to enumerate value %u", i);
968 969
969 er = ::RegDeleteValueW(hkRegistration, sczValueName); 970 er = ::RegDeleteValueW(hkRegistration, sczValueName);
970 ExitOnWin32Error(er, hr, "Failed to delete registration variable value."); 971 if (ERROR_FILE_NOT_FOUND != er)
972 {
973 ExitOnWin32Error(er, hr, "Failed to delete registration variable value.");
974 }
971 } 975 }
972 976
973 // Write variables. 977 // Write variables.
@@ -1486,6 +1490,7 @@ static HRESULT RemoveUpdateRegistration(
1486 LPWSTR sczPackageVersion = NULL; 1490 LPWSTR sczPackageVersion = NULL;
1487 HKEY hkKey = NULL; 1491 HKEY hkKey = NULL;
1488 BOOL fDeleteRegKey = TRUE; 1492 BOOL fDeleteRegKey = TRUE;
1493 BOOL fDeleted = FALSE;
1489 1494
1490 hr = FormatUpdateRegistrationKey(pRegistration, &sczKey); 1495 hr = FormatUpdateRegistrationKey(pRegistration, &sczKey);
1491 ExitOnFailure(hr, "Failed to format key for update registration."); 1496 ExitOnFailure(hr, "Failed to format key for update registration.");
@@ -1513,10 +1518,7 @@ static HRESULT RemoveUpdateRegistration(
1513 if (fDeleteRegKey) 1518 if (fDeleteRegKey)
1514 { 1519 {
1515 hr = RegDelete(pRegistration->hkRoot, sczKey, REG_KEY_DEFAULT, FALSE); 1520 hr = RegDelete(pRegistration->hkRoot, sczKey, REG_KEY_DEFAULT, FALSE);
1516 if (E_FILENOTFOUND != hr) 1521 ExitOnPathFailure(hr, fDeleted, "Failed to remove update registration key: %ls", sczKey);
1517 {
1518 ExitOnFailure(hr, "Failed to remove update registration key: %ls", sczKey);
1519 }
1520 } 1522 }
1521 1523
1522LExit: 1524LExit:
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp
index 586446b1..23e0f352 100644
--- a/src/burn/engine/relatedbundle.cpp
+++ b/src/burn/engine/relatedbundle.cpp
@@ -322,6 +322,7 @@ static HRESULT LoadRelatedBundleFromKey(
322 LPWSTR sczCachePath = NULL; 322 LPWSTR sczCachePath = NULL;
323 BOOL fCached = FALSE; 323 BOOL fCached = FALSE;
324 DWORD64 qwFileSize = 0; 324 DWORD64 qwFileSize = 0;
325 BOOL fExists = FALSE;
325 BURN_DEPENDENCY_PROVIDER dependencyProvider = { }; 326 BURN_DEPENDENCY_PROVIDER dependencyProvider = { };
326 BURN_DEPENDENCY_PROVIDER* pBundleDependencyProvider = NULL; 327 BURN_DEPENDENCY_PROVIDER* pBundleDependencyProvider = NULL;
327 328
@@ -369,10 +370,7 @@ static HRESULT LoadRelatedBundleFromKey(
369 pRelatedBundle->fPlannable = fCached; 370 pRelatedBundle->fPlannable = fCached;
370 371
371 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY, &dependencyProvider.sczKey); 372 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_PROVIDER_KEY, &dependencyProvider.sczKey);
372 if (E_FILENOTFOUND != hr) 373 ExitOnPathFailure(hr, fExists, "Failed to read provider key from registry for bundle: %ls", wzRelatedBundleId);
373 {
374 ExitOnFailure(hr, "Failed to read provider key from registry for bundle: %ls", wzRelatedBundleId);
375 }
376 374
377 if (dependencyProvider.sczKey && *dependencyProvider.sczKey) 375 if (dependencyProvider.sczKey && *dependencyProvider.sczKey)
378 { 376 {
@@ -384,18 +382,11 @@ static HRESULT LoadRelatedBundleFromKey(
384 ExitOnFailure(hr, "Failed to copy version for bundle: %ls", wzRelatedBundleId); 382 ExitOnFailure(hr, "Failed to copy version for bundle: %ls", wzRelatedBundleId);
385 383
386 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME, &dependencyProvider.sczDisplayName); 384 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_DISPLAY_NAME, &dependencyProvider.sczDisplayName);
387 if (E_FILENOTFOUND != hr) 385 ExitOnPathFailure(hr, fExists, "Failed to copy display name for bundle: %ls", wzRelatedBundleId);
388 {
389 ExitOnFailure(hr, "Failed to copy display name for bundle: %ls", wzRelatedBundleId);
390 }
391 } 386 }
392 387
393 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_TAG, &pRelatedBundle->sczTag); 388 hr = RegReadString(hkBundleId, BURN_REGISTRATION_REGISTRY_BUNDLE_TAG, &pRelatedBundle->sczTag);
394 if (E_FILENOTFOUND == hr) 389 ExitOnPathFailure(hr, fExists, "Failed to read tag from registry for bundle: %ls", wzRelatedBundleId);
395 {
396 hr = S_OK;
397 }
398 ExitOnFailure(hr, "Failed to read tag from registry for bundle: %ls", wzRelatedBundleId);
399 390
400 pRelatedBundle->detectRelationType = relationType; 391 pRelatedBundle->detectRelationType = relationType;
401 392
diff --git a/src/burn/engine/search.cpp b/src/burn/engine/search.cpp
index b37dc9bd..a1b6b74a 100644
--- a/src/burn/engine/search.cpp
+++ b/src/burn/engine/search.cpp
@@ -610,6 +610,7 @@ static HRESULT DirectorySearchExists(
610 ) 610 )
611{ 611{
612 HRESULT hr = S_OK; 612 HRESULT hr = S_OK;
613 DWORD er = ERROR_SUCCESS;
613 LPWSTR sczPath = NULL; 614 LPWSTR sczPath = NULL;
614 BOOL fExists = FALSE; 615 BOOL fExists = FALSE;
615 616
@@ -629,21 +630,25 @@ static HRESULT DirectorySearchExists(
629 DWORD dwAttributes = ::GetFileAttributesW(sczPath); 630 DWORD dwAttributes = ::GetFileAttributesW(sczPath);
630 if (INVALID_FILE_ATTRIBUTES == dwAttributes) 631 if (INVALID_FILE_ATTRIBUTES == dwAttributes)
631 { 632 {
632 hr = HRESULT_FROM_WIN32(::GetLastError()); 633 er = ::GetLastError();
633 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 634 if (ERROR_FILE_NOT_FOUND == er || ERROR_PATH_NOT_FOUND == er)
634 { 635 {
635 hr = S_OK; // didn't find file, fExists still is false. 636 LogStringLine(REPORT_STANDARD, "Directory search: %ls, did not find path: %ls", pSearch->sczKey, pSearch->DirectorySearch.sczPath);
637 }
638 else
639 {
640 ExitOnWin32Error(er, hr, "Directory search: %ls, failed get to directory attributes. '%ls'", pSearch->sczKey, pSearch->DirectorySearch.sczPath);
636 } 641 }
637 } 642 }
638 else if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) 643 else if (FILE_ATTRIBUTE_DIRECTORY != (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
644 {
645 LogStringLine(REPORT_STANDARD, "Directory search: %ls, found file at path: %ls", pSearch->sczKey, pSearch->DirectorySearch.sczPath);
646 }
647 else
639 { 648 {
640 fExists = TRUE; 649 fExists = TRUE;
641 } 650 }
642 651
643 // else must have found a file.
644 // What if there is a hidden variable in sczPath?
645 ExitOnFailure(hr, "Failed while searching directory search: %ls, for path: %ls", pSearch->sczKey, sczPath);
646
647 // set variable 652 // set variable
648 hr = VariableSetNumeric(pVariables, pSearch->sczVariable, fExists, FALSE); 653 hr = VariableSetNumeric(pVariables, pSearch->sczVariable, fExists, FALSE);
649 ExitOnFailure(hr, "Failed to set variable."); 654 ExitOnFailure(hr, "Failed to set variable.");
@@ -694,13 +699,12 @@ static HRESULT DirectorySearchPath(
694 hr = E_PATHNOTFOUND; 699 hr = E_PATHNOTFOUND;
695 } 700 }
696 701
697 // What if there is a hidden variable in sczPath?
698 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 702 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
699 { 703 {
700 LogStringLine(REPORT_STANDARD, "Directory search: %ls, did not find path: %ls, reason: 0x%x", pSearch->sczKey, sczPath, hr); 704 LogStringLine(REPORT_STANDARD, "Directory search: %ls, did not find path: %ls, reason: 0x%x", pSearch->sczKey, pSearch->DirectorySearch.sczPath, hr);
701 ExitFunction1(hr = S_OK); 705 ExitFunction1(hr = S_OK);
702 } 706 }
703 ExitOnFailure(hr, "Failed while searching directory search: %ls, for path: %ls", pSearch->sczKey, sczPath); 707 ExitOnFailure(hr, "Failed while searching directory search: %ls, for path: %ls", pSearch->sczKey, pSearch->DirectorySearch.sczPath);
704 708
705LExit: 709LExit:
706#if !defined(_WIN64) 710#if !defined(_WIN64)
@@ -742,15 +746,18 @@ static HRESULT FileSearchExists(
742 er = ::GetLastError(); 746 er = ::GetLastError();
743 if (ERROR_FILE_NOT_FOUND == er || ERROR_PATH_NOT_FOUND == er) 747 if (ERROR_FILE_NOT_FOUND == er || ERROR_PATH_NOT_FOUND == er)
744 { 748 {
745 // What if there is a hidden variable in sczPath? 749 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, pSearch->FileSearch.sczPath);
746 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, sczPath);
747 } 750 }
748 else 751 else
749 { 752 {
750 ExitOnWin32Error(er, hr, "Failed get to file attributes. '%ls'", pSearch->FileSearch.sczPath); 753 ExitOnWin32Error(er, hr, "File search: %ls, failed get to file attributes. '%ls'", pSearch->sczKey, pSearch->FileSearch.sczPath);
751 } 754 }
752 } 755 }
753 else if (FILE_ATTRIBUTE_DIRECTORY != (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) 756 else if (FILE_ATTRIBUTE_DIRECTORY == (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
757 {
758 LogStringLine(REPORT_STANDARD, "File search: %ls, found directory at path: %ls", pSearch->sczKey, pSearch->FileSearch.sczPath);
759 }
760 else
754 { 761 {
755 fExists = TRUE; 762 fExists = TRUE;
756 } 763 }
@@ -795,8 +802,7 @@ static HRESULT FileSearchVersion(
795 hr = FileVersion(sczPath, &uliVersion.HighPart, &uliVersion.LowPart); 802 hr = FileVersion(sczPath, &uliVersion.HighPart, &uliVersion.LowPart);
796 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 803 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
797 { 804 {
798 // What if there is a hidden variable in sczPath? 805 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, pSearch->FileSearch.sczPath);
799 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, sczPath);
800 ExitFunction1(hr = S_OK); 806 ExitFunction1(hr = S_OK);
801 } 807 }
802 ExitOnFailure(hr, "Failed to get file version."); 808 ExitOnFailure(hr, "Failed to get file version.");
@@ -854,13 +860,12 @@ static HRESULT FileSearchPath(
854 ExitOnFailure(hr, "Failed to set variable to file search path."); 860 ExitOnFailure(hr, "Failed to set variable to file search path.");
855 } 861 }
856 862
857 // What if there is a hidden variable in sczPath?
858 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) 863 if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
859 { 864 {
860 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, sczPath); 865 LogStringLine(REPORT_STANDARD, "File search: %ls, did not find path: %ls", pSearch->sczKey, pSearch->FileSearch.sczPath);
861 ExitFunction1(hr = S_OK); 866 ExitFunction1(hr = S_OK);
862 } 867 }
863 ExitOnFailure(hr, "Failed while searching file search: %ls, for path: %ls", pSearch->sczKey, sczPath); 868 ExitOnFailure(hr, "Failed while searching file search: %ls, for path: %ls", pSearch->sczKey, pSearch->FileSearch.sczPath);
864 869
865LExit: 870LExit:
866#if !defined(_WIN64) 871#if !defined(_WIN64)
@@ -891,24 +896,13 @@ static HRESULT RegistrySearchExists(
891 896
892 // open key 897 // open key
893 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey); 898 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey);
894 if (SUCCEEDED(hr)) 899 ExitOnPathFailure(hr, fExists, "Failed to open registry key. Key = '%ls'", pSearch->RegistrySearch.sczKey);
895 { 900
896 fExists = TRUE; 901 if (!fExists)
897 }
898 else if (E_FILENOTFOUND == hr)
899 {
900 // What if there is a hidden variable in sczKey?
901 LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", sczKey);
902 fExists = FALSE;
903 hr = S_OK;
904 }
905 else
906 { 902 {
907 // What if there is a hidden variable in sczKey? 903 LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", pSearch->RegistrySearch.sczKey);
908 ExitOnFailure(hr, "Failed to open registry key. Key = '%ls'", sczKey);
909 } 904 }
910 905 else if (pSearch->RegistrySearch.sczValue)
911 if (fExists && pSearch->RegistrySearch.sczValue)
912 { 906 {
913 // format value string 907 // format value string
914 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczValue, &sczValue, NULL); 908 hr = VariableFormatString(pVariables, pSearch->RegistrySearch.sczValue, &sczValue, NULL);
@@ -922,8 +916,7 @@ static HRESULT RegistrySearchExists(
922 fExists = TRUE; 916 fExists = TRUE;
923 break; 917 break;
924 case ERROR_FILE_NOT_FOUND: 918 case ERROR_FILE_NOT_FOUND:
925 // What if there is a hidden variable in sczKey or sczValue? 919 LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", pSearch->RegistrySearch.sczKey, pSearch->RegistrySearch.sczValue);
926 LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", sczKey, sczValue);
927 fExists = FALSE; 920 fExists = FALSE;
928 break; 921 break;
929 default: 922 default:
@@ -938,8 +931,7 @@ static HRESULT RegistrySearchExists(
938LExit: 931LExit:
939 if (FAILED(hr)) 932 if (FAILED(hr))
940 { 933 {
941 // What if there is a hidden variable in sczKey? 934 LogStringLine(REPORT_STANDARD, "RegistrySearchExists failed: ID '%ls', HRESULT 0x%x", pSearch->sczKey, hr);
942 LogStringLine(REPORT_STANDARD, "RegistrySearchExists failed: ID '%ls', HRESULT 0x%x", sczKey, hr);
943 } 935 }
944 936
945 StrSecureZeroFreeString(sczKey); 937 StrSecureZeroFreeString(sczKey);
@@ -958,6 +950,7 @@ static HRESULT RegistrySearchValue(
958 LPWSTR sczKey = NULL; 950 LPWSTR sczKey = NULL;
959 LPWSTR sczValue = NULL; 951 LPWSTR sczValue = NULL;
960 HKEY hKey = NULL; 952 HKEY hKey = NULL;
953 BOOL fExists = FALSE;
961 DWORD dwType = 0; 954 DWORD dwType = 0;
962 SIZE_T cbData = 0; 955 SIZE_T cbData = 0;
963 LPBYTE pData = NULL; 956 LPBYTE pData = NULL;
@@ -978,21 +971,20 @@ static HRESULT RegistrySearchValue(
978 971
979 // open key 972 // open key
980 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey); 973 hr = RegOpenEx(pSearch->RegistrySearch.hRoot, sczKey, KEY_QUERY_VALUE, pSearch->RegistrySearch.fWin64 ? REG_KEY_64BIT : REG_KEY_32BIT, &hKey);
981 if (E_FILENOTFOUND == hr) 974 ExitOnPathFailure(hr, fExists, "Failed to open registry key.");
975
976 if (!fExists)
982 { 977 {
983 // What if there is a hidden variable in sczKey? 978 LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", pSearch->RegistrySearch.sczKey);
984 LogStringLine(REPORT_STANDARD, "Registry key not found. Key = '%ls'", sczKey);
985 979
986 ExitFunction1(hr = S_OK); 980 ExitFunction();
987 } 981 }
988 ExitOnFailure(hr, "Failed to open registry key.");
989 982
990 // get value 983 // get value
991 hr = RegReadValue(hKey, sczValue, pSearch->RegistrySearch.fExpandEnvironment, &pData, &cbData, &dwType); 984 hr = RegReadValue(hKey, sczValue, pSearch->RegistrySearch.fExpandEnvironment, &pData, &cbData, &dwType);
992 if (E_FILENOTFOUND == hr) 985 if (E_FILENOTFOUND == hr)
993 { 986 {
994 // What if there is a hidden variable in sczKey or sczValue? 987 LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", pSearch->RegistrySearch.sczKey, pSearch->RegistrySearch.sczValue);
995 LogStringLine(REPORT_STANDARD, "Registry value not found. Key = '%ls', Value = '%ls'", sczKey, sczValue);
996 988
997 ExitFunction1(hr = S_OK); 989 ExitFunction1(hr = S_OK);
998 } 990 }
@@ -1034,8 +1026,7 @@ static HRESULT RegistrySearchValue(
1034LExit: 1026LExit:
1035 if (FAILED(hr)) 1027 if (FAILED(hr))
1036 { 1028 {
1037 // What if there is a hidden variable in sczKey? 1029 LogStringLine(REPORT_STANDARD, "RegistrySearchValue failed: ID '%ls', HRESULT 0x%x", pSearch->sczKey, hr);
1038 LogStringLine(REPORT_STANDARD, "RegistrySearchValue failed: ID '%ls', HRESULT 0x%x", sczKey, hr);
1039 } 1030 }
1040 1031
1041 StrSecureZeroFreeString(sczKey); 1032 StrSecureZeroFreeString(sczKey);