From ecf58b610cb9944eb22fc16912f3db29ae9b9b44 Mon Sep 17 00:00:00 2001 From: spv420 Date: Sat, 23 Apr 2022 22:14:32 -0400 Subject: wip call shit --- tools/thread_shit.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/thread_shit.c (limited to 'tools/thread_shit.c') 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 +#include + +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 -- cgit v1.2.3