diff --git a/Dockerfile b/Dockerfile index e9a960c..31a23fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wiiuenv/devkitppc:20210917 +FROM wiiuenv/devkitppc:20220507 WORKDIR tmp_build COPY . . diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal index 080eec7..8ec2277 100644 --- a/Dockerfile.buildlocal +++ b/Dockerfile.buildlocal @@ -1,3 +1,3 @@ -FROM wiiuenv/devkitppc:20211229 +FROM wiiuenv/devkitppc:20220507 WORKDIR project \ No newline at end of file diff --git a/README.md b/README.md index fbdf5cf..227d443 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Publish Docker Image](https://github.com/wiiu-env/libfunctionpatcher/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libfunctionpatcher/actions/workflows/push_image.yml) # libfunctionpatcher -Requires the [FunctionPatcherModule](https://github.com/wiiu-env/FunctionPatcherModule) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader). +Requires the [FunctionPatcherModule](https://github.com/wiiu-env/FunctionPatcherModule) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader). Requires [wut](https://github.com/devkitPro/wut) for building. Install via `make install`. diff --git a/include/function_patcher/fpatching_defines.h b/include/function_patcher/fpatching_defines.h index 0c66432..833b270 100644 --- a/include/function_patcher/fpatching_defines.h +++ b/include/function_patcher/fpatching_defines.h @@ -100,22 +100,18 @@ typedef enum FunctionPatcherTargetProcess { FP_TARGET_PROCESS_GAME_AND_MENU = 16, } FunctionPatcherTargetProcess; -#define FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION 0x00000001 +typedef uint32_t PatchedFunctionHandle; +#define FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION 0x00000002 typedef struct function_replacement_data_t { uint32_t VERSION; - uint32_t physicalAddr; /* [needs to be filled] */ - uint32_t virtualAddr; /* [needs to be filled] */ - uint32_t replaceAddr; /* [needs to be filled] Address of our replacement function */ - uint32_t replaceCall; /* [needs to be filled] Address to access the real_function */ - function_replacement_library_type_t library; /* [needs to be filled] rpl where the function we want to replace is. */ - char function_name[MAXIMUM_FUNCTION_NAME_LENGTH]; /* [needs to be filled] name of the function we want to replace */ - uint32_t realAddr; /* [will be filled] Address of the real function we want to replace. */ - volatile uint32_t replace_data[FUNCTION_PATCHER_METHOD_STORE_SIZE]; /* [will be filled] Space for us to store some jump instructions */ - uint32_t restoreInstruction; /* [will be filled] Copy of the instruction we replaced to jump to our code. */ - FunctionPatcherFunctionType functionType; /* [will be filled] */ - uint8_t alreadyPatched; /* [will be filled] */ - FunctionPatcherTargetProcess targetProcess; /* [will be filled] */ + uint32_t physicalAddr; /* [needs to be filled] */ + uint32_t virtualAddr; /* [needs to be filled] */ + uint32_t replaceAddr; /* [needs to be filled] Address of our replacement function */ + uint32_t *replaceCall; /* [needs to be filled] Address to access the real_function */ + function_replacement_library_type_t library; /* [needs to be filled] rpl where the function we want to replace is. */ + const char *function_name; /* [needs to be filled] name of the function we want to replace */ + FunctionPatcherTargetProcess targetProcess; /* [will be filled] */ } function_replacement_data_t; @@ -137,14 +133,9 @@ typedef struct function_replacement_data_t { physicalAddress, \ effectiveAddress, \ (uint32_t) my_##x, \ - (uint32_t) &real_##x, \ + (uint32_t *) &real_##x, \ lib, \ function_name, \ - 0, \ - {}, \ - 0, \ - FUNCTION_PATCHER_STATIC_FUNCTION, \ - 0, \ process \ } diff --git a/include/function_patcher/function_patching.h b/include/function_patcher/function_patching.h index b3df913..ef3c7a8 100644 --- a/include/function_patcher/function_patching.h +++ b/include/function_patcher/function_patching.h @@ -7,11 +7,9 @@ extern "C" { #endif -extern void FunctionPatcherRestoreDynamicFunctions(function_replacement_data_t *replacements, uint32_t size); +extern bool FunctionPatcherPatchFunction(function_replacement_data_t *function_data, PatchedFunctionHandle *outHandle); -extern void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uint32_t size); - -extern void FunctionPatcherRestoreFunctions(function_replacement_data_t *replacements, uint32_t size); +extern bool FunctionPatcherRestoreFunction(PatchedFunctionHandle outHandle); #ifdef __cplusplus } diff --git a/source/patching.def b/source/patching.def index e363147..ccc6cb4 100644 --- a/source/patching.def +++ b/source/patching.def @@ -2,5 +2,4 @@ :TEXT FunctionPatcherPatchFunction -FunctionPatcherRestoreFunctions -FunctionPatcherRestoreDynamicFunctions \ No newline at end of file +FunctionPatcherRestoreFunction \ No newline at end of file