Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
make some output messages more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
mq1n committed Jun 27, 2021
1 parent 2ce4954 commit 41254b5
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
#define SystemBootEnvironmentInformation 90
#define SystemSecureBootInformation 145
#define TBS_E_TPM_NOT_FOUND 0x8028400F

typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION
{
Expand Down Expand Up @@ -389,6 +390,15 @@ int main(int, char* argv[])

// UEFI
{
const auto GetFirmwareName = [](const uint8_t type) -> std::string {
if (type == FirmwareTypeBios)
return "Legacy/Bios";
else if (type == FirmwareTypeUefi)
return "UEFI";
else
return "Unknown: " + std::to_string(type);
};

std::cout << "Firmware checking..." << std::endl;

ULONG cbSize = 0;
Expand All @@ -405,7 +415,7 @@ int main(int, char* argv[])

if (sbei.FirmwareType != FirmwareTypeUefi)
{
std::cerr << "Boot firmware: " << sbei.FirmwareType << " is not allowed!" << std::endl;
std::cerr << "Boot firmware: " << GetFirmwareName(sbei.FirmwareType) << " is not allowed!" << std::endl;
std::system("PAUSE");
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -445,7 +455,13 @@ int main(int, char* argv[])

TPM_DEVICE_INFO tpmDevInfo{ 0 };
const auto nTpmRet = Tbsi_GetDeviceInfo(sizeof(tpmDevInfo), &tpmDevInfo);
if (nTpmRet != TBS_SUCCESS)
if (nTpmRet == TBS_E_TPM_NOT_FOUND)
{
std::cerr << "TPM module does not exist or activated in system!" << std::endl;
std::system("PAUSE");
return EXIT_FAILURE;
}
else if (nTpmRet != TBS_SUCCESS)
{
std::cerr << "Tbsi_GetDeviceInfo failed with status: " << nTpmRet << std::endl;
std::system("PAUSE");
Expand Down

0 comments on commit 41254b5

Please sign in to comment.