diff --git a/Dockerfile b/Dockerfile index 5a36b70..b843649 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM wiiuenv/devkitppc:20221228 COPY --from=wiiuenv/wiiumodulesystem:20230106 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20220924 /artifacts $DEVKITPRO -COPY --from=wiiuenv/libfunctionpatcher:20220904 /artifacts $DEVKITPRO +COPY --from=wiiuenv/libfunctionpatcher:20230106 /artifacts $DEVKITPRO COPY --from=wiiuenv/libmappedmemory:20220904 /artifacts $DEVKITPRO COPY --from=wiiuenv/libwupsbackend:20220904 /artifacts $DEVKITPRO diff --git a/Makefile b/Makefile index 070c90e..eb05fbf 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ CXXFLAGS := $(CFLAGS) -std=c++20 -fno-exceptions -fno-rtti ASFLAGS := -g $(ARCH) -LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libfunctionpatcher.ld -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS) +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/libmappedmemory.ld $(WUMSSPECS) ifeq ($(DEBUG),1) CXXFLAGS += -DDEBUG -g diff --git a/source/PluginManagement.cpp b/source/PluginManagement.cpp index 321246d..98847d4 100644 --- a/source/PluginManagement.cpp +++ b/source/PluginManagement.cpp @@ -121,7 +121,7 @@ bool PluginManagement::doRelocations(const std::vector> &plugins) { for (const auto &cur : std::ranges::reverse_view(plugins)) { for (const auto &curFunction : std::ranges::reverse_view(cur->getPluginInformation()->getFunctionDataList())) { - if (!curFunction->restore()) { + if (!curFunction->RemovePatch()) { return false; } } @@ -132,7 +132,7 @@ bool PluginManagement::RestoreFunctionPatches(const std::vector> &plugins) { for (const auto &cur : plugins) { for (const auto &curFunction : cur->getPluginInformation()->getFunctionDataList()) { - if (!curFunction->patch()) { + if (!curFunction->AddPatch()) { return false; } } diff --git a/source/main.cpp b/source/main.cpp index 739df4a..8523815 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -14,10 +14,15 @@ WUMS_DEPENDS_ON(homebrew_memorymapping); WUMS_INITIALIZE() { initLogging(); + + if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) { + OSFatal("homebrew_wupsbackend: FunctionPatcher_InitLibrary failed"); + } + DEBUG_FUNCTION_LINE("Patching functions"); for (uint32_t i = 0; i < method_hooks_static_size; i++) { - if (!FunctionPatcherPatchFunction(&method_hooks_static[i], nullptr)) { - OSFatal("homebrew_wupsbackend: Failed to patch function"); + if (FunctionPatcher_AddFunctionPatch(&method_hooks_static[i], nullptr, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { + OSFatal("homebrew_wupsbackend: Failed to AddPatch function"); } } deinitLogging(); diff --git a/source/plugin/FunctionData.h b/source/plugin/FunctionData.h index d0ce979..1836d2c 100644 --- a/source/plugin/FunctionData.h +++ b/source/plugin/FunctionData.h @@ -65,7 +65,7 @@ public: return targetProcess; } - bool patch() { + bool AddPatch() { if (handle == 0) { function_replacement_data_t functionData = { .VERSION = FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION, @@ -77,25 +77,25 @@ public: .function_name = this->name.c_str(), .targetProcess = this->targetProcess}; - if (!FunctionPatcherPatchFunction(&functionData, &handle)) { - DEBUG_FUNCTION_LINE_ERR("Failed to patch function"); + if (FunctionPatcher_AddFunctionPatch(&functionData, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function"); return false; } } else { - DEBUG_FUNCTION_LINE("Function is already patched"); + DEBUG_FUNCTION_LINE("Function patch has already been added."); } return true; } - bool restore() { + bool RemovePatch() { if (handle != 0) { - if (!FunctionPatcherRestoreFunction(handle)) { - DEBUG_FUNCTION_LINE_ERR("Failed to restore function patch"); + if (FunctionPatcher_RemoveFunctionPatch(handle) != FUNCTION_PATCHER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to remove patch for function"); return false; } handle = 0; } else { - DEBUG_FUNCTION_LINE("Was not patched."); + DEBUG_FUNCTION_LINE_VERBOSE("Was not patched."); } return true;