From 8810aa8908ed7887616d86dd5fb821fcfa92f444 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 3 Jun 2022 17:50:22 -0500 Subject: Update Burn algorithm for picking elevated temp path to use SystemTemp. --- src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 80 ---------------------------- 1 file changed, 80 deletions(-) (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp') diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp index becfc67e..0e2a5dec 100644 --- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp @@ -894,86 +894,6 @@ LExit: } -DAPI_(HRESULT) PathGetSystemTempPaths( - __inout_z LPWSTR** prgsczSystemTempPaths, - __inout DWORD* pcSystemTempPaths - ) -{ - HRESULT hr = S_OK; - HKEY hKey = NULL; - LPWSTR sczTemp = NULL; - WCHAR wzTempPath[MAX_PATH + 1] = { }; - DWORD cch = 0; - - // There is no documented API to get system environment variables, so read them from the registry. - hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_READ, &hKey); - if (E_FILENOTFOUND != hr) - { - PathExitOnFailure(hr, "Failed to open system environment registry key."); - - // Follow documented precedence rules for TMP/TEMP from ::GetTempPath. - // TODO: values will be expanded with the current environment variables instead of the system environment variables. - hr = RegReadString(hKey, L"TMP", &sczTemp); - if (E_FILENOTFOUND != hr) - { - PathExitOnFailure(hr, "Failed to get system TMP value."); - - hr = PathBackslashTerminate(&sczTemp); - PathExitOnFailure(hr, "Failed to backslash terminate system TMP value."); - - hr = MemEnsureArraySizeForNewItems(reinterpret_cast(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 3); - PathExitOnFailure(hr, "Failed to ensure array size for system TMP value."); - - (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; - sczTemp = NULL; - *pcSystemTempPaths += 1; - } - - hr = RegReadString(hKey, L"TEMP", &sczTemp); - if (E_FILENOTFOUND != hr) - { - PathExitOnFailure(hr, "Failed to get system TEMP value."); - - hr = PathBackslashTerminate(&sczTemp); - PathExitOnFailure(hr, "Failed to backslash terminate system TEMP value."); - - hr = MemEnsureArraySizeForNewItems(reinterpret_cast(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 2); - PathExitOnFailure(hr, "Failed to ensure array size for system TEMP value."); - - (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; - sczTemp = NULL; - *pcSystemTempPaths += 1; - } - } - - cch = ::GetSystemWindowsDirectoryW(wzTempPath, countof(wzTempPath)); - if (!cch) - { - PathExitWithLastError(hr, "Failed to get Windows directory path."); - } - else if (cch >= countof(wzTempPath)) - { - PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long."); - } - - hr = PathConcat(wzTempPath, L"TEMP\\", &sczTemp); - PathExitOnFailure(hr, "Failed to concat Temp directory on Windows directory path."); - - hr = MemEnsureArraySizeForNewItems(reinterpret_cast(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 1); - PathExitOnFailure(hr, "Failed to ensure array size for Windows\\TEMP value."); - - (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; - sczTemp = NULL; - *pcSystemTempPaths += 1; - -LExit: - ReleaseRegKey(hKey); - ReleaseStr(sczTemp); - - return hr; -} - - DAPI_(HRESULT) PathGetKnownFolder( __in int csidl, __out LPWSTR* psczKnownFolder -- cgit v1.2.3-55-g6feb