mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 04:39:17 +01:00
Use alloc/free from memorymapping module if possible
This commit is contained in:
parent
b2562f6275
commit
cfc2d4197e
@ -12,7 +12,24 @@
|
||||
bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length, uint32_t trampolinID) {
|
||||
std::map<std::string, OSDynLoad_Module> moduleHandleCache;
|
||||
for (auto const &cur : relocData) {
|
||||
uint32_t functionAddress = 0;
|
||||
std::string functionName = cur.getName();
|
||||
|
||||
if (functionName.compare("MEMAllocFromDefaultHeap") == 0) {
|
||||
OSDynLoad_Module rplHandle;
|
||||
OSDynLoad_Acquire("homebrew_memorymapping", &rplHandle);
|
||||
OSDynLoad_FindExport(rplHandle, 1, "MEMAllocFromMappedMemory", (void **) &functionAddress);
|
||||
} else if (functionName.compare("MEMAllocFromDefaultHeapEx") == 0) {
|
||||
OSDynLoad_Module rplHandle;
|
||||
OSDynLoad_Acquire("homebrew_memorymapping", &rplHandle);
|
||||
OSDynLoad_FindExport(rplHandle, 1, "MEMAllocFromMappedMemoryEx", (void **) &functionAddress);
|
||||
} else if (functionName.compare("MEMFreeToDefaultHeap") == 0) {
|
||||
OSDynLoad_Module rplHandle;
|
||||
OSDynLoad_Acquire("homebrew_memorymapping", &rplHandle);
|
||||
OSDynLoad_FindExport(rplHandle, 1, "MEMFreeToMappedMemory", (void **) &functionAddress);
|
||||
}
|
||||
|
||||
if (functionAddress == 0) {
|
||||
std::string rplName = cur.getImportRPLInformation().getName();
|
||||
int32_t isData = cur.getImportRPLInformation().isData();
|
||||
OSDynLoad_Module rplHandle = 0;
|
||||
@ -22,9 +39,9 @@ bool PluginManagement::doRelocation(const std::vector<RelocationData> &relocData
|
||||
OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
|
||||
moduleHandleCache[rplName] = rplHandle;
|
||||
}
|
||||
|
||||
uint32_t functionAddress = 0;
|
||||
OSDynLoad_FindExport(rplHandle, isData, functionName.c_str(), (void **) &functionAddress);
|
||||
}
|
||||
|
||||
if (functionAddress == 0) {
|
||||
DEBUG_FUNCTION_LINE("Failed to find export for %s", functionName.c_str());
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user