Fixed accessing the friendlist while using HID to VPAD.

Updated used dynamic libs/controller patcher
This commit is contained in:
Maschell 2017-07-20 16:08:00 +02:00
parent cf54450cfd
commit f7ccd7d58d
8 changed files with 74 additions and 44 deletions

View File

@ -26,6 +26,8 @@ extern "C" {
#define LIB_NN_ACP 11 #define LIB_NN_ACP 11
#define LIB_SYSHID 12 #define LIB_SYSHID 12
#define LIB_VPADBASE 13 #define LIB_VPADBASE 13
#define LIB_AX_OLD 14
#define LIB_PROC_UI 15
// functions types // functions types
#define STATIC_FUNCTION 0 #define STATIC_FUNCTION 0

@ -1 +1 @@
Subproject commit 3559a18408126682d25ffe51ff6a43f99119e441 Subproject commit f8aa5558cdb6bf8a50da0cae0c340555994800a4

@ -1 +1 @@
Subproject commit a2f4abdbebedce82e36d10635d25d22038169795 Subproject commit 7a31349744a04df5390145c2ac00315967e4377e

View File

@ -10,6 +10,7 @@
#include "dynamic_libs/vpad_functions.h" #include "dynamic_libs/vpad_functions.h"
#include "dynamic_libs/socket_functions.h" #include "dynamic_libs/socket_functions.h"
#include "dynamic_libs/sys_functions.h" #include "dynamic_libs/sys_functions.h"
#include "dynamic_libs/proc_ui_functions.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "utils/utils.h" #include "utils/utils.h"
@ -35,12 +36,17 @@
/* Entry point */ /* Entry point */
extern "C" s32 Menu_Main(void){ extern "C" s32 Menu_Main(void){
if(gAppStatus == 2){
//"No, we don't want to patch stuff again.");
return EXIT_RELAUNCH_ON_LOAD;
}
//!******************************************************************* //!*******************************************************************
//! Initialize function pointers * //! Initialize function pointers *
//!******************************************************************* //!*******************************************************************
//! do OS (for acquire) and sockets first so we got logging //! do OS (for acquire) and sockets first so we got logging
InitOSFunctionPointers(); InitOSFunctionPointers();
InitVPadFunctionPointers(); InitVPadFunctionPointers();
InitProcUIFunctionPointers();
if(OSGetTitleID() == 0x00050000101a5f00L || // Shantae and the Pirate's Curse USA (reason: crashes when pressing HOME, Pro Controller not recognized) if(OSGetTitleID() == 0x00050000101a5f00L || // Shantae and the Pirate's Curse USA (reason: crashes when pressing HOME, Pro Controller not recognized)
OSGetTitleID() == 0x00050000101F7F00L || // Shantae and the Pirate's Curse JAP (シャンティ -海賊の呪い-) (reason: crashes when pressing HOME, Pro Controller not recognized) OSGetTitleID() == 0x00050000101F7F00L || // Shantae and the Pirate's Curse JAP (シャンティ -海賊の呪い-) (reason: crashes when pressing HOME, Pro Controller not recognized)

View File

@ -242,6 +242,16 @@ DECL(void,WPADControlMotor,s32 chan, u32 status ){
real_WPADControlMotor(chan,status); real_WPADControlMotor(chan,status);
} }
DECL(u32, ProcUIProcessMessages, u32 u){
u32 res = real_ProcUIProcessMessages(u);
if(res != gAppStatus){
log_printf("App status changed from %d to %d \n",gAppStatus,res);
gAppStatus = res;
}
return res;
}
hooks_magic_t method_hooks_hid_controller[] __attribute__((section(".data"))) = { hooks_magic_t method_hooks_hid_controller[] __attribute__((section(".data"))) = {
MAKE_MAGIC(VPADRead, LIB_VPAD, STATIC_FUNCTION), MAKE_MAGIC(VPADRead, LIB_VPAD, STATIC_FUNCTION),
MAKE_MAGIC(GX2CopyColorBufferToScanBuffer, LIB_GX2, STATIC_FUNCTION), MAKE_MAGIC(GX2CopyColorBufferToScanBuffer, LIB_GX2, STATIC_FUNCTION),
@ -255,6 +265,7 @@ hooks_magic_t method_hooks_hid_controller[] __attribute__((section(".data"))) =
MAKE_MAGIC(WPADSetDataFormat, LIB_PADSCORE, DYNAMIC_FUNCTION), MAKE_MAGIC(WPADSetDataFormat, LIB_PADSCORE, DYNAMIC_FUNCTION),
MAKE_MAGIC(WPADControlMotor, LIB_PADSCORE, DYNAMIC_FUNCTION), MAKE_MAGIC(WPADControlMotor, LIB_PADSCORE, DYNAMIC_FUNCTION),
MAKE_MAGIC(WPADProbe, LIB_PADSCORE, DYNAMIC_FUNCTION), MAKE_MAGIC(WPADProbe, LIB_PADSCORE, DYNAMIC_FUNCTION),
MAKE_MAGIC(ProcUIProcessMessages, LIB_PROC_UI, DYNAMIC_FUNCTION),
}; };
u32 method_hooks_size_hid_controller __attribute__((section(".data"))) = sizeof(method_hooks_hid_controller) / sizeof(hooks_magic_t); u32 method_hooks_size_hid_controller __attribute__((section(".data"))) = sizeof(method_hooks_hid_controller) / sizeof(hooks_magic_t);

View File

@ -183,6 +183,7 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_informati
} }
method_hooks[i].alreadyPatched = 0; // In case a method_hooks[i].alreadyPatched = 0; // In case a
} }
log_print("Done with restoring given functions!\n"); log_print("Done with restoring given functions!\n");
} }
@ -220,74 +221,85 @@ 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){log_printf("FindExport of %s! From LIB_CORE_INIT\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_CORE_INIT\n", functionName);}
if(coreinit_handle == 0){log_print("LIB_CORE_INIT not aquired\n"); return 0;} if(coreinit_handle == 0){log_print("LIB_CORE_INIT not acquired\n"); return 0;}
rpl_handle = coreinit_handle; rpl_handle = coreinit_handle;
} }
else if(library == LIB_NSYSNET){ else if(library == LIB_NSYSNET){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NSYSNET\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NSYSNET\n", functionName);}
if(nsysnet_handle == 0){log_print("LIB_NSYSNET not aquired\n"); return 0;} if(nsysnet_handle == 0){log_print("LIB_NSYSNET not acquired\n"); return 0;}
rpl_handle = nsysnet_handle; rpl_handle = nsysnet_handle;
} }
else if(library == LIB_GX2){ else if(library == LIB_GX2){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_GX2\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_GX2\n", functionName);}
if(gx2_handle == 0){log_print("LIB_GX2 not aquired\n"); return 0;} if(gx2_handle == 0){log_print("LIB_GX2 not acquired\n"); return 0;}
rpl_handle = gx2_handle; rpl_handle = gx2_handle;
} }
else if(library == LIB_AOC){ else if(library == LIB_AOC){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_AOC\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_AOC\n", functionName);}
if(aoc_handle == 0){log_print("LIB_AOC not aquired\n"); return 0;} if(aoc_handle == 0){log_print("LIB_AOC not acquired\n"); return 0;}
rpl_handle = aoc_handle; rpl_handle = aoc_handle;
} }
else if(library == LIB_AX){ else if(library == LIB_AX){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_AX\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_AX\n", functionName);}
if(sound_handle == 0){log_print("LIB_AX not aquired\n"); return 0;} if(sound_handle == 0){log_print("LIB_AX not acquired\n"); return 0;}
rpl_handle = sound_handle; rpl_handle = sound_handle;
} }
else if(library == LIB_AX_OLD){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_AX_OLD\n", functionName);}
if(sound_handle_old == 0){log_print("LIB_AX_OLD not acquired\n"); return 0;}
rpl_handle = sound_handle_old;
}
else if(library == LIB_FS){ else if(library == LIB_FS){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_FS\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_FS\n", functionName);}
if(coreinit_handle == 0){log_print("LIB_FS not aquired\n"); return 0;} if(coreinit_handle == 0){log_print("LIB_FS not acquired\n"); return 0;}
rpl_handle = coreinit_handle; rpl_handle = coreinit_handle;
} }
else if(library == LIB_OS){ else if(library == LIB_OS){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_OS\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_OS\n", functionName);}
if(coreinit_handle == 0){log_print("LIB_OS not aquired\n"); return 0;} if(coreinit_handle == 0){log_print("LIB_OS not acquired\n"); return 0;}
rpl_handle = coreinit_handle; rpl_handle = coreinit_handle;
} }
else if(library == LIB_PADSCORE){ else if(library == LIB_PADSCORE){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_PADSCORE\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_PADSCORE\n", functionName);}
if(padscore_handle == 0){log_print("LIB_PADSCORE not aquired\n"); return 0;} if(padscore_handle == 0){log_print("LIB_PADSCORE not acquired\n"); return 0;}
rpl_handle = padscore_handle; rpl_handle = padscore_handle;
} }
else if(library == LIB_SOCKET){ else if(library == LIB_SOCKET){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SOCKET\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SOCKET\n", functionName);}
if(nsysnet_handle == 0){log_print("LIB_SOCKET not aquired\n"); return 0;} if(nsysnet_handle == 0){log_print("LIB_SOCKET not acquired\n"); return 0;}
rpl_handle = nsysnet_handle; rpl_handle = nsysnet_handle;
} }
else if(library == LIB_SYS){ else if(library == LIB_SYS){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SYS\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SYS\n", functionName);}
if(sysapp_handle == 0){log_print("LIB_SYS not aquired\n"); return 0;} if(sysapp_handle == 0){log_print("LIB_SYS not acquired\n"); return 0;}
rpl_handle = sysapp_handle; rpl_handle = sysapp_handle;
} }
else if(library == LIB_VPAD){ else if(library == LIB_VPAD){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_VPAD\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_VPAD\n", functionName);}
if(vpad_handle == 0){log_print("LIB_VPAD not aquired\n"); return 0;} if(vpad_handle == 0){log_print("LIB_VPAD not acquired\n"); return 0;}
rpl_handle = vpad_handle; rpl_handle = vpad_handle;
} }
else if(library == LIB_NN_ACP){ else if(library == LIB_NN_ACP){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NN_ACP\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NN_ACP\n", functionName);}
if(acp_handle == 0){log_print("LIB_NN_ACP not aquired\n"); return 0;} if(acp_handle == 0){log_print("LIB_NN_ACP not acquired\n"); return 0;}
rpl_handle = acp_handle; rpl_handle = acp_handle;
} }
else if(library == LIB_SYSHID){ else if(library == LIB_SYSHID){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SYSHID\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SYSHID\n", functionName);}
if(syshid_handle == 0){log_print("LIB_SYSHID not aquired\n"); return 0;} if(syshid_handle == 0){log_print("LIB_SYSHID not acquired\n"); return 0;}
rpl_handle = syshid_handle; rpl_handle = syshid_handle;
} }
else if(library == LIB_VPADBASE){ else if(library == LIB_VPADBASE){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_VPADBASE\n", functionName);} if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_VPADBASE\n", functionName);}
if(vpadbase_handle == 0){log_print("LIB_VPADBASE not aquired\n"); return 0;} if(vpadbase_handle == 0){log_print("LIB_VPADBASE not acquired\n"); return 0;}
rpl_handle = vpadbase_handle; rpl_handle = vpadbase_handle;
} }
else if(library == LIB_PROC_UI){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_PROC_UI\n", functionName);}
if(proc_ui_handle == 0){log_print("LIB_PROC_UI not acquired\n"); return 0;}
rpl_handle = proc_ui_handle;
}
if(!rpl_handle){ if(!rpl_handle){
log_printf("Failed to find the RPL handle for %s\n", functionName); log_printf("Failed to find the RPL handle for %s\n", functionName);
@ -301,20 +313,17 @@ u32 GetAddressOfFunction(const char * functionName,u32 library){
return 0; return 0;
} }
if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000) if((library == LIB_NN_ACP) && (u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000)
{ {
u32 address_diff = (u32)(*(volatile u32*)(real_addr) & 0x03FFFFFC); u32 address_diff = (u32)(*(volatile u32*)(real_addr) & 0x03FFFFFC);
if((address_diff & 0x03000000) == 0x03000000) { if((address_diff & 0x03000000) == 0x03000000) {
address_diff |= 0xFC000000; address_diff |= 0xFC000000;
} }
real_addr += (int)address_diff; real_addr += (s32)address_diff;
if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000){ if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000){
return 0; return 0;
} }
} }
return real_addr; return real_addr;
} }

