Add IOSUHAX_read_otp and IOSUHAX_ODM_GetDiscKey

This commit is contained in:
Maschell 2021-10-09 00:54:48 +02:00
parent 9344b3497a
commit fbfbd3ef7c
2 changed files with 41 additions and 0 deletions

View File

@ -70,6 +70,10 @@ int IOSUHAX_kern_write32(uint32_t address, uint32_t value);
int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count);
int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size);
int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey);
int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt);
int IOSUHAX_FSA_Open();

View File

@ -35,6 +35,7 @@
#define IOCTL_REPEATED_WRITE 0x05
#define IOCTL_KERN_READ32 0x06
#define IOCTL_KERN_WRITE32 0x07
#define IOCTL_READ_OTP 0x08
#define IOCTL_FSA_OPEN 0x40
#define IOCTL_FSA_CLOSE 0x41
@ -115,6 +116,26 @@ int IOSUHAX_memwrite(uint32_t address, const uint8_t *buffer, uint32_t size) {
return res;
}
int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey){
int res = -1;
if(discKey == NULL){
return -2;
}
int odm_handle = IOS_Open("/dev/odm", 1);
res = odm_handle;
if (odm_handle >= 0) {
uint32_t io_buffer[0x20 / 4];
// disc encryption key, only works with patched IOSU
io_buffer[0] = 3;
res = IOS_Ioctl(odm_handle, 0x06, io_buffer, 0x14, io_buffer, 0x20);
if (res == 0) {
memcpy(discKey, io_buffer, 16);
}
IOS_Close(odm_handle);
}
return res;
}
int IOSUHAX_memread(uint32_t address, uint8_t *out_buffer, uint32_t size) {
if (iosuhaxHandle < 0)
return iosuhaxHandle;
@ -162,6 +183,22 @@ int IOSUHAX_kern_write32(uint32_t address, uint32_t value) {
return IOS_Ioctl(iosuhaxHandle, IOCTL_KERN_WRITE32, io_buf, 2 * sizeof(uint32_t), 0, 0);
}
int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size) {
if (iosuhaxHandle < 0) {
return iosuhaxHandle;
}
ALIGN(0x20) uint32_t io_buf[0x400 >> 2];
int res = IOS_Ioctl(iosuhaxHandle, IOCTL_READ_OTP, 0, 0, io_buf, 0x400);
if (res >= 0){
memcpy(out_buffer, io_buf, size > 0x400 ? 0x400 : size);
}
return res;
}
int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count) {
if (iosuhaxHandle < 0)
return iosuhaxHandle;