mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-11-25 11:26:53 +01:00
Use libmocha to load .rpx
This commit is contained in:
parent
3ceb7c8dfc
commit
5ebee36b7f
2
Makefile
2
Makefile
@ -49,7 +49,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
|
|||||||
CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
|
CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LIBS := -lwums -lwut -lfunctionpatcher -lcontentredirection -lwuhbutils -lromfs
|
LIBS := -lwums -lwut -lfunctionpatcher -lcontentredirection -lwuhbutils -lmocha -lromfs
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level
|
# list of directories containing libraries, this must be the top level
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/ios.h>
|
#include <coreinit/ios.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <mocha/mocha.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <nn/acp/title.h>
|
#include <nn/acp/title.h>
|
||||||
#include <romfs_dev.h>
|
#include <romfs_dev.h>
|
||||||
@ -117,11 +118,10 @@ static int parseINIhandler(void *user, const char *section, const char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
||||||
LOAD_REQUEST request;
|
MochaRPXLoadInfo request;
|
||||||
memset(&request, 0, sizeof(request));
|
memset(&request, 0, sizeof(request));
|
||||||
|
|
||||||
request.command = 0xFC; // IPC_CUSTOM_LOAD_CUSTOM_RPX;
|
request.target = LOAD_RPX_TARGET_SD_CARD; // LOAD_FILE_TARGET_SD_CARD
|
||||||
request.target = 0; // LOAD_FILE_TARGET_SD_CARD
|
|
||||||
request.filesize = 0; // unknown filesize
|
request.filesize = 0; // unknown filesize
|
||||||
request.fileoffset = 0; //
|
request.fileoffset = 0; //
|
||||||
|
|
||||||
@ -193,20 +193,18 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
strncat(request.path, bundle_path, sizeof(request.path) - 1);
|
strncat(request.path, bundle_path, sizeof(request.path) - 1);
|
||||||
|
|
||||||
OSMemoryBarrier();
|
OSMemoryBarrier();
|
||||||
|
bool success = false;
|
||||||
int success = false;
|
MochaUtilsStatus res;
|
||||||
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
if ((res = Mocha_PrepareRPXLaunch(&request)) == MOCHA_RESULT_SUCCESS) {
|
||||||
if (mcpFd >= 0) {
|
|
||||||
if (IOS_Ioctl(mcpFd, 100, &request, sizeof(request), nullptr, 0) == IOS_ERROR_OK) {
|
|
||||||
success = true;
|
success = true;
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to prepare rpx launch: %s", Mocha_GetStatusStr(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
IOS_Close(mcpFd);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSMemoryBarrier();
|
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
request.target = LOAD_RPX_TARGET_EXTRA_REVERT_PREPARE;
|
||||||
|
Mocha_PrepareRPXLaunch(&request);
|
||||||
|
|
||||||
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = false;
|
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = false;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to load %s on next restart", request.path);
|
DEBUG_FUNCTION_LINE_ERR("Failed to load %s on next restart", request.path);
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <coreinit/debug.h>
|
#include <coreinit/debug.h>
|
||||||
#include <coreinit/title.h>
|
#include <coreinit/title.h>
|
||||||
|
#include <mocha/mocha.h>
|
||||||
#include <nn/act.h>
|
#include <nn/act.h>
|
||||||
#include <romfs_dev.h>
|
#include <romfs_dev.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -51,6 +52,14 @@ WUMS_INITIALIZE() {
|
|||||||
OSFatal("Failed to init WUHBUtils.");
|
OSFatal("Failed to init WUHBUtils.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Init libmocha
|
||||||
|
MochaUtilsStatus error3;
|
||||||
|
if ((error3 = Mocha_InitLibrary()) != MOCHA_RESULT_SUCCESS) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to init libmocha. Error %s", Mocha_GetStatusStr(error3));
|
||||||
|
OSFatal("Failed to init libmocha. Make sure to use the latest version of MochaPayload");
|
||||||
|
}
|
||||||
|
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ extern "C" {
|
|||||||
LOG_FUNC("[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
LOG_FUNC("[(%s)%18s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#ifdef VERBOSE_DEBUG
|
#ifdef VERBOSE_DEBUG
|
||||||
@ -36,6 +35,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
@ -46,6 +47,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
||||||
|
|
||||||
|
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX(OSReport, "##WARN ## ", "\n", FMT, ##ARGS)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initLogging();
|
void initLogging();
|
||||||
|
Loading…
Reference in New Issue
Block a user