mirror of
https://github.com/Maschell/hid_to_vpad.git
synced 2024-11-21 22:19:16 +01:00
Fixed accessing the friendlist while using HID to VPAD.
Updated used dynamic libs/controller patcher
This commit is contained in:
parent
cf54450cfd
commit
f7ccd7d58d
@ -26,6 +26,8 @@ extern "C" {
|
||||
#define LIB_NN_ACP 11
|
||||
#define LIB_SYSHID 12
|
||||
#define LIB_VPADBASE 13
|
||||
#define LIB_AX_OLD 14
|
||||
#define LIB_PROC_UI 15
|
||||
|
||||
// functions types
|
||||
#define STATIC_FUNCTION 0
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3559a18408126682d25ffe51ff6a43f99119e441
|
||||
Subproject commit f8aa5558cdb6bf8a50da0cae0c340555994800a4
|
@ -1 +1 @@
|
||||
Subproject commit a2f4abdbebedce82e36d10635d25d22038169795
|
||||
Subproject commit 7a31349744a04df5390145c2ac00315967e4377e
|
@ -10,6 +10,7 @@
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
#include "dynamic_libs/socket_functions.h"
|
||||
#include "dynamic_libs/sys_functions.h"
|
||||
#include "dynamic_libs/proc_ui_functions.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
@ -35,12 +36,17 @@
|
||||
|
||||
/* Entry point */
|
||||
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 *
|
||||
//!*******************************************************************
|
||||
//! do OS (for acquire) and sockets first so we got logging
|
||||
InitOSFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
InitProcUIFunctionPointers();
|
||||
|
||||
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)
|
||||
|
@ -242,6 +242,16 @@ DECL(void,WPADControlMotor,s32 chan, u32 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"))) = {
|
||||
MAKE_MAGIC(VPADRead, LIB_VPAD, 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(WPADControlMotor, 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);
|
||||
|
@ -183,6 +183,7 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_informati
|
||||
}
|
||||
method_hooks[i].alreadyPatched = 0; // In case a
|
||||
}
|
||||
|
||||
log_print("Done with restoring given functions!\n");
|
||||
}
|
||||
|
||||
@ -220,74 +221,85 @@ u32 GetAddressOfFunction(const char * functionName,u32 library){
|
||||
u32 rpl_handle = 0;
|
||||
if(library == LIB_CORE_INIT){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_NSYSNET){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_GX2){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_AOC){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_AX){
|
||||
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;
|
||||
}
|
||||
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){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_OS){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_PADSCORE){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_SOCKET){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_SYS){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_VPAD){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_NN_ACP){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_SYSHID){
|
||||
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;
|
||||
}
|
||||
else if(library == LIB_VPADBASE){
|
||||
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;
|
||||
}
|
||||
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){
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
if((address_diff & 0x03000000) == 0x03000000) {
|
||||
address_diff |= 0xFC000000;
|
||||
}
|
||||
real_addr += (int)address_diff;
|
||||
real_addr += (s32)address_diff;
|
||||
if((u32)(*(volatile u32*)(real_addr) & 0x48000002) == 0x48000000){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return real_addr;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ extern "C" {
|
||||
#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"
|
||||
|
||||
//Orignal code by Chadderz.
|
||||
#define DECL(res, name, ...) \
|
||||
@ -52,8 +53,8 @@ typedef struct {
|
||||
const char functionName[50];
|
||||
u32 realAddr;
|
||||
u32 restoreInstruction;
|
||||
unsigned char functionType;
|
||||
unsigned char alreadyPatched;
|
||||
u8 functionType;
|
||||
u8 alreadyPatched;
|
||||
} hooks_magic_t;
|
||||
|
||||
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.
|
||||
#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
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define DEBUG_LOGGER 1
|
||||
#define DEBUG_LOGGER 1
|
||||
|
||||
#ifdef DEBUG_LOGGER
|
||||
void log_init(const char * ip);
|
||||
|
Loading…
Reference in New Issue
Block a user