mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-05 12:35:06 +01:00
Update to use the latest libfunctionpatcher
This commit is contained in:
parent
47ad061f5c
commit
2071c6cbf8
@ -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
|
||||
|
||||
|
2
Makefile
2
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
|
||||
|
@ -121,7 +121,7 @@ bool PluginManagement::doRelocations(const std::vector<std::unique_ptr<PluginCon
|
||||
bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &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<std::unique_ptr<
|
||||
bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
||||
for (const auto &cur : plugins) {
|
||||
for (const auto &curFunction : cur->getPluginInformation()->getFunctionDataList()) {
|
||||
if (!curFunction->patch()) {
|
||||
if (!curFunction->AddPatch()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user