mirror of
https://github.com/wiiu-env/AromaBaseModule.git
synced 2024-11-16 00:45:07 +01:00
Set the "out" value properly in "__OSDynLoad_InternalAcquire" hook to fix calling "OSDynLoad_IsModuleLoaded" with aroma module names
This commit is contained in:
parent
769262a66c
commit
fa6c26e26c
@ -10,6 +10,11 @@ void initDynload() {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate gLoadedRPLData");
|
||||
OSFatal("AromaBaseModule: Failed to allocate gLoadedRPLData");
|
||||
}
|
||||
gRPLData = (RPL_DATA *) malloc(sizeof(RPL_DATA) * gModuleData->number_modules);
|
||||
if (!gRPLData) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to allocate gRPLData");
|
||||
OSFatal("AromaBaseModule: Failed to allocate gRPLData");
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patch functions for dynload patches");
|
||||
for (uint32_t i = 0; i < dynload_function_replacements_size; i++) {
|
||||
|
@ -77,10 +77,14 @@ DECL_FUNCTION(LOADED_RPL *, LiFindRPLByName, char *name) {
|
||||
return real_LiFindRPLByName(name);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(uint32_t, __OSDynLoad_InternalAcquire, char *name, void *out, uint32_t u1, uint32_t u2, uint32_t u3) {
|
||||
DECL_FUNCTION(uint32_t, __OSDynLoad_InternalAcquire, char *name, RPL_DATA **out, uint32_t u1, uint32_t u2, uint32_t u3) {
|
||||
for (uint32_t i = 0; i < gModuleData->number_modules; i++) {
|
||||
auto *curModule = &gModuleData->modules[i];
|
||||
if (strcmp(name, curModule->module_export_name) == 0) {
|
||||
// OSDynLoad_IsModuleLoaded uses __OSDynLoad_InternalAcquire and expects out have a valid value.
|
||||
// It uses the "handle", so don't need to fill the whole struct.
|
||||
gRPLData[i].handle = MODULE_MAGIC | i;
|
||||
*out = &gRPLData[i];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <wut.h>
|
||||
|
||||
// see https://github.com/decaf-emu/decaf-emu/tree/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader
|
||||
struct LiImportTracking {
|
||||
@ -35,6 +36,14 @@ struct LOADED_RPL {
|
||||
char u4[12];
|
||||
};
|
||||
|
||||
// https://github.com/decaf-emu/decaf-emu/blob/6feb1be1db3938e6da2d4a65fc0a7a8599fc8dd6/src/libdecaf/src/cafe/libraries/coreinit/coreinit_dynload.cpp#L40
|
||||
struct RPL_DATA {
|
||||
uint32_t handle;
|
||||
WUT_UNKNOWN_BYTES(0x94 - 0x4);
|
||||
};
|
||||
WUT_CHECK_SIZE(RPL_DATA, 0x94);
|
||||
|
||||
|
||||
#define EXPORT_MASK 0xFFFF0000
|
||||
#define EXPORT_MAGIC_MASK 0x0000FFFF
|
||||
#define FUNCTION_EXPORT_MAGIC 0x88660000
|
||||
|
@ -3,3 +3,4 @@
|
||||
module_information_t *gModuleData __attribute__((section(".data"))) = NULL;
|
||||
int32_t gSDMountRefCount __attribute__((section(".data"))) = 0;
|
||||
LOADED_RPL *gLoadedRPLData __attribute__((section(".data"))) = nullptr;
|
||||
RPL_DATA *gRPLData __attribute__((section(".data"))) = nullptr;
|
@ -4,3 +4,4 @@
|
||||
extern module_information_t *gModuleData;
|
||||
extern int32_t gSDMountRefCount;
|
||||
extern LOADED_RPL *gLoadedRPLData;
|
||||
extern RPL_DATA *gRPLData;
|
Loading…
Reference in New Issue
Block a user