mirror of
https://github.com/wiiu-env/libmocha.git
synced 2024-11-25 21:14:16 +01:00
Return UNSUPPORTED_CFW in CheckVersion
This commit is contained in:
parent
2ac50e4392
commit
f0df840999
@ -19,6 +19,7 @@ typedef enum MochaUtilsStatus {
|
|||||||
MOCHA_RESULT_NOT_FOUND = -0x06,
|
MOCHA_RESULT_NOT_FOUND = -0x06,
|
||||||
MOCHA_RESULT_UNSUPPORTED_API_VERSION = -0x10,
|
MOCHA_RESULT_UNSUPPORTED_API_VERSION = -0x10,
|
||||||
MOCHA_RESULT_UNSUPPORTED_COMMAND = -0x11,
|
MOCHA_RESULT_UNSUPPORTED_COMMAND = -0x11,
|
||||||
|
MOCHA_RESULT_UNSUPPORTED_CFW = -0x12,
|
||||||
MOCHA_RESULT_LIB_UNINITIALIZED = -0x20,
|
MOCHA_RESULT_LIB_UNINITIALIZED = -0x20,
|
||||||
MOCHA_RESULT_UNKNOWN_ERROR = -0x100,
|
MOCHA_RESULT_UNKNOWN_ERROR = -0x100,
|
||||||
} MochaUtilsStatus;
|
} MochaUtilsStatus;
|
||||||
@ -43,9 +44,10 @@ MochaUtilsStatus Mocha_DeinitLibrary();
|
|||||||
*
|
*
|
||||||
* @param outVersion pointer to the variable where the version will be stored.
|
* @param outVersion pointer to the variable where the version will be stored.
|
||||||
*
|
*
|
||||||
* @return MOCHA_RESULT_SUCCESS: The API version has been store in the version ptr<br>
|
* @return MOCHA_RESULT_SUCCESS: The API version has been store in the version ptr<br>
|
||||||
* MOCHA_RESULT_INVALID_ARGUMENT: invalid version pointer<br>
|
* MOCHA_RESULT_INVALID_ARGUMENT: Invalid version pointer<br>
|
||||||
* MOCHA_RESULT_UNSUPPORTED_API_VERSION: Failed to get the API version caused by an outdated mocha version.
|
* MOCHA_RESULT_UNSUPPORTED_API_VERSION: Failed to get the API version caused by an outdated mocha version.<br>
|
||||||
|
* MOCHA_RESULT_UNSUPPORTED_CFW: Failed to get the API version caused by not using a (compatible) CFW.
|
||||||
*/
|
*/
|
||||||
MochaUtilsStatus Mocha_CheckAPIVersion(uint32_t *outVersion);
|
MochaUtilsStatus Mocha_CheckAPIVersion(uint32_t *outVersion);
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ const char *Mocha_GetStatusStr(MochaUtilsStatus status) {
|
|||||||
return "MOCHA_RESULT_UNSUPPORTED_API_VERSION";
|
return "MOCHA_RESULT_UNSUPPORTED_API_VERSION";
|
||||||
case MOCHA_RESULT_UNSUPPORTED_COMMAND:
|
case MOCHA_RESULT_UNSUPPORTED_COMMAND:
|
||||||
return "MOCHA_RESULT_UNSUPPORTED_COMMAND";
|
return "MOCHA_RESULT_UNSUPPORTED_COMMAND";
|
||||||
|
case MOCHA_RESULT_UNSUPPORTED_CFW:
|
||||||
|
return "MOCHA_RESULT_UNSUPPORTED_CFW";
|
||||||
case MOCHA_RESULT_LIB_UNINITIALIZED:
|
case MOCHA_RESULT_LIB_UNINITIALIZED:
|
||||||
return "MOCHA_RESULT_LIB_UNINITIALIZED";
|
return "MOCHA_RESULT_LIB_UNINITIALIZED";
|
||||||
case MOCHA_RESULT_UNKNOWN_ERROR:
|
case MOCHA_RESULT_UNKNOWN_ERROR:
|
||||||
@ -101,11 +103,23 @@ MochaUtilsStatus Mocha_CheckAPIVersion(uint32_t *version) {
|
|||||||
ALIGN_0x40 uint32_t io_buffer[0x40 / 4];
|
ALIGN_0x40 uint32_t io_buffer[0x40 / 4];
|
||||||
io_buffer[0] = IPC_CUSTOM_GET_MOCHA_API_VERSION;
|
io_buffer[0] = IPC_CUSTOM_GET_MOCHA_API_VERSION;
|
||||||
|
|
||||||
if (IOS_Ioctl(mcpFd, 100, io_buffer, 4, io_buffer, 8) == IOS_ERROR_OK && io_buffer[0] == 0xCAFEBABE) {
|
if (IOS_Ioctl(mcpFd, 100, io_buffer, 4, io_buffer, 8) == IOS_ERROR_OK) {
|
||||||
*version = io_buffer[1];
|
// IOCTL_100 hook is available
|
||||||
res = MOCHA_RESULT_SUCCESS;
|
if (io_buffer[0] == 0xCAFEBABE) {
|
||||||
|
// Updated MochaPayload returns magic word
|
||||||
|
*version = io_buffer[1];
|
||||||
|
res = MOCHA_RESULT_SUCCESS;
|
||||||
|
} else if (io_buffer[0] == 1) {
|
||||||
|
// Old MochaPayload returns success, but zero as magic word
|
||||||
|
res = MOCHA_RESULT_UNSUPPORTED_API_VERSION;
|
||||||
|
} else {
|
||||||
|
// No known implementations are known to trigger this
|
||||||
|
res = MOCHA_RESULT_UNSUPPORTED_CFW;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res = MOCHA_RESULT_UNSUPPORTED_API_VERSION;
|
// If IOCTL_100 hook is not available the call returns -1
|
||||||
|
// This is the case with old Mocha CFW or no CFW at all
|
||||||
|
res = MOCHA_RESULT_UNSUPPORTED_CFW;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOS_Close(mcpFd);
|
IOS_Close(mcpFd);
|
||||||
|
Loading…
Reference in New Issue
Block a user