2021-01-01 01:39:28 +01:00
|
|
|
#include "RPXLoading.h"
|
2022-02-04 16:35:35 +01:00
|
|
|
#include "globals.h"
|
2021-01-17 13:57:57 +01:00
|
|
|
#include "utils/FileReader.h"
|
|
|
|
#include "utils/StringTools.h"
|
|
|
|
#include "utils/ini.h"
|
2022-02-04 16:35:35 +01:00
|
|
|
#include "utils/logger.h"
|
|
|
|
#include <coreinit/cache.h>
|
2022-03-12 21:21:21 +01:00
|
|
|
#include <coreinit/debug.h>
|
2022-02-04 16:35:35 +01:00
|
|
|
#include <coreinit/ios.h>
|
2021-01-17 13:57:57 +01:00
|
|
|
#include <cstring>
|
2022-03-12 21:21:21 +01:00
|
|
|
#include <mutex>
|
2022-02-04 16:35:35 +01:00
|
|
|
#include <nn/acp/title.h>
|
|
|
|
#include <romfs_dev.h>
|
2022-03-12 21:21:21 +01:00
|
|
|
#include <rpxloader/rpxloader.h>
|
2022-02-04 16:35:35 +01:00
|
|
|
#include <string>
|
2022-03-12 21:21:21 +01:00
|
|
|
#include <wuhb_utils/utils.h>
|
|
|
|
|
|
|
|
std::mutex fileReaderListMutex;
|
2022-05-08 19:29:42 +02:00
|
|
|
std::forward_list<std::unique_ptr<FileReader>> openFileReaders;
|
2022-03-12 21:21:21 +01:00
|
|
|
|
|
|
|
void RPXLoadingCleanUp() {
|
|
|
|
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
|
|
|
openFileReaders.clear();
|
|
|
|
}
|
2021-01-01 01:39:28 +01:00
|
|
|
|
2021-01-17 13:57:57 +01:00
|
|
|
/*
|
|
|
|
* Patch the meta xml for the home menu
|
|
|
|
*/
|
|
|
|
DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *metaxml, uint32_t device) {
|
2021-04-05 19:54:50 +02:00
|
|
|
if (gReplacementInfo.rpxReplacementInfo.isRPXReplaced) {
|
2021-01-17 13:57:57 +01:00
|
|
|
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
2021-04-05 19:54:50 +02:00
|
|
|
|
|
|
|
snprintf(metaxml->longname_en, sizeof(metaxml->longname_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
|
|
|
snprintf(metaxml->shortname_en, sizeof(metaxml->shortname_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
|
|
|
snprintf(metaxml->publisher_en, sizeof(metaxml->publisher_en), "%s", gReplacementInfo.rpxReplacementInfo.metaInformation.longname);
|
2021-01-24 15:45:30 +01:00
|
|
|
|
|
|
|
// Disbale the emanual
|
2021-01-17 13:57:57 +01:00
|
|
|
metaxml->e_manual = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int result = real_HBM_NN_ACP_ACPGetTitleMetaXmlByDevice(titleid_upper, titleid_lower, metaxml, device);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-05-08 19:29:42 +02:00
|
|
|
DECL_FUNCTION(int, RPX_FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, uint32_t *handle, int error) {
|
2022-03-12 21:21:21 +01:00
|
|
|
const char *iconTex = "iconTex.tga";
|
|
|
|
std::string_view pathView = path;
|
|
|
|
if (gReplacementInfo.rpxReplacementInfo.isRPXReplaced && pathView.ends_with(iconTex)) {
|
|
|
|
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
2022-05-08 19:29:42 +02:00
|
|
|
auto reader = make_unique_nothrow<FileReader>(reinterpret_cast<uint8_t *>(gReplacementInfo.rpxReplacementInfo.iconCache), ICON_SIZE);
|
2022-03-12 21:21:21 +01:00
|
|
|
if (!reader) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to allocate memory for the FileReader");
|
|
|
|
return FS_STATUS_FATAL_ERROR;
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
2022-05-08 19:29:42 +02:00
|
|
|
*handle = reader->getHandle();
|
|
|
|
openFileReaders.push_front(std::move(reader));
|
2022-03-12 21:21:21 +01:00
|
|
|
return FS_STATUS_OK;
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
int result = real_RPX_FSOpenFile(client, block, path, mode, handle, error);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_FUNCTION(FSStatus, RPX_FSReadFile, FSClient *client, FSCmdBlock *block, uint8_t *buffer, uint32_t size, uint32_t count, FSFileHandle handle, uint32_t unk1, uint32_t flags) {
|
2022-03-12 21:21:21 +01:00
|
|
|
if (gReplacementInfo.rpxReplacementInfo.isRPXReplaced) {
|
|
|
|
const std::lock_guard<std::mutex> lock(fileReaderListMutex);
|
|
|
|
for (auto &reader : openFileReaders) {
|
2022-05-08 19:29:42 +02:00
|
|
|
if ((uint32_t) reader->getHandle() == (uint32_t) handle) {
|
2022-03-12 21:21:21 +01:00
|
|
|
return (FSStatus) (reader->read(buffer, size * count) / size);
|
|
|
|
}
|
|
|
|
}
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
2022-03-12 21:21:21 +01:00
|
|
|
return real_RPX_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DECL_FUNCTION(FSStatus, RPX_FSCloseFile, FSClient *client, FSCmdBlock *block, FSFileHandle handle, uint32_t flags) {
|
2022-03-12 21:21:21 +01:00
|
|
|
if (gReplacementInfo.rpxReplacementInfo.isRPXReplaced) {
|
2022-05-08 19:29:42 +02:00
|
|
|
if (remove_locked_first_if(fileReaderListMutex, openFileReaders, [handle](auto &cur) { return cur->getHandle() == (uint32_t) handle; })) {
|
2022-03-12 21:21:21 +01:00
|
|
|
return FS_STATUS_OK;
|
|
|
|
}
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return real_RPX_FSCloseFile(client, block, handle, flags);
|
|
|
|
}
|
|
|
|
|
2021-03-13 13:58:34 +01:00
|
|
|
DECL_FUNCTION(void, Loader_ReportWarn) {
|
|
|
|
}
|
|
|
|
|
2021-01-17 13:57:57 +01:00
|
|
|
function_replacement_data_t rpx_utils_function_replacements[] = {
|
2021-03-13 13:58:34 +01:00
|
|
|
REPLACE_FUNCTION_VIA_ADDRESS(Loader_ReportWarn, 0x32002f74, 0x01002f74),
|
2021-01-17 13:57:57 +01:00
|
|
|
REPLACE_FUNCTION_VIA_ADDRESS_FOR_PROCESS(HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, 0x2E36CE44, 0x0E36CE44, FP_TARGET_PROCESS_HOME_MENU),
|
|
|
|
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSOpenFile, LIBRARY_COREINIT, FSOpenFile, FP_TARGET_PROCESS_HOME_MENU),
|
|
|
|
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSReadFile, LIBRARY_COREINIT, FSReadFile, FP_TARGET_PROCESS_HOME_MENU),
|
|
|
|
REPLACE_FUNCTION_FOR_PROCESS(RPX_FSCloseFile, LIBRARY_COREINIT, FSCloseFile, FP_TARGET_PROCESS_HOME_MENU),
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t rpx_utils_function_replacements_size = sizeof(rpx_utils_function_replacements) / sizeof(function_replacement_data_t);
|
|
|
|
|
|
|
|
static int parseINIhandler(void *user, const char *section, const char *name,
|
|
|
|
const char *value) {
|
2021-02-19 20:32:44 +01:00
|
|
|
auto *fInfo = (MetaInformation *) user;
|
2021-01-17 13:57:57 +01:00
|
|
|
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
|
|
|
if (MATCH("menu", "longname")) {
|
2021-04-05 19:54:50 +02:00
|
|
|
fInfo->longname[0] = '\0';
|
|
|
|
strncat(fInfo->longname, value, sizeof(fInfo->longname) - 1);
|
2021-01-17 13:57:57 +01:00
|
|
|
} else if (MATCH("menu", "shortname")) {
|
2021-04-05 19:54:50 +02:00
|
|
|
fInfo->shortname[0] = '\0';
|
|
|
|
strncat(fInfo->shortname, value, sizeof(fInfo->shortname) - 1);
|
2021-01-17 13:57:57 +01:00
|
|
|
} else if (MATCH("menu", "author")) {
|
2021-04-05 19:54:50 +02:00
|
|
|
fInfo->author[0] = '\0';
|
|
|
|
strncat(fInfo->author, value, sizeof(fInfo->author) - 1);
|
2021-01-17 13:57:57 +01:00
|
|
|
} else {
|
2022-02-04 16:35:35 +01:00
|
|
|
return 0; /* unknown section/name, error */
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
2021-01-01 01:39:28 +01:00
|
|
|
LOAD_REQUEST request;
|
|
|
|
memset(&request, 0, sizeof(request));
|
|
|
|
|
2022-02-04 16:35:35 +01:00
|
|
|
request.command = 0xFC; // IPC_CUSTOM_LOAD_CUSTOM_RPX;
|
|
|
|
request.target = 0; // LOAD_FILE_TARGET_SD_CARD
|
|
|
|
request.filesize = 0; // unknown filesize
|
|
|
|
request.fileoffset = 0; //
|
2021-01-01 01:39:28 +01:00
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
WUHBRPXInfo fileInfo;
|
2021-01-01 01:39:28 +01:00
|
|
|
|
2021-01-17 13:57:57 +01:00
|
|
|
bool metaLoaded = false;
|
|
|
|
|
|
|
|
std::string completePath = std::string("/vol/external01/") + bundle_path;
|
2022-03-12 21:21:21 +01:00
|
|
|
|
|
|
|
bool isBundle = false;
|
|
|
|
auto rpxInfo = WUHBUtils_GetRPXInfo(completePath.c_str(), BundleSource_FileDescriptor_CafeOS, &fileInfo);
|
|
|
|
if (rpxInfo == WUHB_UTILS_RESULT_SUCCESS) {
|
2022-02-04 16:35:35 +01:00
|
|
|
isBundle = true;
|
2022-03-12 21:21:21 +01:00
|
|
|
request.filesize = ((uint32_t *) &fileInfo.length)[1];
|
|
|
|
request.fileoffset = ((uint32_t *) &fileInfo.offset)[1];
|
|
|
|
auto res = -1;
|
|
|
|
|
|
|
|
if (WUHBUtils_MountBundle("rcc", completePath.c_str(), BundleSource_FileDescriptor_CafeOS, &res) == WUHB_UTILS_RESULT_SUCCESS && res == 0) {
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint32_t bufferSize;
|
|
|
|
if (WUHBUtils_ReadWholeFile("rcc:/meta/meta.ini", &buffer, &bufferSize) == WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
buffer[bufferSize - 1] = '\0';
|
2022-03-06 12:51:45 +01:00
|
|
|
if (ini_parse_string((const char *) buffer, parseINIhandler, &gReplacementInfo.rpxReplacementInfo.metaInformation) < 0) {
|
2022-03-12 21:21:21 +01:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to load and parse meta.ini");
|
2022-03-06 12:51:45 +01:00
|
|
|
} else {
|
|
|
|
metaLoaded = true;
|
|
|
|
}
|
2022-03-12 21:21:21 +01:00
|
|
|
free(buffer);
|
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to read whole file meta.ini");
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
2022-03-12 21:21:21 +01:00
|
|
|
buffer = nullptr;
|
|
|
|
bufferSize = 0;
|
|
|
|
|
|
|
|
if (WUHBUtils_ReadWholeFile("rcc:/meta/iconTex.tga", &buffer, &bufferSize) == WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
uint32_t cpySize = ICON_SIZE;
|
|
|
|
if (bufferSize < cpySize) {
|
|
|
|
cpySize = bufferSize;
|
|
|
|
memset(gReplacementInfo.rpxReplacementInfo.iconCache, 0, ICON_SIZE);
|
|
|
|
}
|
|
|
|
memcpy(gReplacementInfo.rpxReplacementInfo.iconCache, buffer, cpySize);
|
2022-03-06 12:51:45 +01:00
|
|
|
free(buffer);
|
2022-03-12 21:21:21 +01:00
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to read iconTex.tga");
|
2022-03-06 12:51:45 +01:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
auto outRes = 0;
|
|
|
|
if (WUHBUtils_UnmountBundle("rcc", &outRes) != WUHB_UTILS_RESULT_SUCCESS || outRes != WUHB_UTILS_RESULT_SUCCESS) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to unmount bundle");
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-05 19:54:50 +02:00
|
|
|
} else {
|
2022-03-12 21:21:21 +01:00
|
|
|
if (!gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) {
|
2021-04-05 19:54:50 +02:00
|
|
|
memset(gReplacementInfo.rpxReplacementInfo.iconCache, 0, sizeof(gReplacementInfo.rpxReplacementInfo.iconCache));
|
|
|
|
}
|
2021-01-01 01:39:28 +01:00
|
|
|
}
|
|
|
|
|
2021-01-17 13:57:57 +01:00
|
|
|
if (!metaLoaded) {
|
2022-02-04 16:35:35 +01:00
|
|
|
gReplacementInfo.rpxReplacementInfo.metaInformation.author[0] = '\0';
|
2021-04-05 19:54:50 +02:00
|
|
|
gReplacementInfo.rpxReplacementInfo.metaInformation.shortname[0] = '\0';
|
2022-02-04 16:35:35 +01:00
|
|
|
gReplacementInfo.rpxReplacementInfo.metaInformation.longname[0] = '\0';
|
2021-04-05 19:54:50 +02:00
|
|
|
|
|
|
|
strncat(gReplacementInfo.rpxReplacementInfo.metaInformation.author, bundle_path, sizeof(gReplacementInfo.rpxReplacementInfo.metaInformation.author) - 1);
|
|
|
|
strncat(gReplacementInfo.rpxReplacementInfo.metaInformation.shortname, bundle_path, sizeof(gReplacementInfo.rpxReplacementInfo.metaInformation.shortname) - 1);
|
|
|
|
strncat(gReplacementInfo.rpxReplacementInfo.metaInformation.longname, bundle_path, sizeof(gReplacementInfo.rpxReplacementInfo.metaInformation.longname) - 1);
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
2021-04-05 19:54:50 +02:00
|
|
|
request.path[0] = '\0';
|
|
|
|
strncat(request.path, bundle_path, sizeof(request.path) - 1);
|
2021-01-01 01:39:28 +01:00
|
|
|
|
2022-02-13 17:33:46 +01:00
|
|
|
OSMemoryBarrier();
|
2021-01-01 01:39:28 +01:00
|
|
|
|
2021-02-19 20:32:44 +01:00
|
|
|
int success = false;
|
2022-02-04 16:35:35 +01:00
|
|
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
2021-01-01 01:39:28 +01:00
|
|
|
if (mcpFd >= 0) {
|
2022-07-25 22:11:07 +02:00
|
|
|
if (IOS_Ioctl(mcpFd, 100, &request, sizeof(request), nullptr, 0) == IOS_ERROR_OK) {
|
2021-02-19 20:32:44 +01:00
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
|
2021-01-01 01:39:28 +01:00
|
|
|
IOS_Close(mcpFd);
|
|
|
|
}
|
|
|
|
|
2022-02-13 17:33:46 +01:00
|
|
|
OSMemoryBarrier();
|
2021-02-19 20:32:44 +01:00
|
|
|
|
|
|
|
if (!success) {
|
2021-04-13 20:14:50 +02:00
|
|
|
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = false;
|
2022-03-12 21:21:21 +01:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("Failed to load %s on next restart", request.path);
|
2021-02-19 20:32:44 +01:00
|
|
|
return false;
|
2021-04-05 19:54:50 +02:00
|
|
|
} else {
|
2021-04-13 20:14:50 +02:00
|
|
|
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = true;
|
2021-02-19 20:32:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_FUNCTION_LINE("Launch %s on next restart [size: %08X offset: %08X]", request.path, request.filesize, request.fileoffset);
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath[0] = '\0';
|
2021-01-17 13:57:57 +01:00
|
|
|
if (isBundle) {
|
2022-03-12 21:21:21 +01:00
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Loaded file is a .wuhb bundle");
|
2021-04-05 19:54:50 +02:00
|
|
|
strncat(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath,
|
|
|
|
completePath.c_str(),
|
|
|
|
sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 1);
|
2021-01-17 13:57:57 +01:00
|
|
|
} else {
|
2022-03-12 21:21:21 +01:00
|
|
|
DEBUG_FUNCTION_LINE_VERBOSE("Loaded file is no bundle");
|
2021-04-13 20:14:50 +02:00
|
|
|
gReplacementInfo.rpxReplacementInfo.willRPXBeReplaced = true;
|
2021-04-05 19:54:50 +02:00
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
if (gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted) {
|
2021-01-09 21:23:48 +01:00
|
|
|
// keep the old /vol/content mounted, this way you can reload just the rpx via wiiload
|
2021-04-05 19:54:50 +02:00
|
|
|
strncat(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath,
|
|
|
|
gReplacementInfo.contentReplacementInfo.bundleMountInformation.mountedPath,
|
2022-01-26 23:19:27 +01:00
|
|
|
sizeof(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) - 2);
|
2021-01-09 21:23:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-13 17:33:46 +01:00
|
|
|
OSMemoryBarrier();
|
2021-02-19 20:32:44 +01:00
|
|
|
|
2021-01-01 01:39:28 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
std::mutex mutex;
|
2021-01-17 13:57:57 +01:00
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
bool RL_DisableContentRedirection() {
|
|
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
|
|
if (contentLayerHandle != 0) {
|
|
|
|
auto res = ContentRedirection_SetActive(contentLayerHandle, false);
|
|
|
|
if (res != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (saveLayerHandle != 0) {
|
|
|
|
auto res = ContentRedirection_SetActive(saveLayerHandle, false);
|
|
|
|
if (res != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
ContentRedirection_SetActive(contentLayerHandle, true);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
bool RL_EnableContentRedirection() {
|
|
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
|
|
if (contentLayerHandle != 0) {
|
|
|
|
auto res = ContentRedirection_SetActive(contentLayerHandle, true);
|
|
|
|
if (res != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-09-28 18:18:03 +02:00
|
|
|
}
|
2022-03-12 21:21:21 +01:00
|
|
|
if (saveLayerHandle != 0) {
|
|
|
|
auto res = ContentRedirection_SetActive(saveLayerHandle, true);
|
|
|
|
if (res != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
ContentRedirection_SetActive(contentLayerHandle, false);
|
|
|
|
return false;
|
2021-09-28 18:18:03 +02:00
|
|
|
}
|
|
|
|
}
|
2022-03-12 21:21:21 +01:00
|
|
|
return true;
|
2021-09-28 18:18:03 +02:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
bool RL_UnmountCurrentRunningBundle() {
|
|
|
|
std::lock_guard<std::mutex> lock(mutex);
|
|
|
|
if (gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted == false) {
|
|
|
|
return true;
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
int outRes = -1;
|
|
|
|
if (ContentRedirection_RemoveDevice(WUHB_ROMFS_NAME, &outRes) == CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
if (outRes < 0) {
|
|
|
|
DEBUG_FUNCTION_LINE_ERR("RemoveDevice \"%s\" failed for ContentRedirection Module", WUHB_ROMFS_NAME);
|
|
|
|
OSFatal("RL_UnmountCurrentRunningBundle: RemoveDevice \"" WUHB_ROMFS_NAME "\" failed for ContentRedirection Module");
|
|
|
|
}
|
2021-01-17 13:57:57 +01:00
|
|
|
} else {
|
2022-03-12 21:21:21 +01:00
|
|
|
DEBUG_FUNCTION_LINE_ERR("ContentRedirection_RemoveDevice failed");
|
|
|
|
OSFatal("RL_UnmountCurrentRunningBundle: ContentRedirection_RemoveDevice failed");
|
2021-01-17 13:57:57 +01:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
bool res = true;
|
2021-01-17 13:57:57 +01:00
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
if (contentLayerHandle != 0) {
|
|
|
|
if (ContentRedirection_RemoveFSLayer(contentLayerHandle) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
contentLayerHandle = 0;
|
|
|
|
}
|
2021-01-17 13:57:57 +01:00
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
if (saveLayerHandle != 0) {
|
|
|
|
if (ContentRedirection_RemoveFSLayer(saveLayerHandle) != CONTENT_REDIRECTION_RESULT_SUCCESS) {
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
saveLayerHandle = 0;
|
2021-04-05 21:32:40 +02:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
romfsUnmount(WUHB_ROMFS_NAME);
|
|
|
|
gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted = false;
|
|
|
|
OSMemoryBarrier();
|
|
|
|
return res;
|
2021-04-05 21:32:40 +02:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
RPXLoaderVersion RL_GetVersion() {
|
|
|
|
return RPX_LOADER_MODULE_VERSION;
|
2021-04-05 21:39:01 +02:00
|
|
|
}
|
|
|
|
|
2022-03-12 21:21:21 +01:00
|
|
|
WUMS_EXPORT_FUNCTION(RL_GetVersion);
|
2021-01-17 13:57:57 +01:00
|
|
|
WUMS_EXPORT_FUNCTION(RL_LoadFromSDOnNextLaunch);
|
2022-03-12 21:21:21 +01:00
|
|
|
WUMS_EXPORT_FUNCTION(RL_EnableContentRedirection);
|
2021-09-28 18:18:03 +02:00
|
|
|
WUMS_EXPORT_FUNCTION(RL_DisableContentRedirection);
|
|
|
|
WUMS_EXPORT_FUNCTION(RL_UnmountCurrentRunningBundle);
|