Skip to content

Commit

Permalink
koekeishiya#725 output mach_error_string(..) when remote thread fails
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Nov 23, 2020
1 parent 8efc57c commit 4d1b220
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/osax/mach_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ bool mach_loader_inject_payload(pid_t pid)
thread_state.__pc = (uint64_t) code + (uint64_t)(((void *) bootstrap_entry) - image);
thread_state.__sp = (uint64_t) (stack + (stack_size / 2) - 8);

if (thread_create_running(task, ARM_THREAD_STATE64, (thread_state_t)&thread_state, ARM_THREAD_STATE64_COUNT, &thread) != KERN_SUCCESS) {
fprintf(stderr, "could not spawn remote thread\n");
kern_return_t error = thread_create_running(task, ARM_THREAD_STATE64, (thread_state_t)&thread_state, ARM_THREAD_STATE64_COUNT, &thread);
if (error != KERN_SUCCESS) {
fprintf(stderr, "could not spawn remote thread: %s\n", mach_error_string(error));
return false;
}
#else
Expand All @@ -106,8 +107,9 @@ bool mach_loader_inject_payload(pid_t pid)
thread_state.__rip = (uint64_t) code + (uint64_t)(((void *) bootstrap_entry) - image);
thread_state.__rsp = (uint64_t) (stack + (stack_size / 2) - 8);

if (thread_create_running(task, x86_THREAD_STATE64, (thread_state_t)&thread_state, x86_THREAD_STATE64_COUNT, &thread) != KERN_SUCCESS) {
fprintf(stderr, "could not spawn remote thread\n");
kern_return_t error = thread_create_running(task, x86_THREAD_STATE64, (thread_state_t)&thread_state, x86_THREAD_STATE64_COUNT, &thread);
if (error != KERN_SUCCESS) {
fprintf(stderr, "could not spawn remote thread: %s\n", mach_error_string(error));
return false;
}
#endif
Expand Down

0 comments on commit 4d1b220

Please sign in to comment.