Implement support for API Version 3 (RPXLoader_GetPathOfSaveRedirection)

This commit is contained in:
Maschell 2024-03-29 08:56:27 +01:00
parent cad78bc932
commit 223bdc6c21
3 changed files with 36 additions and 2 deletions

View File

@ -11,7 +11,7 @@ TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/wut/share/wut_rules
export VER_MAJOR := 1
export VER_MINOR := 2
export VER_MINOR := 3
export VER_PATCH := 0
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)

View File

@ -148,7 +148,7 @@ RPXLoaderStatus RPXLoader_UnmountCurrentRunningBundle();
*
* @param outBuffer buffer where the result will be stored
* @param outSize size of outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the currently running executable has been written to outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the currently running executable has been written to outBuffer. <br>
* RPX_LOADER_RESULT_UNSUPPORTED_COMMAND: Command not supported by the currently loaded RPXLoaderModule version.<br>
* RPX_LOADER_RESULT_INVALID_ARGUMENT: The given outBuffer was NULL or outSize was 0 <br>
* RPX_LOADER_RESULT_LIB_UNINITIALIZED: "RPXLoader_Init()" was not called.<br>
@ -156,6 +156,23 @@ RPXLoaderStatus RPXLoader_UnmountCurrentRunningBundle();
*/
RPXLoaderStatus RPXLoader_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize);
/**
* Returns the path currently used for /vol/save redirection <br>
* This function is not guaranteed to succeed, it only works if the executable is loaded via the RPXLoadingModule <br>
* The returned path is relative to the root of the sd card. <br>
* <br>
* Requires API version 3 or higher. <br>
*
* @param outBuffer buffer where the result will be stored
* @param outSize size of outBuffer
* @return RPX_LOADER_RESULT_SUCCESS: The path of the /vol/save redirection has been written to outBuffer.<br>
* RPX_LOADER_RESULT_UNSUPPORTED_COMMAND: Command not supported by the currently loaded RPXLoaderModule version.<br>
* RPX_LOADER_RESULT_INVALID_ARGUMENT: The given outBuffer was NULL or outSize was 0 <br>
* RPX_LOADER_RESULT_LIB_UNINITIALIZED: "RPXLoader_Init()" was not called.<br>
* RPX_LOADER_RESULT_NOT_AVAILABLE: The path is not available.<br>
*/
RPXLoaderStatus RPXLoader_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -15,6 +15,7 @@ static RPXLoaderStatus (*sRLDisableContentRedirection)()
static RPXLoaderStatus (*sRLEnableContentRedirection)() = nullptr;
static RPXLoaderStatus (*sRLUnmountCurrentRunningBundle)() = nullptr;
static RPXLoaderStatus (*sRL_GetPathOfRunningExecutable)(char *outBuffer, uint32_t outSize) = nullptr;
static RPXLoaderStatus (*sRL_GetPathOfSaveRedirection)(char *outBuffer, uint32_t outSize) = nullptr;
const char *RPXLoader_GetStatusStr(RPXLoaderStatus status) {
switch (status) {
@ -93,6 +94,11 @@ RPXLoaderStatus RPXLoader_InitLibrary() {
sRL_GetPathOfRunningExecutable = nullptr;
}
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "RL_GetPathOfSaveRedirection", (void **) &sRL_GetPathOfSaveRedirection) != OS_DYNLOAD_OK) {
DEBUG_FUNCTION_LINE_WARN("FindExport RL_GetPathOfRunningExecutable failed.");
sRL_GetPathOfSaveRedirection = nullptr;
}
return RPX_LOADER_RESULT_SUCCESS;
}
@ -194,3 +200,14 @@ RPXLoaderStatus RPXLoader_GetPathOfRunningExecutable(char *outBuffer, uint32_t o
return reinterpret_cast<decltype(&RPXLoader_GetPathOfRunningExecutable)>(sRL_GetPathOfRunningExecutable)(outBuffer, outSize);
}
RPXLoaderStatus RPXLoader_GetPathOfSaveRedirection(char *outBuffer, uint32_t outSize) {
if (rpxLoaderVersion == RPX_LOADER_MODULE_VERSION_ERROR) {
return RPX_LOADER_RESULT_LIB_UNINITIALIZED;
}
if (sRL_GetPathOfSaveRedirection == nullptr || rpxLoaderVersion < 3) {
return RPX_LOADER_RESULT_UNSUPPORTED_COMMAND;
}
return reinterpret_cast<decltype(&RPXLoader_GetPathOfSaveRedirection)>(sRL_GetPathOfSaveRedirection)(outBuffer, outSize);
}