From beabc6e229ee3da3ed1c2454e20089a0f36a58cb Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 30 Mar 2024 08:32:53 +0100 Subject: [PATCH] Implement RL_GetPathOfSaveRedirection --- Dockerfile | 2 +- src/RPXLoading.cpp | 15 ++++++++++++++- src/globals.cpp | 3 ++- src/globals.h | 3 ++- src/main.cpp | 9 +++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5971987..4261bda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/src/RPXLoading.cpp b/src/RPXLoading.cpp index 2ab737b..9b19c03 100644 --- a/src/RPXLoading.cpp +++ b/src/RPXLoading.cpp @@ -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); diff --git a/src/globals.cpp b/src/globals.cpp index 6b29cb0..d7438f5 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -2,4 +2,5 @@ RPXLoader_ReplacementInformation gReplacementInfo = {}; CRLayerHandle contentLayerHandle = 0; -CRLayerHandle saveLayerHandle = 0; \ No newline at end of file +CRLayerHandle saveLayerHandle = 0; +std::string gActiveSaveRedirectionPath; \ No newline at end of file diff --git a/src/globals.h b/src/globals.h index e1b3366..03246f4 100644 --- a/src/globals.h +++ b/src/globals.h @@ -53,4 +53,5 @@ typedef struct RPXLoader_ReplacementInformation_t { extern RPXLoader_ReplacementInformation gReplacementInfo; extern CRLayerHandle contentLayerHandle; -extern CRLayerHandle saveLayerHandle; \ No newline at end of file +extern CRLayerHandle saveLayerHandle; +extern std::string gActiveSaveRedirectionPath; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8d31e3f..bf9b2e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 {