Compare commits

..

7 Commits
v0.2.6 ... main

Author SHA1 Message Date
Maschell
6170bcb5e2 Update Dockerfile
Some checks failed
CI-Release / clang-format (push) Has been cancelled
CI-Release / build-binary (push) Has been cancelled
CI-Release / deploy-binary (push) Has been cancelled
2026-01-26 20:07:56 +01:00
Maschell
74f3c8a599 Fix compiling with latest/upcoming devkitppc/wut version 2026-01-26 20:07:56 +01:00
Maschell
dcc0d43fde Update Dockerfile
Some checks failed
CI-Release / clang-format (push) Has been cancelled
CI-Release / build-binary (push) Has been cancelled
CI-Release / deploy-binary (push) Has been cancelled
2025-02-19 13:01:23 +01:00
Maschell
199e959dcc Add support for 0.3.4 to allow an custom rpl allocator 2025-02-19 13:01:23 +01:00
Maschell
f05add408e Update Dockerfile
Some checks failed
CI-Release / clang-format (push) Has been cancelled
CI-Release / build-binary (push) Has been cancelled
CI-Release / deploy-binary (push) Has been cancelled
2025-02-08 14:39:16 +01:00
Maschell
9840f06aac Implement support for WUMS 0.3.3 2025-02-08 14:39:16 +01:00
Maschell
75e6a6af10 Bump version 2025-02-08 14:39:16 +01:00
16 changed files with 117 additions and 52 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ cmake-build-debug/
*.txt
build1/
cmake-build-default/
*.zip

View File

@ -1,5 +1,5 @@
FROM ghcr.io/wiiu-env/devkitppc:20240704
FROM ghcr.io/wiiu-env/devkitppc:20260126
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20240424 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20260126 /artifacts $DEVKITPRO
WORKDIR project

View File

@ -31,7 +31,7 @@ INCLUDES := source
#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
CFLAGS := -Wall -Os -ffunction-sections \
CFLAGS := -Wall -Werror -Os -ffunction-sections \
$(MACHDEP)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__

View File

@ -2,7 +2,7 @@ void __init_wut_malloc();
void __init_wut_newlib();
void __init_wut_stdcpp();
void __init_wut_thread();
void __init_wut_devoptab();
@ -12,17 +12,15 @@ void __fini_wut_malloc();
void __fini_wut_newlib();
void __fini_wut_stdcpp();
void __fini_wut_devoptab();
void __attribute__((weak)) __fini_wut_socket();
void __attribute__((weak))
__init_wut_() {
__init_wut_thread();
__init_wut_malloc();
__init_wut_newlib();
__init_wut_stdcpp();
__init_wut_devoptab();
if (&__init_wut_socket) __init_wut_socket();
}
@ -30,7 +28,6 @@ __init_wut_() {
void __attribute__((weak))
__fini_wut_() {
__fini_wut_devoptab();
__fini_wut_stdcpp();
__fini_wut_newlib();
__fini_wut_malloc();
}

View File

@ -47,7 +47,7 @@ INCLUDES := src
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2 -ffunction-sections $(MACHDEP) $(INCLUDE) -D__WIIU__ -D__WUT__
CFLAGS := -g -Wall -Werror -O2 -ffunction-sections $(MACHDEP) $(INCLUDE) -D__WIIU__ -D__WUT__
CXXFLAGS := $(CFLAGS) -std=c++20 -fno-exceptions -fno-rtti
ASFLAGS := -mregnames
LDFLAGS := -Wl,--gc-sections,--allow-multiple-definition
@ -125,6 +125,8 @@ export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean install
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD))
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

View File

