Changeset 81063 in vbox
- Timestamp:
- Sep 27, 2019 9:54:24 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 133667
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/RTSystemFirmware-win.cpp
r81062 r81063 67 67 /** Defines the UEFI Globals UUID. */ 68 68 #define VBOX_UEFI_UUID_GLOBALS L"{8BE4DF61-93CA-11D2-AA0D-00E098032B8C}" 69 /** Defines an UEFI dummy UUID . */69 /** Defines an UEFI dummy UUID, see MSDN docs of the API. */ 70 70 #define VBOX_UEFI_UUID_DUMMY L"{00000000-0000-0000-0000-000000000000}" 71 71 … … 158 158 rtSystemFirmwareGetPrivileges(SE_SYSTEM_ENVIRONMENT_NAME); 159 159 160 uint8_t fEnabled = 0; /** @todo This type doesn't make sense to bird. */ 161 DWORD cbRet = g_pfnGetFirmwareEnvironmentVariableW(L"", VBOX_UEFI_UUID_GLOBALS, &fEnabled, sizeof(fEnabled)); 162 if (cbRet) 163 { 164 Assert(cbRet == sizeof(fEnabled)); 165 *penmFirmwareType = fEnabled ? RTSYSFWTYPE_UEFI : RTSYSFWTYPE_BIOS; 166 rc = VINF_SUCCESS; 167 } 168 else 169 { 170 DWORD dwErr = GetLastError(); 171 if (dwErr == ERROR_INVALID_FUNCTION) 172 { 173 *penmFirmwareType = RTSYSFWTYPE_BIOS; 174 rc = VINF_SUCCESS; 175 } 176 else 177 rc = RTErrConvertFromWin32(dwErr); 178 } 160 /* On a non-UEFI system (or such a system in legacy boot mode), we will get 161 back ERROR_INVALID_FUNCTION when querying any firmware variable. While on a 162 UEFI system we'll typically get ERROR_ACCESS_DENIED or similar as the dummy 163 is a non-exising dummy namespace. See the API docs. */ 164 SetLastError(0); 165 uint8_t abWhatever[64]; 166 DWORD cbRet = g_pfnGetFirmwareEnvironmentVariableW(L"", VBOX_UEFI_UUID_DUMMY, abWhatever, sizeof(abWhatever)); 167 DWORD dwErr = GetLastError(); 168 *penmFirmwareType = cbRet != 0 || dwErr != ERROR_INVALID_FUNCTION ? RTSYSFWTYPE_UEFI : RTSYSFWTYPE_BIOS; 169 rc = VINF_SUCCESS; 179 170 } 180 171 return rc; … … 199 190 { 200 191 case RTSYSFWPROP_SECURE_BOOT: 201 {202 192 pwszName = L"SecureBoot"; 203 193 pValue->enmType = RTSYSFWVALUETYPE_BOOLEAN; 204 194 break; 205 }206 195 207 196 default: … … 210 199 } 211 200 201 /* 202 * Do type specific query. 203 */ 212 204 if (!g_pfnGetFirmwareEnvironmentVariableW) 213 205 return VERR_NOT_SUPPORTED; -
trunk/src/VBox/Runtime/testcase/tstRTSystemQueryFirmware.cpp
r81062 r81063 45 45 RTTestBanner(hTest); 46 46 47 /* 48 * RTSystemFirmwareQueryType 49 */ 47 50 RTTestSub(hTest, "RTSystemFirmwareQueryType"); 48 RTSYSFWTYPE fwType;49 int rc = RTSystemFirmwareQueryType(& fwType);51 RTSYSFWTYPE enmType = (RTSYSFWTYPE)-42; 52 int rc = RTSystemFirmwareQueryType(&enmType); 50 53 if (RT_SUCCESS(rc)) 51 54 { 52 switch ( fwType)55 switch (enmType) 53 56 { 54 57 case RTSYSFWTYPE_BIOS: 55 RTTestPrintf(hTest, RTTESTLVL_INFO, " Firmware type: BIOS (Legacy)\n");58 RTTestPrintf(hTest, RTTESTLVL_INFO, " Firmware type: BIOS (Legacy)\n"); 56 59 break; 57 60 case RTSYSFWTYPE_UEFI: 58 RTTestPrintf(hTest, RTTESTLVL_INFO, " Firmware type: UEFI\n");61 RTTestPrintf(hTest, RTTESTLVL_INFO, " Firmware type: UEFI\n"); 59 62 break; 60 63 case RTSYSFWTYPE_UNKNOWN: /* Do not fail on not-implemented platforms. */ 61 RT_FALL_THROUGH(); 64 RTTestPrintf(hTest, RTTESTLVL_INFO, " Firmware type: Unknown\n"); 65 break; 62 66 default: 63 RTTest Printf(hTest, RTTESTLVL_INFO, "Unknown firmware type\n");67 RTTestFailed(hTest, "RTSystemFirmwareQueryType return invalid type: %d (%#x)", enmType); 64 68 break; 65 69 } 66 70 } 67 71 else if (rc != VERR_NOT_SUPPORTED) 68 RTTest IFailed("RTSystemFirmwareQueryType failed: %Rrc", rc);72 RTTestFailed(hTest, "RTSystemFirmwareQueryType failed: %Rrc", rc); 69 73 74 /* 75 * RTSystemFirmwareQueryValue 76 */ 70 77 RTTestSub(hTest, "RTSystemFirmwareQueryValue"); 71 78 RTSYSFWVALUE Value; … … 74 81 { 75 82 RTTEST_CHECK(hTest, Value.enmType == RTSYSFWVALUETYPE_BOOLEAN); 76 RTTestPrintf(hTest, RTTESTLVL_INFO, "Secure Boot enabled: %RTbool\n", Value.u.fVal); 83 RTTestPrintf(hTest, RTTESTLVL_INFO, " Secure Boot: %s\n", Value.u.fVal ? "enabled" : "disabled"); 84 RTSystemFirmwareFreeValue(&Value); 77 85 RTSystemFirmwareFreeValue(&Value); 78 86 }
Note:
See TracChangeset
for help on using the changeset viewer.