diff --git a/src/main.cpp b/src/main.cpp index 7ddfaf7..e7b4944 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,9 +4,6 @@ #include "utils/StringTools.h" #include "utils/logger.h" #include "version.h" -#include -#include -#include #include WUMS_MODULE_EXPORT_NAME("homebrew_content_redirection"); @@ -14,6 +11,16 @@ WUMS_USE_WUT_DEVOPTAB(); #define VERSION "v0.2.1" +DECL_FUNCTION(void, OSCancelThread, OSThread *thread) { + if (thread == gThreadData[0].thread || thread == gThreadData[1].thread || thread == gThreadData[2].thread) { + DEBUG_FUNCTION_LINE_INFO("Prevent calling OSCancelThread for ContentRedirection IO Threads"); + return; + } + real_OSCancelThread(thread); +} + +function_replacement_data_t OSCancelThreadReplacement = REPLACE_FUNCTION(OSCancelThread, LIBRARY_COREINIT, OSCancelThread); + WUMS_INITIALIZE() { initLogging(); DEBUG_FUNCTION_LINE("Patch functions"); @@ -27,7 +34,9 @@ WUMS_INITIALIZE() { OSFatal("homebrew_content_redirection: Failed to patch function"); } } - + if (!FunctionPatcherPatchFunction(&OSCancelThreadReplacement, nullptr)) { + OSFatal("homebrew_content_redirection: Failed to patch OSCancelThreadReplacement"); + } DEBUG_FUNCTION_LINE("Patch functions finished"); deinitLogging(); } diff --git a/src/utils/logger.h b/src/utils/logger.h index a2d3423..14c5db6 100644 --- a/src/utils/logger.h +++ b/src/utils/logger.h @@ -39,6 +39,7 @@ extern "C" { #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS) +#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##INFO ## ", "", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS); @@ -54,6 +55,7 @@ extern "C" { #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##WARN ## ", "\n", FMT, ##ARGS) +#define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##INFO ## ", "\n", FMT, ##ARGS) #define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);