mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +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/wiiumodulesystem:20230106 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/wiiupluginsystem:20220924 /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/libmappedmemory:20220904 /artifacts $DEVKITPRO
|
||||||
COPY --from=wiiuenv/libwupsbackend: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
|
CXXFLAGS := $(CFLAGS) -std=c++20 -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
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)
|
ifeq ($(DEBUG),1)
|
||||||
CXXFLAGS += -DDEBUG -g
|
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) {
|
bool PluginManagement::RestoreFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
||||||
for (const auto &cur : std::ranges::reverse_view(plugins)) {
|
for (const auto &cur : std::ranges::reverse_view(plugins)) {
|
||||||
for (const auto &curFunction : std::ranges::reverse_view(cur->getPluginInformation()->getFunctionDataList())) {
|
for (const auto &curFunction : std::ranges::reverse_view(cur->getPluginInformation()->getFunctionDataList())) {
|
||||||
if (!curFunction->restore()) {
|
if (!curFunction->RemovePatch()) {
|
||||||
return false;
|
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) {
|
bool PluginManagement::DoFunctionPatches(const std::vector<std::unique_ptr<PluginContainer>> &plugins) {
|
||||||
for (const auto &cur : plugins) {
|
for (const auto &cur : plugins) {
|
||||||
for (const auto &curFunction : cur->getPluginInformation()->getFunctionDataList()) {
|
for (const auto &curFunction : cur->getPluginInformation()->getFunctionDataList()) {
|
||||||
if (!curFunction->patch()) {
|
if (!curFunction->AddPatch()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,15 @@ WUMS_DEPENDS_ON(homebrew_memorymapping);
|
|||||||
|
|
||||||
WUMS_INITIALIZE() {
|
WUMS_INITIALIZE() {
|
||||||
initLogging();
|
initLogging();
|
||||||
|
|
||||||
|
if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
|
OSFatal("homebrew_wupsbackend: FunctionPatcher_InitLibrary failed");
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Patching functions");
|
DEBUG_FUNCTION_LINE("Patching functions");
|
||||||
for (uint32_t i = 0; i < method_hooks_static_size; i++) {
|
for (uint32_t i = 0; i < method_hooks_static_size; i++) {
|
||||||
if (!FunctionPatcherPatchFunction(&method_hooks_static[i], nullptr)) {
|
if (FunctionPatcher_AddFunctionPatch(&method_hooks_static[i], nullptr, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
OSFatal("homebrew_wupsbackend: Failed to patch function");
|
OSFatal("homebrew_wupsbackend: Failed to AddPatch function");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
return targetProcess;
|
return targetProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool patch() {
|
bool AddPatch() {
|
||||||
if (handle == 0) {
|
if (handle == 0) {
|
||||||
function_replacement_data_t functionData = {
|
function_replacement_data_t functionData = {
|
||||||
.VERSION = FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION,
|
.VERSION = FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION,
|
||||||
@ -77,25 +77,25 @@ public:
|
|||||||
.function_name = this->name.c_str(),
|
.function_name = this->name.c_str(),
|
||||||
.targetProcess = this->targetProcess};
|
.targetProcess = this->targetProcess};
|
||||||
|
|
||||||
if (!FunctionPatcherPatchFunction(&functionData, &handle)) {
|
if (FunctionPatcher_AddFunctionPatch(&functionData, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to patch function");
|
DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Function is already patched");
|
DEBUG_FUNCTION_LINE("Function patch has already been added.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool restore() {
|
bool RemovePatch() {
|
||||||
if (handle != 0) {
|
if (handle != 0) {
|
||||||
if (!FunctionPatcherRestoreFunction(handle)) {
|
if (FunctionPatcher_RemoveFunctionPatch(handle) != FUNCTION_PATCHER_RESULT_SUCCESS) {
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to restore function patch");
|
DEBUG_FUNCTION_LINE_ERR("Failed to remove patch for function");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
handle = 0;
|
handle = 0;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Was not patched.");
|
DEBUG_FUNCTION_LINE_VERBOSE("Was not patched.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user