@ -5,7 +5,7 @@ void __init_wut_malloc();
void __init_wut_newlib();
void __init_wut_stdcpp();
void __init_wut_thread();
void __init_wut_devoptab();
@ -15,17 +15,15 @@ void __fini_wut_malloc();
void __fini_wut_newlib();
void __fini_wut_stdcpp();
void __fini_wut_devoptab();
void __attribute__((weak)) __fini_wut_socket();
void __attribute__((weak))
init_wut() {
__init_wut_thread();
__init_wut_malloc();
__init_wut_newlib();
__init_wut_stdcpp();
__init_wut_devoptab();
if (&__init_wut_socket) __init_wut_socket();
}
@ -33,7 +31,6 @@ init_wut() {
void __attribute__((weak))
fini_wut() {
__fini_wut_devoptab();
__fini_wut_stdcpp();
__fini_wut_newlib();
__fini_wut_malloc();
}

View File

@ -16,7 +16,7 @@
#include <cstdint>
#include <list>
#define VERSION "v0.2.6"
#define VERSION "v0.2.9"
void CallInitHooksForModule(const std::shared_ptr<ModuleData> &curModule);
@ -86,7 +86,7 @@ void doStart(int argc, char **argv) {
* Bit 13 - OS relaunch (OSForceFullRelaunch()).
See more https://wiiubrew.org/wiki/Boot1#PowerFlags */
if ((bootFlags & 0x00002000) != 0 && argc == WUMS_LOADER_SETUP_MAGIC_WORD) {
OSReport("OSForceFullRelaunch detected, skipping WUMS\n", bootFlags);
OSReport("OSForceFullRelaunch detected, skipping WUMS\n");
return;
}
init_wut();
@ -98,7 +98,7 @@ void doStart(int argc, char **argv) {
// If an allocated rpl was not released properly (e.g. if something else calls OSDynload_Acquire without releasing it)
// memory gets leaked. Let's clean this up!
for (auto &addr : gAllocatedAddresses) {
DEBUG_FUNCTION_LINE_WARN("Memory allocated by OSDynload was not freed properly, let's clean it up! (%08X)", addr);
DEBUG_FUNCTION_LINE_WARN("Memory allocated by OSDynload was not freed properly, let's clean it up! (%p)", addr);
free((void *) addr);
}
gAllocatedAddresses.clear();
@ -121,8 +121,7 @@ void doStart(int argc, char **argv) {
continue;
}
DEBUG_FUNCTION_LINE("Loading module %s", modules.GetFilepath(i));
auto moduleData = ModuleDataFactory::load(modules.GetFilepath(i));
if (moduleData) {
if (auto moduleData = ModuleDataFactory::load(modules.GetFilepath(i))) {
DEBUG_FUNCTION_LINE("Successfully loaded %s", modules.GetFilepath(i));
gLoadedModules.push_back(std::move(moduleData.value()));
} else {
@ -138,9 +137,8 @@ void doStart(int argc, char **argv) {
{
// make sure the plugin backend module is at the end.
auto it = std::find_if(gLoadedModules.begin(),
gLoadedModules.end(),
[](auto &cur) { return std::string_view(cur->getExportName()) == "homebrew_wupsbackend"; });
const auto it = std::ranges::find_if(gLoadedModules,
[](auto &cur) { return std::string_view(cur->getExportName()) == "homebrew_wupsbackend"; });
if (it != gLoadedModules.end()) {
auto module = *it;
gLoadedModules.erase(it);
@ -180,9 +178,8 @@ void doStart(int argc, char **argv) {
}
// move homebrew_basemodule to the front
auto it = std::find_if(gLoadedModulesCopy.begin(),
gLoadedModulesCopy.end(),
[](auto &cur) { return std::string_view(cur->getExportName()) == "homebrew_basemodule"; });
const auto it = std::ranges::find_if(gLoadedModulesCopy,
[](auto &cur) { return std::string_view(cur->getExportName()) == "homebrew_basemodule"; });
if (it != gLoadedModulesCopy.end()) {
auto module = *it;
gLoadedModulesCopy.erase(it);
@ -209,7 +206,7 @@ void doStart(int argc, char **argv) {
}
#endif
DEBUG_FUNCTION_LINE_VERBOSE("Resolve relocations without replacing alloc functions");
DEBUG_FUNCTION_LINE_VERBOSE("Resolve relocations without loading additonal rpls");
ResolveRelocations(gLoadedModules, true, gUsedRPLs);
for (auto &curModule : gLoadedModules) {
@ -218,6 +215,12 @@ void doStart(int argc, char **argv) {
}
}
// Hacky workaround for modules to allow register a custom rpl allocator function
CallHook(gLoadedModules, WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR);
// Now we can load unloaded rpls.
ResolveRelocations(gLoadedModules, false, gUsedRPLs);
DEBUG_FUNCTION_LINE_VERBOSE("Call Relocations done hook");
CallHook(gLoadedModules, WUMS_HOOK_RELOCATIONS_DONE);
@ -227,7 +230,8 @@ void doStart(int argc, char **argv) {
}
}
} else {
DEBUG_FUNCTION_LINE("Resolve relocations and replace alloc functions");
DEBUG_FUNCTION_LINE("Resolve relocations and load unloaded rpls functions");
CallHook(gLoadedModules, WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY);
ResolveRelocations(gLoadedModules, false, gUsedRPLs);
CallHook(gLoadedModules, WUMS_HOOK_RELOCATIONS_DONE);
}
@ -237,12 +241,14 @@ void doStart(int argc, char **argv) {
CallHook(gLoadedModules, WUMS_HOOK_INIT_WUT_DEVOPTAB);
CallHook(gLoadedModules, WUMS_HOOK_INIT_WUT_SOCKETS);
CallHook(gLoadedModules, WUMS_HOOK_APPLICATION_STARTS);
CallHook(gLoadedModules, WUMS_HOOK_ALL_APPLICATION_STARTS_DONE);
deinitLogging();
fini_wut();
}
void CallInitHooksForModule(const std::shared_ptr<ModuleData> &curModule) {
CallHook(curModule, WUMS_HOOK_INIT_WUT_THREAD);
CallHook(curModule, WUMS_HOOK_INIT_WUT_MALLOC);
CallHook(curModule, WUMS_HOOK_INIT_WUT_NEWLIB);
CallHook(curModule, WUMS_HOOK_INIT_WUT_STDCPP);
@ -300,7 +306,7 @@ std::vector<std::shared_ptr<ModuleData>> OrderModulesByDependencies(const std::v
OSFatal("Error: module depends on homebrew_wupsbackend, this is not supported");
}
if (!loadedModulesExportNames.contains(curImportRPL)) {
DEBUG_FUNCTION_LINE_VERBOSE("We can't load the module, because %s is not loaded yet", curImportRPL.begin());
DEBUG_FUNCTION_LINE_VERBOSE("We can't load the module, because %s is not loaded yet", curImportRPL.c_str());
canLoad = false;
break;
}

View File

@ -7,4 +7,7 @@ std::vector<std::shared_ptr<ModuleData>> gLoadedModules __attribute__((section("
std::unique_ptr<module_information_single_t[]> gModuleDataInfo __attribute__((section(".data")));
std::map<std::string, OSDynLoad_Module> gUsedRPLs __attribute__((section(".data")));
std::vector<void *> gAllocatedAddresses __attribute__((section(".data")));
std::vector<void *> gAllocatedAddresses __attribute__((section(".data")));
WUMSRPLAllocatorAllocFn gCustomRPLAllocatorAllocFn __attribute__((section(".data"))) = nullptr;
WUMSRPLAllocatorFreeFn gCustomRPLAllocatorFreeFn __attribute__((section(".data"))) = nullptr;

View File

@ -14,6 +14,9 @@ extern std::unique_ptr<module_information_single_t[]> gModuleDataInfo;
extern std::map<std::string, OSDynLoad_Module> gUsedRPLs;
extern std::vector<void *> gAllocatedAddresses;
extern WUMSRPLAllocatorAllocFn gCustomRPLAllocatorAllocFn;
extern WUMSRPLAllocatorFreeFn gCustomRPLAllocatorFreeFn;
#define MEMORY_REGION_START 0x00800000
#define MEMORY_REGION_SIZE 0x00800000

View File

@ -95,7 +95,7 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
}
} else if (key == "wums" || key == "wum") {
checkedVersion = true;
if (value != "0.3.1" && value != "0.3.2") {
if (value != "0.3.1" && value != "0.3.2" && value != "0.3.3" && value != "0.3.4" && value != "0.3.5") {
DEBUG_FUNCTION_LINE_WARN("Ignoring module - Unsupported WUMS version: %s.", value.c_str());
return std::nullopt;
}
@ -198,7 +198,7 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
DEBUG_FUNCTION_LINE("memset section %s %08X to 0 (%d bytes)", psec->get_name().c_str(), destination, sectionSize);
memset((void *) destination, 0, sectionSize);
} else if (psec->get_type() == SHT_PROGBITS) {
DEBUG_FUNCTION_LINE("Copy section %s %08X -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
DEBUG_FUNCTION_LINE("Copy section %s %p -> %08X (%d bytes)", psec->get_name().c_str(), p, destination, sectionSize);
memcpy((void *) destination, p, sectionSize);
}
@ -242,7 +242,7 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
if (entries != nullptr) {
for (size_t j = 0; j < entries_count; j++) {
wums_entry_t *exp = &entries[j];
DEBUG_FUNCTION_LINE("Saving export of type %08X, name %s, target: %08X", exp->type, exp->name, exp->address);
DEBUG_FUNCTION_LINE("Saving export of type %d, name %s, target: %p", exp->type, exp->name, exp->address);
auto exportData = make_unique_nothrow<ExportData>(exp->type, exp->name, exp->address);
if (!exportData) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc ExportData");
@ -275,7 +275,7 @@ std::optional<std::shared_ptr<ModuleData>> ModuleDataFactory::load(const std::st
if (hooks != nullptr) {
for (size_t j = 0; j < entries_count; j++) {
wums_hook_t *hook = &hooks[j];
DEBUG_FUNCTION_LINE("Saving hook of type %08X, target: %08X", hook->type, hook->target);
DEBUG_FUNCTION_LINE("Saving hook of type %08X, target: %p", hook->type, hook->target);
auto hookData = make_unique_nothrow<HookData>(hook->type, hook->target);
if (!hookData) {
DEBUG_FUNCTION_LINE_ERR("Failed to alloc HookData");
@ -403,7 +403,7 @@ bool ModuleDataFactory::getImportRelocationData(std::shared_ptr<ModuleData> &mod
uint32_t section_index = psec->get_info();
if (!infoMap.contains(sym_section_index)) {
DEBUG_FUNCTION_LINE_ERR("Relocation is referencing a unknown section. %d destination: %08X sym_name %s", section_index, destinations[section_index], sym_name.c_str());
DEBUG_FUNCTION_LINE_ERR("Relocation is referencing a unknown section. %d destination: %p sym_name %s", section_index, destinations[section_index], sym_name.c_str());
OSFatal("Relocation is referencing a unknown section.");
}

View File

@ -33,33 +33,41 @@ static void CustomDynLoadFree(void *addr) {
free(addr);
// Remove from list
auto it = std::find(gAllocatedAddresses.begin(), gAllocatedAddresses.end(), addr);
if (it != gAllocatedAddresses.end()) {
if (const auto it = std::ranges::find(gAllocatedAddresses, addr); it != gAllocatedAddresses.end()) {
gAllocatedAddresses.erase(it);
}
}
bool ResolveRelocations(std::vector<std::shared_ptr<ModuleData>> &loadedModules, bool skipMemoryMappingModule, std::map<std::string, OSDynLoad_Module> &usedRPls) {
bool ResolveRelocations(const std::vector<std::shared_ptr<ModuleData>> &loadedModules, const bool skipUnloadedRpl, std::map<std::string, OSDynLoad_Module> &usedRPls) {
bool wasSuccessful = true;
OSDynLoadAllocFn prevDynLoadAlloc = nullptr;
OSDynLoadFreeFn prevDynLoadFree = nullptr;
OSDynLoad_GetAllocator(&prevDynLoadAlloc, &prevDynLoadFree);
OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree);
if (!skipUnloadedRpl) {
OSDynLoad_GetAllocator(&prevDynLoadAlloc, &prevDynLoadFree);
if (gCustomRPLAllocatorAllocFn != nullptr && gCustomRPLAllocatorFreeFn != nullptr) {
OSDynLoad_SetAllocator(reinterpret_cast<OSDynLoadAllocFn>(gCustomRPLAllocatorAllocFn), gCustomRPLAllocatorFreeFn);
} else {
OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree);
}
}
for (auto &curModule : loadedModules) {
DEBUG_FUNCTION_LINE("Let's do the relocations for %s", curModule->getExportName().c_str());
auto &relocData = curModule->getRelocationDataList();
if (!doRelocation(gLoadedModules, relocData, nullptr, 0, usedRPls)) {
if (!doRelocation(gLoadedModules, relocData, nullptr, 0, usedRPls, skipUnloadedRpl)) {
wasSuccessful = false;
DEBUG_FUNCTION_LINE_ERR("Failed to do Relocations for %s", curModule->getExportName().c_str());
OSFatal("Failed to do Relocations");
}
}
OSDynLoad_SetAllocator(prevDynLoadAlloc, prevDynLoadFree);
if (!skipUnloadedRpl) {
OSDynLoad_SetAllocator(prevDynLoadAlloc, prevDynLoadFree);
}
DCFlushRange((void *) MEMORY_REGION_START, MEMORY_REGION_SIZE);
ICInvalidateRange((void *) MEMORY_REGION_START, MEMORY_REGION_SIZE);
@ -70,8 +78,9 @@ bool ResolveRelocations(std::vector<std::shared_ptr<ModuleData>> &loadedModules,
bool doRelocation(const std::vector<std::shared_ptr<ModuleData>> &moduleList,
const std::vector<std::unique_ptr<RelocationData>> &relocData,
relocation_trampoline_entry_t *tramp_data,
uint32_t tramp_length,
std::map<std::string, OSDynLoad_Module> &usedRPls) {
const uint32_t tramp_length,
std::map<std::string, OSDynLoad_Module> &usedRPls,
const bool skipUnloadedRpl) {
for (auto const &curReloc : relocData) {
auto &functionName = curReloc->getName();
std::string rplName = curReloc->getImportRPLInformation()->getRPLName();
@ -106,7 +115,14 @@ bool doRelocation(const std::vector<std::shared_ptr<ModuleData>> &moduleList,
OSDynLoad_Module rplHandle = nullptr;
if (!usedRPls.contains(rplName)) {
DEBUG_FUNCTION_LINE_VERBOSE("Acquire %s", rplName.c_str());
OSDynLoad_Module tmp = nullptr;
if (OSDynLoad_IsModuleLoaded(rplName.c_str(), &tmp) != OS_DYNLOAD_OK || tmp == nullptr) {
if (skipUnloadedRpl) {
DEBUG_FUNCTION_LINE_VERBOSE("Skip acquire of %s", rplName.c_str());
continue;
}
}
// Always acquire to increase refcount and make sure it won't get unloaded while we're using it.
OSDynLoad_Error err = OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
if (err != OS_DYNLOAD_OK) {

View File

@ -4,12 +4,13 @@
#include <map>
#include <vector>
bool ResolveRelocations(std::vector<std::shared_ptr<ModuleData>> &loadedModules,
bool skipMemoryMappingModule,
bool ResolveRelocations(const std::vector<std::shared_ptr<ModuleData>> &loadedModules,
bool skipUnloadedRpl,
std::map<std::string, OSDynLoad_Module> &usedRPls);
bool doRelocation(const std::vector<std::shared_ptr<ModuleData>> &moduleList,
const std::vector<std::unique_ptr<RelocationData>> &relocData,
relocation_trampoline_entry_t *tramp_data,
uint32_t tramp_length,
std::map<std::string, OSDynLoad_Module> &usedRPls);
std::map<std::string, OSDynLoad_Module> &usedRPls,
bool skipUnloadedRpl);

View File

@ -27,7 +27,17 @@ static const char **hook_names = (const char *[]){
"WUMS_HOOK_APPLICATION_ENDS",
"WUMS_HOOK_RELOCATIONS_DONE",
"WUMS_HOOK_APPLICATION_REQUESTS_EXIT",
"WUMS_HOOK_DEINIT"};
"WUMS_HOOK_DEINIT",
"WUMS_HOOK_ALL_APPLICATION_STARTS_DONE",
"WUMS_HOOK_ALL_APPLICATION_ENDS_DONE",
"WUMS_HOOK_ALL_APPLICATION_REQUESTS_EXIT_DONE",
"WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR",
"WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY",
"WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY",
"WUMS_HOOK_INIT_WUT_THREAD"};
#endif
void CallHook(const std::vector<std::shared_ptr<ModuleData>> &modules, wums_hook_type_t type, bool condition) {
@ -50,7 +60,9 @@ void CallHook(const std::shared_ptr<ModuleData> &module, wums_hook_type_t type,
}
void CallHook(const std::shared_ptr<ModuleData> &module, wums_hook_type_t type) {
#ifdef DEBUG
bool foundHook = false;
#endif
for (auto &curHook : module->getHookDataList()) {
auto func_ptr = (uint32_t) curHook->getTarget();
if (func_ptr == 0) {
@ -59,7 +71,9 @@ void CallHook(const std::shared_ptr<ModuleData> &module, wums_hook_type_t type)
}
if (type == curHook->getType()) {
#ifdef DEBUG
foundHook = true;
#endif
if ((type == WUMS_HOOK_APPLICATION_STARTS ||
type == WUMS_HOOK_APPLICATION_ENDS ||
type == WUMS_HOOK_INIT_WUT_MALLOC ||
@ -75,16 +89,28 @@ void CallHook(const std::shared_ptr<ModuleData> &module, wums_hook_type_t type)
type == WUMS_HOOK_FINI_WUT_SOCKETS ||
type == WUMS_HOOK_INIT_WRAPPER ||
type == WUMS_HOOK_FINI_WRAPPER ||
type == WUMS_HOOK_DEINIT)) {
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s: %08X", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
type == WUMS_HOOK_DEINIT ||
type == WUMS_HOOK_ALL_APPLICATION_STARTS_DONE ||
type == WUMS_HOOK_ALL_APPLICATION_ENDS_DONE ||
type == WUMS_HOOK_CLEAR_ALLOCATED_RPL_MEMORY ||
type == WUMS_HOOK_ALL_APPLICATION_REQUESTS_EXIT_DONE ||
type == WUMS_HOOK_INIT_WUT_THREAD)) {
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s: %p", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
((void (*)())((uint32_t *) func_ptr))();
break;
} else if (type == WUMS_HOOK_INIT ||
type == WUMS_HOOK_RELOCATIONS_DONE) {
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s: %08X", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s: %p", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
wums_app_init_args_t args;
args.module_information = &gModuleInformation;
((void (*)(wums_app_init_args_t *))((uint32_t *) func_ptr))(&args);
} else if (type == WUMS_HOOK_GET_CUSTOM_RPL_ALLOCATOR) {
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s: %p", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
const auto [allocFn, freeFn] = reinterpret_cast<wums_internal_custom_rpl_allocator_t (*)()>(reinterpret_cast<uint32_t *>(func_ptr))();
gCustomRPLAllocatorAllocFn = allocFn;
gCustomRPLAllocatorFreeFn = freeFn;
} else {
DEBUG_FUNCTION_LINE_ERR("#########################################");
DEBUG_FUNCTION_LINE_ERR("#########HOOK NOT IMPLEMENTED %d#########", type);

View File

@ -3,7 +3,7 @@
#include "module/ModuleData.h"
#include <memory>
#include <vector>
#include <wums.h>
#include <wums/hooks.h>
void CallHook(const std::vector<std::shared_ptr<ModuleData>> &modules, wums_hook_type_t type, bool condition);

View File

@ -44,6 +44,18 @@ IMPORT(MEMCheckHeap);
IMPORT(MEMGetBaseHeapHandle);
IMPORT(MEMCheckExpHeap);
IMPORT(OSGetBootPMFlags);
IMPORT(OSFastMutex_Lock);
IMPORT(OSFastMutex_Init);
IMPORT(OSFastCond_Init);
IMPORT(OSCancelAlarm);
IMPORT(OSFastCond_Wait);
IMPORT(OSSetAlarm);
IMPORT(OSSetAlarmUserData);
IMPORT(OSCreateAlarm);
IMPORT(OSFastCond_Signal);
IMPORT(OSFastMutex_Unlock);
IMPORT(OSInitSpinLock);
IMPORT(OSGetAlarmUserData);
IMPORT(FSTimeToCalendarTime);
IMPORT(FSInit);

View File

@ -49,6 +49,7 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX(OSReport, "##WARN ## ", "\n", FMT, ##ARGS)
#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX(OSReport, "##INFO ## ", "\n", FMT, ##ARGS)
#endif