Support using the plugin without RPXLoadingModule

This commit is contained in:
Maschell 2022-08-25 15:53:37 +02:00
parent b406c05c7b
commit b65dd08792
5 changed files with 16 additions and 2 deletions

3
src/globals.cpp Normal file
View File

@ -0,0 +1,3 @@
#include "globals.h"
bool gLibRPXLoaderInitDone __attribute__((section(".data"))) = false;

3
src/globals.h Normal file
View File

@ -0,0 +1,3 @@
#include <stdint.h>
extern bool gLibRPXLoaderInitDone;

View File

@ -1,3 +1,4 @@
#include "globals.h"
#include "utils/TcpReceiver.h" #include "utils/TcpReceiver.h"
#include "utils/logger.h" #include "utils/logger.h"
#include <coreinit/debug.h> #include <coreinit/debug.h>
@ -18,7 +19,8 @@ INITIALIZE_PLUGIN() {
RPXLoaderStatus error; RPXLoaderStatus error;
if ((error = RPXLoader_InitLibrary()) != RPX_LOADER_RESULT_SUCCESS) { if ((error = RPXLoader_InitLibrary()) != RPX_LOADER_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("WiiLoad Plugin: Failed to init RPXLoader. Error %d", error); DEBUG_FUNCTION_LINE_ERR("WiiLoad Plugin: Failed to init RPXLoader. Error %d", error);
OSFatal("WiiLoad Plugin: Failed to init RPXLoader."); } else {
gLibRPXLoaderInitDone = true;
} }
} }

View File

@ -1,5 +1,6 @@
#include "TcpReceiver.h" #include "TcpReceiver.h"
#include "fs/FSUtils.h" #include "fs/FSUtils.h"
#include "globals.h"
#include "utils/net.h" #include "utils/net.h"
#include "utils/utils.h" #include "utils/utils.h"
#include <algorithm> #include <algorithm>
@ -299,11 +300,15 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
free(loadAddress); free(loadAddress);
if (!res) { 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; return NOT_ENOUGH_MEMORY;
} }
if (loadedRPX) { if (loadedRPX) {
if (!gLibRPXLoaderInitDone) {
DEBUG_FUNCTION_LINE_ERR("RPXLoaderModule missing, failed to launch homebrew.");
return NOT_SUPPORTED;
}
RPXLoaderStatus launchRes; RPXLoaderStatus launchRes;
if ((launchRes = RPXLoader_LaunchHomebrew(file_path)) != RPX_LOADER_RESULT_SUCCESS) { if ((launchRes = RPXLoader_LaunchHomebrew(file_path)) != RPX_LOADER_RESULT_SUCCESS) {
DEBUG_FUNCTION_LINE_ERR("Failed to start %s %s", file_path, RPXLoader_GetStatusStr(launchRes)); DEBUG_FUNCTION_LINE_ERR("Failed to start %s %s", file_path, RPXLoader_GetStatusStr(launchRes));

View File

@ -14,6 +14,7 @@ public:
FILE_READ_ERROR = -3, FILE_READ_ERROR = -3,
NOT_ENOUGH_MEMORY = -4, NOT_ENOUGH_MEMORY = -4,
NOT_A_VALID_PLUGIN = -5, NOT_A_VALID_PLUGIN = -5,
NOT_SUPPORTED = -6,
}; };
explicit TcpReceiver(int32_t port); explicit TcpReceiver(int32_t port);