diff options
| author | spv420 <unomilliono@gmail.com> | 2022-04-23 22:14:32 -0400 |
|---|---|---|
| committer | spv420 <unomilliono@gmail.com> | 2022-04-23 22:14:32 -0400 |
| commit | ecf58b610cb9944eb22fc16912f3db29ae9b9b44 (patch) | |
| tree | 8050b5a08b5d083a2f60d659d3914500a175a01e /tools/thread_shit.c | |
| parent | c2a85ee473a72ec22542c2e34b1ee700d9dd68d8 (diff) | |
wip call shit
Diffstat (limited to 'tools/thread_shit.c')
| -rw-r--r-- | tools/thread_shit.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/thread_shit.c b/tools/thread_shit.c new file mode 100644 index 0000000..c5650eb --- /dev/null +++ b/tools/thread_shit.c @@ -0,0 +1,31 @@ +#include <mach/mach.h> +#include <stdio.h> + +int main(int argc, char* argv[]) { + kern_return_t kr; + thread_t th; + mach_port_name_t mytask, mythread; + printf("Hello, world!\n"); + mytask = mach_task_self(); + mythread = mach_thread_self(); + + thread_create(mytask, &th); + arm_thread_state_t state; + mach_msg_type_number_t count; + kr = thread_get_state(th, ARM_THREAD_STATE, (thread_state_t)&state, &count); + printf("%d %d %s\n", kr, KERN_SUCCESS, mach_error_string(kr)); + for (int i = 0; i < 13; i++) { + state.__r[i] = 0x41414140 + i; + } + state.__sp = 0x4141414c; + state.__lr = 0x4141414d; + state.__pc = 0x4141414e; + kr = thread_set_state(th, ARM_THREAD_STATE, (thread_state_t)&state, ARM_THREAD_STATE_COUNT); + printf("%d %d %s\n", kr, KERN_SUCCESS, mach_error_string(kr)); + kr = thread_resume(th); + printf("%d %d %s\n", kr, KERN_SUCCESS, mach_error_string(kr)); + + printf("still alive?\n"); + + return 0; +}
\ No newline at end of file |
