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/logger.h"
#include <coreinit/debug.h>
@ -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;
}
}

View File

@ -1,5 +1,6 @@
#include "TcpReceiver.h"
#include "fs/FSUtils.h"
#include "globals.h"
#include "utils/net.h"
#include "utils/utils.h"
#include <algorithm>
@ -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));

View File

@ -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);