diff options
Diffstat (limited to 'src/engine/registration.cpp')
-rw-r--r-- | src/engine/registration.cpp | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/engine/registration.cpp b/src/engine/registration.cpp index fc5ae627..b8a2283f 100644 --- a/src/engine/registration.cpp +++ b/src/engine/registration.cpp | |||
@@ -31,6 +31,7 @@ const LPCWSTR REGISTRY_BUNDLE_UNINSTALL_STRING = L"UninstallString"; | |||
31 | const LPCWSTR REGISTRY_BUNDLE_RESUME_COMMAND_LINE = L"BundleResumeCommandLine"; | 31 | const LPCWSTR REGISTRY_BUNDLE_RESUME_COMMAND_LINE = L"BundleResumeCommandLine"; |
32 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MAJOR = L"VersionMajor"; | 32 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MAJOR = L"VersionMajor"; |
33 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MINOR = L"VersionMinor"; | 33 | const LPCWSTR REGISTRY_BUNDLE_VERSION_MINOR = L"VersionMinor"; |
34 | const LPCWSTR SWIDTAG_FOLDER = L"swidtag"; | ||
34 | 35 | ||
35 | // internal function declarations | 36 | // internal function declarations |
36 | 37 | ||
@@ -67,11 +68,11 @@ static HRESULT FormatUpdateRegistrationKey( | |||
67 | __out_z LPWSTR* psczKey | 68 | __out_z LPWSTR* psczKey |
68 | ); | 69 | ); |
69 | static HRESULT WriteSoftwareTags( | 70 | static HRESULT WriteSoftwareTags( |
70 | __in BOOL fPerMachine, | 71 | __in BURN_VARIABLES* pVariables, |
71 | __in BURN_SOFTWARE_TAGS* pSoftwareTags | 72 | __in BURN_SOFTWARE_TAGS* pSoftwareTags |
72 | ); | 73 | ); |
73 | static HRESULT RemoveSoftwareTags( | 74 | static HRESULT RemoveSoftwareTags( |
74 | __in BOOL fPerMachine, | 75 | __in BURN_VARIABLES* pVariables, |
75 | __in BURN_SOFTWARE_TAGS* pSoftwareTags | 76 | __in BURN_SOFTWARE_TAGS* pSoftwareTags |
76 | ); | 77 | ); |
77 | static HRESULT WriteUpdateRegistration( | 78 | static HRESULT WriteUpdateRegistration( |
@@ -392,6 +393,7 @@ extern "C" void RegistrationUninitialize( | |||
392 | { | 393 | { |
393 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczFilename); | 394 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczFilename); |
394 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczRegid); | 395 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczRegid); |
396 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczPath); | ||
395 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczTag); | 397 | ReleaseStr(pRegistration->softwareTags.rgSoftwareTags[i].sczTag); |
396 | } | 398 | } |
397 | 399 | ||
@@ -778,7 +780,7 @@ extern "C" HRESULT RegistrationSessionBegin( | |||
778 | 780 | ||
779 | if (pRegistration->softwareTags.cSoftwareTags) | 781 | if (pRegistration->softwareTags.cSoftwareTags) |
780 | { | 782 | { |
781 | hr = WriteSoftwareTags(pRegistration->fPerMachine, &pRegistration->softwareTags); | 783 | hr = WriteSoftwareTags(pVariables, &pRegistration->softwareTags); |
782 | ExitOnFailure(hr, "Failed to write software tags."); | 784 | ExitOnFailure(hr, "Failed to write software tags."); |
783 | } | 785 | } |
784 | 786 | ||
@@ -867,6 +869,7 @@ LExit: | |||
867 | *******************************************************************/ | 869 | *******************************************************************/ |
868 | extern "C" HRESULT RegistrationSessionEnd( | 870 | extern "C" HRESULT RegistrationSessionEnd( |
869 | __in BURN_REGISTRATION* pRegistration, | 871 | __in BURN_REGISTRATION* pRegistration, |
872 | __in BURN_VARIABLES* pVariables, | ||
870 | __in BURN_PACKAGES* pPackages, | 873 | __in BURN_PACKAGES* pPackages, |
871 | __in BURN_RESUME_MODE resumeMode, | 874 | __in BURN_RESUME_MODE resumeMode, |
872 | __in BOOTSTRAPPER_APPLY_RESTART restart, | 875 | __in BOOTSTRAPPER_APPLY_RESTART restart, |
@@ -920,7 +923,7 @@ extern "C" HRESULT RegistrationSessionEnd( | |||
920 | RemoveUpdateRegistration(pRegistration); | 923 | RemoveUpdateRegistration(pRegistration); |
921 | } | 924 | } |
922 | 925 | ||
923 | RemoveSoftwareTags(pRegistration->fPerMachine, &pRegistration->softwareTags); | 926 | RemoveSoftwareTags(pVariables, &pRegistration->softwareTags); |
924 | 927 | ||
925 | // Delete registration key. | 928 | // Delete registration key. |
926 | hr = RegDelete(pRegistration->hkRoot, pRegistration->sczRegistrationKey, REG_KEY_DEFAULT, FALSE); | 929 | hr = RegDelete(pRegistration->hkRoot, pRegistration->sczRegistrationKey, REG_KEY_DEFAULT, FALSE); |
@@ -1063,6 +1066,9 @@ static HRESULT ParseSoftwareTagsFromXml( | |||
1063 | hr = XmlGetAttributeEx(pixnNode, L"Regid", &pSoftwareTag->sczRegid); | 1066 | hr = XmlGetAttributeEx(pixnNode, L"Regid", &pSoftwareTag->sczRegid); |
1064 | ExitOnFailure(hr, "Failed to get @Regid."); | 1067 | ExitOnFailure(hr, "Failed to get @Regid."); |
1065 | 1068 | ||
1069 | hr = XmlGetAttributeEx(pixnNode, L"Path", &pSoftwareTag->sczPath); | ||
1070 | ExitOnFailure(hr, "Failed to get @Path."); | ||
1071 | |||
1066 | hr = XmlGetText(pixnNode, &bstrTagXml); | 1072 | hr = XmlGetText(pixnNode, &bstrTagXml); |
1067 | ExitOnFailure(hr, "Failed to get SoftwareTag text."); | 1073 | ExitOnFailure(hr, "Failed to get SoftwareTag text."); |
1068 | 1074 | ||
@@ -1370,30 +1376,30 @@ LExit: | |||
1370 | } | 1376 | } |
1371 | 1377 | ||
1372 | static HRESULT WriteSoftwareTags( | 1378 | static HRESULT WriteSoftwareTags( |
1373 | __in BOOL fPerMachine, | 1379 | __in BURN_VARIABLES* pVariables, |
1374 | __in BURN_SOFTWARE_TAGS* pSoftwareTags | 1380 | __in BURN_SOFTWARE_TAGS* pSoftwareTags |
1375 | ) | 1381 | ) |
1376 | { | 1382 | { |
1377 | HRESULT hr = S_OK; | 1383 | HRESULT hr = S_OK; |
1378 | LPWSTR sczRootFolder = NULL; | 1384 | LPWSTR sczRootFolder = NULL; |
1379 | LPWSTR sczRegidFolder = NULL; | 1385 | LPWSTR sczTagFolder = NULL; |
1380 | LPWSTR sczPath = NULL; | 1386 | LPWSTR sczPath = NULL; |
1381 | 1387 | ||
1382 | hr = PathGetKnownFolder(fPerMachine ? CSIDL_COMMON_APPDATA : CSIDL_LOCAL_APPDATA, &sczRootFolder); | ||
1383 | ExitOnFailure(hr, "Failed to find local %hs appdata directory.", fPerMachine ? "per-machine" : "per-user"); | ||
1384 | |||
1385 | for (DWORD iTag = 0; iTag < pSoftwareTags->cSoftwareTags; ++iTag) | 1388 | for (DWORD iTag = 0; iTag < pSoftwareTags->cSoftwareTags; ++iTag) |
1386 | { | 1389 | { |
1387 | BURN_SOFTWARE_TAG* pSoftwareTag = pSoftwareTags->rgSoftwareTags + iTag; | 1390 | BURN_SOFTWARE_TAG* pSoftwareTag = pSoftwareTags->rgSoftwareTags + iTag; |
1388 | 1391 | ||
1389 | hr = PathConcat(sczRootFolder, pSoftwareTag->sczRegid, &sczRegidFolder); | 1392 | hr = VariableFormatString(pVariables, pSoftwareTag->sczPath, &sczRootFolder, NULL); |
1390 | ExitOnFailure(hr, "Failed to allocate regid folder path."); | 1393 | ExitOnFailure(hr, "Failed to format tag folder path."); |
1391 | 1394 | ||
1392 | hr = PathConcat(sczRegidFolder, pSoftwareTag->sczFilename, &sczPath); | 1395 | hr = PathConcat(sczRootFolder, SWIDTAG_FOLDER, &sczTagFolder); |
1393 | ExitOnFailure(hr, "Failed to allocate regid folder path."); | 1396 | ExitOnFailure(hr, "Failed to allocate regid folder path."); |
1394 | 1397 | ||
1395 | hr = DirEnsureExists(sczRegidFolder, NULL); | 1398 | hr = PathConcat(sczTagFolder, pSoftwareTag->sczFilename, &sczPath); |
1396 | ExitOnFailure(hr, "Failed to create regid folder: %ls", sczRegidFolder); | 1399 | ExitOnFailure(hr, "Failed to allocate regid file path."); |
1400 | |||
1401 | hr = DirEnsureExists(sczTagFolder, NULL); | ||
1402 | ExitOnFailure(hr, "Failed to create regid folder: %ls", sczTagFolder); | ||
1397 | 1403 | ||
1398 | hr = FileWrite(sczPath, FILE_ATTRIBUTE_NORMAL, reinterpret_cast<LPBYTE>(pSoftwareTag->sczTag), lstrlenA(pSoftwareTag->sczTag), NULL); | 1404 | hr = FileWrite(sczPath, FILE_ATTRIBUTE_NORMAL, reinterpret_cast<LPBYTE>(pSoftwareTag->sczTag), lstrlenA(pSoftwareTag->sczTag), NULL); |
1399 | ExitOnFailure(hr, "Failed to write tag xml to file: %ls", sczPath); | 1405 | ExitOnFailure(hr, "Failed to write tag xml to file: %ls", sczPath); |
@@ -1401,44 +1407,44 @@ static HRESULT WriteSoftwareTags( | |||
1401 | 1407 | ||
1402 | LExit: | 1408 | LExit: |
1403 | ReleaseStr(sczPath); | 1409 | ReleaseStr(sczPath); |
1404 | ReleaseStr(sczRegidFolder); | 1410 | ReleaseStr(sczTagFolder); |
1405 | ReleaseStr(sczRootFolder); | 1411 | ReleaseStr(sczRootFolder); |
1406 | 1412 | ||
1407 | return hr; | 1413 | return hr; |
1408 | } | 1414 | } |
1409 | 1415 | ||
1410 | static HRESULT RemoveSoftwareTags( | 1416 | static HRESULT RemoveSoftwareTags( |
1411 | __in BOOL fPerMachine, | 1417 | __in BURN_VARIABLES* pVariables, |
1412 | __in BURN_SOFTWARE_TAGS* pSoftwareTags | 1418 | __in BURN_SOFTWARE_TAGS* pSoftwareTags |
1413 | ) | 1419 | ) |
1414 | { | 1420 | { |
1415 | HRESULT hr = S_OK; | 1421 | HRESULT hr = S_OK; |
1416 | LPWSTR sczRootFolder = NULL; | 1422 | LPWSTR sczRootFolder = NULL; |
1417 | LPWSTR sczRegidFolder = NULL; | 1423 | LPWSTR sczTagFolder = NULL; |
1418 | LPWSTR sczPath = NULL; | 1424 | LPWSTR sczPath = NULL; |
1419 | 1425 | ||
1420 | hr = PathGetKnownFolder(fPerMachine ? CSIDL_COMMON_APPDATA : CSIDL_LOCAL_APPDATA, &sczRootFolder); | ||
1421 | ExitOnFailure(hr, "Failed to find local %hs appdata directory.", fPerMachine ? "per-machine" : "per-user"); | ||
1422 | |||
1423 | for (DWORD iTag = 0; iTag < pSoftwareTags->cSoftwareTags; ++iTag) | 1426 | for (DWORD iTag = 0; iTag < pSoftwareTags->cSoftwareTags; ++iTag) |
1424 | { | 1427 | { |
1425 | BURN_SOFTWARE_TAG* pSoftwareTag = pSoftwareTags->rgSoftwareTags + iTag; | 1428 | BURN_SOFTWARE_TAG* pSoftwareTag = pSoftwareTags->rgSoftwareTags + iTag; |
1426 | 1429 | ||
1427 | hr = PathConcat(sczRootFolder, pSoftwareTag->sczRegid, &sczRegidFolder); | 1430 | hr = VariableFormatString(pVariables, pSoftwareTag->sczPath, &sczRootFolder, NULL); |
1428 | ExitOnFailure(hr, "Failed to allocate regid folder path."); | 1431 | ExitOnFailure(hr, "Failed to format tag folder path."); |
1429 | 1432 | ||
1430 | hr = PathConcat(sczRegidFolder, pSoftwareTag->sczFilename, &sczPath); | 1433 | hr = PathConcat(sczRootFolder, SWIDTAG_FOLDER, &sczTagFolder); |
1431 | ExitOnFailure(hr, "Failed to allocate regid folder path."); | 1434 | ExitOnFailure(hr, "Failed to allocate regid folder path."); |
1432 | 1435 | ||
1436 | hr = PathConcat(sczTagFolder, pSoftwareTag->sczFilename, &sczPath); | ||
1437 | ExitOnFailure(hr, "Failed to allocate regid file path."); | ||
1438 | |||
1433 | // Best effort to delete the software tag file and the regid folder. | 1439 | // Best effort to delete the software tag file and the regid folder. |
1434 | FileEnsureDelete(sczPath); | 1440 | FileEnsureDelete(sczPath); |
1435 | 1441 | ||
1436 | ::RemoveDirectoryW(sczRegidFolder); | 1442 | DirDeleteEmptyDirectoriesToRoot(sczTagFolder, 0); |
1437 | } | 1443 | } |
1438 | 1444 | ||
1439 | LExit: | 1445 | LExit: |
1440 | ReleaseStr(sczPath); | 1446 | ReleaseStr(sczPath); |
1441 | ReleaseStr(sczRegidFolder); | 1447 | ReleaseStr(sczTagFolder); |
1442 | ReleaseStr(sczRootFolder); | 1448 | ReleaseStr(sczRootFolder); |
1443 | 1449 | ||
1444 | return hr; | 1450 | return hr; |