From 0e6f4def1421b2fc17c2d942fefd3cfc8550b005 Mon Sep 17 00:00:00 2001 From: donnaskiez Date: Sat, 13 Jul 2024 19:51:06 +1000 Subject: [PATCH] small fix --- driver/modules.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/driver/modules.c b/driver/modules.c index 7be18cb..ff4b50b 100644 --- a/driver/modules.c +++ b/driver/modules.c @@ -691,7 +691,16 @@ DoesRetInstructionCauseException(_In_ UINT64 ReturnAddress) if (IsUserModeAddress(ReturnAddress)) return FALSE; - RtlCopyMemory(&opcodes, ReturnAddress, sizeof(opcodes)); + if (!MmIsAddressValid(ReturnAddress)) + return FALSE; + + /* Shoudln't really ever occur */ + __try { + RtlCopyMemory(&opcodes, ReturnAddress, sizeof(opcodes)); + } + __except (EXCEPTION_EXECUTE_HANDLER) { + return FALSE; + } if (opcodes[0] == INSTRUCTION_UD2_BYTE_1 && opcodes[1] == INSTRUCTION_UD2_BYTE_2) @@ -700,7 +709,7 @@ DoesRetInstructionCauseException(_In_ UINT64 ReturnAddress) if (opcodes[0] == INSTRUCTION_INT3_BYTE_1) return TRUE; - DEBUG_VERBOSE("Ret address instruction doesnt throw exception"); + DEBUG_VERBOSE("Ret address instruction doesnt unconditionally throw exception"); return FALSE; }