mirror of
https://github.com/wiiu-env/FunctionPatcherModule.git
synced 2024-11-17 15:29:23 +01:00
Fix restoring functions patches for other proccesses
This commit is contained in:
parent
361f37f566
commit
73947c0a13
@ -202,23 +202,34 @@ void FunctionPatcherRestoreFunctions(function_replacement_data_t *replacements,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t physical = (uint32_t) OSEffectiveToPhysical(replacements[i].realAddr);
|
uint32_t targetAddrPhys = (uint32_t) replacements[i].physicalAddr;
|
||||||
if (isDynamicFunction(physical)) {
|
|
||||||
|
if (replacements[i].library != LIBRARY_OTHER) {
|
||||||
|
targetAddrPhys = (uint32_t) OSEffectiveToPhysical(replacements[i].realAddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDynamicFunction(targetAddrPhys) &&
|
||||||
|
// Other processes than the wii u menu and game one seem to keep their rpl's loaded.
|
||||||
|
replacements[i].targetProcess != FP_TARGET_PROCESS_GAME_AND_MENU &&
|
||||||
|
replacements[i].targetProcess != FP_TARGET_PROCESS_GAME &&
|
||||||
|
replacements[i].targetProcess != FP_TARGET_PROCESS_WII_U_MENU
|
||||||
|
) {
|
||||||
WHBLogPrintf("Its a dynamic function. We don't need to restore it!", replacements[i].function_name);
|
WHBLogPrintf("Its a dynamic function. We don't need to restore it!", replacements[i].function_name);
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG_LOG_DYN) {
|
if (DEBUG_LOG_DYN) {
|
||||||
WHBLogPrintf("");
|
WHBLogPrintf("");
|
||||||
DEBUG_FUNCTION_LINE("Restoring %08X to %08X", (uint32_t) replacements[i].restoreInstruction, replacements[i].realAddr);
|
DEBUG_FUNCTION_LINE("Restoring %08X to %08X [%08X]", (uint32_t) replacements[i].restoreInstruction, replacements[i].realAddr, targetAddrPhys);
|
||||||
}
|
}
|
||||||
uint32_t targetAddr = (uint32_t) &replacements[i].restoreInstruction;
|
uint32_t sourceAddr = (uint32_t) &replacements[i].restoreInstruction;
|
||||||
|
|
||||||
targetAddr = (uint32_t) OSEffectiveToPhysical(targetAddr);
|
uint32_t sourceAddrPhys = (uint32_t) OSEffectiveToPhysical(sourceAddr);
|
||||||
|
|
||||||
if (targetAddr == 0 && (targetAddr >= 0x00800000 || targetAddr < 0x01000000)) {
|
// These hardcoded values should be replaced with something more dynamic.
|
||||||
targetAddr = targetAddr + 0x30800000 - 0x00800000;
|
if (sourceAddrPhys == 0 && (sourceAddr >= 0x00800000 || sourceAddr < 0x01000000)) {
|
||||||
|
sourceAddrPhys = sourceAddr + 0x30800000 - 0x00800000;
|
||||||
}
|
}
|
||||||
|
|
||||||
KernelCopyData(physical, targetAddr, 4);
|
KernelCopyData(targetAddrPhys, sourceAddrPhys, 4);
|
||||||
if (DEBUG_LOG_DYN) {
|
if (DEBUG_LOG_DYN) {
|
||||||
WHBLogPrintf("");
|
WHBLogPrintf("");
|
||||||
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X", (void *) replacements[i].realAddr);
|
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X", (void *) replacements[i].realAddr);
|
||||||
|
Loading…
Reference in New Issue
Block a user