mirror of
https://github.com/wiiu-env/librpxloader.git
synced 2024-11-21 17:59:17 +01:00
Add support for RPXLoader_GetPathOfRunningExecutable
This commit is contained in:
parent
9a143365bf
commit
278e2b895b
@ -15,6 +15,7 @@ typedef enum RPXLoaderStatus {
|
||||
RPX_LOADER_RESULT_LIB_UNINITIALIZED = -0x20,
|
||||
RPX_LOADER_RESULT_MODULE_NOT_FOUND = -0x30,
|
||||
RPX_LOADER_RESULT_MODULE_MISSING_EXPORT = -0x31,
|
||||
RPX_LOADER_RESULT_NOT_AVAILABLE = -0x40,
|
||||
RPX_LOADER_RESULT_UNKNOWN_ERROR = -0x100,
|
||||
} RPXLoaderStatus;
|
||||
|
||||
@ -56,7 +57,7 @@ RPXLoaderStatus RPXLoader_GetVersion(uint32_t *outVersion);
|
||||
* Sets the .rpx or .wuhb that will be loaded the next time the homebrew wrapper application is launched (e.g. Health & Safety or Daily Log).<br>
|
||||
* When a .wuhb will be loaded, accesses to /vol/content will be redirected to the .wuhb, /vol/save will be redirected to the sd card.<br>
|
||||
* <br>
|
||||
* The path is **relative** to the root of the given target device.<br>
|
||||
* The path is **relative** to the root of the sd card<br>
|
||||
* <br>
|
||||
* To launch the prepared RPX call RPXLoader_LaunchPreparedHomebrew if this call was successful.<br>
|
||||
* <br>
|
||||
@ -138,6 +139,23 @@ RPXLoaderStatus RPXLoader_DisableContentRedirection();
|
||||
*/
|
||||
RPXLoaderStatus RPXLoader_UnmountCurrentRunningBundle();
|
||||
|
||||
/**
|
||||
* Returns the path of the currently running executable <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 2 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 currently running executable has been written to outBuffer
|
||||
* 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_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
@ -11,9 +11,10 @@ static RPXLoaderStatus (*sRLPrepareLaunchFromSD)(const char *path) = nullptr;
|
||||
static RPXLoaderStatus (*sRLLaunchPreparedHomebrew)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLLaunchHomebrew)(const char *bundle_path) = nullptr;
|
||||
|
||||
static RPXLoaderStatus (*sRLDisableContentRedirection)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLEnableContentRedirection)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLUnmountCurrentRunningBundle)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLDisableContentRedirection)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLEnableContentRedirection)() = nullptr;
|
||||
static RPXLoaderStatus (*sRLUnmountCurrentRunningBundle)() = nullptr;
|
||||
static RPXLoaderStatus (*sRL_GetPathOfRunningExecutable)(char *outBuffer, uint32_t outSize) = nullptr;
|
||||
|
||||
const char *RPXLoader_GetStatusStr(RPXLoaderStatus status) {
|
||||
switch (status) {
|
||||
@ -35,6 +36,8 @@ const char *RPXLoader_GetStatusStr(RPXLoaderStatus status) {
|
||||
return "RPX_LOADER_RESULT_UNSUPPORTED_API_VERSION";
|
||||
case RPX_LOADER_RESULT_UNSUPPORTED_COMMAND:
|
||||
return "RPX_LOADER_RESULT_UNSUPPORTED_COMMAND";
|
||||
case RPX_LOADER_RESULT_NOT_AVAILABLE:
|
||||
return "RPX_LOADER_RESULT_NOT_AVAILABLE";
|
||||
}
|
||||
return "RPX_LOADER_RESULT_UNKNOWN_ERROR";
|
||||
}
|
||||
@ -85,6 +88,11 @@ RPXLoaderStatus RPXLoader_InitLibrary() {
|
||||
sRLUnmountCurrentRunningBundle = nullptr;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, FALSE, "RL_GetPathOfRunningExecutable", (void **) &sRL_GetPathOfRunningExecutable) != OS_DYNLOAD_OK) {
|
||||
DEBUG_FUNCTION_LINE_WARN("FindExport RL_GetPathOfRunningExecutable failed.");
|
||||
sRL_GetPathOfRunningExecutable = nullptr;
|
||||
}
|
||||
|
||||
return RPX_LOADER_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@ -174,4 +182,15 @@ RPXLoaderStatus RPXLoader_UnmountCurrentRunningBundle() {
|
||||
}
|
||||
|
||||
return reinterpret_cast<decltype(&RPXLoader_UnmountCurrentRunningBundle)>(sRLUnmountCurrentRunningBundle)();
|
||||
}
|
||||
|
||||
RPXLoaderStatus RPXLoader_GetPathOfRunningExecutable(char *outBuffer, uint32_t outSize) {
|
||||
if (rpxLoaderVersion == RPX_LOADER_MODULE_VERSION_ERROR) {
|
||||
return RPX_LOADER_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sRL_GetPathOfRunningExecutable == nullptr || rpxLoaderVersion < 2) {
|
||||
return RPX_LOADER_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
return reinterpret_cast<decltype(&RPXLoader_GetPathOfRunningExecutable)>(sRL_GetPathOfRunningExecutable)(outBuffer, outSize);
|
||||
}
|
Loading…
Reference in New Issue
Block a user