IsSecureBootEnabled - checks if secure bool is enabled on machine through a powershell cmdlet (`Confirm-SecureBootUEFI`) returns `true` if secure boot is enabled */
| 385 | returns `true` if secure boot is enabled |
| 386 | */ |
| 387 | BOOL Services::IsSecureBootEnabled() |
| 388 | { |
| 389 | HKEY hKey; |
| 390 | LONG lResult; |
| 391 | DWORD dwSize = sizeof(DWORD); |
| 392 | DWORD dwValue = 0; |
| 393 | const char* registryPath = "SYSTEM\\CurrentControlSet\\Control\\SecureBoot\\State"; |
| 394 | const char* valueName = "UEFISecureBootEnabled"; |
| 395 | |
| 396 | lResult = RegOpenKeyExA(HKEY_LOCAL_MACHINE, registryPath, 0, KEY_READ, &hKey); |
| 397 | if (lResult != ERROR_SUCCESS) |
| 398 | { |
| 399 | Logger::logf(Err, "Error opening registry key: (%d) @ Services::IsSecureBootEnabled", GetLastError()); |
| 400 | return FALSE; |
| 401 | } |
| 402 | |
| 403 | lResult = RegQueryValueExA(hKey, valueName, NULL, NULL, (LPBYTE)&dwValue, &dwSize); |
| 404 | |
| 405 | if (lResult != ERROR_SUCCESS) |
| 406 | { |
| 407 | Logger::logf(Err, "Error querying registry value: %d @ Services::IsSecureBootEnabled", GetLastError()); |
| 408 | RegCloseKey(hKey); |
| 409 | return FALSE; |
| 410 | } |
| 411 | |
| 412 | RegCloseKey(hKey); |
| 413 | return dwValue; |
| 414 | } |
| 415 | |
| 416 | /* |
| 417 | GetWindowsDrive - return drive where windows is installed, such as C:\\ |
nothing calls this directly
no outgoing calls
no test coverage detected