Added missing defines and optimized the function patcher

This commit is contained in:
Maschell 2017-10-30 21:48:24 +01:00
parent 7db739c0b1
commit 69f8e96c4a
4 changed files with 203 additions and 82 deletions

View File

@ -8,6 +8,96 @@
extern "C" { extern "C" {
#endif #endif
// original structure in the kernel that is originally 0x1270 long
typedef struct
{
uint32_t version_cos_xml; // version tag from cos.xml
uint64_t os_version; // os_version from app.xml
uint64_t title_id; // title_id tag from app.xml
uint32_t app_type; // app_type tag from app.xml
uint32_t cmdFlags; // unknown tag as it is always 0 (might be cmdFlags from cos.xml but i am not sure)
char rpx_name[0x1000]; // rpx name from cos.xml
uint32_t unknown2; // 0x050B8304 in mii maker and system menu (looks a bit like permissions complex that got masked!?)
uint32_t unknown3[63]; // those were all zeros, but its probably connected with unknown2
uint32_t max_size; // max_size in cos.xml which defines the maximum amount of memory reserved for the app
uint32_t avail_size; // avail_size or codegen_size in cos.xml (seems to mostly be 0?)
uint32_t codegen_size; // codegen_size or avail_size in cos.xml (seems to mostly be 0?)
uint32_t codegen_core; // codegen_core in cos.xml (seems to mostly be 1?)
uint32_t max_codesize; // max_codesize in cos.xml
uint32_t overlay_arena; // overlay_arena in cos.xml
uint32_t unknown4[59]; // all zeros it seems
uint32_t default_stack0_size; // not sure because always 0 but very likely
uint32_t default_stack1_size; // not sure because always 0 but very likely
uint32_t default_stack2_size; // not sure because always 0 but very likely
uint32_t default_redzone0_size; // not sure because always 0 but very likely
uint32_t default_redzone1_size; // not sure because always 0 but very likely
uint32_t default_redzone2_size; // not sure because always 0 but very likely
uint32_t exception_stack0_size; // from cos.xml, 0x1000 on mii maker
uint32_t exception_stack1_size; // from cos.xml, 0x1000 on mii maker
uint32_t exception_stack2_size; // from cos.xml, 0x1000 on mii maker
uint32_t sdk_version; // from app.xml, 20909 (0x51AD) on mii maker
uint32_t title_version; // from app.xml, 0x32 on mii maker
/*
// ---------------------------------------------------------------------------------------------------------------------------------------------
// the next part might be changing from title to title?! I don't think its important but nice to know maybe....
// ---------------------------------------------------------------------------------------------------------------------------------------------
char mlc[4]; // string "mlc" on mii maker and sysmenu
uint32_t unknown5[7]; // all zeros on mii maker and sysmenu
uint32_t unknown6_one; // 0x01 on mii maker and sysmenu
// ---------------------------------------------------------------------------------------------------------------------------------------------
char ACP[4]; // string "ACP" on mii maker and sysmenu
uint32_t unknown7[15]; // all zeros on mii maker and sysmenu
uint32_t unknown8_5; // 0x05 on mii maker and sysmenu
uint32_t unknown9_zero; // 0x00 on mii maker and sysmenu
uint32_t unknown10_ptr; // 0xFF23DD0C pointer on mii maker and sysmenu
// ---------------------------------------------------------------------------------------------------------------------------------------------
char UVD[4]; // string "UVD" on mii maker and sysmenu
uint32_t unknown11[15]; // all zeros on mii maker and sysmenu
uint32_t unknown12_5; // 0x05 on mii maker and sysmenu
uint32_t unknown13_zero; // 0x00 on mii maker and sysmenu
uint32_t unknown14_ptr; // 0xFF23EFC8 pointer on mii maker and sysmenu
// ---------------------------------------------------------------------------------------------------------------------------------------------
char SND[4]; // string "SND" on mii maker and sysmenu
uint32_t unknown15[15]; // all zeros on mii maker and sysmenu
uint32_t unknown16_5; // 0x05 on mii maker and sysmenu
uint32_t unknown17_zero; // 0x00 on mii maker and sysmenu
uint32_t unknown18_ptr; // 0xFF23F014 pointer on mii maker and sysmenu
// ---------------------------------------------------------------------------------------------------------------------------------------------
uint32_t unknown19; // 0x02 on miimaker, 0x0F on system menu
*/
// after that only zeros follow
} __attribute__((packed)) CosAppXmlInfo;
// Our own cos/app.xml struct which uses only uses as much memory as really needed, since many things are just zeros in the above structure
// This structure is only 0x64 bytes long + RPX name length (dynamic up to 0x1000 theoretically)
typedef struct
{
uint32_t version_cos_xml; // version tag from cos.xml
uint64_t os_version; // os_version from app.xml
uint64_t title_id; // title_id tag from app.xml
uint32_t app_type; // app_type tag from app.xml
uint32_t cmdFlags; // unknown tag as it is always 0 (might be cmdFlags from cos.xml but i am not sure)
uint32_t max_size; // max_size in cos.xml which defines the maximum amount of memory reserved for the app
uint32_t avail_size; // avail_size or codegen_size in cos.xml (seems to mostly be 0?)
uint32_t codegen_size; // codegen_size or avail_size in cos.xml (seems to mostly be 0?)
uint32_t codegen_core; // codegen_core in cos.xml (seems to mostly be 1?)
uint32_t max_codesize; // max_codesize in cos.xml
uint32_t overlay_arena; // overlay_arena in cos.xml
uint32_t default_stack0_size; // not sure because always 0 but very likely
uint32_t default_stack1_size; // not sure because always 0 but very likely
uint32_t default_stack2_size; // not sure because always 0 but very likely
uint32_t default_redzone0_size; // not sure because always 0 but very likely
uint32_t default_redzone1_size; // not sure because always 0 but very likely
uint32_t default_redzone2_size; // not sure because always 0 but very likely
uint32_t exception_stack0_size; // from cos.xml, 0x1000 on mii maker
uint32_t exception_stack1_size; // from cos.xml, 0x1000 on mii maker
uint32_t exception_stack2_size; // from cos.xml, 0x1000 on mii maker
uint32_t sdk_version; // from app.xml, 20909 (0x51AD) on mii maker
uint32_t title_version; // from app.xml, 0x32 on mii maker
char rpx_name[FS_MAX_ENTNAME_SIZE]; // rpx name from cos.xml, length 256 as it can't get bigger from FS anyway
} __attribute__((packed)) ReducedCosAppXmlInfo;
typedef struct _bat_t typedef struct _bat_t
{ {
u32 h; u32 h;

View File

@ -22,6 +22,9 @@ extern "C"
{ {
#endif #endif
#define tr(s) gettext(s)
#define trNOOP(s) s
bool gettextLoadLanguage(const char* langFile); bool gettextLoadLanguage(const char* langFile);
void gettextCleanUp(void); void gettextCleanUp(void);
/* /*

View File

@ -31,6 +31,25 @@
#define CODE_RW_BASE_OFFSET 0x00000000 #define CODE_RW_BASE_OFFSET 0x00000000
#define DEBUG_LOG_DYN 0 #define DEBUG_LOG_DYN 0
u32 acp_handle_internal = 0;
u32 aoc_handle_internal = 0;
u32 sound_handle_internal = 0;
u32 sound_handle_internal_old = 0;
u32 libcurl_handle_internal = 0;
u32 gx2_handle_internal = 0;
u32 nfp_handle_internal = 0;
u32 nn_act_handle_internal = 0;
u32 nn_nim_handle_internal = 0;
u32 nn_save_handle_internal = 0;
u32 ntag_handle_internal = 0;
u32 coreinit_handle_internal = 0;
u32 padscore_handle_internal = 0;
u32 proc_ui_handle_internal = 0;
u32 nsysnet_handle_internal = 0;
u32 sysapp_handle_internal = 0;
u32 syshid_handle_internal = 0;
u32 vpad_handle_internal = 0;
u32 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. * Patches a function that is loaded at the start of each application. Its not required to restore, at least when they are really dynamic.
@ -38,6 +57,8 @@
*/ */
void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_size, volatile u32 dynamic_method_calls[]){ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_size, volatile u32 dynamic_method_calls[]){
SetupKernelCallback(); //Patch Kernel. Just to be sure. SetupKernelCallback(); //Patch Kernel. Just to be sure.
InitAcquireOS();
resetLibs();
DEBUG_FUNCTION_LINE("Patching %d given functions\n",hook_information_size); DEBUG_FUNCTION_LINE("Patching %d given functions\n",hook_information_size);
/* Patch branches to it. */ /* Patch branches to it. */
@ -145,8 +166,9 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
/* ****************************************************************** */ /* ****************************************************************** */
/* RESTORE ORIGINAL INSTRUCTIONS */ /* RESTORE ORIGINAL INSTRUCTIONS */
/* ****************************************************************** */ /* ****************************************************************** */
void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_information_size) void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_information_size){
{ InitAcquireOS();
resetLibs();
DEBUG_FUNCTION_LINE("Restoring given functions!\n"); DEBUG_FUNCTION_LINE("Restoring given functions!\n");
s32 method_hooks_count = hook_information_size; s32 method_hooks_count = hook_information_size;
for(s32 i = 0; i < method_hooks_count; i++) for(s32 i = 0; i < method_hooks_count; i++)
@ -223,130 +245,129 @@ u32 GetAddressOfFunction(const char * functionName,u32 library){
u32 rpl_handle = 0; u32 rpl_handle = 0;
if(library == LIB_CORE_INIT){ if(library == LIB_CORE_INIT){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_CORE_INIT\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_CORE_INIT\n", functionName);}
if(coreinit_handle == 0){InitAcquireOS();} if(coreinit_handle_internal == 0){OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("LIB_CORE_INIT failed to acquire\n"); return 0;} if(coreinit_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_CORE_INIT failed to acquire\n"); return 0;}
rpl_handle = coreinit_handle_internal;
rpl_handle = coreinit_handle;
} }
else if(library == LIB_NSYSNET){ else if(library == LIB_NSYSNET){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NSYSNET\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NSYSNET\n", functionName);}
if(nsysnet_handle == 0){InitAcquireSocket();} if(nsysnet_handle_internal == 0){OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle_internal);}
if(nsysnet_handle == 0){DEBUG_FUNCTION_LINE("LIB_NSYSNET failed to acquire\n"); return 0;} if(nsysnet_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_NSYSNET failed to acquire\n"); return 0;}
rpl_handle = nsysnet_handle; rpl_handle = nsysnet_handle_internal;
} }
else if(library == LIB_GX2){ else if(library == LIB_GX2){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_GX2\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_GX2\n", functionName);}
if(gx2_handle == 0){InitAcquireGX2();} if(gx2_handle_internal == 0){OSDynLoad_Acquire("gx2.rpl", &gx2_handle_internal);}
if(gx2_handle == 0){DEBUG_FUNCTION_LINE("LIB_GX2 failed to acquire\n"); return 0;} if(gx2_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_GX2 failed to acquire\n"); return 0;}
rpl_handle = gx2_handle; rpl_handle = gx2_handle_internal;
} }
else if(library == LIB_AOC){ else if(library == LIB_AOC){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AOC\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AOC\n", functionName);}
if(aoc_handle == 0){InitAcquireAoc();} if(aoc_handle_internal == 0){OSDynLoad_Acquire("nn_aoc.rpl", &aoc_handle_internal);}
if(aoc_handle == 0){DEBUG_FUNCTION_LINE("LIB_AOC failed to acquire\n"); return 0;} if(aoc_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_AOC failed to acquire\n"); return 0;}
rpl_handle = aoc_handle; rpl_handle = aoc_handle_internal;
} }
else if(library == LIB_AX){ else if(library == LIB_AX){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX\n", functionName);}
if(sound_handle == 0){InitAcquireAX();} if(sound_handle_internal == 0){OSDynLoad_Acquire("sndcore2.rpl", &sound_handle_internal);}
if(sound_handle == 0){DEBUG_FUNCTION_LINE("LIB_AX failed to acquire\n"); return 0;} if(sound_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_AX failed to acquire\n"); return 0;}
rpl_handle = sound_handle; rpl_handle = sound_handle_internal;
} }
else if(library == LIB_AX_OLD){ else if(library == LIB_AX_OLD){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX_OLD\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX_OLD\n", functionName);}
if(sound_handle_old == 0){InitAcquireAX();} if(sound_handle_internal_old == 0){OSDynLoad_Acquire("snd_core.rpl", &sound_handle_internal_old);}
if(sound_handle_old == 0){DEBUG_FUNCTION_LINE("LIB_AX_OLD failed to acquire\n"); return 0;} if(sound_handle_internal_old == 0){DEBUG_FUNCTION_LINE("LIB_AX_OLD failed to acquire\n"); return 0;}
rpl_handle = sound_handle_old; rpl_handle = sound_handle_internal_old;
} }
else if(library == LIB_FS){ else if(library == LIB_FS){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_FS\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_FS\n", functionName);}
if(coreinit_handle == 0){InitAcquireOS();} if(coreinit_handle_internal == 0){OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("LIB_FS failed to acquire\n"); return 0;} if(coreinit_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_FS failed to acquire\n"); return 0;}
rpl_handle = coreinit_handle; rpl_handle = coreinit_handle_internal;
} }
else if(library == LIB_OS){ else if(library == LIB_OS){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_OS\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_OS\n", functionName);}
if(coreinit_handle == 0){InitAcquireOS();} if(coreinit_handle_internal == 0){OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle_internal);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("LIB_OS failed to acquire\n"); return 0;} if(coreinit_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_OS failed to acquire\n"); return 0;}
rpl_handle = coreinit_handle; rpl_handle = coreinit_handle_internal;
} }
else if(library == LIB_PADSCORE){ else if(library == LIB_PADSCORE){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PADSCORE\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PADSCORE\n", functionName);}
if(padscore_handle == 0){InitAcquirePadScore();} if(padscore_handle_internal == 0){OSDynLoad_Acquire("padscore.rpl", &padscore_handle_internal);}
if(padscore_handle == 0){DEBUG_FUNCTION_LINE("LIB_PADSCORE failed to acquire\n"); return 0;} if(padscore_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_PADSCORE failed to acquire\n"); return 0;}
rpl_handle = padscore_handle; rpl_handle = padscore_handle_internal;
} }
else if(library == LIB_SOCKET){ else if(library == LIB_SOCKET){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SOCKET\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SOCKET\n", functionName);}
if(nsysnet_handle == 0){InitAcquireSocket();} if(nsysnet_handle_internal == 0){OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle_internal);}
if(nsysnet_handle == 0){DEBUG_FUNCTION_LINE("LIB_SOCKET failed to acquire\n"); return 0;} if(nsysnet_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_SOCKET failed to acquire\n"); return 0;}
rpl_handle = nsysnet_handle; rpl_handle = nsysnet_handle_internal;
} }
else if(library == LIB_SYS){ else if(library == LIB_SYS){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYS\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYS\n", functionName);}
if(sysapp_handle == 0){InitAcquireSys();} if(sysapp_handle_internal == 0){OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle_internal);}
if(sysapp_handle == 0){DEBUG_FUNCTION_LINE("LIB_SYS failed to acquire\n"); return 0;} if(sysapp_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_SYS failed to acquire\n"); return 0;}
rpl_handle = sysapp_handle; rpl_handle = sysapp_handle_internal;
} }
else if(library == LIB_VPAD){ else if(library == LIB_VPAD){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPAD\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPAD\n", functionName);}
if(vpad_handle == 0){InitAcquireVPad();} if(vpad_handle_internal == 0){ OSDynLoad_Acquire("vpad.rpl", &vpad_handle_internal);}
if(vpad_handle == 0){DEBUG_FUNCTION_LINE("LIB_VPAD failed to acquire\n"); return 0;} if(vpad_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_VPAD failed to acquire\n"); return 0;}
rpl_handle = vpad_handle; rpl_handle = vpad_handle_internal;
} }
else if(library == LIB_NN_ACP){ else if(library == LIB_NN_ACP){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NN_ACP\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NN_ACP\n", functionName);}
if(acp_handle == 0){InitAcquireACP();} if(acp_handle_internal == 0){OSDynLoad_Acquire("nn_acp.rpl", &acp_handle_internal);}
if(acp_handle == 0){DEBUG_FUNCTION_LINE("LIB_NN_ACP failed to acquire\n"); return 0;} if(acp_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_NN_ACP failed to acquire\n"); return 0;}
rpl_handle = acp_handle; rpl_handle = acp_handle_internal;
} }
else if(library == LIB_SYSHID){ else if(library == LIB_SYSHID){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYSHID\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYSHID\n", functionName);}
if(syshid_handle == 0){InitAcquireSysHID();} if(syshid_handle_internal == 0){OSDynLoad_Acquire("nsyshid.rpl", &syshid_handle_internal);}
if(syshid_handle == 0){DEBUG_FUNCTION_LINE("LIB_SYSHID failed to acquire\n"); return 0;} if(syshid_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_SYSHID failed to acquire\n"); return 0;}
rpl_handle = syshid_handle; rpl_handle = syshid_handle_internal;
} }
else if(library == LIB_VPADBASE){ else if(library == LIB_VPADBASE){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPADBASE\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPADBASE\n", functionName);}
if(vpadbase_handle == 0){InitAcquireVPad();} if(vpadbase_handle_internal == 0){OSDynLoad_Acquire("vpadbase.rpl", &vpadbase_handle_internal);}
if(vpadbase_handle == 0){DEBUG_FUNCTION_LINE("LIB_VPADBASE failed to acquire\n"); return 0;} if(vpadbase_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_VPADBASE failed to acquire\n"); return 0;}
rpl_handle = vpadbase_handle; rpl_handle = vpadbase_handle_internal;
} }
else if(library == LIB_PROC_UI){ else if(library == LIB_PROC_UI){
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PROC_UI\n", functionName);} if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PROC_UI\n", functionName);}
if(proc_ui_handle == 0){InitAcquireProcUI();} if(proc_ui_handle_internal == 0){OSDynLoad_Acquire("proc_ui.rpl", &proc_ui_handle_internal);}
if(proc_ui_handle == 0){DEBUG_FUNCTION_LINE("LIB_PROC_UI failed to acquire\n"); return 0;} if(proc_ui_handle_internal == 0){DEBUG_FUNCTION_LINE("LIB_PROC_UI failed to acquire\n"); return 0;}
rpl_handle = proc_ui_handle; rpl_handle = proc_ui_handle_internal;
} }
else if(library == LIB_NTAG){ else if(library == LIB_NTAG){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NTAG\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NTAG\n", functionName);}
if(ntag_handle == 0){InitAcquireNTAG();} if(ntag_handle_internal == 0){OSDynLoad_Acquire("ntag.rpl", &ntag_handle_internal);}
if(ntag_handle == 0){log_print("LIB_NTAG failed to acquire\n"); return 0;} if(ntag_handle_internal == 0){log_print("LIB_NTAG failed to acquire\n"); return 0;}
rpl_handle = ntag_handle; rpl_handle = ntag_handle_internal;
} }
else if(library == LIB_NFP){ else if(library == LIB_NFP){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NFP\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NFP\n", functionName);}
if(nfp_handle == 0){InitAcquireNFP();} if(nfp_handle_internal == 0){OSDynLoad_Acquire("nn_nfp.rpl", &nfp_handle_internal);}
if(nfp_handle == 0){log_print("LIB_NFP failed to acquire\n"); return 0;} if(nfp_handle_internal == 0){log_print("LIB_NFP failed to acquire\n"); return 0;}
rpl_handle = nfp_handle; rpl_handle = nfp_handle_internal;
} }
else if(library == LIB_SAVE){ else if(library == LIB_SAVE){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SAVE\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SAVE\n", functionName);}
if(nn_save_handle == 0){InitAcquireSave();} if(nn_save_handle_internal == 0){OSDynLoad_Acquire("nn_save.rpl", &nn_save_handle_internal);}
if(nn_save_handle == 0){log_print("LIB_SAVE failed to acquire\n"); return 0;} if(nn_save_handle_internal == 0){log_print("LIB_SAVE failed to acquire\n"); return 0;}
rpl_handle = nn_save_handle; rpl_handle = nn_save_handle_internal;
} }
else if(library == LIB_ACT){ else if(library == LIB_ACT){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_ACT\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_ACT\n", functionName);}
if(nn_act_handle == 0){InitAcquireACT();} if(nn_act_handle_internal == 0){OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle_internal);}
if(nn_act_handle == 0){log_print("LIB_ACT failed to acquire\n"); return 0;} if(nn_act_handle_internal == 0){log_print("LIB_ACT failed to acquire\n"); return 0;}
rpl_handle = nn_act_handle; rpl_handle = nn_act_handle_internal;
} }
else if(library == LIB_NIM){ else if(library == LIB_NIM){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NIM\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NIM\n", functionName);}
if(nn_nim_handle == 0){InitAcquireNim();} if(nn_nim_handle_internal == 0){OSDynLoad_Acquire("nn_nim.rpl", &nn_nim_handle_internal);}
if(nn_nim_handle == 0){log_print("LIB_NIM failed to acquire\n"); return 0;} if(nn_nim_handle_internal == 0){log_print("LIB_NIM failed to acquire\n"); return 0;}
rpl_handle = nn_nim_handle; rpl_handle = nn_nim_handle_internal;
} }
if(!rpl_handle){ if(!rpl_handle){
@ -375,3 +396,25 @@ u32 GetAddressOfFunction(const char * functionName,u32 library){
return real_addr; return real_addr;
} }
void resetLibs(){
acp_handle_internal = 0;
aoc_handle_internal = 0;
sound_handle_internal = 0;
sound_handle_internal_old = 0;
libcurl_handle_internal = 0;
gx2_handle_internal = 0;
nfp_handle_internal = 0;
nn_act_handle_internal = 0;
nn_nim_handle_internal = 0;
nn_save_handle_internal = 0;
ntag_handle_internal = 0;
coreinit_handle_internal = 0;
padscore_handle_internal = 0;
proc_ui_handle_internal = 0;
nsysnet_handle_internal = 0;
sysapp_handle_internal = 0;
syshid_handle_internal = 0;
vpad_handle_internal = 0;
vpadbase_handle_internal = 0;
}

View File

@ -23,23 +23,7 @@
extern "C" { extern "C" {
#endif #endif
#include <dynamic_libs/aoc_functions.h>
#include <dynamic_libs/ax_functions.h>
#include <dynamic_libs/fs_functions.h>
#include <dynamic_libs/gx2_functions.h>
#include <dynamic_libs/os_functions.h> #include <dynamic_libs/os_functions.h>
#include <dynamic_libs/padscore_functions.h>
#include <dynamic_libs/socket_functions.h>
#include <dynamic_libs/sys_functions.h>
#include <dynamic_libs/vpad_functions.h>
#include <dynamic_libs/acp_functions.h>
#include <dynamic_libs/syshid_functions.h>
#include <dynamic_libs/proc_ui_functions.h>
#include <dynamic_libs/ntag_functions.h>
#include <dynamic_libs/nfp_functions.h>
#include <dynamic_libs/nn_save_functions.h>
#include <dynamic_libs/nn_act_functions.h>
#include <dynamic_libs/nn_nim_functions.h>
/* Macros for libs */ /* Macros for libs */
#define LIB_CORE_INIT 0 #define LIB_CORE_INIT 0
@ -90,6 +74,7 @@ void PatchInvidualMethodHooks(hooks_magic_t hook_information[],s32 hook_informat
void RestoreInvidualInstructions(hooks_magic_t hook_information[],s32 hook_information_size); void RestoreInvidualInstructions(hooks_magic_t hook_information[],s32 hook_information_size);
u32 GetAddressOfFunction(const char * functionName,u32 library); u32 GetAddressOfFunction(const char * functionName,u32 library);
s32 isDynamicFunction(u32 physicalAddress); s32 isDynamicFunction(u32 physicalAddress);
void resetLibs();
//Orignal code by Chadderz. //Orignal code by Chadderz.
#define MAKE_MAGIC(x, lib,functionType) { (u32) my_ ## x, (u32) &real_ ## x, lib, # x,0,0,functionType,0} #define MAKE_MAGIC(x, lib,functionType) { (u32) my_ ## x, (u32) &real_ ## x, lib, # x,0,0,functionType,0}