diff options
author | Matthijs Lavrijsen <mattiwatti@gmail.com> | 2022-08-17 07:27:29 +0200 |
---|---|---|
committer | Matthijs Lavrijsen <mattiwatti@gmail.com> | 2022-08-17 07:27:29 +0200 |
commit | 6ef2473bc64dbde337fa4c475acd1c3a3fa788d1 (patch) | |
tree | c7d6be116ccaae439269012dafd94b1540a6865a | |
parent | 1f170890f57a54d3c1fa1698b0fd21d4621d287e (diff) |
DXE driver: store the full kernel build number in global context
-rw-r--r-- | EfiGuardDxe/EfiGuardDxe.c | 4 | ||||
-rw-r--r-- | EfiGuardDxe/EfiGuardDxe.h | 2 | ||||
-rw-r--r-- | EfiGuardDxe/PatchWinload.c | 6 |
3 files changed, 6 insertions, 6 deletions
diff --git a/EfiGuardDxe/EfiGuardDxe.c b/EfiGuardDxe/EfiGuardDxe.c index 4d28559..5bb300b 100644 --- a/EfiGuardDxe/EfiGuardDxe.c +++ b/EfiGuardDxe/EfiGuardDxe.c @@ -360,7 +360,7 @@ ExitBootServicesEvent( WaitForKey(); } } - else + else if (gKernelPatchInfo.BuildNumber >= 6000) { // 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. @@ -629,7 +629,7 @@ EfiGuardInitialize( gKernelPatchInfo.Status = EFI_SUCCESS; gKernelPatchInfo.BufferSize = 0; SetMem64(gKernelPatchInfo.Buffer, sizeof(gKernelPatchInfo.Buffer), 0ULL); - gKernelPatchInfo.LegacyLoaderBlock = FALSE; + gKernelPatchInfo.BuildNumber = 0; gKernelPatchInfo.KernelBase = NULL; // Wipe our image info and PE headers diff --git a/EfiGuardDxe/EfiGuardDxe.h b/EfiGuardDxe/EfiGuardDxe.h index e26dc5e..4859953 100644 --- a/EfiGuardDxe/EfiGuardDxe.h +++ b/EfiGuardDxe/EfiGuardDxe.h @@ -202,7 +202,7 @@ 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 - BOOLEAN LegacyLoaderBlock; // TRUE if the loader block provided by winload.efi will be for Vista or older kernels + UINT32 BuildNumber; // Used to determine whether the loader block provided by winload.efi will be for Vista (or older) kernels VOID* KernelBase; } KERNEL_PATCH_INFORMATION; diff --git a/EfiGuardDxe/PatchWinload.c b/EfiGuardDxe/PatchWinload.c index fe8ab35..277d9d2 100644 --- a/EfiGuardDxe/PatchWinload.c +++ b/EfiGuardDxe/PatchWinload.c @@ -83,7 +83,7 @@ HookedOslFwpKernelSetupPhase1( CopyMem((VOID*)gOriginalOslFwpKernelSetupPhase1, gOslFwpKernelSetupPhase1Backup, sizeof(gOslFwpKernelSetupPhase1Backup)); UINT8* LoadOrderListHeadAddress = (UINT8*)&LoaderBlock->LoadOrderListHead; - if (gKernelPatchInfo.LegacyLoaderBlock) + if (gKernelPatchInfo.BuildNumber < 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. @@ -570,8 +570,8 @@ PatchWinload( goto Exit; } - // Some... adjustments... need to be made later on in the case of pre-Windows 7 loader blocks - gKernelPatchInfo.LegacyLoaderBlock = BuildNumber < 7600; + // 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 |