From d9457e8cdc4d823c2944b3e2826861d60351ef24 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 16 Feb 2023 12:36:04 +0100 Subject: [PATCH] Implement KiValidateUserDataRange and KiValidateUserCodeRange hook --- source/function_replacements.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/function_replacements.cpp b/source/function_replacements.cpp index 90c49f7..bdd3a34 100644 --- a/source/function_replacements.cpp +++ b/source/function_replacements.cpp @@ -10,6 +10,23 @@ DECL_FUNCTION(uint32_t, KiEffectiveToPhysical, uint32_t addressSpace, uint32_t v return result; } + +DECL_FUNCTION(int32_t, KiValidateUserDataRange, uint32_t address, uint32_t size) { + if ((address >= 0x00800000 && address < 0x01000000) || (address & 0xF0000000) == (MEMORY_START_BASE & 0xF0000000)) { + return 1; + } + + return real_KiValidateUserDataRange(address, size); +} + +DECL_FUNCTION(int32_t, KiValidateUserCodeRange, uint32_t address, uint32_t size) { + if ((address >= 0x00800000 && address < 0x01000000) || (address & 0xF0000000) == (MEMORY_START_BASE & 0xF0000000)) { + return 1; + } + + return real_KiValidateUserCodeRange(address, size); +} + DECL_FUNCTION(int32_t, sCheckDataRange, uint32_t address, uint32_t maxDataSize) { if ((address >= 0x00800000 && address < 0x01000000) || (address & 0xF0000000) == (MEMORY_START_BASE & 0xF0000000)) { return 1; @@ -106,6 +123,8 @@ function_replacement_data_t function_replacements[] __attribute__((section(".dat REPLACE_FUNCTION_VIA_ADDRESS(KiPhysicalToEffectiveUncached, 0xffee0a80, 0xffee0a80), REPLACE_FUNCTION_VIA_ADDRESS(KiIsEffectiveRangeValid, 0xffee0d6c, 0xffee0d6c), REPLACE_FUNCTION_VIA_ADDRESS(IPCKDriver_ValidatePhysicalAddress, 0xfff0cb5c, 0xfff0cb5c), + REPLACE_FUNCTION_VIA_ADDRESS(KiValidateUserDataRange, 0xffee10cc, 0xffee10cc), + REPLACE_FUNCTION_VIA_ADDRESS(KiValidateUserCodeRange, 0xffee1074, 0xffee1074), REPLACE_FUNCTION_VIA_ADDRESS(KiGetOrPutUserData, 0xffee0794, 0xffee0794), REPLACE_FUNCTION(MEMFindContainHeap, LIBRARY_COREINIT, MEMFindContainHeap), };