Created
December 5, 2021 17:28
-
-
Save al3xtjames/f7f2aaa8fe338c4b7d7b6f737d98d9ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Library/OcMainLib/OpenCoreUefi.c b/Library/OcMainLib/OpenCoreUefi.c | |
index fb1ec184..88ff8a95 100644 | |
--- a/Library/OcMainLib/OpenCoreUefi.c | |
+++ b/Library/OcMainLib/OpenCoreUefi.c | |
@@ -808,6 +808,52 @@ OcReserveMemory ( | |
} | |
+STATIC | |
+VOID | |
+OcPatchIdt ( | |
+ VOID | |
+ ) | |
+{ | |
+ IA32_DESCRIPTOR Idtr; | |
+ IA32_IDT_GATE_DESCRIPTOR *IdtTable; | |
+ UINTN NumberOfIdtEntries; | |
+ UINTN Index; | |
+ UINTN Vector; | |
+ | |
+ AsmReadIdtr (&Idtr); | |
+ IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) Idtr.Base; | |
+ NumberOfIdtEntries = (Idtr.Limit + 1) / sizeof(*IdtTable); | |
+ | |
+ DEBUG (( | |
+ DEBUG_INFO, | |
+ "OC: IDT base 0x%lx limit 0x%x number of entries %lu\n", | |
+ Idtr.Base, | |
+ Idtr.Limit, | |
+ NumberOfIdtEntries | |
+ )); | |
+ | |
+ for (Index = 0; Index < 20; Index++) { | |
+ Vector = (((UINTN) IdtTable[Index].Bits.OffsetUpper) << 32) | | |
+ (IdtTable[Index].Bits.OffsetHigh << 16) | | |
+ IdtTable[Index].Bits.OffsetLow; | |
+ | |
+ DEBUG (( | |
+ DEBUG_INFO, | |
+ "OC: IDT entry %lu OffsetUpper 0x%x OffsetHigh 0x%x OffsetLow 0x%x Vector 0x%lx\n", | |
+ Index, | |
+ IdtTable[Index].Bits.OffsetUpper, | |
+ IdtTable[Index].Bits.OffsetHigh, | |
+ IdtTable[Index].Bits.OffsetLow, | |
+ Vector | |
+ )); | |
+ | |
+ if (Vector != 0) { | |
+ SetMem ((VOID *)Vector, 1, 0xF1); | |
+ } | |
+ } | |
+} | |
+ | |
+ | |
VOID | |
OcLoadUefiSupport ( | |
IN OC_STORAGE_CONTEXT *Storage, | |
@@ -821,6 +867,8 @@ OcLoadUefiSupport ( | |
EFI_EVENT Event; | |
BOOLEAN AvxEnabled; | |
+ OcPatchIdt (); | |
+ | |
OcReinstallProtocols (Config); | |
OcImageLoaderInit (Config->Booter.Quirks.ProtectUefiServices); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment