aboutsummaryrefslogtreecommitdiff
path: root/EfiGuardDxe
diff options
context:
space:
mode:
Diffstat (limited to 'EfiGuardDxe')
-rw-r--r--EfiGuardDxe/EfiGuardDxe.c10
-rw-r--r--EfiGuardDxe/EfiGuardDxe.h3
-rw-r--r--EfiGuardDxe/PatchNtoskrnl.c1
-rw-r--r--EfiGuardDxe/PatchWinload.c8
4 files changed, 14 insertions, 8 deletions
diff --git a/EfiGuardDxe/EfiGuardDxe.c b/EfiGuardDxe/EfiGuardDxe.c
index 8b17f7e..3b6fe9b 100644
--- a/EfiGuardDxe/EfiGuardDxe.c
+++ b/EfiGuardDxe/EfiGuardDxe.c
@@ -354,6 +354,9 @@ ExitBootServicesEvent(
{
CONST EFI_STATUS Status = gKernelPatchInfo.Status;
CONST INT32 OriginalAttribute = gST->ConOut->Mode->Attribute;
+
+ // Default to showing a message in case of errors unless we are booting a pre-Vista kernel such as XP, in which case EFI_UNSUPPORTED is expected.
+ CONST BOOLEAN ShowErrorMessage = gKernelPatchInfo.KernelBuildNumber == 0 || gKernelPatchInfo.KernelBuildNumber >= 6001 || Status != EFI_UNSUPPORTED;
if (Status == EFI_SUCCESS)
{
SetConsoleTextColour(EFI_GREEN, TRUE);
@@ -366,7 +369,7 @@ ExitBootServicesEvent(
WaitForKey();
}
}
- else if (gKernelPatchInfo.BuildNumber >= 6000)
+ else if (ShowErrorMessage)
{
// Patch failed. Most important stuff first: make a fake BSOD, because... reasons
// TODO if really bored: use GOP to set the BG colour on the whole screen.
@@ -392,7 +395,7 @@ ExitBootServicesEvent(
}
gST->ConOut->SetAttribute(gST->ConOut, OriginalAttribute);
- if (Status != EFI_SUCCESS)
+ if (Status != EFI_SUCCESS && ShowErrorMessage)
gST->ConOut->ClearScreen(gST->ConOut);
}
@@ -635,7 +638,8 @@ EfiGuardInitialize(
gKernelPatchInfo.Status = EFI_SUCCESS;
gKernelPatchInfo.BufferSize = 0;
SetMem64(gKernelPatchInfo.Buffer, sizeof(gKernelPatchInfo.Buffer), 0ULL);
- gKernelPatchInfo.BuildNumber = 0;
+ gKernelPatchInfo.WinloadBuildNumber = 0;
+ gKernelPatchInfo.KernelBuildNumber = 0;
gKernelPatchInfo.KernelBase = NULL;
// The ASCII banner is very pretty - ensure the user has enough time to admire it
diff --git a/EfiGuardDxe/EfiGuardDxe.h b/EfiGuardDxe/EfiGuardDxe.h
index 249ed8c..5d87513 100644
--- a/EfiGuardDxe/EfiGuardDxe.h
+++ b/EfiGuardDxe/EfiGuardDxe.h
@@ -203,7 +203,8 @@ typedef struct _KERNEL_PATCH_INFORMATION
EFI_STATUS Status;
UINTN BufferSize; // In bytes, excluding null terminator. This may be 0. The maximum buffer size is simply sizeof(Buffer).
CHAR16 Buffer[8192]; // 8K ought to be enough for everyone
- UINT32 BuildNumber; // Used to determine whether the loader block provided by winload.efi will be for Vista (or older) kernels
+ UINT32 WinloadBuildNumber; // Used to determine whether the loader block provided by winload.efi will be for Vista (or older) kernels
+ UINT32 KernelBuildNumber; // Used to determine whether an error message should be shown
VOID* KernelBase;
} KERNEL_PATCH_INFORMATION;
diff --git a/EfiGuardDxe/PatchNtoskrnl.c b/EfiGuardDxe/PatchNtoskrnl.c
index fad6914..49a3ba3 100644
--- a/EfiGuardDxe/PatchNtoskrnl.c
+++ b/EfiGuardDxe/PatchNtoskrnl.c
@@ -767,6 +767,7 @@ PatchNtoskrnl(
else
{
PRINT_KERNEL_PATCH_MSG(L"[PatchNtoskrnl] Patching ntoskrnl.exe v%u.%u.%u.%u...\r\n", MajorVersion, MinorVersion, BuildNumber, Revision);
+ gKernelPatchInfo.KernelBuildNumber = BuildNumber;
// Check if this is a supported kernel version. All versions after Vista SP1 should be supported.
// There is no "maximum allowed" version; e.g. 10.1, 11.0... are OK. Windows 10 is a whole three major versions higher than Windows 7,
diff --git a/EfiGuardDxe/PatchWinload.c b/EfiGuardDxe/PatchWinload.c
index baa28d7..197ca75 100644
--- a/EfiGuardDxe/PatchWinload.c
+++ b/EfiGuardDxe/PatchWinload.c
@@ -131,7 +131,7 @@ HookedOslFwpKernelSetupPhase1(
CopyWpMem((VOID*)gOriginalOslFwpKernelSetupPhase1, gOslFwpKernelSetupPhase1Backup, sizeof(gHookTemplate));
UINT8* LoadOrderListHeadAddress = (UINT8*)&LoaderBlock->LoadOrderListHead;
- if (gKernelPatchInfo.BuildNumber < 7600)
+ if (gKernelPatchInfo.WinloadBuildNumber < 7600)
{
// We are booting Vista or some other fossil, which means that our LOADER_PARAMETER_BLOCK declaration in no way matches what is
// actually being passed by the loader. Notably, the first four UINT32 fields are absent, so fix up the list entry pointer.
@@ -609,6 +609,9 @@ PatchWinload(
{
Print(L"\r\nPatching winload.efi v%u.%u.%u.%u...\r\n", MajorVersion, MinorVersion, BuildNumber, Revision);
+ // Some... adjustments... need to be made later on in the case of pre-Windows 7 loader blocks, so store the build number
+ gKernelPatchInfo.WinloadBuildNumber = BuildNumber;
+
// Check if this is a supported winload version. All patches should work on all versions since Vista SP1,
// except for the ImgpFilterValidationFailure patch because this function only exists on Windows 7 and higher.
if (BuildNumber < 6001)
@@ -617,9 +620,6 @@ PatchWinload(
Status = EFI_UNSUPPORTED;
goto Exit;
}
-
- // Some... adjustments... need to be made later on in the case of pre-Windows 7 loader blocks, so store the build number
- gKernelPatchInfo.BuildNumber = BuildNumber;
}
// Find the .text and .rdata sections