Use the latest version of the CRGetVersion implementation

This commit is contained in:
Maschell 2022-09-03 16:55:20 +02:00
parent 7a2fd2d624
commit 43749f30a8
2 changed files with 22 additions and 10 deletions

View File

@ -52,7 +52,7 @@ typedef enum ContentRedirectionStatus {
typedef uint32_t CRLayerHandle;
typedef uint32_t ContentRedirectionVersion;
#define CONTENT_REDIRECT_MODULE_VERSION 0x00000001
#define CONTENT_REDIRECTION_MODULE_VERSION_ERROR 0xFFFFFFFF
typedef enum ContentRedirectionApiErrorType {
CONTENT_REDIRECTION_API_ERROR_NONE = 0,
@ -73,10 +73,15 @@ typedef enum ContentRedirectionApiErrorType {
ContentRedirectionStatus ContentRedirection_InitLibrary();
/**
* Returns the API Version of the Content Redirection Module.
* @return The ContentRedirectionVersion of the Module
* Retrieves the API Version of the loaded ContentRedirectionModule.<br>
* <br>
* @param outVersion pointer to the variable where the version will be stored.
*
* @return CONTENT_REDIRECTION_RESULT_SUCCESS: The API version has been store in the version ptr.<br>
* CONTENT_REDIRECTION_RESULT_INVALID_ARGUMENT: Invalid version pointer.<br>
* CONTENT_REDIRECTION_RESULT_UNKNOWN_ERROR: Retrieving the module version failed.
*/
ContentRedirectionVersion ContentRedirection_GetVersion();
ContentRedirectionStatus ContentRedirection_GetVersion(ContentRedirectionVersion *outVersion);
/**
* Adds a a FSLayers that redirects the /vol/content or /vol/save fs calles for the Game/Wii U Menu process.

View File

@ -8,10 +8,13 @@ static OSDynLoad_Module sModuleHandle = nullptr;
static ContentRedirectionApiErrorType (*sCRAddFSLayer)(CRLayerHandle *, const char *, const char *, FSLayerType) = nullptr;
static ContentRedirectionApiErrorType (*sCRRemoveFSLayer)(CRLayerHandle) = nullptr;
static ContentRedirectionApiErrorType (*sCRSetActive)(CRLayerHandle) = nullptr;
static ContentRedirectionVersion (*sCRGetVersion)() = nullptr;
static ContentRedirectionApiErrorType (*sCRGetVersion)(ContentRedirectionVersion *) = nullptr;
static ContentRedirectionApiErrorType (*sCRAddDevice)(const devoptab_t *, int *) = nullptr;
static ContentRedirectionApiErrorType (*sCRRemoveDevice)(const char *) = nullptr;
static ContentRedirectionVersion sContentRedirectionVersion = CONTENT_REDIRECTION_MODULE_VERSION_ERROR;
ContentRedirectionStatus ContentRedirection_InitLibrary() {
if (OSDynLoad_Acquire("homebrew_content_redirection", &sModuleHandle) != OS_DYNLOAD_OK) {
OSReport("ContentRedirection_Init: OSDynLoad_Acquire failed.\n");
@ -22,8 +25,8 @@ ContentRedirectionStatus ContentRedirection_InitLibrary() {
OSReport("ContentRedirection_Init: CRGetVersion failed.\n");
return CONTENT_REDIRECTION_RESULT_MODULE_MISSING_EXPORT;
}
auto res = ContentRedirection_GetVersion();
if (res != CONTENT_REDIRECT_MODULE_VERSION) {
auto res = ContentRedirection_GetVersion(&sContentRedirectionVersion);
if (res != CONTENT_REDIRECTION_RESULT_SUCCESS) {
return CONTENT_REDIRECTION_RESULT_UNSUPPORTED_VERSION;
}
@ -55,13 +58,17 @@ ContentRedirectionStatus ContentRedirection_InitLibrary() {
return CONTENT_REDIRECTION_RESULT_SUCCESS;
}
ContentRedirectionVersion GetVersion();
ContentRedirectionVersion ContentRedirection_GetVersion() {
ContentRedirectionApiErrorType GetVersion(ContentRedirectionVersion *);
ContentRedirectionStatus ContentRedirection_GetVersion(ContentRedirectionVersion *outVariable) {
if (sCRGetVersion == nullptr) {
return CONTENT_REDIRECTION_RESULT_LIB_UNINITIALIZED;
}
return reinterpret_cast<decltype(&GetVersion)>(sCRGetVersion)();
auto res = reinterpret_cast<decltype(&GetVersion)>(sCRGetVersion)(outVariable);
if (res == CONTENT_REDIRECTION_API_ERROR_NONE) {
return CONTENT_REDIRECTION_RESULT_SUCCESS;
}
return res == CONTENT_REDIRECTION_API_ERROR_INVALID_ARG ? CONTENT_REDIRECTION_RESULT_INVALID_ARGUMENT : CONTENT_REDIRECTION_RESULT_UNKNOWN_ERROR;
}