From 040cfa90d3e7df231479be13a03f82e656e19c02 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 24 Jun 2018 15:20:16 -0600 Subject: [PATCH] Fusee: Add kernel patches for 1.0.0. --- fusee/fusee-secondary/src/kernel_patches.c | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/fusee/fusee-secondary/src/kernel_patches.c b/fusee/fusee-secondary/src/kernel_patches.c index 3f23260cf..53f335343 100644 --- a/fusee/fusee-secondary/src/kernel_patches.c +++ b/fusee/fusee-secondary/src/kernel_patches.c @@ -27,6 +27,40 @@ typedef struct { } kernel_info_t; /* Patch definitions. */ +/* + stp x10, x11, [sp, #-0x10]! + mov w11, w14 + lsl x11, x11, #2 + ldr x11, [x28, x11] + mov x9, #0x0000ffffffffffff + and x8, x11, x9 + mov x9, #0xffff000000000000 + and x11, x11, x9 + mov x9, #0xfffe000000000000 + cmp x11, x9 + beq #8 + ldr x8, [x10,#0x250] + ldp x10, x11, [sp],#0x10 +*/ +static const uint8_t MAKE_KERNEL_PATTERN_NAME(100, proc_id_send)[] = {0x48, 0x29, 0x41, 0xF9, 0xC9, 0xF5, 0x7E, 0xD3, 0xCE, 0x09, 0x00, 0x11, 0x48, 0x6A, 0x29, 0xF8}; +static const instruction_t MAKE_KERNEL_HOOK_NAME(100, proc_id_send)[] = {0xA9BF2FEA, 0x2A0E03EB, 0xD37EF56B, 0xF86B6B8B, 0x92FFFFE9, 0x8A090168, 0xD2FFFFE9, 0x8A09016B, 0xD2FFFFC9, 0xEB09017F, 0x54000040, 0xF9412948, 0xA8C12FEA}; +/* + stp x10, x11, [sp, #-0x10]! + mov w10, w28 + lsl x10, x10, #2 + ldr x10, [x13, x10] + mov x9, #0x0000ffffffffffff + and x8, x10, x9 + mov x9, #0xffff000000000000 + and x10, x10, x9 + mov x9, #0xfffe000000000000 + cmp x10, x9 + beq #8 + ldr x8, [x11,#0x250] + ldp x10, x11, [sp],#0x10 +*/ +static const uint8_t MAKE_KERNEL_PATTERN_NAME(100, proc_id_recv)[] = {0x68, 0x29, 0x41, 0xF9, 0x89, 0xF7, 0x7E, 0xD3, 0x9C, 0x0B, 0x00, 0x11, 0x48, 0x69, 0x29, 0xF8}; +static const instruction_t MAKE_KERNEL_HOOK_NAME(100, proc_id_recv)[] = {0xA9BF2FEA, 0x2A1C03EA, 0xD37EF54A, 0xF86A69AA, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000040, 0xF9412968, 0xA8C12FEA}; /* mov w10, w23 lsl x10, x10, #2 @@ -98,7 +132,22 @@ static const instruction_t MAKE_KERNEL_HOOK_NAME(500, proc_id_recv)[] = {0xF9403 /* Hook Definitions. */ static const kernel_hook_t g_kernel_hooks_100[] = { - /* TODO */ + { /* Send Message Process ID Patch. */ + .pattern_size = 0x10, + .pattern = MAKE_KERNEL_PATTERN_NAME(100, proc_id_send), + .pattern_hook_offset = 0x0, + .payload_num_instructions = 13, + .branch_back_offset = 0x4, + .payload = MAKE_KERNEL_HOOK_NAME(100, proc_id_send) + }, + { /* Receive Message Process ID Patch. */ + .pattern_size = 0x10, + .pattern = MAKE_KERNEL_PATTERN_NAME(100, proc_id_recv), + .pattern_hook_offset = 0x0, + .payload_num_instructions = 13, + .branch_back_offset = 0x4, + .payload = MAKE_KERNEL_HOOK_NAME(100, proc_id_recv) + } }; static const kernel_hook_t g_kernel_hooks_200[] = { /* TODO */ @@ -151,6 +200,7 @@ static const kernel_hook_t g_kernel_hooks_500[] = { /* Kernel Infos. */ static const kernel_info_t g_kernel_infos[] = { { /* 1.0.0. */ + .hash = {0xB8, 0xC5, 0x0C, 0x68, 0x25, 0xA9, 0xB9, 0x5B, 0xD2, 0x4D, 0x2C, 0x7C, 0x81, 0x7F, 0xE6, 0x96, 0xF2, 0x42, 0x4E, 0x1D, 0x78, 0xDF, 0x3B, 0xCA, 0x3D, 0x6B, 0x68, 0x12, 0xDD, 0xA9, 0xCB, 0x9C}, .free_code_space_offset = 0x4597C, KERNEL_HOOKS(100) },