diff --git a/fusee/fusee-secondary/src/kernel_patches.c b/fusee/fusee-secondary/src/kernel_patches.c index 192e457e5..87bcd5615 100644 --- a/fusee/fusee-secondary/src/kernel_patches.c +++ b/fusee/fusee-secondary/src/kernel_patches.c @@ -28,6 +28,40 @@ typedef struct { /* Patch definitions. */ /* + mov w10, w23 + lsl x10, x10, #2 + ldr x10, [x28, x10] + mov x9, #0x0000ffffffffffff + and x8, x10, x9 + mov x9, #0xffff000000000000 + and x10, x10, x9 + mov x9, #0xfffe000000000000 + cmp x10, x9 + beq #12 + ldr x10, [sp,#0xa0] + ldr x8, [x10,#0x2b0] + ldr x10, [sp,#0xa0] +*/ +static const uint8_t MAKE_KERNEL_PATTERN_NAME(400, proc_id_send)[] = {0xEA, 0x53, 0x40, 0xF9, 0x48, 0x59, 0x41, 0xF9, 0xE9, 0x03, 0x17, 0x2A, 0x29, 0xF5, 0x7E, 0xD3}; +static const instruction_t MAKE_KERNEL_HOOK_NAME(400, proc_id_send)[] = {0xF9403BED, 0x2A0E03EA, 0xD37EF54A, 0xF86A69AA, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000040, 0xF9415B28, 0xD503201F}; +/* + ldr x13, [sp,#0x70] + mov w10, w14 + 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, [x25,#0x2b0] + nop +*/ +static const uint8_t MAKE_KERNEL_PATTERN_NAME(400, proc_id_recv)[] = {0x28, 0x5B, 0x41, 0xF9, 0xE9, 0x03, 0x0E, 0x2A, 0xCE, 0x09, 0x00, 0x11, 0x29, 0xF5, 0x7E, 0xD3}; +static const instruction_t MAKE_KERNEL_HOOK_NAME(400, proc_id_recv)[] = {0xD280000D, 0x2A0E03ED, 0xD37EF5AD, 0xF86D6B4D, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A0901AD, 0xD2FFFFC9, 0xEB09015F, 0x54000040, 0xF9415B28, 0xD503201F}; +/* mov w10, w23 lsl x10, x10, #2 ldr x10, [x27, x10] @@ -76,7 +110,22 @@ static const kernel_hook_t g_kernel_hooks_302[] = { /* TODO */ }; static const kernel_hook_t g_kernel_hooks_400[] = { - /* TODO */ + { /* Send Message Process ID Patch. */ + .pattern_size = 0x10, + .pattern = MAKE_KERNEL_PATTERN_NAME(400, proc_id_send), + .pattern_hook_offset = 0x0, + .payload_num_instructions = 13, + .branch_back_offset = 0x8, + .payload = MAKE_KERNEL_HOOK_NAME(400, proc_id_send) + }, + { /* Receive Message Process ID Patch. */ + .pattern_size = 0x10, + .pattern = MAKE_KERNEL_PATTERN_NAME(400, proc_id_recv), + .pattern_hook_offset = 0x0, + .payload_num_instructions = 13, + .branch_back_offset = 0x4, + .payload = MAKE_KERNEL_HOOK_NAME(400, proc_id_recv) + } }; static const kernel_hook_t g_kernel_hooks_500[] = { { /* Send Message Process ID Patch. */