Changeset 105786 in vbox for trunk/src/VBox/Runtime/r3/win/RTSystemFirmware-win.cpp
- Timestamp:
- Aug 21, 2024 5:27:35 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/RTSystemFirmware-win.cpp
r105766 r105786 54 54 55 55 #include "internal-r3-win.h" 56 #include "internal-r3-registry-win.h" 56 57 57 58 … … 124 125 125 126 CloseHandle(hToken); 126 127 return rc;128 }129 130 131 /**132 * Queries a DWORD value from a Windows registry key, Unicode (wide char) version.133 *134 * @returns IPRT status code.135 * @retval VERR_FILE_NOT_FOUND if the value has not been found.136 * @param hKey Registry handle to use.137 * @param pwszKey Registry key to query \a pwszName in.138 * @param pwszName Name of the value to query.139 * @param pdwValue Where to return the actual value on success.140 */141 static int rtSystemWinRegistryGetDWORDW(HKEY hKey, LPCWSTR pwszKey, LPCWSTR pwszName, DWORD *pdwValue)142 {143 LONG lErr = RegOpenKeyExW(hKey, pwszKey, 0, KEY_QUERY_VALUE, &hKey);144 if (lErr != ERROR_SUCCESS)145 return RTErrConvertFromWin32(lErr);146 147 int rc = VINF_SUCCESS;148 149 DWORD cbType = sizeof(DWORD);150 DWORD dwType = 0;151 DWORD dwValue;152 lErr = RegQueryValueExW(hKey, pwszName, NULL, &dwType, (BYTE *)&dwValue, &cbType);153 if (lErr == ERROR_SUCCESS)154 {155 if (cbType == sizeof(DWORD))156 {157 if (dwType == REG_DWORD)158 {159 *pdwValue = dwValue;160 }161 else162 rc = VERR_WRONG_TYPE;163 }164 else165 rc = VERR_MISMATCH;166 }167 else168 rc = RTErrConvertFromWin32(lErr);169 170 RegCloseKey(hKey);171 172 return rc;173 }174 175 176 /**177 * Queries a DWORD value from a Windows registry key.178 *179 * @returns IPRT status code.180 * @retval VERR_FILE_NOT_FOUND if the value has not been found.181 * @param hKey Registry handle to use.182 * @param pszKey Registry key to query \a pszName in.183 * @param pszName Name of the value to query.184 * @param pdwValue Where to return the actual value on success.185 */186 static int rtSystemRegistryGetDWORDA(HKEY hKey, const char *pszKey, const char *pszName, DWORD *pdwValue)187 {188 PRTUTF16 pwszKey;189 int rc = RTStrToUtf16Ex(pszKey, RTSTR_MAX, &pwszKey, 0, NULL);190 if (RT_SUCCESS(rc))191 {192 PRTUTF16 pwszName;193 rc = RTStrToUtf16Ex(pszName, RTSTR_MAX, &pwszName, 0, NULL);194 if (RT_SUCCESS(rc))195 {196 rc = rtSystemWinRegistryGetDWORDW(hKey, pwszKey, pwszName, pdwValue);197 RTUtf16Free(pwszName);198 }199 RTUtf16Free(pwszKey);200 }201 127 202 128 return rc; … … 310 236 { 311 237 DWORD dwEnabled; 312 rc = rtSystemRegistryGetDWORDA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\SecureBoot\\State",313 "UEFISecureBootEnabled", &dwEnabled);238 rc = RTSystemWinRegistryQueryDWORD(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\SecureBoot\\State", 239 "UEFISecureBootEnabled", &dwEnabled); 314 240 if (RT_SUCCESS(rc)) 315 241 {
Note:
See TracChangeset
for help on using the changeset viewer.