2020-04-27 13:32:37 +02:00
|
|
|
#include <coreinit/debug.h>
|
2022-02-02 19:42:35 +01:00
|
|
|
#include <coreinit/dynload.h>
|
2020-04-27 13:32:37 +02:00
|
|
|
|
2022-02-02 19:42:35 +01:00
|
|
|
#define IMPORT(name) void *addr_##name
|
2020-04-27 13:32:37 +02:00
|
|
|
#define IMPORT_BEGIN(lib)
|
|
|
|
#define IMPORT_END()
|
2020-08-23 10:44:14 +02:00
|
|
|
|
2020-04-27 13:32:37 +02:00
|
|
|
#include "imports.h"
|
|
|
|
|
|
|
|
#undef IMPORT
|
|
|
|
#undef IMPORT_BEGIN
|
|
|
|
#undef IMPORT_END
|
|
|
|
|
2022-02-02 19:42:35 +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) OSDynLoad_Acquire(#lib ".rpl", &handle)
|
2020-04-27 13:32:37 +02:00
|
|
|
/* #define IMPORT_END() OSDynLoad_Release(handle) */
|
|
|
|
#define IMPORT_END()
|
|
|
|
|
2022-02-02 19:42:35 +01:00
|
|
|
#define EXPORT_VAR(type, var) type var __attribute__((section(".data")));
|
2020-04-27 13:32:37 +02:00
|
|
|
|
2020-05-28 20:53:27 +02:00
|
|
|
EXPORT_VAR(uint32_t *, MEMAllocFromDefaultHeap);
|
|
|
|
EXPORT_VAR(uint32_t *, MEMAllocFromDefaultHeapEx);
|
|
|
|
EXPORT_VAR(uint32_t *, MEMFreeToDefaultHeap);
|
2020-04-27 13:32:37 +02:00
|
|
|
|
|
|
|
void InitFunctionPointers(void) {
|
|
|
|
OSDynLoad_Module handle;
|
2023-01-05 14:55:07 +01:00
|
|
|
addr_OSDynLoad_Acquire = (void *) 0x0102A3B4;
|
|
|
|
addr_OSDynLoad_FindExport = (void *) 0x0102B828;
|
|
|
|
addr_OSDynLoad_IsModuleLoaded = (void *) 0x0102A59C; // 0200e19c - 0xFE3C00
|
2020-04-27 13:32:37 +02:00
|
|
|
|
|
|
|
OSDynLoad_Acquire("coreinit.rpl", &handle);
|
2020-05-28 20:53:27 +02:00
|
|
|
|
2020-08-23 10:44:14 +02:00
|
|
|
uint32_t **value = 0;
|
|
|
|
OSDynLoad_FindExport(handle, 1, "MEMAllocFromDefaultHeap", (void **) &value);
|
2020-05-28 20:53:27 +02:00
|
|
|
MEMAllocFromDefaultHeap = *value;
|
2020-08-23 10:44:14 +02:00
|
|
|
OSDynLoad_FindExport(handle, 1, "MEMAllocFromDefaultHeapEx", (void **) &value);
|
2020-05-28 20:53:27 +02:00
|
|
|
MEMAllocFromDefaultHeapEx = *value;
|
2020-08-23 10:44:14 +02:00
|
|
|
OSDynLoad_FindExport(handle, 1, "MEMFreeToDefaultHeap", (void **) &value);
|
2020-05-28 20:53:27 +02:00
|
|
|
MEMFreeToDefaultHeap = *value;
|
2020-04-27 13:32:37 +02:00
|
|
|
|
|
|
|
#include "imports.h"
|
|
|
|
|
2023-01-05 14:55:07 +01:00
|
|
|
OSDynLoad_IsModuleLoaded("coreinit.rpl", &handle);
|
2020-05-28 20:53:27 +02:00
|
|
|
// override failed __rplwrap_exit find export
|
2020-08-23 10:44:14 +02:00
|
|
|
OSDynLoad_FindExport(handle, 0, "exit", (void **) &addr___rplwrap_exit);
|
2020-04-27 13:32:37 +02:00
|
|
|
}
|