/
odm.c
30 lines (29 loc) · 1022 Bytes
/
odm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* Copyright (C) 2016 FIX94
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#define IOS_FS_IOSC_CREATEOBJ ((int (*)(void*, int, int))0x107F20DC)
#define IOS_FS_IOSC_DECRYPT ((void (*)(int, void*, unsigned int, const void*, unsigned int, void*, unsigned int))0x107F3FE0)
#define IOS_FS_MEMCPY ((void* (*)(void*, const void*, unsigned int))0x107F4F7C)
#define IOS_FS_MEMSET ((void* (*)(void*, int, unsigned int))0x107F5018)
int odm_readkey(void *obj, void *key, unsigned int base)
{
if(*(volatile int*)(base + 0x409AC) == 0)
{
char iv[0x10];
IOS_FS_MEMSET(iv, 0, 0x10);
//session key fd, used to decrypt drive data
int fd = *(volatile int*)(base + 0x409CC);
//decrypt disc key with the session key
IOS_FS_IOSC_DECRYPT(fd, iv, 0x10, key, 0x10, (void*)0x1E10C00, 0x10);
}
else
{
//no session key decrypt needed
IOS_FS_MEMCPY((void*)0x1E10C00, key, 0x10);
}
//original code
return IOS_FS_IOSC_CREATEOBJ(obj, 0, 0);
}