mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-08-29 22:51:06 -05:00
Even more formatting
This commit is contained in:
@@ -57,10 +57,10 @@ OSDynLoad_Module vpadbase_handle_internal = 0;
|
||||
* Patches a function that is loaded at the start of each application. Its not required to restore, at least when they are really dynamic.
|
||||
* "normal" functions should be patch with the normal patcher. Current Code by Maschell with the help of dimok. Orignal code by Chadderz.
|
||||
*/
|
||||
void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_information_size, volatile uint32_t dynamic_method_calls[]) {
|
||||
void PatchInvidualMethodHooks(hooks_magic_t method_hooks[], int32_t hook_information_size, volatile uint32_t dynamic_method_calls[]) {
|
||||
resetLibs();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Patching %d given functions",hook_information_size);
|
||||
DEBUG_FUNCTION_LINE("Patching %d given functions", hook_information_size);
|
||||
/* Patch branches to it. */
|
||||
volatile uint32_t *space = &dynamic_method_calls[0];
|
||||
|
||||
@@ -69,11 +69,11 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
uint32_t skip_instr = 1;
|
||||
uint32_t my_instr_len = 6;
|
||||
uint32_t instr_len = my_instr_len + skip_instr;
|
||||
uint32_t flush_len = 4*instr_len;
|
||||
for(int32_t i = 0; i < method_hooks_count; i++) {
|
||||
log_printf("Patching %s ...",method_hooks[i].functionName);
|
||||
if(method_hooks[i].functionType == STATIC_FUNCTION && method_hooks[i].alreadyPatched == 1) {
|
||||
if(isDynamicFunction((uint32_t)OSEffectiveToPhysical(method_hooks[i].realAddr))) {
|
||||
uint32_t flush_len = 4 * instr_len;
|
||||
for (int32_t i = 0; i < method_hooks_count; i++) {
|
||||
log_printf("Patching %s ...", method_hooks[i].functionName);
|
||||
if (method_hooks[i].functionType == STATIC_FUNCTION && method_hooks[i].alreadyPatched == 1) {
|
||||
if (isDynamicFunction((uint32_t) OSEffectiveToPhysical(method_hooks[i].realAddr))) {
|
||||
log_printf("The function %s is a dynamic function. Please fix that <3", method_hooks[i].functionName);
|
||||
method_hooks[i].functionType = DYNAMIC_FUNCTION;
|
||||
} else {
|
||||
@@ -84,38 +84,38 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
}
|
||||
|
||||
uint32_t physical = 0;
|
||||
uint32_t repl_addr = (uint32_t)method_hooks[i].replaceAddr;
|
||||
uint32_t call_addr = (uint32_t)method_hooks[i].replaceCall;
|
||||
uint32_t repl_addr = (uint32_t) method_hooks[i].replaceAddr;
|
||||
uint32_t call_addr = (uint32_t) method_hooks[i].replaceCall;
|
||||
|
||||
uint32_t real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library);
|
||||
uint32_t real_addr = GetAddressOfFunction(method_hooks[i].functionName, method_hooks[i].library);
|
||||
|
||||
if(!real_addr) {
|
||||
if (!real_addr) {
|
||||
log_printf("");
|
||||
DEBUG_FUNCTION_LINE("OSDynLoad_FindExport failed for %s", method_hooks[i].functionName);
|
||||
space += instr_len;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s is located at %08X!", method_hooks[i].functionName,real_addr);
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s is located at %08X!", method_hooks[i].functionName, real_addr);
|
||||
}
|
||||
|
||||
physical = (uint32_t)OSEffectiveToPhysical(real_addr);
|
||||
if(!physical) {
|
||||
physical = (uint32_t) OSEffectiveToPhysical(real_addr);
|
||||
if (!physical) {
|
||||
log_printf("Error. Something is wrong with the physical address");
|
||||
space += instr_len;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s physical is located at %08X!", method_hooks[i].functionName,physical);
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("%s physical is located at %08X!", method_hooks[i].functionName, physical);
|
||||
}
|
||||
|
||||
*(volatile uint32_t *)(call_addr) = (uint32_t)(space) - CODE_RW_BASE_OFFSET;
|
||||
*(volatile uint32_t *) (call_addr) = (uint32_t) (space) - CODE_RW_BASE_OFFSET;
|
||||
|
||||
|
||||
uint32_t targetAddr = (uint32_t)space;
|
||||
if(targetAddr < 0x00800000 || targetAddr >= 0x01000000) {
|
||||
uint32_t targetAddr = (uint32_t) space;
|
||||
if (targetAddr < 0x00800000 || targetAddr >= 0x01000000) {
|
||||
targetAddr = (uint32_t) OSEffectiveToPhysical(targetAddr);
|
||||
} else {
|
||||
targetAddr = targetAddr + 0x30800000 - 0x00800000;
|
||||
@@ -123,20 +123,20 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
|
||||
KernelCopyData(targetAddr, physical, 4);
|
||||
|
||||
ICInvalidateRange((void*)(space), 4);
|
||||
DCFlushRange((void*)(space), 4);
|
||||
ICInvalidateRange((void *) (space), 4);
|
||||
DCFlushRange((void *) (space), 4);
|
||||
space++;
|
||||
|
||||
//Only works if skip_instr == 1
|
||||
if(skip_instr == 1) {
|
||||
if (skip_instr == 1) {
|
||||
// fill the restore instruction section
|
||||
method_hooks[i].realAddr = real_addr;
|
||||
method_hooks[i].restoreInstruction = *(space-1);
|
||||
if(DEBUG_LOG_DYN) {
|
||||
method_hooks[i].restoreInstruction = *(space - 1);
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("method_hooks[i].realAddr = %08X!", method_hooks[i].realAddr);
|
||||
}
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("method_hooks[i].restoreInstruction = %08X!",method_hooks[i].restoreInstruction) ;
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("method_hooks[i].restoreInstruction = %08X!", method_hooks[i].restoreInstruction);
|
||||
}
|
||||
} else {
|
||||
log_printf("Error. Can't save %s for restoring!", method_hooks[i].functionName);
|
||||
@@ -154,7 +154,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
space++;
|
||||
*space = 0x3C600000 | (((real_addr + (skip_instr * 4)) >> 16) & 0x0000FFFF); // lis r3, real_addr@h
|
||||
space++;
|
||||
*space = 0x60630000 | ((real_addr + (skip_instr * 4)) & 0x0000ffff); // ori r3, r3, real_addr@l
|
||||
*space = 0x60630000 | ((real_addr + (skip_instr * 4)) & 0x0000ffff); // ori r3, r3, real_addr@l
|
||||
space++;
|
||||
*space = 0x7C6903A6; // mtctr r3
|
||||
space++;
|
||||
@@ -162,15 +162,15 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
space++;
|
||||
*space = 0x4E800420; // bctr
|
||||
space++;
|
||||
DCFlushRange((void*)(space - instr_len), flush_len);
|
||||
ICInvalidateRange((unsigned char*)(space - instr_len), flush_len);
|
||||
DCFlushRange((void *) (space - instr_len), flush_len);
|
||||
ICInvalidateRange((unsigned char *) (space - instr_len), flush_len);
|
||||
|
||||
//setting jump back
|
||||
uint32_t replace_instr = 0x48000002 | (repl_addr & 0x03fffffc);
|
||||
DCFlushRange(&replace_instr, 4);
|
||||
|
||||
KernelCopyData(physical, (uint32_t)OSEffectiveToPhysical((uint32_t)&replace_instr), 4);
|
||||
ICInvalidateRange((void*)(real_addr), 4);
|
||||
KernelCopyData(physical, (uint32_t) OSEffectiveToPhysical((uint32_t) &replace_instr), 4);
|
||||
ICInvalidateRange((void *) (real_addr), 4);
|
||||
|
||||
method_hooks[i].alreadyPatched = 1;
|
||||
log_printf("done!\n");
|
||||
@@ -182,49 +182,49 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],int32_t hook_informat
|
||||
/* ****************************************************************** */
|
||||
/* RESTORE ORIGINAL INSTRUCTIONS */
|
||||
/* ****************************************************************** */
|
||||
void RestoreInvidualInstructions(hooks_magic_t method_hooks[],int32_t hook_information_size) {
|
||||
void RestoreInvidualInstructions(hooks_magic_t method_hooks[], int32_t hook_information_size) {
|
||||
resetLibs();
|
||||
DEBUG_FUNCTION_LINE("Restoring given functions!");
|
||||
int32_t method_hooks_count = hook_information_size;
|
||||
for(int32_t i = 0; i < method_hooks_count; i++) {
|
||||
DEBUG_FUNCTION_LINE("Restoring %s... ",method_hooks[i].functionName);
|
||||
if(method_hooks[i].restoreInstruction == 0 || method_hooks[i].realAddr == 0) {
|
||||
for (int32_t i = 0; i < method_hooks_count; i++) {
|
||||
DEBUG_FUNCTION_LINE("Restoring %s... ", method_hooks[i].functionName);
|
||||
if (method_hooks[i].restoreInstruction == 0 || method_hooks[i].realAddr == 0) {
|
||||
log_printf("I dont have the information for the restore =( skip");
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library);
|
||||
uint32_t real_addr = GetAddressOfFunction(method_hooks[i].functionName, method_hooks[i].library);
|
||||
|
||||
if(!real_addr) {
|
||||
if (!real_addr) {
|
||||
log_printf("OSDynLoad_FindExport failed for %s", method_hooks[i].functionName);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t physical = (uint32_t)OSEffectiveToPhysical(real_addr);
|
||||
if(!physical) {
|
||||
uint32_t physical = (uint32_t) OSEffectiveToPhysical(real_addr);
|
||||
if (!physical) {
|
||||
log_printf("Something is wrong with the physical address");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isDynamicFunction(physical)) {
|
||||
log_printf("Its a dynamic function. We don't need to restore it!",method_hooks[i].functionName);
|
||||
if (isDynamicFunction(physical)) {
|
||||
log_printf("Its a dynamic function. We don't need to restore it!", method_hooks[i].functionName);
|
||||
} else {
|
||||
physical = (uint32_t)OSEffectiveToPhysical(method_hooks[i].realAddr); //When its an static function, we need to use the old location
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("Restoring %08X to %08X",(uint32_t)method_hooks[i].restoreInstruction,physical);
|
||||
physical = (uint32_t) OSEffectiveToPhysical(method_hooks[i].realAddr); //When its an static function, we need to use the old location
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("Restoring %08X to %08X", (uint32_t) method_hooks[i].restoreInstruction, physical);
|
||||
}
|
||||
uint32_t targetAddr = (uint32_t)&method_hooks[i].restoreInstruction;
|
||||
if(targetAddr < 0x00800000 || targetAddr >= 0x01000000) {
|
||||
uint32_t targetAddr = (uint32_t) &method_hooks[i].restoreInstruction;
|
||||
if (targetAddr < 0x00800000 || targetAddr >= 0x01000000) {
|
||||
targetAddr = (uint32_t) OSEffectiveToPhysical(targetAddr);
|
||||
} else {
|
||||
targetAddr = targetAddr + 0x30800000 - 0x00800000;
|
||||
}
|
||||
|
||||
KernelCopyData(physical,targetAddr, 4);
|
||||
if(DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X",(void*)method_hooks[i].realAddr);
|
||||
KernelCopyData(physical, targetAddr, 4);
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("ICInvalidateRange %08X", (void *) method_hooks[i].realAddr);
|
||||
}
|
||||
ICInvalidateRange((void*)method_hooks[i].realAddr, 4);
|
||||
ICInvalidateRange((void *) method_hooks[i].realAddr, 4);
|
||||
log_printf("done");
|
||||
}
|
||||
method_hooks[i].alreadyPatched = 0; // In case a
|
||||
@@ -234,13 +234,13 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],int32_t hook_infor
|
||||
}
|
||||
|
||||
int32_t isDynamicFunction(uint32_t physicalAddress) {
|
||||
if((physicalAddress & 0x80000000) == 0x80000000) {
|
||||
if ((physicalAddress & 0x80000000) == 0x80000000) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t GetAddressOfFunction(const char * functionName,uint32_t library) {
|
||||
uint32_t GetAddressOfFunction(const char *functionName, uint32_t library) {
|
||||
uint32_t real_addr = 0;
|
||||
|
||||
/*
|
||||
@@ -262,282 +262,282 @@ uint32_t GetAddressOfFunction(const char * functionName,uint32_t library) {
|
||||
*/
|
||||
|
||||
OSDynLoad_Module rpl_handle = 0;
|
||||
if(library == LIB_CORE_INIT) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
if (library == LIB_CORE_INIT) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_CORE_INIT", functionName);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_CORE_INIT failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = coreinit_handle_internal;
|
||||
} else if(library == LIB_NSYSNET) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_NSYSNET) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NSYSNET", functionName);
|
||||
}
|
||||
if(nsysnet_handle_internal == 0) {
|
||||
if (nsysnet_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle_internal);
|
||||
}
|
||||
if(nsysnet_handle_internal == 0) {
|
||||
if (nsysnet_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_NSYSNET failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nsysnet_handle_internal;
|
||||
} else if(library == LIB_GX2) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_GX2) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_GX2", functionName);
|
||||
}
|
||||
if(gx2_handle_internal == 0) {
|
||||
if (gx2_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("gx2.rpl", &gx2_handle_internal);
|
||||
}
|
||||
if(gx2_handle_internal == 0) {
|
||||
if (gx2_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_GX2 failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = gx2_handle_internal;
|
||||
} else if(library == LIB_AOC) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_AOC) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AOC", functionName);
|
||||
}
|
||||
if(aoc_handle_internal == 0) {
|
||||
if (aoc_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_aoc.rpl", &aoc_handle_internal);
|
||||
}
|
||||
if(aoc_handle_internal == 0) {
|
||||
if (aoc_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_AOC failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = aoc_handle_internal;
|
||||
} else if(library == LIB_AX) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_AX) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX", functionName);
|
||||
}
|
||||
if(sound_handle_internal == 0) {
|
||||
if (sound_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("sndcore2.rpl", &sound_handle_internal);
|
||||
}
|
||||
if(sound_handle_internal == 0) {
|
||||
if (sound_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_AX failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = sound_handle_internal;
|
||||
} else if(library == LIB_AX_OLD) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_AX_OLD) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX_OLD", functionName);
|
||||
}
|
||||
if(sound_handle_internal_old == 0) {
|
||||
if (sound_handle_internal_old == 0) {
|
||||
OSDynLoad_Acquire("snd_core.rpl", &sound_handle_internal_old);
|
||||
}
|
||||
if(sound_handle_internal_old == 0) {
|
||||
if (sound_handle_internal_old == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_AX_OLD failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = sound_handle_internal_old;
|
||||
} else if(library == LIB_FS) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_FS) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_FS", functionName);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_FS failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = coreinit_handle_internal;
|
||||
} else if(library == LIB_OS) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_OS) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_OS", functionName);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);
|
||||
}
|
||||
if(coreinit_handle_internal == 0) {
|
||||
if (coreinit_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_OS failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = coreinit_handle_internal;
|
||||
} else if(library == LIB_PADSCORE) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_PADSCORE) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PADSCORE", functionName);
|
||||
}
|
||||
if(padscore_handle_internal == 0) {
|
||||
if (padscore_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("padscore.rpl", &padscore_handle_internal);
|
||||
}
|
||||
if(padscore_handle_internal == 0) {
|
||||
if (padscore_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_PADSCORE failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = padscore_handle_internal;
|
||||
} else if(library == LIB_SOCKET) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_SOCKET) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SOCKET", functionName);
|
||||
}
|
||||
if(nsysnet_handle_internal == 0) {
|
||||
if (nsysnet_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle_internal);
|
||||
}
|
||||
if(nsysnet_handle_internal == 0) {
|
||||
if (nsysnet_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_SOCKET failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nsysnet_handle_internal;
|
||||
} else if(library == LIB_SYS) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_SYS) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYS", functionName);
|
||||
}
|
||||
if(sysapp_handle_internal == 0) {
|
||||
if (sysapp_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle_internal);
|
||||
}
|
||||
if(sysapp_handle_internal == 0) {
|
||||
if (sysapp_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_SYS failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = sysapp_handle_internal;
|
||||
} else if(library == LIB_VPAD) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_VPAD) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPAD", functionName);
|
||||
}
|
||||
if(vpad_handle_internal == 0) {
|
||||
if (vpad_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("vpad.rpl", &vpad_handle_internal);
|
||||
}
|
||||
if(vpad_handle_internal == 0) {
|
||||
if (vpad_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_VPAD failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = vpad_handle_internal;
|
||||
} else if(library == LIB_NN_ACP) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_NN_ACP) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NN_ACP", functionName);
|
||||
}
|
||||
if(acp_handle_internal == 0) {
|
||||
if (acp_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_acp.rpl", &acp_handle_internal);
|
||||
}
|
||||
if(acp_handle_internal == 0) {
|
||||
if (acp_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_NN_ACP failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = acp_handle_internal;
|
||||
} else if(library == LIB_SYSHID) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_SYSHID) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYSHID", functionName);
|
||||
}
|
||||
if(syshid_handle_internal == 0) {
|
||||
if (syshid_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nsyshid.rpl", &syshid_handle_internal);
|
||||
}
|
||||
if(syshid_handle_internal == 0) {
|
||||
if (syshid_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_SYSHID failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = syshid_handle_internal;
|
||||
} else if(library == LIB_VPADBASE) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_VPADBASE) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPADBASE", functionName);
|
||||
}
|
||||
if(vpadbase_handle_internal == 0) {
|
||||
if (vpadbase_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("vpadbase.rpl", &vpadbase_handle_internal);
|
||||
}
|
||||
if(vpadbase_handle_internal == 0) {
|
||||
if (vpadbase_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_VPADBASE failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = vpadbase_handle_internal;
|
||||
} else if(library == LIB_PROC_UI) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_PROC_UI) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PROC_UI", functionName);
|
||||
}
|
||||
if(proc_ui_handle_internal == 0) {
|
||||
if (proc_ui_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("proc_ui.rpl", &proc_ui_handle_internal);
|
||||
}
|
||||
if(proc_ui_handle_internal == 0) {
|
||||
if (proc_ui_handle_internal == 0) {
|
||||
DEBUG_FUNCTION_LINE("LIB_PROC_UI failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = proc_ui_handle_internal;
|
||||
} else if(library == LIB_NTAG) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_NTAG) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
log_printf("FindExport of %s! From LIB_NTAG", functionName);
|
||||
}
|
||||
if(ntag_handle_internal == 0) {
|
||||
if (ntag_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("ntag.rpl", &ntag_handle_internal);
|
||||
}
|
||||
if(ntag_handle_internal == 0) {
|
||||
if (ntag_handle_internal == 0) {
|
||||
log_print("LIB_NTAG failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = ntag_handle_internal;
|
||||
} else if(library == LIB_NFP) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_NFP) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
log_printf("FindExport of %s! From LIB_NFP", functionName);
|
||||
}
|
||||
if(nfp_handle_internal == 0) {
|
||||
if (nfp_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_nfp.rpl", &nfp_handle_internal);
|
||||
}
|
||||
if(nfp_handle_internal == 0) {
|
||||
if (nfp_handle_internal == 0) {
|
||||
log_print("LIB_NFP failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nfp_handle_internal;
|
||||
} else if(library == LIB_SAVE) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_SAVE) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
log_printf("FindExport of %s! From LIB_SAVE", functionName);
|
||||
}
|
||||
if(nn_save_handle_internal == 0) {
|
||||
if (nn_save_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_save.rpl", &nn_save_handle_internal);
|
||||
}
|
||||
if(nn_save_handle_internal == 0) {
|
||||
if (nn_save_handle_internal == 0) {
|
||||
log_print("LIB_SAVE failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nn_save_handle_internal;
|
||||
} else if(library == LIB_ACT) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_ACT) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
log_printf("FindExport of %s! From LIB_ACT", functionName);
|
||||
}
|
||||
if(nn_act_handle_internal == 0) {
|
||||
if (nn_act_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle_internal);
|
||||
}
|
||||
if(nn_act_handle_internal == 0) {
|
||||
if (nn_act_handle_internal == 0) {
|
||||
log_print("LIB_ACT failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nn_act_handle_internal;
|
||||
} else if(library == LIB_NIM) {
|
||||
if(DEBUG_LOG_DYN) {
|
||||
} else if (library == LIB_NIM) {
|
||||
if (DEBUG_LOG_DYN) {
|
||||
log_printf("FindExport of %s! From LIB_NIM", functionName);
|
||||
}
|
||||
if(nn_nim_handle_internal == 0) {
|
||||
if (nn_nim_handle_internal == 0) {
|
||||
OSDynLoad_Acquire("nn_nim.rpl", &nn_nim_handle_internal);
|
||||
}
|
||||
if(nn_nim_handle_internal == 0) {
|
||||
if (nn_nim_handle_internal == 0) {
|
||||
log_print("LIB_NIM failed to acquire");
|
||||
return 0;
|
||||
}
|
||||
rpl_handle = nn_nim_handle_internal;
|
||||
}
|
||||
|
||||
if(!rpl_handle) {
|
||||
if (!rpl_handle) {
|
||||
DEBUG_FUNCTION_LINE("Failed to find the RPL handle for %s", functionName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSDynLoad_FindExport(rpl_handle, 0, functionName, (void**) &real_addr);
|
||||
OSDynLoad_FindExport(rpl_handle, 0, functionName, (void **) &real_addr);
|
||||
|
||||
if(!real_addr) {
|
||||
OSDynLoad_FindExport(rpl_handle, 1, functionName, (void**) &real_addr);
|
||||
if(!real_addr) {
|
||||
if (!real_addr) {
|
||||
OSDynLoad_FindExport(rpl_handle, 1, functionName, (void **) &real_addr);
|
||||
if (!real_addr) {
|
||||
DEBUG_FUNCTION_LINE("OSDynLoad_FindExport failed for %s", functionName);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if((library == LIB_NN_ACP) && (uint32_t)(*(volatile uint32_t*)(real_addr) & 0x48000002) == 0x48000000) {
|
||||
uint32_t address_diff = (uint32_t)(*(volatile uint32_t*)(real_addr) & 0x03FFFFFC);
|
||||
if((address_diff & 0x03000000) == 0x03000000) {
|
||||
address_diff |= 0xFC000000;
|
||||
if ((library == LIB_NN_ACP) && (uint32_t) (*(volatile uint32_t *) (real_addr) & 0x48000002) == 0x48000000) {
|
||||
uint32_t address_diff = (uint32_t) (*(volatile uint32_t *) (real_addr) & 0x03FFFFFC);
|
||||
if ((address_diff & 0x03000000) == 0x03000000) {
|
||||
address_diff |= 0xFC000000;
|
||||
}
|
||||
real_addr += (int32_t)address_diff;
|
||||
if((uint32_t)(*(volatile uint32_t*)(real_addr) & 0x48000002) == 0x48000000) {
|
||||
real_addr += (int32_t) address_diff;
|
||||
if ((uint32_t) (*(volatile uint32_t *) (real_addr) & 0x48000002) == 0x48000000) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user