mirror of
https://github.com/wiiu-env/libmocha.git
synced 2024-11-08 21:15:06 +01:00
Improve Mocha_ODMGetDiscKey behaviour and add documentation
This commit is contained in:
parent
819adf8030
commit
6b49c2099d
@ -12,6 +12,7 @@ typedef enum MochaUtilsStatus {
|
||||
MOCHA_RESULT_SUCCESS = 0,
|
||||
MOCHA_RESULT_INVALID_ARGUMENT = -0x01,
|
||||
MOCHA_RESULT_MAX_CLIENT = -0x02,
|
||||
MOCHA_RESULT_NOT_FOUND = -0x06,
|
||||
MOCHA_RESULT_UNSUPPORTED_API_VERSION = -0x10,
|
||||
MOCHA_RESULT_UNSUPPORTED_COMMAND = -0x11,
|
||||
MOCHA_RESULT_LIB_UNINITIALIZED = -0x20,
|
||||
@ -90,6 +91,17 @@ typedef struct WUDDiscKey {
|
||||
uint8_t key[0x10];
|
||||
} WUDDiscKey;
|
||||
|
||||
/**
|
||||
* Reads the disc key (used to decrypt the SI partition) of the inserted disc.
|
||||
*
|
||||
* @param discKey target buffer where the result will be stored.
|
||||
* @return MOCHA_RESULT_SUCCESS: The disc key of the inserted disc has been read into the given buffer.<br>
|
||||
* MOCHA_RESULT_INVALID_ARGUMENT: The given discKey buffer was NULL <br>
|
||||
* MOCHA_RESULT_LIB_UNINITIALIZED: Library was not initialized. Call Mocha_InitLibrary() before using this function.<br>
|
||||
* MOCHA_RESULT_UNSUPPORTED_COMMAND: Command not supported by the currently loaded mocha version.<br>
|
||||
* MOCHA_RESULT_NOT_FOUND: Failed to obtain disc key, no disc inserted?.
|
||||
* MOCHA_RESULT_UNKNOWN_ERROR: Unknown error.
|
||||
*/
|
||||
MochaUtilsStatus Mocha_ODMGetDiscKey(WUDDiscKey *discKey);
|
||||
|
||||
MochaUtilsStatus Mocha_SEEPROMRead(uint8_t *out_buffer, uint32_t offset, uint32_t size);
|
||||
|
@ -170,11 +170,13 @@ MochaUtilsStatus Mocha_ODMGetDiscKey(WUDDiscKey *discKey) {
|
||||
if (odm_handle >= 0) {
|
||||
ALIGN_0x40 uint32_t io_buffer[0x40 / 4];
|
||||
// disc encryption key, only works with patched IOSU
|
||||
io_buffer[0] = 3;
|
||||
|
||||
if (IOS_Ioctl(odm_handle, 0x06, io_buffer, 0x14, io_buffer, 0x20) == IOS_ERROR_OK) {
|
||||
io_buffer[0] = 3;
|
||||
IOSError ioctlResult = IOS_Ioctl(odm_handle, 0x06, io_buffer, 0x14, io_buffer, 0x20);
|
||||
if (ioctlResult == IOS_ERROR_OK) {
|
||||
memcpy(discKey, io_buffer, 16);
|
||||
res = MOCHA_RESULT_SUCCESS;
|
||||
} else if (ioctlResult == (IOSError) 0xFFF1EFFF) {
|
||||
res = MOCHA_RESULT_NOT_FOUND;
|
||||
}
|
||||
IOS_Close(odm_handle);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user