diff --git a/src/globals.cpp b/src/globals.cpp new file mode 100644 index 0000000..dec8437 --- /dev/null +++ b/src/globals.cpp @@ -0,0 +1,3 @@ +#include "globals.h" + +bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false; diff --git a/src/globals.h b/src/globals.h new file mode 100644 index 0000000..1fdb9da --- /dev/null +++ b/src/globals.h @@ -0,0 +1,3 @@ +#include + +extern bool gLibRPXLoaderInitDone; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8d8b7af..2babf59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "globals.h" #include "utils/TcpReceiver.h" #include "utils/logger.h" #include @@ -18,7 +19,8 @@ INITIALIZE_PLUGIN() { RPXLoaderStatus error; if ((error = RPXLoader_InitLibrary()) != RPX_LOADER_RESULT_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("WiiLoad Plugin: Failed to init RPXLoader. Error %d", error); - OSFatal("WiiLoad Plugin: Failed to init RPXLoader."); + } else { + gLibRPXLoaderInitDone = true; } } diff --git a/src/utils/TcpReceiver.cpp b/src/utils/TcpReceiver.cpp index ae0d13a..9a7b19a 100644 --- a/src/utils/TcpReceiver.cpp +++ b/src/utils/TcpReceiver.cpp @@ -1,5 +1,6 @@ #include "TcpReceiver.h" #include "fs/FSUtils.h" +#include "globals.h" #include "utils/net.h" #include "utils/utils.h" #include @@ -299,11 +300,15 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { free(loadAddress); if (!res) { - DEBUG_FUNCTION_LINE_ERR("Failed to launch save a executable to the sd card"); + DEBUG_FUNCTION_LINE_ERR("Failed to launch save a homebrew to the sd card"); return NOT_ENOUGH_MEMORY; } if (loadedRPX) { + if (!gLibRPXLoaderInitDone) { + DEBUG_FUNCTION_LINE_ERR("RPXLoaderModule missing, failed to launch homebrew."); + return NOT_SUPPORTED; + } RPXLoaderStatus launchRes; if ((launchRes = RPXLoader_LaunchHomebrew(file_path)) != RPX_LOADER_RESULT_SUCCESS) { DEBUG_FUNCTION_LINE_ERR("Failed to start %s %s", file_path, RPXLoader_GetStatusStr(launchRes)); diff --git a/src/utils/TcpReceiver.h b/src/utils/TcpReceiver.h index efe1094..6741af2 100644 --- a/src/utils/TcpReceiver.h +++ b/src/utils/TcpReceiver.h @@ -14,6 +14,7 @@ public: FILE_READ_ERROR = -3, NOT_ENOUGH_MEMORY = -4, NOT_A_VALID_PLUGIN = -5, + NOT_SUPPORTED = -6, }; explicit TcpReceiver(int32_t port);