mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-08-23 11:24:34 -05:00
Set a custom OSDynLoad Allocator when processing relocations
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "utils/logger.h"
|
||||
#include "utils.h"
|
||||
#include "logger.h"
|
||||
#include <coreinit/ios.h>
|
||||
#include <cstring>
|
||||
#include <malloc.h>
|
||||
@@ -53,3 +54,25 @@ void dumpHex(const void *data, size_t size) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OSDynLoad_Error CustomDynLoadAlloc(int32_t size, int32_t align, void **outAddr) {
|
||||
if (!outAddr) {
|
||||
return OS_DYNLOAD_INVALID_ALLOCATOR_PTR;
|
||||
}
|
||||
|
||||
if (align >= 0 && align < 4) {
|
||||
align = 4;
|
||||
} else if (align < 0 && align > -4) {
|
||||
align = -4;
|
||||
}
|
||||
|
||||
if (!(*outAddr = memalign(align, size))) {
|
||||
return OS_DYNLOAD_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return OS_DYNLOAD_OK;
|
||||
}
|
||||
|
||||
void CustomDynLoadFree(void *addr) {
|
||||
free(addr);
|
||||
}
|
||||
Reference in New Issue
Block a user