mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2025-01-12 08:19:07 +01:00
relocator: formatting
This commit is contained in:
parent
29c90bc943
commit
985691e608
@ -52,24 +52,24 @@ bool doRelocation(std::vector<RelocationData> &relocData, relocation_trampolin_e
|
||||
uint32_t functionAddress = 0;
|
||||
|
||||
if (replaceAllocFunctions) {
|
||||
if(functionName.compare("MEMAllocFromDefaultHeap") == 0){
|
||||
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){
|
||||
} 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){
|
||||
} else if (functionName.compare("MEMFreeToDefaultHeap") == 0) {
|
||||
OSDynLoad_Module rplHandle;
|
||||
OSDynLoad_Acquire("homebrew_memorymapping", &rplHandle);
|
||||
OSDynLoad_FindExport(rplHandle, 1, "MEMFreeToMappedMemory", (void **) &functionAddress);
|
||||
}
|
||||
if(functionAddress != 0){
|
||||
if (functionAddress != 0) {
|
||||
// DEBUG_FUNCTION_LINE("Using memorymapping function %08X %08X\n", functionAddress, *((uint32_t*)functionAddress));
|
||||
}
|
||||
}
|
||||
if(functionAddress == 0){
|
||||
if (functionAddress == 0) {
|
||||
int32_t isData = curReloc.getImportRPLInformation().isData();
|
||||
OSDynLoad_Module rplHandle = 0;
|
||||
if (moduleCache.count(rplName) == 0) {
|
||||
@ -104,8 +104,8 @@ bool ResolveRelocations(const std::vector<ModuleData> &loadedModules, bool repla
|
||||
if (wasSuccessful) {
|
||||
std::vector<RelocationData> relocData = curModule.getRelocationDataList();
|
||||
bool replaceAlloc = replaceAllocFunctions;
|
||||
if(replaceAlloc){
|
||||
if(curModule.getExportName().compare("homebrew_memorymapping") == 0){
|
||||
if (replaceAlloc) {
|
||||
if (curModule.getExportName().compare("homebrew_memorymapping") == 0) {
|
||||
DEBUG_FUNCTION_LINE("Skip malloc replacement for mapping\n");
|
||||
replaceAlloc = false;
|
||||
}
|
||||
@ -144,16 +144,16 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
gInitCalled = 1;
|
||||
DEBUG_FUNCTION_LINE("Resolve relocations without replacing alloc functions\n");
|
||||
ResolveRelocations(loadedModules, false);
|
||||
for(auto& curModule : loadedModules){
|
||||
if(curModule.getExportName().compare("homebrew_memorymapping") == 0){
|
||||
for(auto& curExport : curModule.getExportDataList()){
|
||||
if(curExport.getName().compare("MemoryMappingEffectiveToPhysical") == 0){
|
||||
for (auto &curModule : loadedModules) {
|
||||
if (curModule.getExportName().compare("homebrew_memorymapping") == 0) {
|
||||
for (auto &curExport : curModule.getExportDataList()) {
|
||||
if (curExport.getName().compare("MemoryMappingEffectiveToPhysical") == 0) {
|
||||
|
||||
CallHook(loadedModules, WUMS_HOOK_INIT);
|
||||
CallHook(loadedModules, WUMS_HOOK_INIT);
|
||||
|
||||
DEBUG_FUNCTION_LINE("Setting MemoryMappingEffectiveToPhysicalPTR to %08X\n", curExport.getAddress());
|
||||
MemoryMappingEffectiveToPhysicalPTR = (uint32_t) curExport.getAddress();
|
||||
}else if(curExport.getName().compare("MemoryMappingPhysicalToEffective") == 0){
|
||||
} else if (curExport.getName().compare("MemoryMappingPhysicalToEffective") == 0) {
|
||||
DEBUG_FUNCTION_LINE("Setting MemoryMappingPhysicalToEffectivePTR to %08X\n", curExport.getAddress());
|
||||
MemoryMappingPhysicalToEffectivePTR = (uint32_t) curExport.getAddress();
|
||||
}
|
||||
@ -167,7 +167,7 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
ResolveRelocations(loadedModules, true);
|
||||
|
||||
for (int i = 0; i < gModuleData->number_used_modules; i++) {
|
||||
if(strcmp(gModuleData->module_data[i].module_export_name, "homebrew_memorymapping") == 0){
|
||||
if (strcmp(gModuleData->module_data[i].module_export_name, "homebrew_memorymapping") == 0) {
|
||||
DEBUG_FUNCTION_LINE("About to call memory mapping (%08X)\n", gModuleData->module_data[i].entrypoint);
|
||||
int ret = ((int (*)(int, char **)) (gModuleData->module_data[i].entrypoint))(argc, argv);
|
||||
DEBUG_FUNCTION_LINE("return code was %d\n", ret);
|
||||
@ -176,7 +176,7 @@ extern "C" void doStart(int argc, char **argv) {
|
||||
}
|
||||
|
||||
for (int i = 0; i < gModuleData->number_used_modules; i++) {
|
||||
if(strcmp(gModuleData->module_data[i].module_export_name, "homebrew_memorymapping") != 0) {
|
||||
if (strcmp(gModuleData->module_data[i].module_export_name, "homebrew_memorymapping") != 0) {
|
||||
DEBUG_FUNCTION_LINE("About to call %08X\n", gModuleData->module_data[i].entrypoint);
|
||||
int ret = ((int (*)(int, char **)) (gModuleData->module_data[i].entrypoint))(argc, argv);
|
||||
DEBUG_FUNCTION_LINE("return code was %d\n", ret);
|
||||
|
@ -5,4 +5,4 @@
|
||||
#include <vector>
|
||||
#include "../../source/module/ModuleData.h"
|
||||
|
||||
void CallHook(const std::vector<ModuleData>& modules, wums_hook_type_t type);
|
||||
void CallHook(const std::vector<ModuleData> &modules, wums_hook_type_t type);
|
@ -56,7 +56,7 @@ DECL(OSDynLoad_Error, OSDynLoad_FindExport, OSDynLoad_Module module, BOOL isData
|
||||
DECL(int32_t, KiEffectiveToPhysical, uint32_t addressSpace, uint32_t virtualAddress) {
|
||||
int32_t result = real_KiEffectiveToPhysical(addressSpace, virtualAddress);
|
||||
if (result == 0) {
|
||||
if(MemoryMappingEffectiveToPhysicalPTR != 0){
|
||||
if (MemoryMappingEffectiveToPhysicalPTR != 0) {
|
||||
return ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingEffectiveToPhysicalPTR))(virtualAddress);
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,7 @@ DECL(int32_t, KiEffectiveToPhysical, uint32_t addressSpace, uint32_t virtualAddr
|
||||
DECL(int32_t, KiPhysicalToEffectiveCached, uint32_t addressSpace, uint32_t virtualAddress) {
|
||||
int32_t result = real_KiPhysicalToEffectiveCached(addressSpace, virtualAddress);
|
||||
if (result == 0) {
|
||||
if(MemoryMappingPhysicalToEffectivePTR != 0){
|
||||
if (MemoryMappingPhysicalToEffectivePTR != 0) {
|
||||
return ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingPhysicalToEffectivePTR))(virtualAddress);
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ DECL(int32_t, KiPhysicalToEffectiveCached, uint32_t addressSpace, uint32_t virtu
|
||||
DECL(int32_t, KiPhysicalToEffectiveUncached, uint32_t addressSpace, uint32_t virtualAddress) {
|
||||
int32_t result = real_KiPhysicalToEffectiveUncached(addressSpace, virtualAddress);
|
||||
if (result == 0) {
|
||||
if(MemoryMappingPhysicalToEffectivePTR != 0){
|
||||
if (MemoryMappingPhysicalToEffectivePTR != 0) {
|
||||
return ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingPhysicalToEffectivePTR))(virtualAddress);
|
||||
}
|
||||
}
|
||||
@ -85,10 +85,10 @@ DECL(int32_t, KiPhysicalToEffectiveUncached, uint32_t addressSpace, uint32_t vir
|
||||
|
||||
DECL(uint32_t, IPCKDriver_ValidatePhysicalAddress, uint32_t u1, uint32_t physStart, uint32_t physEnd) {
|
||||
uint32_t result = 0;
|
||||
if(MemoryMappingPhysicalToEffectivePTR != 0){
|
||||
if (MemoryMappingPhysicalToEffectivePTR != 0) {
|
||||
result = ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingPhysicalToEffectivePTR))(physStart) > 0;
|
||||
}
|
||||
if(result){
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -98,7 +98,8 @@ DECL(uint32_t, IPCKDriver_ValidatePhysicalAddress, uint32_t u1, uint32_t physSta
|
||||
DECL(uint32_t, KiIsEffectiveRangeValid, uint32_t addressSpace, uint32_t virtualAddress, uint32_t size) {
|
||||
uint32_t result = real_KiIsEffectiveRangeValid(addressSpace, virtualAddress, size);
|
||||
if (result == 0) {
|
||||
if(MemoryMappingEffectiveToPhysicalPTR != 0){
|
||||
return 1;
|
||||
if (MemoryMappingEffectiveToPhysicalPTR != 0) {
|
||||
return ((uint32_t (*)(uint32_t)) ((uint32_t *) MemoryMappingEffectiveToPhysicalPTR))(virtualAddress) > 0;
|
||||
}
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[], int32_t hook_informa
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s is located at %08X!", method_hooks[i].functionName, real_addr);
|
||||
}
|
||||
if(real_addr > 0xF0000000){
|
||||
if (real_addr > 0xF0000000) {
|
||||
physical = real_addr;
|
||||
}else{
|
||||
} else {
|
||||
physical = (uint32_t) OSEffectiveToPhysical(real_addr);
|
||||
if (!physical) {
|
||||
DEBUG_FUNCTION_LINE("Error. Something is wrong with the physical address\n");
|
||||
@ -247,15 +247,15 @@ int32_t isDynamicFunction(uint32_t physicalAddress) {
|
||||
uint32_t GetAddressOfFunction(const char *functionName, uint32_t library) {
|
||||
uint32_t real_addr = 0;
|
||||
|
||||
if(strcmp(functionName, "KiEffectiveToPhysical") == 0){
|
||||
if (strcmp(functionName, "KiEffectiveToPhysical") == 0) {
|
||||
return 0xffee0aac;
|
||||
}else if(strcmp(functionName, "KiPhysicalToEffectiveCached") == 0){
|
||||
} else if (strcmp(functionName, "KiPhysicalToEffectiveCached") == 0) {
|
||||
return 0xffee0a3c;
|
||||
}else if(strcmp(functionName, "KiPhysicalToEffectiveUncached") == 0){
|
||||
} else if (strcmp(functionName, "KiPhysicalToEffectiveUncached") == 0) {
|
||||
return 0xffee0a80;
|
||||
}else if(strcmp(functionName, "IPCKDriver_ValidatePhysicalAddress") == 0){
|
||||
} else if (strcmp(functionName, "IPCKDriver_ValidatePhysicalAddress") == 0) {
|
||||
return 0xfff0cb5c;
|
||||
}else if(strcmp(functionName, "KiIsEffectiveRangeValid") == 0){
|
||||
} else if (strcmp(functionName, "KiIsEffectiveRangeValid") == 0) {
|
||||
return 0xffee0d6c;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user