Serveral minor improvements

- Improved logging
- Updated logger to make a broadcast logging when enabled
- Using the new controller_patcher lib (improved logging + more checks when parsing an .ini)
- Updated the function patcher
This commit is contained in:
Maschell 2017-10-14 13:25:18 +02:00
parent efe14da687
commit 746f4712f5
9 changed files with 129 additions and 106 deletions

View File

@ -54,19 +54,19 @@ Application::Application()
}
Application::~Application(){
log_printf("Application::~Application(line %d): Destroy music\n",__LINE__);
DEBUG_FUNCTION_LINE("Destroy music\n");
delete bgMusic;
log_printf("Application::~Application(line %d): Destroy controller\n",__LINE__);
DEBUG_FUNCTION_LINE("Destroy controller\n");
for(s32 i = 0; i < 5; i++)
delete controller[i];
//We may have to handle Asyncdelete in the Destructors.
log_printf("Application::~Application(line %d): Destroy async deleter\n",__LINE__);
DEBUG_FUNCTION_LINE("Destroy async deleter\n");
do{
log_printf("Application::~Application(line %d): Triggering AsyncDeleter\n",__LINE__);
DEBUG_FUNCTION_LINE("Triggering AsyncDeleter\n");
AsyncDeleter::triggerDeleteProcess();
while(!AsyncDeleter::realListEmpty()){
os_usleep(1000);
@ -74,10 +74,10 @@ Application::~Application(){
}while(!AsyncDeleter::deleteListEmpty());
AsyncDeleter::destroyInstance();
log_printf("Application::~Application(line %d): Clear resources\n",__LINE__);
DEBUG_FUNCTION_LINE("Clear resources\n");
Resources::Clear();
log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__);
DEBUG_FUNCTION_LINE("Stop sound handler\n");
SoundHandler::DestroyInstance();
}
@ -142,13 +142,13 @@ void Application::fadeOut(){
}
void Application::executeThread(void){
log_printf("Application::executeThread(line %d): Initialize video\n",__LINE__);
DEBUG_FUNCTION_LINE("Initialize video\n");
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_SINGLE);
log_printf("Application::executeThread(line %d): Video size %i x %i\n",__LINE__, video->getTvWidth(), video->getTvHeight());
DEBUG_FUNCTION_LINE("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight());
//! setup default Font
log_printf("Application::executeThread(line %d): Initialize main font system\n",__LINE__);
DEBUG_FUNCTION_LINE("Initialize main font system\n");
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
GuiText::setPresetFont(fontSystem);
@ -159,12 +159,12 @@ void Application::executeThread(void){
while(reloadUIflag){
reloadUIflag = false;
exitCode = EXIT_RELAUNCH_ON_LOAD;
log_printf("Application::executeThread(line %d): Initialize the language\n",__LINE__);
DEBUG_FUNCTION_LINE("Initialize the language\n");
loadLanguageFromConfig();
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
DEBUG_FUNCTION_LINE("Initialize main window\n");
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__);
DEBUG_FUNCTION_LINE("Entering main loop\n");
exitApplication = false;
//! main GX2 loop (60 Hz cycle with max priority on core 1)
while(!exitApplication && !reloadUIflag){

View File

@ -28,6 +28,11 @@ extern "C" {
#define LIB_VPADBASE 13
#define LIB_AX_OLD 14
#define LIB_PROC_UI 15
#define LIB_NTAG 16
#define LIB_NFP 17
#define LIB_SAVE 18
#define LIB_ACT 19
#define LIB_NIM 20
// functions types
#define STATIC_FUNCTION 0

@ -1 +1 @@
Subproject commit 3bf07857bebe4f1addf94c2e4cf2727e72d98789
Subproject commit c9284c023845a23f049c50d7b4c2f6348431da8f

View File

@ -72,13 +72,13 @@ extern "C" s32 Menu_Main(void){
SetupKernelCallback();
log_init("192.168.0.181");
log_printf("HID to VPAD %s - %s %s - by Maschell\n\n",APP_VERION,__DATE__,__TIME__);
log_init();
DEBUG_FUNCTION_LINE("HID to VPAD %s - %s %s - by Maschell\n\n",APP_VERION,__DATE__,__TIME__);
//!*******************************************************************
//! Initialize HID Config *
//!*******************************************************************
log_printf("Menu_Main (line %d): Initializing the controller data\n",__LINE__);
DEBUG_FUNCTION_LINE("Initializing the controller data\n");
bool res = ControllerPatcher::Init();
if(!res){
SplashScreen(5, std::string("Error. The app starts in 5 seconds without patches.").c_str(),0,0);
@ -94,23 +94,23 @@ extern "C" s32 Menu_Main(void){
//!*******************************************************************
//! Initialize heap memory *
//!*******************************************************************
log_printf("Menu_Main (line %d): Initialize memory management\n",__LINE__);
DEBUG_FUNCTION_LINE("Initialize memory management\n");
memoryInitialize();
log_printf("Menu_Main (line %d): Mount SD partition\n",__LINE__);
DEBUG_FUNCTION_LINE("Mount SD partition\n");
mount_sd_fat("sd");
log_printf("Menu_Main (line %d): Start main application\n",__LINE__);
DEBUG_FUNCTION_LINE("Start main application\n");
result = Application::instance()->exec();
log_printf("Menu_Main (line %d): Main application stopped result: %d\n",__LINE__,result);
DEBUG_FUNCTION_LINE("Main application stopped result: %d\n",result);
Application::destroyInstance();
bool rumble = CSettings::instance()->getValueAsBool(CSettings::RumbleActivated);
log_printf("Menu_Main (line %d): Setting rumble to: %d\n",__LINE__,rumble);
DEBUG_FUNCTION_LINE("Setting rumble to: %d\n",rumble);
ControllerPatcher::setRumbleActivated(rumble);
bool networkController = CSettings::instance()->getValueAsBool(CSettings::NetworkControllerActivated);
ControllerPatcher::setNetworkControllerActivated(networkController);
log_printf("Menu_Main (line %d): Unmount SD\n",__LINE__);
DEBUG_FUNCTION_LINE("Unmount SD\n");
unmount_sd_fat("sd");
log_printf("Menu_Main (line %d): Release memory\n",__LINE__);
DEBUG_FUNCTION_LINE("Release memory\n");
memoryRelease();
ControllerPatcher::destroyConfigHelper();
CSettings::destroyInstance();
@ -120,7 +120,7 @@ extern "C" s32 Menu_Main(void){
//!*******************************************************************
//! Patching functions *
//!*******************************************************************
log_printf("Menu_Main(line %d): Patching functions\n",__LINE__);
DEBUG_FUNCTION_LINE("Menu_Main(line %d): Patching functions\n");
ApplyPatches();
if(!isInMiiMakerHBL()){
@ -129,11 +129,11 @@ extern "C" s32 Menu_Main(void){
}
if(result == APPLICATION_CLOSE_APPLY){
log_printf("Menu_Main (line %d): Loading the system menu.\n",__LINE__);
DEBUG_FUNCTION_LINE("Loading the system menu.\n");
SYSLaunchMenu();
return EXIT_RELAUNCH_ON_LOAD;
}
log_printf("Menu_Main (line %d): Going back to the Homebrew Launcher\n",__LINE__);
DEBUG_FUNCTION_LINE("Going back to the Homebrew Launcher\n");
ControllerPatcher::restoreWiiUEnergySetting();
deInit();
return EXIT_SUCCESS;
@ -151,7 +151,6 @@ void deInit(){
RestorePatches();
ControllerPatcher::DeInit();
ControllerPatcher::stopNetworkServer();
log_deinit();
}
s32 isInMiiMakerHBL(){
if (OSGetTitleID != 0 && (

View File

@ -85,7 +85,7 @@ bool CSettings::Load(){
std::string filepath = configPath;
filepath += CONFIG_FILENAME;
log_printf("CSettings::Load(line %d): Loading Configuration from %s\n",__LINE__,filepath.c_str());
DEBUG_FUNCTION_LINE("Loading Configuration from %s\n",filepath.c_str());
CFile file(filepath, CFile::ReadOnly);
if (!file.isOpen())

View File

@ -38,7 +38,7 @@
*/
void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_size, volatile u32 dynamic_method_calls[])
{
log_printf("Patching %d given functions\n",hook_information_size);
DEBUG_FUNCTION_LINE("Patching %d given functions\n",hook_information_size);
/* Patch branches to it. */
volatile u32 *space = &dynamic_method_calls[0];
@ -50,7 +50,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
u32 flush_len = 4*instr_len;
for(s32 i = 0; i < method_hooks_count; i++)
{
log_printf("Patching %s ...",method_hooks[i].functionName);
DEBUG_FUNCTION_LINE("Patching %s ...",method_hooks[i].functionName);
if(method_hooks[i].functionType == STATIC_FUNCTION && method_hooks[i].alreadyPatched == 1){
if(isDynamicFunction((u32)OSEffectiveToPhysical((void*)method_hooks[i].realAddr))){
log_printf("The function %s is a dynamic function. Please fix that <3\n", method_hooks[i].functionName);
@ -69,12 +69,13 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
u32 real_addr = GetAddressOfFunction(method_hooks[i].functionName,method_hooks[i].library);
if(!real_addr){
log_printf("OSDynLoad_FindExport failed for %s\n", method_hooks[i].functionName);
log_printf("\n");
DEBUG_FUNCTION_LINE("OSDynLoad_FindExport failed for %s\n", method_hooks[i].functionName);
space += instr_len;
continue;
}
if(DEBUG_LOG_DYN){log_printf("%s is located at %08X!\n", method_hooks[i].functionName,real_addr);}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("%s is located at %08X!\n", method_hooks[i].functionName,real_addr);}
physical = (u32)OSEffectiveToPhysical((void*)real_addr);
if(!physical){
@ -83,7 +84,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
continue;
}
if(DEBUG_LOG_DYN){log_printf("%s physical is located at %08X!\n", method_hooks[i].functionName,physical);}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("%s physical is located at %08X!\n", method_hooks[i].functionName,physical);}
*(volatile u32 *)(call_addr) = (u32)(space) - CODE_RW_BASE_OFFSET;
@ -96,8 +97,8 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
// fill the restore instruction section
method_hooks[i].realAddr = real_addr;
method_hooks[i].restoreInstruction = *(space-1);
if(DEBUG_LOG_DYN){log_printf("method_hooks[i].realAddr = %08X!\n", method_hooks[i].realAddr);}
if(DEBUG_LOG_DYN){log_printf("method_hooks[i].restoreInstruction = %08X!\n",method_hooks[i].restoreInstruction) ;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("method_hooks[i].realAddr = %08X!\n", method_hooks[i].realAddr);}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("method_hooks[i].restoreInstruction = %08X!\n",method_hooks[i].restoreInstruction) ;}
}
else{
log_printf("Error. Can't save %s for restoring!\n", method_hooks[i].functionName);
@ -137,7 +138,7 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
log_printf("done!\n");
}
log_print("Done with patching given functions!\n");
DEBUG_FUNCTION_LINE("Done with patching given functions!\n");
}
/* ****************************************************************** */
@ -145,11 +146,11 @@ void PatchInvidualMethodHooks(hooks_magic_t method_hooks[],s32 hook_information_
/* ****************************************************************** */
void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_information_size)
{
log_printf("Restoring given functions!\n");
DEBUG_FUNCTION_LINE("Restoring given functions!\n");
s32 method_hooks_count = hook_information_size;
for(s32 i = 0; i < method_hooks_count; i++)
{
log_printf("Restoring %s... ",method_hooks[i].functionName);
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\n");
continue;
@ -175,16 +176,16 @@ void RestoreInvidualInstructions(hooks_magic_t method_hooks[],s32 hook_informati
else
{
physical = (u32)OSEffectiveToPhysical((void*)method_hooks[i].realAddr); //When its an static function, we need to use the old location
if(DEBUG_LOG_DYN){log_printf("Restoring %08X to %08X\n",(u32)method_hooks[i].restoreInstruction,physical);}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("Restoring %08X to %08X\n",(u32)method_hooks[i].restoreInstruction,physical);}
SC0x25_KernelCopyData(physical,(u32)&method_hooks[i].restoreInstruction , 4);
if(DEBUG_LOG_DYN){log_printf("ICInvalidateRange %08X\n",(void*)method_hooks[i].realAddr);}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("ICInvalidateRange %08X\n",(void*)method_hooks[i].realAddr);}
ICInvalidateRange((void*)method_hooks[i].realAddr, 4);
log_printf("done\n");
}
method_hooks[i].alreadyPatched = 0; // In case a
}
log_print("Done with restoring given functions!\n");
DEBUG_FUNCTION_LINE("Done with restoring given functions!\n");
}
s32 isDynamicFunction(u32 physicalAddress){
@ -220,96 +221,120 @@ 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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_CORE_INIT\n", functionName);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NSYSNET\n", functionName);}
if(nsysnet_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_GX2\n", functionName);}
if(gx2_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AOC\n", functionName);}
if(aoc_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX\n", functionName);}
if(sound_handle == 0){DEBUG_FUNCTION_LINE("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;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_AX_OLD\n", functionName);}
if(sound_handle_old == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_FS\n", functionName);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_OS\n", functionName);}
if(coreinit_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PADSCORE\n", functionName);}
if(padscore_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SOCKET\n", functionName);}
if(nsysnet_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYS\n", functionName);}
if(sysapp_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPAD\n", functionName);}
if(vpad_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_NN_ACP\n", functionName);}
if(acp_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_SYSHID\n", functionName);}
if(syshid_handle == 0){DEBUG_FUNCTION_LINE("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 acquired\n"); return 0;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_VPADBASE\n", functionName);}
if(vpadbase_handle == 0){DEBUG_FUNCTION_LINE("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;}
if(DEBUG_LOG_DYN){DEBUG_FUNCTION_LINE("FindExport of %s! From LIB_PROC_UI\n", functionName);}
if(proc_ui_handle == 0){DEBUG_FUNCTION_LINE("LIB_PROC_UI not acquired\n"); return 0;}
rpl_handle = proc_ui_handle;
}
else if(library == LIB_NTAG){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NTAG\n", functionName);}
if(ntag_handle == 0){log_print("LIB_NTAG not acquired\n"); return 0;}
rpl_handle = proc_ui_handle;
}
else if(library == LIB_NFP){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NFP\n", functionName);}
if(nfp_handle == 0){log_print("LIB_NFP not acquired\n"); return 0;}
rpl_handle = nfp_handle;
}
else if(library == LIB_SAVE){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_SAVE\n", functionName);}
if(nn_save_handle == 0){log_print("LIB_SAVE not acquired\n"); return 0;}
rpl_handle = nn_save_handle;
}
else if(library == LIB_ACT){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_ACT\n", functionName);}
if(nn_act_handle == 0){log_print("LIB_ACT not acquired\n"); return 0;}
rpl_handle = nn_act_handle;
}
else if(library == LIB_NIM){
if(DEBUG_LOG_DYN){log_printf("FindExport of %s! From LIB_NIM\n", functionName);}
if(nn_nim_handle == 0){log_print("LIB_NIM not acquired\n"); return 0;}
rpl_handle = nn_nim_handle;
}
if(!rpl_handle){
log_printf("Failed to find the RPL handle for %s\n", functionName);
DEBUG_FUNCTION_LINE("Failed to find the RPL handle for %s\n", functionName);
return 0;
}
OSDynLoad_FindExport(rpl_handle, 0, functionName, &real_addr);
if(!real_addr){
log_printf("OSDynLoad_FindExport failed for %s\n", functionName);
DEBUG_FUNCTION_LINE("OSDynLoad_FindExport failed for %s\n", functionName);
return 0;
}

View File

@ -38,6 +38,11 @@ extern "C" {
#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"
//Orignal code by Chadderz.
#define DECL(res, name, ...) \

View File

@ -8,36 +8,24 @@
#include "logger.h"
#ifdef DEBUG_LOGGER
static s32 log_socket = -1;
static volatile s32 log_lock = 0;
static int log_socket = -1;
static struct sockaddr_in connect_addr;
static volatile int log_lock = 0;
void log_init(const char * ipString)
void log_init()
{
int broadcastEnable = 1;
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (log_socket < 0)
return;
struct sockaddr_in connect_addr;
memset(&connect_addr, 0, sizeof(connect_addr));
setsockopt(log_socket, SOL_SOCKET, SO_BROADCAST, &broadcastEnable, sizeof(broadcastEnable));
memset(&connect_addr, 0, sizeof(struct sockaddr_in));
connect_addr.sin_family = AF_INET;
connect_addr.sin_port = 4405;
inet_aton(ipString, &connect_addr.sin_addr);
if(connect(log_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
{
socketclose(log_socket);
log_socket = -1;
}
}
void log_deinit(void)
{
if(log_socket >= 0)
{
socketclose(log_socket);
log_socket = -1;
}
connect_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
}
void log_print(const char *str)
@ -51,11 +39,11 @@ void log_print(const char *str)
os_usleep(1000);
log_lock = 1;
s32 len = strlen(str);
s32 ret;
int len = strlen(str);
int ret;
while (len > 0) {
s32 block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
ret = send(log_socket, str, block, 0);
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
ret = sendto(log_socket, str, block, 0, (struct sockaddr *)&connect_addr, sizeof(struct sockaddr_in));
if(ret < 0)
break;

View File

@ -6,23 +6,24 @@ extern "C" {
#endif
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
log_printf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#define DEBUG_LOGGER 1
#define DEBUG_LOGGER 0
#ifdef DEBUG_LOGGER
void log_init(const char * ip);
void log_init();
void log_deinit(void);
void log_print(const char *str);
void log_printf(const char *format, ...);
#else
#define log_init(x)
#define log_deinit()
#define log_init()
#define log_print(x)
#define log_printf(x, ...)
#endif