From ad9b5f33fa57cb70f654e335c4ad8919613ff6d9 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 9 Sep 2013 09:41:45 -0700 Subject: [PATCH] Use MACHINE_THREAD_STATE{,_COUNT} to simplify Mach. --- Mach/Inject.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Mach/Inject.cpp b/Mach/Inject.cpp index 46f61be..74e5b30 100644 --- a/Mach/Inject.cpp +++ b/Mach/Inject.cpp @@ -69,23 +69,18 @@ void InjectLibrary(pid_t pid) { thread_act_t thread; _krncall(thread_create(task, &thread)); - thread_state_flavor_t flavor; #if defined (__i386__) || defined(__x86_64__) x86_thread_state_t state; - flavor = x86_THREAD_STATE; - count = x86_THREAD_STATE_COUNT; #elif defined(__arm__) arm_thread_state_t state; - flavor = ARM_THREAD_STATE; - count = ARM_THREAD_STATE_COUNT; #else #error XXX: implement #endif memset(&state, 0, sizeof(state)); - mach_msg_type_number_t read(count); - _krncall(thread_get_state(thread, flavor, reinterpret_cast(&state), &read)); - _assert(read == count); + mach_msg_type_number_t read(MACHINE_THREAD_STATE_COUNT); + _krncall(thread_get_state(thread, MACHINE_THREAD_STATE, reinterpret_cast(&state), &read)); + _assert(read == MACHINE_THREAD_STATE_COUNT); Trampoline *trampoline; size_t align; @@ -173,7 +168,7 @@ void InjectLibrary(pid_t pid) { if (sizeof(frame) != 0) _krncall(mach_vm_write(task, stack + Stack_ - sizeof(frame), reinterpret_cast(frame), sizeof(frame))); - _krncall(thread_set_state(thread, flavor, reinterpret_cast(&state), count)); + _krncall(thread_set_state(thread, MACHINE_THREAD_STATE, reinterpret_cast(&state), MACHINE_THREAD_STATE_COUNT)); _krncall(thread_resume(thread)); _krncall(mach_port_deallocate(self, task)); -- 2.45.2