mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-11-22 09:59:17 +01:00
Reimplement RPX/Bundle loading logic.
This commit is contained in:
parent
158db91f7a
commit
06e92de8e5
@ -346,13 +346,13 @@ DECL_FUNCTION(FSStatus, FSGetFreeSpaceSizeAsync, FSClient *client, FSCmdBlock *b
|
|||||||
|
|
||||||
DECL_FUNCTION(FSStatus, FSChangeDirAsync, FSClient *client, FSCmdBlock *block, const char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
DECL_FUNCTION(FSStatus, FSChangeDirAsync, FSClient *client, FSCmdBlock *block, const char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
|
||||||
DEBUG_FUNCTION_LINE("FSChangeDirAsync %s", path);
|
DEBUG_FUNCTION_LINE("FSChangeDirAsync %s", path);
|
||||||
strncpy(gWorkingDir, path, sizeof(gWorkingDir));
|
strncpy(gReplacementInfo.bundleMountInformation.workingDir, path, sizeof(gReplacementInfo.bundleMountInformation.workingDir));
|
||||||
int len = strlen(gWorkingDir);
|
int len = strlen(gReplacementInfo.bundleMountInformation.workingDir);
|
||||||
if(len > 0 && gWorkingDir[len-1] != '/'){
|
if(len > 0 && gReplacementInfo.bundleMountInformation.workingDir[len-1] != '/'){
|
||||||
gWorkingDir[len-1] = '/';
|
gReplacementInfo.bundleMountInformation.workingDir[len-1] = '/';
|
||||||
gWorkingDir[len] = 0;
|
gReplacementInfo.bundleMountInformation.workingDir[len] = 0;
|
||||||
}
|
}
|
||||||
DCFlushRange(gWorkingDir, sizeof(gWorkingDir));
|
DCFlushRange(gReplacementInfo.bundleMountInformation.workingDir, sizeof(gReplacementInfo.bundleMountInformation.workingDir));
|
||||||
return real_FSChangeDirAsync(client, block, path, errorMask, asyncData);
|
return real_FSChangeDirAsync(client, block, path, errorMask, asyncData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ std::mutex file_handle_mutex;
|
|||||||
|
|
||||||
inline void getFullPath(char *pathForCheck, int pathSize, char *path) {
|
inline void getFullPath(char *pathForCheck, int pathSize, char *path) {
|
||||||
if (path[0] != '/' && path[0] != '\\') {
|
if (path[0] != '/' && path[0] != '\\') {
|
||||||
snprintf(pathForCheck, pathSize, "%s%s", gWorkingDir, path);
|
snprintf(pathForCheck, pathSize, "%s%s", gReplacementInfo.bundleMountInformation.workingDir, path);
|
||||||
DEBUG_FUNCTION_LINE_VERBOSE("Real path is %s", path);
|
DEBUG_FUNCTION_LINE_VERBOSE("Real path is %s", path);
|
||||||
} else {
|
} else {
|
||||||
strncpy(pathForCheck, path, pathSize - 1);
|
strncpy(pathForCheck, path, pathSize - 1);
|
||||||
@ -33,7 +33,7 @@ inline bool checkForSave(char *pathForCheck, int pathSize, char *path) {
|
|||||||
memcpy(copy, path, copyLen);
|
memcpy(copy, path, copyLen);
|
||||||
copy[copyLen] = 0;
|
copy[copyLen] = 0;
|
||||||
memset(pathForCheck,0, pathSize);
|
memset(pathForCheck,0, pathSize);
|
||||||
snprintf(pathForCheck, pathSize, "%s%s", gSavePath, ©[9]);
|
snprintf(pathForCheck, pathSize, "%s%s", gReplacementInfo.savePath, ©[9]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -127,7 +127,7 @@ FSStatus FSOpenDirWrapper(char *path,
|
|||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
std::function<FSStatus(char *_path)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
|||||||
FSDirectoryEntry *entry,
|
FSDirectoryEntry *entry,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidDirHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidDirHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ FSStatus FSReadDirWrapper(FSDirectoryHandle handle,
|
|||||||
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidDirHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidDirHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -257,7 +257,7 @@ FSStatus FSCloseDirWrapper(FSDirectoryHandle handle,
|
|||||||
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
FSStatus FSRewindDirWrapper(FSDirectoryHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidDirHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidDirHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -278,7 +278,7 @@ FSStatus FSMakeDirWrapper(char *path,
|
|||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
std::function<FSStatus(char *_path)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ FSStatus FSOpenFileWrapper(char *path,
|
|||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
std::function<FSStatus(char *_path)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
@ -386,7 +386,7 @@ FSStatus FSOpenFileWrapper(char *path,
|
|||||||
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ FSStatus FSCloseFileWrapper(FSFileHandle handle,
|
|||||||
FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask,
|
FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
std::function<FSStatus(char *_path)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
@ -470,7 +470,7 @@ FSStatus FSGetStatFileWrapper(FSFileHandle handle,
|
|||||||
FSStat *stats,
|
FSStat *stats,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -511,7 +511,7 @@ FSStatus FSReadFileWrapper(void *buffer,
|
|||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -556,7 +556,7 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
|
|||||||
int32_t unk1,
|
int32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
FSStatus result;
|
FSStatus result;
|
||||||
@ -579,7 +579,7 @@ FSStatus FSSetPosFileWrapper(FSFileHandle handle,
|
|||||||
uint32_t pos,
|
uint32_t pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,7 +609,7 @@ FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
|||||||
uint32_t *pos,
|
uint32_t *pos,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -640,7 +640,7 @@ FSStatus FSGetPosFileWrapper(FSFileHandle handle,
|
|||||||
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
FSStatus FSIsEofWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -674,7 +674,7 @@ FSStatus FSIsEofWrapper(FSFileHandle handle,
|
|||||||
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
FSStatus FSTruncateFileWrapper(FSFileHandle handle,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
uint32_t handle_index = handle & HANDLE_MASK;
|
uint32_t handle_index = handle & HANDLE_MASK;
|
||||||
@ -697,7 +697,7 @@ FSStatus FSWriteFileWrapper(uint8_t *buffer,
|
|||||||
uint32_t unk1,
|
uint32_t unk1,
|
||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
FSStatus result = FS_STATUS_OK;
|
FSStatus result = FS_STATUS_OK;
|
||||||
@ -711,7 +711,7 @@ FSStatus FSRemoveWrapper(char *path,
|
|||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_path)> fallback_function,
|
std::function<FSStatus(char *_path)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +740,7 @@ FSStatus FSRenameWrapper(char *oldPath,
|
|||||||
FSErrorFlag errorMask,
|
FSErrorFlag errorMask,
|
||||||
std::function<FSStatus(char *_oldPath, char *_newPath)> fallback_function,
|
std::function<FSStatus(char *_oldPath, char *_newPath)> fallback_function,
|
||||||
std::function<FSStatus(FSStatus)> result_handler) {
|
std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,7 +767,7 @@ FSStatus FSRenameWrapper(char *oldPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, std::function<FSStatus(FSStatus)> result_handler) {
|
FSStatus FSFlushFileWrapper(FSFileHandle handle, FSErrorFlag errorMask, std::function<FSStatus(FSStatus)> result_handler) {
|
||||||
if (!gIsMounted || !isValidFileHandle(handle)) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted || !isValidFileHandle(handle)) {
|
||||||
return FS_STATUS_USE_REAL_OS;
|
return FS_STATUS_USE_REAL_OS;
|
||||||
}
|
}
|
||||||
FSStatus result = FS_STATUS_OK;
|
FSStatus result = FS_STATUS_OK;
|
||||||
|
@ -16,17 +16,16 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <rpxloader.h>
|
#include <rpxloader.h>
|
||||||
|
|
||||||
char gIconCache[65580] __attribute__((section(".data")));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Patch the meta xml for the home menu
|
* 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) {
|
DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *metaxml, uint32_t device) {
|
||||||
if (gReplacedRPX) {
|
if (gReplacementInfo.isRPXReplaced) {
|
||||||
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
memset(&metaxml->longname_ja, 0, 0x338C - 0x38C); // clear all names
|
||||||
strncpy(metaxml->longname_en, gBundleInfo.longname, sizeof(gBundleInfo.longname));
|
strncpy(metaxml->longname_en, gReplacementInfo.metaInformation.longname, sizeof(gReplacementInfo.metaInformation.longname));
|
||||||
strncpy(metaxml->shortname_en, gBundleInfo.shortname, sizeof(gBundleInfo.longname));
|
strncpy(metaxml->shortname_en, gReplacementInfo.metaInformation.shortname, sizeof(gReplacementInfo.metaInformation.shortname));
|
||||||
strncpy(metaxml->publisher_en, gBundleInfo.author, sizeof(gBundleInfo.longname));
|
strncpy(metaxml->publisher_en, gReplacementInfo.metaInformation.author, sizeof(gReplacementInfo.metaInformation.author));
|
||||||
|
|
||||||
// Disbale the emanual
|
// Disbale the emanual
|
||||||
metaxml->e_manual = 0;
|
metaxml->e_manual = 0;
|
||||||
@ -40,9 +39,9 @@ DECL_FUNCTION(int32_t, HBM_NN_ACP_ACPGetTitleMetaXmlByDevice, uint32_t titleid_u
|
|||||||
DECL_FUNCTION(int, RPX_FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, int *handle, int error) {
|
DECL_FUNCTION(int, RPX_FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, int *handle, int error) {
|
||||||
const char *iconTex = "iconTex.tga";
|
const char *iconTex = "iconTex.tga";
|
||||||
if (StringTools::EndsWith(path, iconTex)) {
|
if (StringTools::EndsWith(path, iconTex)) {
|
||||||
if (gReplacedRPX) {
|
if (gReplacementInfo.isRPXReplaced) {
|
||||||
if (StringTools::EndsWith(path, iconTex)) {
|
if (StringTools::EndsWith(path, iconTex)) {
|
||||||
auto *reader = new FileReader(reinterpret_cast<uint8_t *>(gIconCache), sizeof(gIconCache));
|
auto *reader = new FileReader(reinterpret_cast<uint8_t *>(gReplacementInfo.iconCache), sizeof(gReplacementInfo.iconCache));
|
||||||
*handle = (uint32_t) reader;
|
*handle = (uint32_t) reader;
|
||||||
return FS_STATUS_OK;
|
return FS_STATUS_OK;
|
||||||
}
|
}
|
||||||
@ -85,7 +84,7 @@ uint32_t rpx_utils_function_replacements_size = sizeof(rpx_utils_function_replac
|
|||||||
|
|
||||||
static int parseINIhandler(void *user, const char *section, const char *name,
|
static int parseINIhandler(void *user, const char *section, const char *name,
|
||||||
const char *value) {
|
const char *value) {
|
||||||
auto *fInfo = (BundleInformation *) user;
|
auto *fInfo = (MetaInformation *) user;
|
||||||
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
|
||||||
if (MATCH("menu", "longname")) {
|
if (MATCH("menu", "longname")) {
|
||||||
strncpy(fInfo->longname, value, 64 - 1);
|
strncpy(fInfo->longname, value, 64 - 1);
|
||||||
@ -113,16 +112,19 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
|
|
||||||
bool metaLoaded = false;
|
bool metaLoaded = false;
|
||||||
|
|
||||||
|
gReplacementInfo.replacementType = RPXLoader_RPX;
|
||||||
|
|
||||||
std::string completePath = std::string("/vol/external01/") + bundle_path;
|
std::string completePath = std::string("/vol/external01/") + bundle_path;
|
||||||
int res = getRPXInfoForPath(completePath, &info);
|
int res = getRPXInfoForPath(completePath, &info);
|
||||||
bool isBundle = false;
|
bool isBundle = false;
|
||||||
if (res >= 0) {
|
if (res >= 0) {
|
||||||
|
gReplacementInfo.replacementType = RPXLoader_BUNDLE;
|
||||||
isBundle = true;
|
isBundle = true;
|
||||||
request.filesize = ((uint32_t *) &info.length)[1];
|
request.filesize = ((uint32_t *) &info.length)[1];
|
||||||
request.fileoffset = ((uint32_t *) &info.offset)[1];
|
request.fileoffset = ((uint32_t *) &info.offset)[1];
|
||||||
|
|
||||||
if (romfsMount("rcc", completePath.c_str(), RomfsSource_FileDescriptor_CafeOS) == 0) {
|
if (romfsMount("rcc", completePath.c_str(), RomfsSource_FileDescriptor_CafeOS) == 0) {
|
||||||
if (ini_parse("rcc:/meta/meta.ini", parseINIhandler, &gBundleInfo) < 0) {
|
if (ini_parse("rcc:/meta/meta.ini", parseINIhandler, &gReplacementInfo.metaInformation) < 0) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to load and parse meta.ini");
|
DEBUG_FUNCTION_LINE("Failed to load and parse meta.ini");
|
||||||
} else {
|
} else {
|
||||||
metaLoaded = true;
|
metaLoaded = true;
|
||||||
@ -138,60 +140,74 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
|
|||||||
}
|
}
|
||||||
if (reader) {
|
if (reader) {
|
||||||
uint32_t alreadyRead = 0;
|
uint32_t alreadyRead = 0;
|
||||||
uint32_t toRead = sizeof(gIconCache);
|
uint32_t toRead = sizeof(gReplacementInfo.iconCache);
|
||||||
do {
|
do {
|
||||||
int read = reader->read(reinterpret_cast<uint8_t *>(&gIconCache[alreadyRead]), toRead);
|
int read = reader->read(reinterpret_cast<uint8_t *>(&gReplacementInfo.iconCache[alreadyRead]), toRead);
|
||||||
if (read <= 0) {
|
if (read <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
alreadyRead += read;
|
alreadyRead += read;
|
||||||
toRead -= read;
|
toRead -= read;
|
||||||
} while (alreadyRead < sizeof(gIconCache));
|
} while (alreadyRead < sizeof(gReplacementInfo.iconCache));
|
||||||
delete reader;
|
delete reader;
|
||||||
} else {
|
} else {
|
||||||
memset(gIconCache, 0, sizeof(gIconCache));
|
memset(gReplacementInfo.iconCache, 0, sizeof(gReplacementInfo.iconCache));
|
||||||
}
|
}
|
||||||
romfsUnmount("rcc");
|
romfsUnmount("rcc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!metaLoaded) {
|
if (!metaLoaded) {
|
||||||
strncpy(gBundleInfo.author, bundle_path, 64 - 1);
|
strncpy(gReplacementInfo.metaInformation.author, bundle_path, sizeof(gReplacementInfo.metaInformation.author));
|
||||||
strncpy(gBundleInfo.shortname, bundle_path, 64 - 1);
|
strncpy(gReplacementInfo.metaInformation.shortname, bundle_path, sizeof(gReplacementInfo.metaInformation.shortname));
|
||||||
strncpy(gBundleInfo.longname, bundle_path, 64 - 1);
|
strncpy(gReplacementInfo.metaInformation.longname, bundle_path, sizeof(gReplacementInfo.metaInformation.longname));
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(request.path, bundle_path, 255);
|
strncpy(request.path, bundle_path, 255);
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Launch %s on next restart [size: %08X offset: %08X]", request.path, request.filesize, request.fileoffset);
|
|
||||||
|
|
||||||
DCFlushRange(gIconCache, sizeof(gIconCache));
|
|
||||||
DCFlushRange(&request, sizeof(LOAD_REQUEST));
|
DCFlushRange(&request, sizeof(LOAD_REQUEST));
|
||||||
DCFlushRange(&gBundleInfo, sizeof(gBundleInfo));
|
|
||||||
|
|
||||||
|
int success = false;
|
||||||
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
||||||
if (mcpFd >= 0) {
|
if (mcpFd >= 0) {
|
||||||
int out = 0;
|
int out = 0;
|
||||||
IOS_Ioctl(mcpFd, 100, &request, sizeof(request), &out, sizeof(out));
|
IOS_Ioctl(mcpFd, 100, &request, sizeof(request), &out, sizeof(out));
|
||||||
|
if (out > 0) {
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
|
||||||
IOS_Close(mcpFd);
|
IOS_Close(mcpFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
gReplacementInfo.replacementType = RPXLoader_NONE;
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to load %s on next restart", request.path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Launch %s on next restart [size: %08X offset: %08X]", request.path, request.filesize, request.fileoffset);
|
||||||
|
|
||||||
if (isBundle) {
|
if (isBundle) {
|
||||||
DEBUG_FUNCTION_LINE("Loaded file is a .wuhb bundle");
|
DEBUG_FUNCTION_LINE("Loaded file is a .wuhb bundle");
|
||||||
gTryToReplaceOnNextLaunch = true;
|
memset(gReplacementInfo.bundleMountInformation.path, 0, sizeof(gReplacementInfo.bundleMountInformation.path));
|
||||||
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
strncpy(gReplacementInfo.bundleMountInformation.path, completePath.c_str(), completePath.length());
|
||||||
strncpy(gLoadedBundlePath, completePath.c_str(), completePath.length());
|
gReplacementInfo.replacementType = RPXLoader_BUNDLE;
|
||||||
|
gReplacementInfo.bundleMountInformation.redirectionRequested = true;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Loaded file is no bundle");
|
DEBUG_FUNCTION_LINE("Loaded file is no bundle");
|
||||||
if (!gIsMounted) {
|
if (!gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
gTryToReplaceOnNextLaunch = false;
|
memset(gReplacementInfo.bundleMountInformation.path, 0, sizeof(gReplacementInfo.bundleMountInformation.path));
|
||||||
memset(gLoadedBundlePath, 0, sizeof(gLoadedBundlePath));
|
|
||||||
} else {
|
} else {
|
||||||
|
gReplacementInfo.replacementType = RPXLoader_BUNDLE_OTHER_RPX;
|
||||||
|
gReplacementInfo.bundleMountInformation.redirectionRequested = true;
|
||||||
// keep the old /vol/content mounted, this way you can reload just the rpx via wiiload
|
// keep the old /vol/content mounted, this way you can reload just the rpx via wiiload
|
||||||
gTryToReplaceOnNextLaunch = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
bool gIsMounted __attribute__((section(".data"))) = false;
|
RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data")));
|
||||||
uint32_t gCurrentHash __attribute__((section(".data"))) = 0;
|
|
||||||
bool gTryToReplaceOnNextLaunch __attribute__((section(".data"))) = false;
|
|
||||||
char gLoadedBundlePath[256] __attribute__((section(".data")));
|
|
||||||
char gSavePath[256] __attribute__((section(".data")));
|
|
||||||
char gWorkingDir[256] __attribute__((section(".data")));
|
|
||||||
|
|
||||||
bool gReplacedRPX __attribute__((section(".data"))) = false;
|
|
||||||
BundleInformation gBundleInfo __attribute__((section(".data")));
|
|
@ -1,18 +1,34 @@
|
|||||||
#include <wums.h>
|
#include <wums.h>
|
||||||
#include <coreinit/mutex.h>
|
#include <coreinit/mutex.h>
|
||||||
|
|
||||||
typedef struct BundleInformation_t {
|
typedef struct MetaInformation_t {
|
||||||
char shortname[64];
|
char shortname[64];
|
||||||
char longname[64];
|
char longname[64];
|
||||||
char author[64];
|
char author[64];
|
||||||
} BundleInformation;
|
} MetaInformation;
|
||||||
|
|
||||||
|
typedef struct BundleMountInformation_t {
|
||||||
|
bool redirectionRequested;
|
||||||
|
bool isMounted;
|
||||||
|
char path[255];
|
||||||
|
char workingDir[255];
|
||||||
|
} BundleMountInformation;
|
||||||
|
|
||||||
extern bool gIsMounted;
|
typedef enum RPXLoader_Type {
|
||||||
extern bool gTryToReplaceOnNextLaunch;
|
RPXLoader_NONE,
|
||||||
extern char gLoadedBundlePath[256];
|
RPXLoader_RPX,
|
||||||
extern char gSavePath[256];
|
RPXLoader_BUNDLE,
|
||||||
extern char gWorkingDir[256];
|
RPXLoader_BUNDLE_OTHER_RPX,
|
||||||
extern uint32_t gCurrentHash;
|
} RPXLoader_Type;
|
||||||
extern bool gReplacedRPX;
|
|
||||||
extern BundleInformation gBundleInfo;
|
typedef struct RPXLoader_ReplacementInformation_t {
|
||||||
|
bool isRPXReplaced;
|
||||||
|
MetaInformation metaInformation;
|
||||||
|
RPXLoader_Type replacementType;
|
||||||
|
BundleMountInformation bundleMountInformation;
|
||||||
|
char iconCache[65580];
|
||||||
|
uint32_t currentHash;
|
||||||
|
char savePath[255];
|
||||||
|
} RPXLoader_ReplacementInformation;
|
||||||
|
|
||||||
|
extern RPXLoader_ReplacementInformation gReplacementInfo;
|
80
src/main.cpp
80
src/main.cpp
@ -27,16 +27,16 @@ WUMS_INITIALIZE() {
|
|||||||
FunctionPatcherPatchFunction(fs_dir_function_replacements, fs_dir_function_replacements_size);
|
FunctionPatcherPatchFunction(fs_dir_function_replacements, fs_dir_function_replacements_size);
|
||||||
FunctionPatcherPatchFunction(rpx_utils_function_replacements, rpx_utils_function_replacements_size);
|
FunctionPatcherPatchFunction(rpx_utils_function_replacements, rpx_utils_function_replacements_size);
|
||||||
DEBUG_FUNCTION_LINE("Patch functions finished");
|
DEBUG_FUNCTION_LINE("Patch functions finished");
|
||||||
gIsMounted = false;
|
gReplacementInfo = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WUMS_APPLICATION_ENDS() {
|
WUMS_APPLICATION_ENDS() {
|
||||||
if (gIsMounted) {
|
if (gReplacementInfo.bundleMountInformation.isMounted) {
|
||||||
DEBUG_FUNCTION_LINE("Unmount /vol/content");
|
DEBUG_FUNCTION_LINE("Unmount /vol/content");
|
||||||
romfsUnmount("rom");
|
romfsUnmount("rom");
|
||||||
gIsMounted = false;
|
gReplacementInfo.bundleMountInformation.isMounted = false;
|
||||||
DCFlushRange(&gIsMounted, sizeof(gIsMounted));
|
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,43 +48,45 @@ WUMS_APPLICATION_STARTS() {
|
|||||||
WHBLogUdpInit();
|
WHBLogUdpInit();
|
||||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) != OSGetTitleID()) {
|
||||||
DEBUG_FUNCTION_LINE("Set gTryToReplaceOnNextLaunch, gReplacedRPX and gIsMounted to FALSE");
|
DEBUG_FUNCTION_LINE("Set gTryToReplaceOnNextLaunch, gReplacedRPX and gIsMounted to FALSE");
|
||||||
gReplacedRPX = false;
|
gReplacementInfo.replacementType = RPXLoader_NONE;
|
||||||
gTryToReplaceOnNextLaunch = false;
|
gReplacementInfo.isRPXReplaced = false;
|
||||||
gIsMounted = false;
|
gReplacementInfo.bundleMountInformation.isMounted = false;
|
||||||
DCFlushRange(&gReplacedRPX, sizeof(gReplacedRPX));
|
gReplacementInfo.bundleMountInformation.redirectionRequested = false;
|
||||||
DCFlushRange(&gTryToReplaceOnNextLaunch, sizeof(gTryToReplaceOnNextLaunch));
|
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||||
DCFlushRange(&gIsMounted, sizeof(gIsMounted));
|
|
||||||
} else {
|
} else {
|
||||||
if (gTryToReplaceOnNextLaunch) {
|
if (gReplacementInfo.replacementType != RPXLoader_NONE) {
|
||||||
gCurrentHash = StringTools::hash(gLoadedBundlePath);
|
gReplacementInfo.isRPXReplaced = true;
|
||||||
|
|
||||||
nn::act::Initialize();
|
|
||||||
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
|
||||||
nn::act::Finalize();
|
|
||||||
|
|
||||||
std::string basePath = StringTools::strfmt("/vol/external01/wiiu/apps/save/%08X", gCurrentHash);
|
|
||||||
std::string common = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/common", gCurrentHash);
|
|
||||||
std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", gCurrentHash, 0x80000000 | slot);
|
|
||||||
|
|
||||||
strncpy(gSavePath,basePath.c_str(), 255);
|
|
||||||
memset(gWorkingDir, 0, sizeof(gWorkingDir));
|
|
||||||
DCFlushRange(gWorkingDir, sizeof(gWorkingDir));
|
|
||||||
|
|
||||||
CreateSubfolder(common.c_str());
|
|
||||||
CreateSubfolder(user.c_str());
|
|
||||||
DEBUG_FUNCTION_LINE("Created %s and %s", common.c_str(), user.c_str());
|
|
||||||
if (romfsMount("rom", gLoadedBundlePath, RomfsSource_FileDescriptor_CafeOS) == 0) {
|
|
||||||
DEBUG_FUNCTION_LINE("Mounted %s to /vol/content", gLoadedBundlePath);
|
|
||||||
gIsMounted = true;
|
|
||||||
} else {
|
|
||||||
DEBUG_FUNCTION_LINE("Failed to mount %s", gLoadedBundlePath);
|
|
||||||
gIsMounted = false;
|
|
||||||
}
|
|
||||||
gReplacedRPX = true;
|
|
||||||
DCFlushRange(&gReplacedRPX, sizeof(gReplacedRPX));
|
|
||||||
DCFlushRange(&gIsMounted, sizeof(gIsMounted));
|
|
||||||
DCFlushRange(&gTryToReplaceOnNextLaunch, sizeof(gTryToReplaceOnNextLaunch));
|
|
||||||
}
|
}
|
||||||
|
if (gReplacementInfo.bundleMountInformation.redirectionRequested) {
|
||||||
|
if (gReplacementInfo.replacementType == RPXLoader_BUNDLE || gReplacementInfo.replacementType == RPXLoader_BUNDLE_OTHER_RPX) {
|
||||||
|
gReplacementInfo.currentHash = StringTools::hash(gReplacementInfo.bundleMountInformation.path);
|
||||||
|
|
||||||
|
nn::act::Initialize();
|
||||||
|
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
||||||
|
nn::act::Finalize();
|
||||||
|
|
||||||
|
std::string basePath = StringTools::strfmt("/vol/external01/wiiu/apps/save/%08X", gReplacementInfo.currentHash);
|
||||||
|
std::string common = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/common", gReplacementInfo.currentHash);
|
||||||
|
std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", gReplacementInfo.currentHash, 0x80000000 | slot);
|
||||||
|
|
||||||
|
strncpy(gReplacementInfo.savePath, basePath.c_str(), sizeof(gReplacementInfo.savePath));
|
||||||
|
memset(gReplacementInfo.bundleMountInformation.workingDir, 0, sizeof(gReplacementInfo.bundleMountInformation.workingDir));
|
||||||
|
|
||||||
|
CreateSubfolder(common.c_str());
|
||||||
|
CreateSubfolder(user.c_str());
|
||||||
|
DEBUG_FUNCTION_LINE("Created %s and %s", common.c_str(), user.c_str());
|
||||||
|
if (romfsMount("rom", gReplacementInfo.bundleMountInformation.path, RomfsSource_FileDescriptor_CafeOS) == 0) {
|
||||||
|
DEBUG_FUNCTION_LINE("Mounted %s to /vol/content", gReplacementInfo.bundleMountInformation.path);
|
||||||
|
gReplacementInfo.bundleMountInformation.isMounted = true;
|
||||||
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Failed to mount %s", gReplacementInfo.bundleMountInformation.path);
|
||||||
|
gReplacementInfo.bundleMountInformation.isMounted = false;
|
||||||
|
}
|
||||||
|
} else if (gReplacementInfo.replacementType == RPXLoader_RPX) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user