WUMSLoader/relocator/src/utils/dynamic.c

33 lines
1.3 KiB
C
Raw Normal View History

2020-04-28 14:43:07 +02:00
#include <coreinit/debug.h>
2022-02-04 21:44:03 +01:00
#include <coreinit/dynload.h>
2020-04-28 14:43:07 +02:00
2022-02-04 21:44:03 +01:00
#define IMPORT(name) void *addr_##name
2020-04-28 14:43:07 +02:00
#define IMPORT_BEGIN(lib)
#define IMPORT_END()
2020-05-17 19:05:51 +02:00
2020-04-28 14:43:07 +02:00
#include "imports.h"
#undef IMPORT
#undef IMPORT_BEGIN
#undef IMPORT_END
2022-02-04 21:44:03 +01:00
#define IMPORT(name) \
do { \
if (OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0) OSFatal("Function " #name " is NULL"); \
} while (0)
#define IMPORT_BEGIN(lib) \
do { \
if (OSDynLoad_IsModuleLoaded(#lib ".rpl", &handle) != OS_DYNLOAD_OK) OSFatal(#lib ".rpl is not loaded"); \
} while (0)
2020-04-28 14:43:07 +02:00
#define IMPORT_END()
void InitFunctionPointers(void) {
OSDynLoad_Module handle;
2022-02-04 21:44:03 +01:00
addr_OSDynLoad_Acquire = (void *) 0x0102A3B4; // 0x0200dfb4 - 0xFE3C00
addr_OSDynLoad_FindExport = (void *) 0x0102B828; // 0200f428 - 0xFE3C00
addr_OSDynLoad_IsModuleLoaded = (void *) 0x0102A59C; // 0200e19c - 0xFE3C00
2020-04-28 14:43:07 +02:00
#include "imports.h"
}