aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-06-24 12:28:27 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-06-27 11:14:21 -0500
commiteb53852d7ae6838e54525eb57df1d8ce8a722f9b (patch)
tree7fa05bd6df1bce2e20d87c5fbacc1c658dc000aa /src/burn
parent6ee12a64cb75097a238e60d4fd0ea542e8312214 (diff)
downloadwix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.tar.gz
wix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.tar.bz2
wix-eb53852d7ae6838e54525eb57df1d8ce8a722f9b.zip
Add longPathAware to Burn manifest to support long paths.
Fixes 3455
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/approvedexe.cpp9
-rw-r--r--src/burn/engine/cache.cpp6
-rw-r--r--src/burn/engine/engine.cpp2
-rw-r--r--src/burn/engine/exeengine.cpp7
-rw-r--r--src/burn/engine/logging.cpp18
-rw-r--r--src/burn/engine/msuengine.cpp9
-rw-r--r--src/burn/engine/userexperience.cpp5
-rw-r--r--src/burn/engine/variable.cpp75
-rw-r--r--src/burn/test/BurnUnitTest/RegistrationTest.cpp6
9 files changed, 65 insertions, 72 deletions
diff --git a/src/burn/engine/approvedexe.cpp b/src/burn/engine/approvedexe.cpp
index 2a96868e..d8bd956b 100644
--- a/src/burn/engine/approvedexe.cpp
+++ b/src/burn/engine/approvedexe.cpp
@@ -148,6 +148,7 @@ extern "C" HRESULT ApprovedExesLaunch(
148 LPWSTR sczCommand = NULL; 148 LPWSTR sczCommand = NULL;
149 LPWSTR sczCommandObfuscated = NULL; 149 LPWSTR sczCommandObfuscated = NULL;
150 LPWSTR sczExecutableDirectory = NULL; 150 LPWSTR sczExecutableDirectory = NULL;
151 size_t cchExecutableDirectory = 0;
151 STARTUPINFOW si = { }; 152 STARTUPINFOW si = { };
152 PROCESS_INFORMATION pi = { }; 153 PROCESS_INFORMATION pi = { };
153 154
@@ -177,9 +178,17 @@ extern "C" HRESULT ApprovedExesLaunch(
177 // Try to get the directory of the executable so we can set the current directory of the process to help those executables 178 // Try to get the directory of the executable so we can set the current directory of the process to help those executables
178 // that expect stuff to be relative to them. Best effort only. 179 // that expect stuff to be relative to them. Best effort only.
179 hr = PathGetDirectory(pLaunchApprovedExe->sczExecutablePath, &sczExecutableDirectory); 180 hr = PathGetDirectory(pLaunchApprovedExe->sczExecutablePath, &sczExecutableDirectory);
181 if (SUCCEEDED(hr))
182 {
183 // CreateProcessW has undocumented MAX_PATH restriction for lpCurrentDirectory even when long path support is enabled.
184 hr = ::StringCchLengthW(sczExecutableDirectory, MAX_PATH - 1, &cchExecutableDirectory);
185 }
186
180 if (FAILED(hr)) 187 if (FAILED(hr))
181 { 188 {
182 ReleaseNullStr(sczExecutableDirectory); 189 ReleaseNullStr(sczExecutableDirectory);
190
191 hr = S_OK;
183 } 192 }
184 193
185 LogId(REPORT_STANDARD, MSG_LAUNCHING_APPROVED_EXE, pLaunchApprovedExe->sczExecutablePath, sczCommandObfuscated); 194 LogId(REPORT_STANDARD, MSG_LAUNCHING_APPROVED_EXE, pLaunchApprovedExe->sczExecutablePath, sczCommandObfuscated);
diff --git a/src/burn/engine/cache.cpp b/src/burn/engine/cache.cpp
index cf9de1c3..eb5cc508 100644
--- a/src/burn/engine/cache.cpp
+++ b/src/burn/engine/cache.cpp
@@ -174,7 +174,7 @@ extern "C" HRESULT CacheInitialize(
174 174
175 // Cache paths are initialized once so they cannot be changed while the engine is caching payloads. 175 // Cache paths are initialized once so they cannot be changed while the engine is caching payloads.
176 // Always construct the default machine package cache path so we can determine if we're redirected. 176 // Always construct the default machine package cache path so we can determine if we're redirected.
177 hr = PathGetKnownFolder(CSIDL_COMMON_APPDATA, &sczAppData); 177 hr = ShelGetFolder(&sczAppData, CSIDL_COMMON_APPDATA);
178 ExitOnFailure(hr, "Failed to find local %hs appdata directory.", "per-machine"); 178 ExitOnFailure(hr, "Failed to find local %hs appdata directory.", "per-machine");
179 179
180 hr = PathConcat(sczAppData, PACKAGE_CACHE_FOLDER_NAME, &pCache->sczDefaultMachinePackageCache); 180 hr = PathConcat(sczAppData, PACKAGE_CACHE_FOLDER_NAME, &pCache->sczDefaultMachinePackageCache);
@@ -210,7 +210,7 @@ extern "C" HRESULT CacheInitialize(
210 pCache->fCustomMachinePackageCache = !fPathEqual; 210 pCache->fCustomMachinePackageCache = !fPathEqual;
211 211
212 212
213 hr = PathGetKnownFolder(CSIDL_LOCAL_APPDATA, &sczAppData); 213 hr = ShelGetFolder(&sczAppData, CSIDL_LOCAL_APPDATA);
214 ExitOnFailure(hr, "Failed to find local %hs appdata directory.", "per-user"); 214 ExitOnFailure(hr, "Failed to find local %hs appdata directory.", "per-user");
215 215
216 hr = PathConcat(sczAppData, PACKAGE_CACHE_FOLDER_NAME, &pCache->sczDefaultUserPackageCache); 216 hr = PathConcat(sczAppData, PACKAGE_CACHE_FOLDER_NAME, &pCache->sczDefaultUserPackageCache);
@@ -1469,7 +1469,7 @@ static HRESULT CalculateWorkingFolders(
1469 HRESULT hr = S_OK; 1469 HRESULT hr = S_OK;
1470 LPWSTR sczBaseAcquisitionPath = NULL; 1470 LPWSTR sczBaseAcquisitionPath = NULL;
1471 1471
1472 hr = PathGetTempPath(&sczBaseAcquisitionPath); 1472 hr = PathGetTempPath(&sczBaseAcquisitionPath, NULL);
1473 ExitOnFailure(hr, "Failed to get temp folder path for acquisition folder base."); 1473 ExitOnFailure(hr, "Failed to get temp folder path for acquisition folder base.");
1474 1474
1475 hr = PathBackslashTerminate(&sczBaseAcquisitionPath); 1475 hr = PathBackslashTerminate(&sczBaseAcquisitionPath);
diff --git a/src/burn/engine/engine.cpp b/src/burn/engine/engine.cpp
index 7fca1141..13075497 100644
--- a/src/burn/engine/engine.cpp
+++ b/src/burn/engine/engine.cpp
@@ -486,7 +486,7 @@ static HRESULT RunUntrusted(
486 486
487 si.cb = sizeof(si); 487 si.cb = sizeof(si);
488 si.wShowWindow = static_cast<WORD>(pEngineState->command.nCmdShow); 488 si.wShowWindow = static_cast<WORD>(pEngineState->command.nCmdShow);
489 if (!::CreateProcessW(wzCleanRoomBundlePath, sczFullCommandLine, NULL, NULL, TRUE, 0, 0, NULL, &si, &pi)) 489 if (!::CreateProcessW(wzCleanRoomBundlePath, sczFullCommandLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi))
490 { 490 {
491 ExitWithLastError(hr, "Failed to launch clean room process: %ls", sczFullCommandLine); 491 ExitWithLastError(hr, "Failed to launch clean room process: %ls", sczFullCommandLine);
492 } 492 }
diff --git a/src/burn/engine/exeengine.cpp b/src/burn/engine/exeengine.cpp
index f7be082d..701adb74 100644
--- a/src/burn/engine/exeengine.cpp
+++ b/src/burn/engine/exeengine.cpp
@@ -695,6 +695,7 @@ extern "C" HRESULT ExeEngineRunProcess(
695 BOOL fDelayedCancel = FALSE; 695 BOOL fDelayedCancel = FALSE;
696 BOOL fFireAndForget = BURN_PACKAGE_TYPE_EXE == pPackage->type && pPackage->Exe.fFireAndForget; 696 BOOL fFireAndForget = BURN_PACKAGE_TYPE_EXE == pPackage->type && pPackage->Exe.fFireAndForget;
697 BOOL fInheritHandles = BURN_PACKAGE_TYPE_BUNDLE == pPackage->type; 697 BOOL fInheritHandles = BURN_PACKAGE_TYPE_BUNDLE == pPackage->type;
698 size_t cchCachedDirectory = 0;
698 699
699 // Always add user supplied arguments last. 700 // Always add user supplied arguments last.
700 if (wzUserArgs) 701 if (wzUserArgs)
@@ -703,6 +704,12 @@ extern "C" HRESULT ExeEngineRunProcess(
703 ExitOnFailure(hr, "Failed to append user args."); 704 ExitOnFailure(hr, "Failed to append user args.");
704 } 705 }
705 706
707 // CreateProcessW has undocumented MAX_PATH restriction for lpCurrentDirectory even when long path support is enabled.
708 if (wzCachedDirectory && FAILED(::StringCchLengthW(wzCachedDirectory, MAX_PATH - 1, &cchCachedDirectory)))
709 {
710 wzCachedDirectory = NULL;
711 }
712
706 // Make the cache location of the executable the current directory to help those executables 713 // Make the cache location of the executable the current directory to help those executables
707 // that expect stuff to be relative to them. 714 // that expect stuff to be relative to them.
708 si.cb = sizeof(si); 715 si.cb = sizeof(si);
diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp
index 1020d01f..68f0c35b 100644
--- a/src/burn/engine/logging.cpp
+++ b/src/burn/engine/logging.cpp
@@ -211,7 +211,7 @@ extern "C" void LoggingOpenFailed()
211 LPCWSTR* lpStrings = const_cast<LPCWSTR*>(&LOG_FAILED_EVENT_LOG_MESSAGE); 211 LPCWSTR* lpStrings = const_cast<LPCWSTR*>(&LOG_FAILED_EVENT_LOG_MESSAGE);
212 WORD wNumStrings = 1; 212 WORD wNumStrings = 1;
213 213
214 hr = LogOpen(NULL, L"Setup", L"_Failed", L"txt", FALSE, FALSE, NULL); 214 hr = LogOpen(NULL, L"Setup", L"_Failed", L"log", FALSE, FALSE, NULL);
215 if (SUCCEEDED(hr)) 215 if (SUCCEEDED(hr))
216 { 216 {
217 ExitFunction(); 217 ExitFunction();
@@ -965,19 +965,14 @@ static HRESULT GetNonSessionSpecificTempFolder(
965 ) 965 )
966{ 966{
967 HRESULT hr = S_OK; 967 HRESULT hr = S_OK;
968 WCHAR wzTempFolder[MAX_PATH] = { }; 968 LPWSTR sczTempFolder = NULL;
969 SIZE_T cchTempFolder = 0; 969 SIZE_T cchTempFolder = 0;
970 DWORD dwSessionId = 0; 970 DWORD dwSessionId = 0;
971 LPWSTR sczSessionId = 0; 971 LPWSTR sczSessionId = 0;
972 SIZE_T cchSessionId = 0; 972 SIZE_T cchSessionId = 0;
973 973
974 if (!::GetTempPathW(countof(wzTempFolder), wzTempFolder)) 974 hr = PathGetTempPath(&sczTempFolder, &cchTempFolder);
975 { 975 ExitOnFailure(hr, "Failed to get temp folder.");
976 ExitWithLastError(hr, "Failed to get temp folder.");
977 }
978
979 hr = ::StringCchLengthW(wzTempFolder, countof(wzTempFolder), reinterpret_cast<size_t*>(&cchTempFolder));
980 ExitOnFailure(hr, "Failed to get length of temp folder.");
981 976
982 // If our session id is in the TEMP path then remove that part so we get the non-session 977 // If our session id is in the TEMP path then remove that part so we get the non-session
983 // specific temporary folder. 978 // specific temporary folder.
@@ -989,17 +984,18 @@ static HRESULT GetNonSessionSpecificTempFolder(
989 hr = ::StringCchLengthW(sczSessionId, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchSessionId)); 984 hr = ::StringCchLengthW(sczSessionId, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cchSessionId));
990 ExitOnFailure(hr, "Failed to get length of session id string."); 985 ExitOnFailure(hr, "Failed to get length of session id string.");
991 986
992 if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, wzTempFolder + cchTempFolder - cchSessionId, static_cast<DWORD>(cchSessionId), sczSessionId, static_cast<DWORD>(cchSessionId))) 987 if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, sczTempFolder + cchTempFolder - cchSessionId, static_cast<DWORD>(cchSessionId), sczSessionId, static_cast<DWORD>(cchSessionId)))
993 { 988 {
994 cchTempFolder -= cchSessionId; 989 cchTempFolder -= cchSessionId;
995 } 990 }
996 } 991 }
997 992
998 hr = StrAllocString(psczNonSessionTempFolder, wzTempFolder, cchTempFolder); 993 hr = StrAllocString(psczNonSessionTempFolder, sczTempFolder, cchTempFolder);
999 ExitOnFailure(hr, "Failed to copy temp folder."); 994 ExitOnFailure(hr, "Failed to copy temp folder.");
1000 995
1001LExit: 996LExit:
1002 ReleaseStr(sczSessionId); 997 ReleaseStr(sczSessionId);
998 ReleaseStr(sczTempFolder);
1003 999
1004 return hr; 1000 return hr;
1005} 1001}
diff --git a/src/burn/engine/msuengine.cpp b/src/burn/engine/msuengine.cpp
index 1b051165..400fdc92 100644
--- a/src/burn/engine/msuengine.cpp
+++ b/src/burn/engine/msuengine.cpp
@@ -269,7 +269,6 @@ extern "C" HRESULT MsuEngineExecutePackage(
269 HRESULT hr = S_OK; 269 HRESULT hr = S_OK;
270 LPWSTR sczCachedDirectory = NULL; 270 LPWSTR sczCachedDirectory = NULL;
271 LPWSTR sczMsuPath = NULL; 271 LPWSTR sczMsuPath = NULL;
272 LPWSTR sczWindowsPath = NULL;
273 LPWSTR sczSystemPath = NULL; 272 LPWSTR sczSystemPath = NULL;
274 LPWSTR sczWusaPath = NULL; 273 LPWSTR sczWusaPath = NULL;
275 LPWSTR sczCommand = NULL; 274 LPWSTR sczCommand = NULL;
@@ -294,15 +293,12 @@ extern "C" HRESULT MsuEngineExecutePackage(
294 // get wusa.exe path 293 // get wusa.exe path
295 if (fUseSysNativePath) 294 if (fUseSysNativePath)
296 { 295 {
297 hr = PathGetKnownFolder(CSIDL_WINDOWS, &sczWindowsPath); 296 hr = PathSystemWindowsSubdirectory(L"SysNative\\", &sczSystemPath);
298 ExitOnFailure(hr, "Failed to find Windows directory.");
299
300 hr = PathConcat(sczWindowsPath, L"SysNative\\", &sczSystemPath);
301 ExitOnFailure(hr, "Failed to append SysNative directory."); 297 ExitOnFailure(hr, "Failed to append SysNative directory.");
302 } 298 }
303 else 299 else
304 { 300 {
305 hr = PathGetKnownFolder(CSIDL_SYSTEM, &sczSystemPath); 301 hr = PathGetSystemDirectory(&sczSystemPath);
306 ExitOnFailure(hr, "Failed to find System32 directory."); 302 ExitOnFailure(hr, "Failed to find System32 directory.");
307 } 303 }
308 304
@@ -390,7 +386,6 @@ LExit:
390 ReleaseStr(sczCachedDirectory); 386 ReleaseStr(sczCachedDirectory);
391 ReleaseStr(sczMsuPath); 387 ReleaseStr(sczMsuPath);
392 ReleaseStr(sczSystemPath); 388 ReleaseStr(sczSystemPath);
393 ReleaseStr(sczWindowsPath);
394 ReleaseStr(sczWusaPath); 389 ReleaseStr(sczWusaPath);
395 ReleaseStr(sczCommand); 390 ReleaseStr(sczCommand);
396 ReleaseStr(sczEscapedKB); 391 ReleaseStr(sczEscapedKB);
diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp
index a97234ef..6f84caba 100644
--- a/src/burn/engine/userexperience.cpp
+++ b/src/burn/engine/userexperience.cpp
@@ -99,6 +99,7 @@ extern "C" HRESULT UserExperienceLoad(
99 HRESULT hr = S_OK; 99 HRESULT hr = S_OK;
100 BOOTSTRAPPER_CREATE_ARGS args = { }; 100 BOOTSTRAPPER_CREATE_ARGS args = { };
101 BOOTSTRAPPER_CREATE_RESULTS results = { }; 101 BOOTSTRAPPER_CREATE_RESULTS results = { };
102 LPCWSTR wzPath = pUserExperience->payloads.rgPayloads[0].sczLocalFilePath;
102 103
103 args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); 104 args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS);
104 args.pCommand = pCommand; 105 args.pCommand = pCommand;
@@ -109,8 +110,8 @@ extern "C" HRESULT UserExperienceLoad(
109 results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); 110 results.cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS);
110 111
111 // Load BA DLL. 112 // Load BA DLL.
112 pUserExperience->hUXModule = ::LoadLibraryExW(pUserExperience->payloads.rgPayloads[0].sczLocalFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 113 pUserExperience->hUXModule = ::LoadLibraryExW(wzPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
113 ExitOnNullWithLastError(pUserExperience->hUXModule, hr, "Failed to load BA DLL."); 114 ExitOnNullWithLastError(pUserExperience->hUXModule, hr, "Failed to load BA DLL: %ls", wzPath);
114 115
115 // Get BootstrapperApplicationCreate entry-point. 116 // Get BootstrapperApplicationCreate entry-point.
116 PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(pUserExperience->hUXModule, "BootstrapperApplicationCreate"); 117 PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(pUserExperience->hUXModule, "BootstrapperApplicationCreate");
diff --git a/src/burn/engine/variable.cpp b/src/burn/engine/variable.cpp
index c96e9d95..8d208a66 100644
--- a/src/burn/engine/variable.cpp
+++ b/src/burn/engine/variable.cpp
@@ -1947,18 +1947,18 @@ static HRESULT InitializeVariableTempFolder(
1947 UNREFERENCED_PARAMETER(dwpData); 1947 UNREFERENCED_PARAMETER(dwpData);
1948 1948
1949 HRESULT hr = S_OK; 1949 HRESULT hr = S_OK;
1950 WCHAR wzPath[MAX_PATH] = { }; 1950 LPWSTR sczPath = NULL;
1951 1951
1952 if (!::GetTempPathW(MAX_PATH, wzPath)) 1952 hr = PathGetTempPath(&sczPath, NULL);
1953 { 1953 ExitOnFailure(hr, "Failed to get temp path.");
1954 ExitWithLastError(hr, "Failed to get temp path.");
1955 }
1956 1954
1957 // set value 1955 // set value
1958 hr = BVariantSetString(pValue, wzPath, 0, FALSE); 1956 hr = BVariantSetString(pValue, sczPath, 0, FALSE);
1959 ExitOnFailure(hr, "Failed to set variant value."); 1957 ExitOnFailure(hr, "Failed to set variant value.");
1960 1958
1961LExit: 1959LExit:
1960 ReleaseStr(sczPath);
1961
1962 return hr; 1962 return hr;
1963} 1963}
1964 1964
@@ -1969,7 +1969,7 @@ static HRESULT InitializeVariableSystemFolder(
1969{ 1969{
1970 HRESULT hr = S_OK; 1970 HRESULT hr = S_OK;
1971 BOOL f64 = (BOOL)dwpData; 1971 BOOL f64 = (BOOL)dwpData;
1972 WCHAR wzSystemFolder[MAX_PATH + 2] = { }; 1972 LPWSTR sczSystemFolder = NULL;
1973 1973
1974#if !defined(_WIN64) 1974#if !defined(_WIN64)
1975 BOOL fIsWow64 = FALSE; 1975 BOOL fIsWow64 = FALSE;
@@ -1979,57 +1979,43 @@ static HRESULT InitializeVariableSystemFolder(
1979 { 1979 {
1980 if (f64) 1980 if (f64)
1981 { 1981 {
1982 if (!::GetSystemDirectoryW(wzSystemFolder, countof(wzSystemFolder))) 1982 hr = PathGetSystemDirectory(&sczSystemFolder);
1983 { 1983 ExitOnFailure(hr, "Failed to get 64-bit system folder.");
1984 ExitWithLastError(hr, "Failed to get 64-bit system folder.");
1985 }
1986 } 1984 }
1987 else 1985 else
1988 { 1986 {
1989 if (!::GetSystemWow64DirectoryW(wzSystemFolder, countof(wzSystemFolder))) 1987 hr = PathGetSystemWow64Directory(&sczSystemFolder);
1990 { 1988 ExitOnFailure(hr, "Failed to get 32-bit system folder.");
1991 ExitWithLastError(hr, "Failed to get 32-bit system folder.");
1992 }
1993 } 1989 }
1994 } 1990 }
1995 else 1991 else
1996 { 1992 {
1997 if (!f64) 1993 if (!f64)
1998 { 1994 {
1999 if (!::GetSystemDirectoryW(wzSystemFolder, countof(wzSystemFolder))) 1995 hr = PathGetSystemDirectory(&sczSystemFolder);
2000 { 1996 ExitOnFailure(hr, "Failed to get 32-bit system folder.");
2001 ExitWithLastError(hr, "Failed to get 32-bit system folder.");
2002 }
2003 } 1997 }
2004 } 1998 }
2005#else 1999#else
2006 if (f64) 2000 if (f64)
2007 { 2001 {
2008 if (!::GetSystemDirectoryW(wzSystemFolder, countof(wzSystemFolder))) 2002 hr = PathGetSystemDirectory(&sczSystemFolder);
2009 { 2003 ExitOnFailure(hr, "Failed to get 64-bit system folder.");
2010 ExitWithLastError(hr, "Failed to get 64-bit system folder.");
2011 }
2012 } 2004 }
2013 else 2005 else
2014 { 2006 {
2015 if (!::GetSystemWow64DirectoryW(wzSystemFolder, countof(wzSystemFolder))) 2007 hr = PathGetSystemWow64Directory(&sczSystemFolder);
2016 { 2008 ExitOnFailure(hr, "Failed to get 32-bit system folder.");
2017 ExitWithLastError(hr, "Failed to get 32-bit system folder.");
2018 }
2019 } 2009 }
2020#endif 2010#endif
2021 2011
2022 if (*wzSystemFolder)
2023 {
2024 hr = PathFixedBackslashTerminate(wzSystemFolder, countof(wzSystemFolder));
2025 ExitOnFailure(hr, "Failed to backslash terminate system folder.");
2026 }
2027
2028 // set value 2012 // set value
2029 hr = BVariantSetString(pValue, wzSystemFolder, 0, FALSE); 2013 hr = BVariantSetString(pValue, sczSystemFolder, 0, FALSE);
2030 ExitOnFailure(hr, "Failed to set system folder variant value."); 2014 ExitOnFailure(hr, "Failed to set system folder variant value.");
2031 2015
2032LExit: 2016LExit:
2017 ReleaseStr(sczSystemFolder);
2018
2033 return hr; 2019 return hr;
2034} 2020}
2035 2021
@@ -2041,26 +2027,25 @@ static HRESULT InitializeVariableWindowsVolumeFolder(
2041 UNREFERENCED_PARAMETER(dwpData); 2027 UNREFERENCED_PARAMETER(dwpData);
2042 2028
2043 HRESULT hr = S_OK; 2029 HRESULT hr = S_OK;
2044 WCHAR wzWindowsPath[MAX_PATH] = { }; 2030 LPWSTR sczWindowsPath = NULL;
2045 WCHAR wzVolumePath[MAX_PATH] = { }; 2031 LPWSTR sczVolumePath = NULL;
2046 2032
2047 // get windows directory 2033 // get windows directory
2048 if (!::GetWindowsDirectoryW(wzWindowsPath, countof(wzWindowsPath))) 2034 hr = PathSystemWindowsSubdirectory(NULL, &sczWindowsPath);
2049 { 2035 ExitOnFailure(hr, "Failed to get windows directory.");
2050 ExitWithLastError(hr, "Failed to get windows directory.");
2051 }
2052 2036
2053 // get volume path name 2037 // get volume path name
2054 if (!::GetVolumePathNameW(wzWindowsPath, wzVolumePath, MAX_PATH)) 2038 hr = PathGetVolumePathName(sczWindowsPath, &sczVolumePath);
2055 { 2039 ExitOnFailure(hr, "Failed to get volume path name.");
2056 ExitWithLastError(hr, "Failed to get volume path name.");
2057 }
2058 2040
2059 // set value 2041 // set value
2060 hr = BVariantSetString(pValue, wzVolumePath, 0, FALSE); 2042 hr = BVariantSetString(pValue, sczVolumePath, 0, FALSE);
2061 ExitOnFailure(hr, "Failed to set variant value."); 2043 ExitOnFailure(hr, "Failed to set variant value.");
2062 2044
2063LExit: 2045LExit:
2046 ReleaseStr(sczWindowsPath);
2047 ReleaseStr(sczVolumePath);
2048
2064 return hr; 2049 return hr;
2065} 2050}
2066 2051
diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp
index 883b9cc8..aa3bd34b 100644
--- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp
+++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp
@@ -108,8 +108,8 @@ namespace Bootstrapper
108 TestThrowOnFailure(hr, L"Failed to register bundle."); 108 TestThrowOnFailure(hr, L"Failed to register bundle.");
109 109
110 // verify that registration was created 110 // verify that registration was created
111 Assert::True(Directory::Exists(cacheDirectory)); 111 Assert::True(Directory::Exists(cacheDirectory), "Cache directory didn't exist.");
112 Assert::True(File::Exists(Path::Combine(cacheDirectory, gcnew String(L"setup.exe")))); 112 Assert::True(File::Exists(Path::Combine(cacheDirectory, gcnew String(L"setup.exe"))), "Bundle exe wasn't cached.");
113 113
114 this->ValidateUninstallKeyResume(Int32(BURN_RESUME_MODE_ACTIVE)); 114 this->ValidateUninstallKeyResume(Int32(BURN_RESUME_MODE_ACTIVE));
115 this->ValidateRunOnceKeyEntry(cacheExePath); 115 this->ValidateRunOnceKeyEntry(cacheExePath);
@@ -119,7 +119,7 @@ namespace Bootstrapper
119 TestThrowOnFailure(hr, L"Failed to unregister bundle."); 119 TestThrowOnFailure(hr, L"Failed to unregister bundle.");
120 120
121 // verify that registration was removed 121 // verify that registration was removed
122 Assert::False(Directory::Exists(cacheDirectory)); 122 Assert::False(Directory::Exists(cacheDirectory), "Cache directory wasn't removed.");
123 123
124 this->ValidateUninstallKeyNull(L"Resume"); 124 this->ValidateUninstallKeyNull(L"Resume");
125 this->ValidateRunOnceKeyString(TEST_BUNDLE_ID, nullptr); 125 this->ValidateRunOnceKeyString(TEST_BUNDLE_ID, nullptr);