diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-03 17:50:22 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-07 19:44:36 -0500 |
| commit | 8810aa8908ed7887616d86dd5fb821fcfa92f444 (patch) | |
| tree | 8bc05667c36cc0d3db73504c867e85b01f1a79b0 /src/libs/dutil/WixToolset.DUtil/pathutil.cpp | |
| parent | 266b097c0b0a13dd4934f55f61cad62ffcbb953d (diff) | |
| download | wix-8810aa8908ed7887616d86dd5fb821fcfa92f444.tar.gz wix-8810aa8908ed7887616d86dd5fb821fcfa92f444.tar.bz2 wix-8810aa8908ed7887616d86dd5fb821fcfa92f444.zip | |
Update Burn algorithm for picking elevated temp path to use SystemTemp.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp')
| -rw-r--r-- | src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
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: | |||
| 894 | } | 894 | } |
| 895 | 895 | ||
| 896 | 896 | ||
| 897 | DAPI_(HRESULT) PathGetSystemTempPaths( | ||
| 898 | __inout_z LPWSTR** prgsczSystemTempPaths, | ||
| 899 | __inout DWORD* pcSystemTempPaths | ||
| 900 | ) | ||
| 901 | { | ||
| 902 | HRESULT hr = S_OK; | ||
| 903 | HKEY hKey = NULL; | ||
| 904 | LPWSTR sczTemp = NULL; | ||
| 905 | WCHAR wzTempPath[MAX_PATH + 1] = { }; | ||
| 906 | DWORD cch = 0; | ||
| 907 | |||
| 908 | // There is no documented API to get system environment variables, so read them from the registry. | ||
| 909 | hr = RegOpen(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", KEY_READ, &hKey); | ||
| 910 | if (E_FILENOTFOUND != hr) | ||
| 911 | { | ||
| 912 | PathExitOnFailure(hr, "Failed to open system environment registry key."); | ||
| 913 | |||
| 914 | // Follow documented precedence rules for TMP/TEMP from ::GetTempPath. | ||
| 915 | // TODO: values will be expanded with the current environment variables instead of the system environment variables. | ||
| 916 | hr = RegReadString(hKey, L"TMP", &sczTemp); | ||
| 917 | if (E_FILENOTFOUND != hr) | ||
| 918 | { | ||
| 919 | PathExitOnFailure(hr, "Failed to get system TMP value."); | ||
| 920 | |||
| 921 | hr = PathBackslashTerminate(&sczTemp); | ||
| 922 | PathExitOnFailure(hr, "Failed to backslash terminate system TMP value."); | ||
| 923 | |||
| 924 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 3); | ||
| 925 | PathExitOnFailure(hr, "Failed to ensure array size for system TMP value."); | ||
| 926 | |||
| 927 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
| 928 | sczTemp = NULL; | ||
| 929 | *pcSystemTempPaths += 1; | ||
| 930 | } | ||
| 931 | |||
| 932 | hr = RegReadString(hKey, L"TEMP", &sczTemp); | ||
| 933 | if (E_FILENOTFOUND != hr) | ||
| 934 | { | ||
| 935 | PathExitOnFailure(hr, "Failed to get system TEMP value."); | ||
| 936 | |||
| 937 | hr = PathBackslashTerminate(&sczTemp); | ||
| 938 | PathExitOnFailure(hr, "Failed to backslash terminate system TEMP value."); | ||
| 939 | |||
| 940 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 2); | ||
| 941 | PathExitOnFailure(hr, "Failed to ensure array size for system TEMP value."); | ||
| 942 | |||
| 943 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
| 944 | sczTemp = NULL; | ||
| 945 | *pcSystemTempPaths += 1; | ||
| 946 | } | ||
| 947 | } | ||
| 948 | |||
| 949 | cch = ::GetSystemWindowsDirectoryW(wzTempPath, countof(wzTempPath)); | ||
| 950 | if (!cch) | ||
| 951 | { | ||
| 952 | PathExitWithLastError(hr, "Failed to get Windows directory path."); | ||
| 953 | } | ||
| 954 | else if (cch >= countof(wzTempPath)) | ||
| 955 | { | ||
| 956 | PathExitWithRootFailure(hr, E_INSUFFICIENT_BUFFER, "Windows directory path too long."); | ||
| 957 | } | ||
| 958 | |||
| 959 | hr = PathConcat(wzTempPath, L"TEMP\\", &sczTemp); | ||
| 960 | PathExitOnFailure(hr, "Failed to concat Temp directory on Windows directory path."); | ||
| 961 | |||
| 962 | hr = MemEnsureArraySizeForNewItems(reinterpret_cast<LPVOID*>(prgsczSystemTempPaths), *pcSystemTempPaths, 1, sizeof(LPWSTR), 1); | ||
| 963 | PathExitOnFailure(hr, "Failed to ensure array size for Windows\\TEMP value."); | ||
| 964 | |||
| 965 | (*prgsczSystemTempPaths)[*pcSystemTempPaths] = sczTemp; | ||
| 966 | sczTemp = NULL; | ||
| 967 | *pcSystemTempPaths += 1; | ||
| 968 | |||
| 969 | LExit: | ||
| 970 | ReleaseRegKey(hKey); | ||
| 971 | ReleaseStr(sczTemp); | ||
| 972 | |||
| 973 | return hr; | ||
| 974 | } | ||
| 975 | |||
| 976 | |||
| 977 | DAPI_(HRESULT) PathGetKnownFolder( | 897 | DAPI_(HRESULT) PathGetKnownFolder( |
| 978 | __in int csidl, | 898 | __in int csidl, |
| 979 | __out LPWSTR* psczKnownFolder | 899 | __out LPWSTR* psczKnownFolder |
