From 0225c49e3a2a90fd0759ed233f95c31693940b42 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 31 May 2020 02:25:07 +0200 Subject: [PATCH] reloactor: Add KiIsEffectiveRangeValid patch --- relocator/src/hooks_patcher_static.cpp | 10 ++++++++++ relocator/src/utils/function_patcher.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/relocator/src/hooks_patcher_static.cpp b/relocator/src/hooks_patcher_static.cpp index b429d91..c51de7a 100644 --- a/relocator/src/hooks_patcher_static.cpp +++ b/relocator/src/hooks_patcher_static.cpp @@ -95,10 +95,20 @@ DECL(uint32_t, IPCKDriver_ValidatePhysicalAddress, uint32_t u1, uint32_t physSta return real_IPCKDriver_ValidatePhysicalAddress(u1, physStart, physEnd); } +DECL(uint32_t, KiIsEffectiveRangeValid, uint32_t addressSpace, uint32_t virtualAddress, uint32_t size) { + uint32_t result = real_KiIsEffectiveRangeValid(addressSpace, virtualAddress, size); + if (result == 0) { + if(MemoryMappingEffectiveToPhysicalPTR != 0){ + return ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingEffectiveToPhysicalPTR))(virtualAddress); + } + } + return result; +} hooks_magic_t method_hooks_hooks_static[] __attribute__((section(".data"))) = { MAKE_MAGIC(KiEffectiveToPhysical, LIB_CORE_INIT, STATIC_FUNCTION), MAKE_MAGIC(KiPhysicalToEffectiveCached, LIB_CORE_INIT, STATIC_FUNCTION), MAKE_MAGIC(KiPhysicalToEffectiveUncached, LIB_CORE_INIT, STATIC_FUNCTION), + MAKE_MAGIC(KiIsEffectiveRangeValid, LIB_CORE_INIT, STATIC_FUNCTION), MAKE_MAGIC(IPCKDriver_ValidatePhysicalAddress, LIB_CORE_INIT, STATIC_FUNCTION), MAKE_MAGIC(OSDynLoad_Acquire, LIB_CORE_INIT, STATIC_FUNCTION), MAKE_MAGIC(OSDynLoad_FindExport, LIB_CORE_INIT, STATIC_FUNCTION) diff --git a/relocator/src/utils/function_patcher.cpp b/relocator/src/utils/function_patcher.cpp index 03b00a7..417c5bd 100644 --- a/relocator/src/utils/function_patcher.cpp +++ b/relocator/src/utils/function_patcher.cpp @@ -253,6 +253,8 @@ uint32_t GetAddressOfFunction(const char *functionName, uint32_t library) { return 0xffee0a3c; }else if(strcmp(functionName, "IPCKDriver_ValidatePhysicalAddress") == 0){ return 0xfff0cb5c; + }else if(strcmp(functionName, "KiIsEffectiveRangeValid") == 0){ + return 0xffee0d6c; } OSDynLoad_Module rpl_handle = 0;