Implement RL_GetPathOfSaveRedirection

This commit is contained in:
Maschell 2024-03-30 08:32:53 +01:00
parent 7ad49381b6
commit beabc6e229
5 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,6 @@
FROM ghcr.io/wiiu-env/devkitppc:20230621
COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/librpxloader:0.1.3-dev-20240329-8a2fc9f /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libfunctionpatcher:20230621 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/wiiumodulesystem:20230719 /artifacts $DEVKITPRO
COPY --from=ghcr.io/wiiu-env/libwuhbutils:20230621 /artifacts $DEVKITPRO

View File

@ -382,7 +382,7 @@ RPXLoaderStatus RL_GetVersion(RPXLoaderVersion *outVersion) {
if (!outVersion) {
return RPX_LOADER_RESULT_INVALID_ARGUMENT;
}
*outVersion = 2;
*outVersion = 3;
return RPX_LOADER_RESULT_SUCCESS;
}
@ -398,6 +398,18 @@ RPXLoaderStatus RL_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize)
return RPX_LOADER_RESULT_NOT_AVAILABLE;
}
RPXLoaderStatus RL_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize) {
if (outBuffer == nullptr || outSize == 0) {
return RPX_LOADER_RESULT_INVALID_ARGUMENT;
}
if (saveLayerHandle != 0 && !gActiveSaveRedirectionPath.empty()) {
strncpy(outBuffer, gActiveSaveRedirectionPath.c_str(), outSize - 1);
return RPX_LOADER_RESULT_SUCCESS;
}
return RPX_LOADER_RESULT_NOT_AVAILABLE;
}
WUMS_EXPORT_FUNCTION(RL_PrepareLaunchFromSD);
WUMS_EXPORT_FUNCTION(RL_LaunchPreparedHomebrew);
WUMS_EXPORT_FUNCTION(RL_LaunchHomebrew);
@ -407,3 +419,4 @@ WUMS_EXPORT_FUNCTION(RL_EnableContentRedirection);
WUMS_EXPORT_FUNCTION(RL_DisableContentRedirection);
WUMS_EXPORT_FUNCTION(RL_UnmountCurrentRunningBundle);
WUMS_EXPORT_FUNCTION(RL_GetPathOfRunningExecutable);
WUMS_EXPORT_FUNCTION(RL_GetPathOfSaveRedirection);

View File

@ -2,4 +2,5 @@
RPXLoader_ReplacementInformation gReplacementInfo = {};
CRLayerHandle contentLayerHandle = 0;
CRLayerHandle saveLayerHandle = 0;
CRLayerHandle saveLayerHandle = 0;
std::string gActiveSaveRedirectionPath;

View File

@ -53,4 +53,5 @@ typedef struct RPXLoader_ReplacementInformation_t {
extern RPXLoader_ReplacementInformation gReplacementInfo;
extern CRLayerHandle contentLayerHandle;
extern CRLayerHandle saveLayerHandle;
extern CRLayerHandle saveLayerHandle;
extern std::string gActiveSaveRedirectionPath;

View File

@ -91,6 +91,8 @@ WUMS_APPLICATION_STARTS() {
gReplacementInfo.lastFileLoaded[0] = '\0';
}
gActiveSaveRedirectionPath.clear();
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) == OSGetTitleID() &&
strlen(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) > 0) {
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
@ -100,10 +102,11 @@ WUMS_APPLICATION_STARTS() {
nn::act::PersistentId persistentId = nn::act::GetPersistentId();
nn::act::Finalize();
std::string basePath = string_format("fs:/vol/external01/wiiu/apps/save/%08X", currentHash);
std::string relativePath = string_format("wiiu/apps/save/%08X", currentHash);
if (!shortNameSanitized.empty()) {
basePath += string_format(" (%s)", shortNameSanitized.c_str());
relativePath += string_format(" (%s)", shortNameSanitized.c_str());
}
std::string basePath = "fs:/vol/external01/" + relativePath;
std::string common = basePath + "/common";
std::string user = basePath + string_format("/%08X", 0x80000000 | persistentId);
@ -145,6 +148,8 @@ WUMS_APPLICATION_STARTS() {
gReplacementInfo.contentReplacementInfo.bundleMountInformation.isMounted = true;
gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath[0] = '\0';
gActiveSaveRedirectionPath = relativePath;
OSMemoryBarrier();
return;
} else {