fitzgen / mach

A rust interface to the Mach 3.0 kernel that underlies OSX.
https://docs.rs/mach
Other
81 stars 28 forks source link

Make fields of thread state struct public #35

Closed codimension closed 6 years ago

codimension commented 6 years ago

The fields of the public struct x86_thread_state64_t should be public so that the user can access them.

Example code:

use mach::structs::x86_thread_state64_t;
use mach::thread_act::thread_get_state;
use mach::thread_status::{x86_THREAD_STATE64, thread_state_t};

let thread_state = x86_thread_state64_t::new();
let thread_state_p = &mut x86_thread_state64_t as *mut x86_thread_state64_t;
let result = unsafe {thread_get_state(some_thread, x86_THREAD_STATE64, thread_state_p as thread_state_t, &mut new_state_count)};
// Should be able to get the instruction pointer by doing:
let rip = unsafe{ thread_state.rip };

// Currently, get the below error message
// -> field `__rip` of struct `mach::structs::x86_thread_state64_t` is private

I think simply making the fields public is the right option for this library given that it tries to be a low-level wrapper around the system headers.