code cleanup
const etc
This commit is contained in:
parent
d8d3d85444
commit
dbdfa84fab
3 changed files with 17 additions and 10 deletions
|
|
@ -30,6 +30,7 @@ typedef struct detour_region
|
|||
detour_trampoline* free_list_head; // List of free trampolines in this region.
|
||||
} detour_region;
|
||||
|
||||
// ReSharper disable once CppMultiCharacterLiteral
|
||||
static const uint32_t DETOUR_REGION_SIGNATURE = 'Rrtd';
|
||||
static const uint32_t DETOUR_REGION_SIZE = 0x10000;
|
||||
static const uint32_t DETOUR_TRAMPOLINES_PER_REGION = (DETOUR_REGION_SIZE / sizeof(detour_trampoline)) - 1;
|
||||
|
|
@ -119,7 +120,8 @@ static void internal_detour_free_unused_trampoline_regions()
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Trampoline Helpers
|
||||
|
||||
static uint8_t internal_detour_align_from_trampoline(detour_trampoline* trampoline, uint8_t offset_trampoline)
|
||||
static uint8_t internal_detour_align_from_trampoline(const detour_trampoline* trampoline,
|
||||
const uint8_t offset_trampoline)
|
||||
{
|
||||
for (int32_t n = 0; n < ARRAYSIZE(trampoline->align); n++) {
|
||||
if (trampoline->align[n].offset_trampoline == offset_trampoline) {
|
||||
|
|
@ -129,7 +131,7 @@ static uint8_t internal_detour_align_from_trampoline(detour_trampoline* trampoli
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t internal_detour_align_from_target(detour_trampoline* trampoline, uint8_t offset_target)
|
||||
static uint8_t internal_detour_align_from_target(const detour_trampoline* trampoline, const uint8_t offset_target)
|
||||
{
|
||||
for (int32_t n = 0; n < ARRAYSIZE(trampoline->align); n++) {
|
||||
if (trampoline->align[n].offset_target == offset_target) {
|
||||
|
|
@ -285,6 +287,7 @@ mach_error_t detour_transaction_commit_ex(detour_func_t** out_failed_target)
|
|||
uint8_t* code = internal_detour_gen_jmp_indirect(operation->target,
|
||||
(uint64_t*)&(operation->trampoline->ptr_detour));
|
||||
code = internal_detour_gen_brk(code, operation->trampoline->ptr_remain);
|
||||
UNUSED_VARIABLE(code);
|
||||
*operation->pointer = operation->trampoline->code;
|
||||
#endif // DETOURS_ARM64
|
||||
|
||||
|
|
@ -315,8 +318,8 @@ mach_error_t detour_transaction_commit_ex(detour_func_t** out_failed_target)
|
|||
for (detour_pending_thread* thread = s_pending_threads_head; thread != nullptr; thread = thread->next) {
|
||||
arm_thread_state64_t threadState;
|
||||
mach_msg_type_number_t threadStateCnt = ARM_THREAD_STATE64_COUNT;
|
||||
kern_return_t error = thread_get_state(thread->thread, ARM_THREAD_STATE64, (thread_state_t)&threadState,
|
||||
&threadStateCnt);
|
||||
const kern_return_t error = thread_get_state(thread->thread, ARM_THREAD_STATE64, (thread_state_t)&threadState,
|
||||
&threadStateCnt);
|
||||
if (error != err_none) {
|
||||
DETOUR_BREAK();
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue