pub use mach2::{
exception_types as et,
kern_return::{KERN_SUCCESS, kern_return_t},
mach_init::mach_thread_self,
mach_port as mp, mach_types as mt, message as msg,
port::{self, MACH_PORT_NULL, mach_port_t},
task, thread_status as ts,
traps::mach_task_self,
};
pub const EXC_TYPES_COUNT: usize = 14;
pub const EXC_SOFT_SIGNAL: u32 = 0x10003;
cfg_if::cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
pub const THREAD_STATE_NONE: ts::thread_state_flavor_t = 13;
} else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
pub const THREAD_STATE_NONE: ts::thread_state_flavor_t = 5;
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct NdrRecord {
pub mig_vers: u8,
pub if_vers: u8,
pub reserved1: u8,
pub mig_encoding: u8,
pub int_rep: u8,
pub char_rep: u8,
pub float_rep: u8,
pub reserved2: u8,
}
#[repr(C, packed(4))]
pub struct MachMsgPortDescriptor {
pub name: u32,
__pad1: u32,
__pad2: u16,
__disposition: u8,
__type: u8,
}
#[repr(C, packed(4))]
pub struct MachMsgBody {
pub descriptor_count: u32,
}
#[repr(C, packed(4))]
pub struct MachMsgHeader {
pub bits: u32,
pub size: u32,
pub remote_port: u32,
pub local_port: u32,
pub voucher_port: u32,
pub id: u32,
}
#[repr(C, packed(4))]
pub struct MachMsgTrailer {
pub kind: u32,
pub size: u32,
}
#[repr(C, packed(4))]
pub struct ExceptionMessage {
pub header: MachMsgHeader,
pub body: MachMsgBody,
pub thread: MachMsgPortDescriptor,
pub task: MachMsgPortDescriptor,
_ndr: NdrRecord,
pub exception: u32,
pub code_count: u32,
pub code: [u64; 2],
_trailer: MachMsgTrailer,
}
#[repr(C, packed(4))]
pub struct ExceptionRaiseReply {
pub header: MachMsgHeader,
pub ndr: NdrRecord,
pub ret_code: kern_return_t,
}
unsafe extern "C" {
pub fn task_swap_exception_ports(
task: mt::task_t, exception_mask: et::exception_mask_t, new_port: mach_port_t, behavior: et::exception_behavior_t, new_flavor: ts::thread_state_flavor_t, masks: *mut et::exception_mask_t, masks_count: *mut u32, old_handlers: *mut mach_port_t, old_behaviors: *mut et::exception_behavior_t, old_flavors: *mut ts::thread_state_flavor_t, ) -> kern_return_t;
pub fn task_set_exception_ports(
task: mt::task_t, exception_mask: et::exception_mask_t, new_port: mach_port_t, behavior: et::exception_behavior_t, new_flavor: ts::thread_state_flavor_t, ) -> kern_return_t;
pub static NDR_record: NdrRecord;
}