mirror of
https://github.com/wiiu-env/FunctionPatcherModule.git
synced 2024-11-17 15:29:23 +01:00
Add FunctionPatcherRestoreFunctions
This commit is contained in:
parent
a4a58c7857
commit
64a2b952ba
@ -197,6 +197,43 @@ void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FunctionPatcherRestoreFunctions(function_replacement_data_t *replacements, uint32_t size) {
|
||||||
|
DEBUG_FUNCTION_LINE("Restoring given functions!\n");
|
||||||
|
for (uint32_t i = 0; i < size; i++) {
|
||||||
|
DEBUG_FUNCTION_LINE("Restoring %s... ", replacements[i].function_name);
|
||||||
|
if (replacements[i].restoreInstruction == 0 || replacements[i].realAddr == 0) {
|
||||||
|
DEBUG_FUNCTION_LINE("I dont have the information for the restore =( skip");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t physical = (uint32_t) OSEffectiveToPhysical(replacements[i].realAddr);
|
||||||
|
if (isDynamicFunction(physical)) {
|
||||||
|
WHBLogPrintf("Its a dynamic function. We don't need to restore it!\n", replacements[i].function_name);
|
||||||
|
} else {
|
||||||
|
if (DEBUG_LOG_DYN) {
|
||||||
|
DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n", (uint32_t) replacements[i].restoreInstruction, replacements[i].realAddr);
|
||||||
|
}
|
||||||
|
uint32_t targetAddr = (uint32_t) &replacements[i].restoreInstruction;
|
||||||
|
|
||||||
|
targetAddr = (uint32_t) OSEffectiveToPhysical(targetAddr);
|
||||||
|
|
||||||
|
if (targetAddr == 0 && (targetAddr >= 0x00800000 || targetAddr < 0x01000000)) {
|
||||||
|
targetAddr = targetAddr + 0x30800000 - 0x00800000;
|
||||||
|
}
|
||||||
|
|
||||||
|
KernelCopyData(physical, targetAddr, 4);
|
||||||
|
if (DEBUG_LOG_DYN) {
|
||||||
|
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X\n", (void *) replacements[i].realAddr);
|
||||||
|
}
|
||||||
|
ICInvalidateRange((void *) replacements[i].realAddr, 4);
|
||||||
|
WHBLogPrintf("done\n");
|
||||||
|
}
|
||||||
|
replacements[i].alreadyPatched = 0; // In case a
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Done with restoring given functions!\n");
|
||||||
|
}
|
||||||
|
|
||||||
bool isDynamicFunction(uint32_t physicalAddress) {
|
bool isDynamicFunction(uint32_t physicalAddress) {
|
||||||
if ((physicalAddress & 0x80000000) == 0x80000000) {
|
if ((physicalAddress & 0x80000000) == 0x80000000) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -14,6 +14,8 @@ typedef struct rpl_handling {
|
|||||||
|
|
||||||
void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uint32_t size);
|
void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uint32_t size);
|
||||||
|
|
||||||
|
void FunctionPatcherRestoreFunctions(function_replacement_data_t *replacements, uint32_t size);
|
||||||
|
|
||||||
void FunctionPatcherResetLibHandles();
|
void FunctionPatcherResetLibHandles();
|
||||||
|
|
||||||
uint32_t getAddressOfFunction(char * functionName, function_replacement_library_type_t type);
|
uint32_t getAddressOfFunction(char * functionName, function_replacement_library_type_t type);
|
||||||
|
@ -13,3 +13,4 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WUMS_EXPORT_FUNCTION(FunctionPatcherPatchFunction);
|
WUMS_EXPORT_FUNCTION(FunctionPatcherPatchFunction);
|
||||||
|
WUMS_EXPORT_FUNCTION(FunctionPatcherRestoreFunctions);
|
||||||
|
Loading…
Reference in New Issue
Block a user