Add FunctionPatcherRestoreDynamicFunctions

This commit is contained in:
Maschell 2020-12-28 14:45:28 +01:00
parent e745f34b3a
commit 978678675c
3 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,24 @@ void writeDataAndFlushIC(CThread *thread, void *arg) {
ICInvalidateRange((void *) (effective_address), 4);
}
void FunctionPatcherRestoreDynamicFunctions(function_replacement_data_t *replacements, uint32_t size) {
for (uint32_t i = 0; i < size; i++) {
function_replacement_data_t *function_data = &replacements[i];
if (function_data->VERSION != FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION) {
OSFatal("Failed to patch function. struct version mismatch");
}
uint32_t targetAddrPhys = function_data->physicalAddr;
if (function_data->library != LIBRARY_OTHER) {
targetAddrPhys = (uint32_t) OSEffectiveToPhysical(function_data->realAddr);
}
if (isDynamicFunction(targetAddrPhys)) {
DEBUG_FUNCTION_LINE("Setting alreadyPatched to false for %s because it's a dynamic function", function_data->function_name);
function_data->alreadyPatched = 0;
}
}
}
void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uint32_t size) {
for (uint32_t i = 0; i < size; i++) {
function_replacement_data_t *function_data = &replacements[i];

View File

@ -12,6 +12,8 @@ typedef struct rpl_handling {
OSDynLoad_Module handle;
} rpl_handling;
void FunctionPatcherRestoreDynamicFunctions(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);

View File

@ -16,3 +16,4 @@ WUMS_APPLICATION_STARTS() {
WUMS_EXPORT_FUNCTION(FunctionPatcherPatchFunction);
WUMS_EXPORT_FUNCTION(FunctionPatcherRestoreFunctions);
WUMS_EXPORT_FUNCTION(FunctionPatcherRestoreDynamicFunctions);