From b78bf27449fb5760131392576eb553e522a75a78 Mon Sep 17 00:00:00 2001 From: Lysann Tranvouez Date: Mon, 29 Sep 2025 00:07:48 +0200 Subject: [PATCH] code style --- src/arm64/detours_arm64.h | 24 +++++++++++++----------- src/mach_detours.c | 6 +++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/arm64/detours_arm64.h b/src/arm64/detours_arm64.h index bf73c85..c1e2e1c 100644 --- a/src/arm64/detours_arm64.h +++ b/src/arm64/detours_arm64.h @@ -9,8 +9,8 @@ typedef struct detour_align { - uint8_t obTarget; - uint8_t obTrampoline; + uint8_t obTarget; + uint8_t obTrampoline; } detour_align; typedef struct detour_trampoline @@ -39,15 +39,17 @@ typedef struct detour_trampoline // // The number is rounded up to 128. m_rbScratchDst should match this. // - uint8_t rbCode[128]; // target code + jmp to pbRemain - uint8_t cbCode; // size of moved target code. - uint8_t cbCodeBreak[3]; // padding to make debugging easier. - uint8_t rbRestore[24]; // original target code. - uint8_t cbRestore; // size of original target code. - uint8_t cbRestoreBreak[3]; // padding to make debugging easier. - detour_align rAlign[8]; // instruction alignment array. - uint8_t* pbRemain; // first instruction after moved code. [free list] - uint8_t* pbDetour; // first instruction of detour function. + uint8_t code[128]; // target code + jmp to pbRemain + uint8_t code_size; // size of moved target code. + uint8_t code_padding[3]; // padding to make debugging easier. + + uint8_t restore_code[24]; // original target code. + uint8_t restore_code_size; // size of original target code. + uint8_t restore_code_padding[3]; // padding to make debugging easier. + + detour_align align[8]; // instruction alignment array. + uint8_t* ptr_remain; // first instruction after moved code. [free list] + uint8_t* ptr_detour; // first instruction of detour function. } detour_trampoline; static_assert(sizeof(detour_trampoline) == 192); diff --git a/src/mach_detours.c b/src/mach_detours.c index 632d9e2..840deb1 100644 --- a/src/mach_detours.c +++ b/src/mach_detours.c @@ -57,8 +57,8 @@ static void internal_detour_runnable_trampoline_regions() // Transactions typedef enum detour_operation_kind { - attach, - detach, + detour_operation_kind_attach, + detour_operation_kind_detach, } detour_operation_kind; typedef struct detour_operation @@ -67,7 +67,7 @@ typedef struct detour_operation detour_operation_kind kind; uint8_t** pointer; uint8_t* target; - struct detour_trampoline* trampoline; + detour_trampoline* trampoline; vm_prot_t perm; } detour_operation;