diff options
Diffstat (limited to 'src/burn/engine/variable.cpp')
-rw-r--r-- | src/burn/engine/variable.cpp | 75 |
1 files changed, 30 insertions, 45 deletions
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 | ||
1961 | LExit: | 1959 | LExit: |
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 | ||
2032 | LExit: | 2016 | LExit: |
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 | ||
2063 | LExit: | 2045 | LExit: |
2046 | ReleaseStr(sczWindowsPath); | ||
2047 | ReleaseStr(sczVolumePath); | ||
2048 | |||
2064 | return hr; | 2049 | return hr; |
2065 | } | 2050 | } |
2066 | 2051 | ||