summaryrefslogtreecommitdiff
path: root/tools/thread_shit.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/thread_shit.c')
-rw-r--r--tools/thread_shit.c31
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