View File

@ -37,6 +37,7 @@ extern "C" {
#include "dynamic_libs/vpad_functions.h" #include "dynamic_libs/vpad_functions.h"
#include "dynamic_libs/acp_functions.h" #include "dynamic_libs/acp_functions.h"
#include "dynamic_libs/syshid_functions.h" #include "dynamic_libs/syshid_functions.h"
#include "dynamic_libs/proc_ui_functions.h"
//Orignal code by Chadderz. //Orignal code by Chadderz.
#define DECL(res, name, ...) \ #define DECL(res, name, ...) \
@ -52,8 +53,8 @@ typedef struct {
const char functionName[50]; const char functionName[50];
u32 realAddr; u32 realAddr;
u32 restoreInstruction; u32 restoreInstruction;
unsigned char functionType; u8 functionType;
unsigned char alreadyPatched; u8 alreadyPatched;
} hooks_magic_t; } hooks_magic_t;
void PatchInvidualMethodHooks(hooks_magic_t hook_information[],s32 hook_information_size, volatile u32 dynamic_method_calls[]); void PatchInvidualMethodHooks(hooks_magic_t hook_information[],s32 hook_information_size, volatile u32 dynamic_method_calls[]);
@ -63,6 +64,7 @@ s32 isDynamicFunction(u32 physicalAddress);
//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}
#define MAKE_MAGIC_NAME(x,y, lib,functionType) { (u32) my_ ## x, (u32) &real_ ## x, lib, # y,0,0,functionType,0}
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
//#define DEBUG_LOGGER 1 #define DEBUG_LOGGER 1
#ifdef DEBUG_LOGGER #ifdef DEBUG_LOGGER
void log_init(const char * ip); void log_init(const char * ip);