#ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif #include "mach.h" #define EXPORT_BOOLEAN #include #include #include #include #include #include #include #include /* LINTLIBRARY */ #ifndef mig_internal #define mig_internal static #endif #ifndef mig_external #define mig_external #endif #ifndef TypeCheck #define TypeCheck 1 #endif #ifndef UseExternRCSId #define UseExternRCSId 1 #endif #define BAD_TYPECHECK(type, check) ({\ union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) #define msgh_request_port msgh_remote_port #define msgh_reply_port msgh_local_port #include #include /* Routine task_create */ mig_external kern_return_t task_create ( mach_port_t target_task, boolean_t inherit_memory, mach_port_t *child_task ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t inherit_memoryType; boolean_t inherit_memory; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t child_taskType; mach_port_t child_task; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t inherit_memoryType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t child_taskCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->inherit_memoryType = inherit_memoryType; InP->inherit_memory = inherit_memory; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2007; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2107) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 40) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->child_taskType, &child_taskCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *child_task = OutP->child_task; return KERN_SUCCESS; } /* Routine task_terminate */ mig_external kern_return_t task_terminate ( mach_port_t target_task ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2008; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2108) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_get_emulation_vector */ mig_external kern_return_t task_get_emulation_vector ( mach_port_t task, int *vector_start, emulation_vector_t *emulation_vector, mach_msg_type_number_t *emulation_vectorCnt ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t vector_startType; int vector_start; mach_msg_type_long_t emulation_vectorType; emulation_vector_t emulation_vector; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t vector_startCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2009; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2109) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 56) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->vector_startType, &vector_startCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *vector_start = OutP->vector_start; #if TypeCheck if ((OutP->emulation_vectorType.msgtl_header.msgt_inline != FALSE) || (OutP->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || (OutP->emulation_vectorType.msgtl_name != 2) || (OutP->emulation_vectorType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *emulation_vector = OutP->emulation_vector; *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; return KERN_SUCCESS; } /* Routine task_set_emulation_vector */ mig_external kern_return_t task_set_emulation_vector ( mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t vector_startType; int vector_start; mach_msg_type_long_t emulation_vectorType; emulation_vector_t emulation_vector; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t vector_startType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t emulation_vectorType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ FALSE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 2, /* msgtl_size = */ 32, /* msgtl_number = */ 0, }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->vector_startType = vector_startType; InP->vector_start = vector_start; InP->emulation_vectorType = emulation_vectorType; InP->emulation_vector = emulation_vector; InP->emulation_vectorType.msgtl_number = emulation_vectorCnt; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2010; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2110) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_threads */ mig_external kern_return_t task_threads ( mach_port_t target_task, thread_array_t *thread_list, mach_msg_type_number_t *thread_listCnt ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t thread_listType; thread_array_t thread_list; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2011; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2111) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 48) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->thread_listType.msgtl_header.msgt_inline != FALSE) || (OutP->thread_listType.msgtl_header.msgt_longform != TRUE) || (OutP->thread_listType.msgtl_name != 17) || (OutP->thread_listType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *thread_list = OutP->thread_list; *thread_listCnt = OutP->thread_listType.msgtl_number; return KERN_SUCCESS; } /* Routine task_info */ mig_external kern_return_t task_info ( mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; mach_msg_type_t task_info_outCntType; mach_msg_type_number_t task_info_outCnt; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t task_info_outType; natural_t task_info_out[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t task_info_outCntType = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->task_info_outCntType = task_info_outCntType; if (*task_info_outCnt < 1024) InP->task_info_outCnt = *task_info_outCnt; else InP->task_info_outCnt = 1024; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2012; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2112) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 36) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->task_info_outType.msgt_inline != TRUE) || (OutP->task_info_outType.msgt_longform != FALSE) || (OutP->task_info_outType.msgt_name != 2) || (OutP->task_info_outType.msgt_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 36 + (4 * OutP->task_info_outType.msgt_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->task_info_outType.msgt_number > *task_info_outCnt) { memcpy(task_info_out, OutP->task_info_out, 4 * *task_info_outCnt); *task_info_outCnt = OutP->task_info_outType.msgt_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(task_info_out, OutP->task_info_out, 4 * OutP->task_info_outType.msgt_number); } *task_info_outCnt = OutP->task_info_outType.msgt_number; return KERN_SUCCESS; } /* Routine thread_terminate */ mig_external kern_return_t thread_terminate ( mach_port_t target_thread ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2016; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2116) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine thread_get_state */ mig_external kern_return_t thread_get_state ( mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; mach_msg_type_t old_stateCntType; mach_msg_type_number_t old_stateCnt; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t old_stateType; natural_t old_state[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t old_stateCntType = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->old_stateCntType = old_stateCntType; if (*old_stateCnt < 1024) InP->old_stateCnt = *old_stateCnt; else InP->old_stateCnt = 1024; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2017; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2117) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 36) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->old_stateType.msgt_inline != TRUE) || (OutP->old_stateType.msgt_longform != FALSE) || (OutP->old_stateType.msgt_name != 2) || (OutP->old_stateType.msgt_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 36 + (4 * OutP->old_stateType.msgt_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->old_stateType.msgt_number > *old_stateCnt) { memcpy(old_state, OutP->old_state, 4 * *old_stateCnt); *old_stateCnt = OutP->old_stateType.msgt_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(old_state, OutP->old_state, 4 * OutP->old_stateType.msgt_number); } *old_stateCnt = OutP->old_stateType.msgt_number; return KERN_SUCCESS; } /* Routine thread_set_state */ mig_external kern_return_t thread_set_state ( mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; mach_msg_type_t new_stateType; natural_t new_state[1024]; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t new_stateType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1024, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->new_stateType = new_stateType; if (new_stateCnt > 1024) { return MIG_ARRAY_TOO_LARGE; } else { memcpy(InP->new_state, new_state, 4 * new_stateCnt); } InP->new_stateType.msgt_number = new_stateCnt; msgh_size = 36 + (4 * new_stateCnt); InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2018; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2118) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine thread_info */ mig_external kern_return_t thread_info ( mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; mach_msg_type_t thread_info_outCntType; mach_msg_type_number_t thread_info_outCnt; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t thread_info_outType; natural_t thread_info_out[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t thread_info_outCntType = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->thread_info_outCntType = thread_info_outCntType; if (*thread_info_outCnt < 1024) InP->thread_info_outCnt = *thread_info_outCnt; else InP->thread_info_outCnt = 1024; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2019; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2119) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 36) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->thread_info_outType.msgt_inline != TRUE) || (OutP->thread_info_outType.msgt_longform != FALSE) || (OutP->thread_info_outType.msgt_name != 2) || (OutP->thread_info_outType.msgt_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 36 + (4 * OutP->thread_info_outType.msgt_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->thread_info_outType.msgt_number > *thread_info_outCnt) { memcpy(thread_info_out, OutP->thread_info_out, 4 * *thread_info_outCnt); *thread_info_outCnt = OutP->thread_info_outType.msgt_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(thread_info_out, OutP->thread_info_out, 4 * OutP->thread_info_outType.msgt_number); } *thread_info_outCnt = OutP->thread_info_outType.msgt_number; return KERN_SUCCESS; } /* Routine vm_allocate */ mig_external kern_return_t vm_allocate ( mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t anywhereType; boolean_t anywhere; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t addressType; vm_address_t address; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t anywhereType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t addressCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = *address; InP->sizeType = sizeType; InP->size = size; InP->anywhereType = anywhereType; InP->anywhere = anywhere; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2021; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2121) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 40) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *address = OutP->address; return KERN_SUCCESS; } /* Routine vm_deallocate */ mig_external kern_return_t vm_deallocate ( mach_port_t target_task, vm_address_t address, vm_size_t size ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->sizeType = sizeType; InP->size = size; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2023; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2123) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_protect */ mig_external kern_return_t vm_protect ( mach_port_t target_task, vm_address_t address, vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t set_maximumType; boolean_t set_maximum; mach_msg_type_t new_protectionType; vm_prot_t new_protection; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t set_maximumType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t new_protectionType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->sizeType = sizeType; InP->size = size; InP->set_maximumType = set_maximumType; InP->set_maximum = set_maximum; InP->new_protectionType = new_protectionType; InP->new_protection = new_protection; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2024; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2124) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_inherit */ mig_external kern_return_t vm_inherit ( mach_port_t target_task, vm_address_t address, vm_size_t size, vm_inherit_t new_inheritance ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t new_inheritanceType; vm_inherit_t new_inheritance; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t new_inheritanceType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->sizeType = sizeType; InP->size = size; InP->new_inheritanceType = new_inheritanceType; InP->new_inheritance = new_inheritance; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2025; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2125) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_read */ mig_external kern_return_t vm_read ( mach_port_t target_task, vm_address_t address, vm_size_t size, vm_offset_t *data, mach_msg_type_number_t *dataCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t dataType; vm_offset_t data; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->sizeType = sizeType; InP->size = size; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2026; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2126) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 48) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->dataType.msgtl_header.msgt_inline != FALSE) || (OutP->dataType.msgtl_header.msgt_longform != TRUE) || (OutP->dataType.msgtl_name != 9) || (OutP->dataType.msgtl_size != 8)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *data = OutP->data; *dataCnt = OutP->dataType.msgtl_number; return KERN_SUCCESS; } /* Routine vm_write */ mig_external kern_return_t vm_write ( mach_port_t target_task, vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_long_t dataType; vm_offset_t data; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t dataType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ FALSE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 9, /* msgtl_size = */ 8, /* msgtl_number = */ 0, }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->dataType = dataType; InP->data = data; InP->dataType.msgtl_number = dataCnt; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2027; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2127) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_copy */ mig_external kern_return_t vm_copy ( mach_port_t target_task, vm_address_t source_address, vm_size_t size, vm_address_t dest_address ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t source_addressType; vm_address_t source_address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t dest_addressType; vm_address_t dest_address; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t source_addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t dest_addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->source_addressType = source_addressType; InP->source_address = source_address; InP->sizeType = sizeType; InP->size = size; InP->dest_addressType = dest_addressType; InP->dest_address = dest_address; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2028; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2128) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_region */ mig_external kern_return_t vm_region ( mach_port_t target_task, vm_address_t *address, vm_size_t *size, vm_prot_t *protection, vm_prot_t *max_protection, vm_inherit_t *inheritance, boolean_t *is_shared, mach_port_t *object_name, vm_offset_t *offset ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t protectionType; vm_prot_t protection; mach_msg_type_t max_protectionType; vm_prot_t max_protection; mach_msg_type_t inheritanceType; vm_inherit_t inheritance; mach_msg_type_t is_sharedType; boolean_t is_shared; mach_msg_type_t object_nameType; mach_port_t object_name; mach_msg_type_t offsetType; vm_offset_t offset; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t addressCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t protectionCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t max_protectionCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t inheritanceCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t is_sharedCheck = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t object_nameCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t offsetCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = *address; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2029; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2129) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 96) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *address = OutP->address; #if TypeCheck if (BAD_TYPECHECK (&OutP->sizeType, &sizeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *size = OutP->size; #if TypeCheck if (BAD_TYPECHECK (&OutP->protectionType, &protectionCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *protection = OutP->protection; #if TypeCheck if (BAD_TYPECHECK (&OutP->max_protectionType, &max_protectionCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *max_protection = OutP->max_protection; #if TypeCheck if (BAD_TYPECHECK (&OutP->inheritanceType, &inheritanceCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *inheritance = OutP->inheritance; #if TypeCheck if (BAD_TYPECHECK (&OutP->is_sharedType, &is_sharedCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *is_shared = OutP->is_shared; #if TypeCheck if (BAD_TYPECHECK (&OutP->object_nameType, &object_nameCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *object_name = OutP->object_name; #if TypeCheck if (BAD_TYPECHECK (&OutP->offsetType, &offsetCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *offset = OutP->offset; return KERN_SUCCESS; } /* Routine vm_statistics */ mig_external kern_return_t vm_statistics ( mach_port_t target_task, vm_statistics_data_t *vm_stats ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t vm_statsType; vm_statistics_data_t vm_stats; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t vm_statsCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 13, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2030; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2130) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 88) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->vm_statsType, &vm_statsCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *vm_stats = OutP->vm_stats; return KERN_SUCCESS; } /* Routine mach_ports_register */ mig_external kern_return_t mach_ports_register ( mach_port_t target_task, mach_port_array_t init_port_set, mach_msg_type_number_t init_port_setCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_long_t init_port_setType; mach_port_array_t init_port_set; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_long_t init_port_setType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ FALSE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 19, /* msgtl_size = */ 32, /* msgtl_number = */ 0, }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->init_port_setType = init_port_setType; InP->init_port_set = init_port_set; InP->init_port_setType.msgtl_number = init_port_setCnt; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2033; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2133) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine mach_ports_lookup */ mig_external kern_return_t mach_ports_lookup ( mach_port_t target_task, mach_port_array_t *init_port_set, mach_msg_type_number_t *init_port_setCnt ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t init_port_setType; mach_port_array_t init_port_set; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2034; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2134) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 48) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->init_port_setType.msgtl_header.msgt_inline != FALSE) || (OutP->init_port_setType.msgtl_header.msgt_longform != TRUE) || (OutP->init_port_setType.msgtl_name != 17) || (OutP->init_port_setType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *init_port_set = OutP->init_port_set; *init_port_setCnt = OutP->init_port_setType.msgtl_number; return KERN_SUCCESS; } /* SimpleRoutine memory_object_data_provided */ mig_external kern_return_t memory_object_data_provided ( mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, vm_prot_t lock_value ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_long_t dataType; vm_offset_t data; mach_msg_type_t lock_valueType; vm_prot_t lock_value; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t dataType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ FALSE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 9, /* msgtl_size = */ 8, /* msgtl_number = */ 0, }; auto const mach_msg_type_t lock_valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->dataType = dataType; InP->data = data; InP->dataType.msgtl_number = dataCnt; InP->lock_valueType = lock_valueType; InP->lock_value = lock_value; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2038; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 56, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_data_unavailable */ mig_external kern_return_t memory_object_data_unavailable ( mach_port_t memory_control, vm_offset_t offset, vm_size_t size ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_t sizeType; vm_size_t size; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->sizeType = sizeType; InP->size = size; InP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2039; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* Routine memory_object_get_attributes */ mig_external kern_return_t memory_object_get_attributes ( mach_port_t memory_control, boolean_t *object_ready, boolean_t *may_cache, memory_object_copy_strategy_t *copy_strategy ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t object_readyType; boolean_t object_ready; mach_msg_type_t may_cacheType; boolean_t may_cache; mach_msg_type_t copy_strategyType; memory_object_copy_strategy_t copy_strategy; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t object_readyCheck = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t may_cacheCheck = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t copy_strategyCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2040; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2140) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 56) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->object_readyType, &object_readyCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *object_ready = OutP->object_ready; #if TypeCheck if (BAD_TYPECHECK (&OutP->may_cacheType, &may_cacheCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *may_cache = OutP->may_cache; #if TypeCheck if (BAD_TYPECHECK (&OutP->copy_strategyType, ©_strategyCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *copy_strategy = OutP->copy_strategy; return KERN_SUCCESS; } /* Routine vm_set_default_memory_manager */ mig_external kern_return_t vm_set_default_memory_manager ( mach_port_t host_priv, mach_port_t *default_manager ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t default_managerType; mach_port_t default_manager; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t default_managerType; mach_port_t default_manager; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t default_managerType = { /* msgt_name = */ 20, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t default_managerCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->default_managerType = default_managerType; InP->default_manager = *default_manager; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = host_priv; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2041; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2141) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 40) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->default_managerType, &default_managerCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *default_manager = OutP->default_manager; return KERN_SUCCESS; } /* SimpleRoutine xxx_memory_object_lock_request */ mig_external kern_return_t xxx_memory_object_lock_request ( mach_port_t memory_control, vm_offset_t offset, vm_size_t size, boolean_t should_clean, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t should_cleanType; boolean_t should_clean; mach_msg_type_t should_flushType; boolean_t should_flush; mach_msg_type_t lock_valueType; vm_prot_t lock_value; mach_msg_type_t reply_toType; mach_port_t reply_to; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t should_cleanType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t should_flushType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t lock_valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t reply_toType = { /* msgt_name = */ 21, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->sizeType = sizeType; InP->size = size; InP->should_cleanType = should_cleanType; InP->should_clean = should_clean; InP->should_flushType = should_flushType; InP->should_flush = should_flush; InP->lock_valueType = lock_valueType; InP->lock_value = lock_value; InP->reply_toType = reply_toType; InP->reply_to = reply_to; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2043; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_lock_request */ mig_external kern_return_t memory_object_lock_request ( mach_port_t memory_control, vm_offset_t offset, vm_size_t size, memory_object_return_t should_return, boolean_t should_flush, vm_prot_t lock_value, mach_port_t reply_to ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t should_returnType; memory_object_return_t should_return; mach_msg_type_t should_flushType; boolean_t should_flush; mach_msg_type_t lock_valueType; vm_prot_t lock_value; mach_msg_type_t reply_toType; mach_port_t reply_to; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t should_returnType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t should_flushType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t lock_valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t reply_toType = { /* msgt_name = */ 21, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->sizeType = sizeType; InP->size = size; InP->should_returnType = should_returnType; InP->should_return = should_return; InP->should_flushType = should_flushType; InP->should_flush = should_flush; InP->lock_valueType = lock_valueType; InP->lock_value = lock_value; InP->reply_toType = reply_toType; InP->reply_to = reply_to; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2044; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* Routine xxx_task_get_emulation_vector */ mig_external kern_return_t xxx_task_get_emulation_vector ( mach_port_t task, int *vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t *emulation_vectorCnt ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t vector_startType; int vector_start; mach_msg_type_long_t emulation_vectorType; vm_offset_t emulation_vector[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t vector_startCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2045; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2145) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 52) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->vector_startType, &vector_startCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *vector_start = OutP->vector_start; #if TypeCheck if ((OutP->emulation_vectorType.msgtl_header.msgt_inline != TRUE) || (OutP->emulation_vectorType.msgtl_header.msgt_longform != TRUE) || (OutP->emulation_vectorType.msgtl_name != 2) || (OutP->emulation_vectorType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 52 + (4 * OutP->emulation_vectorType.msgtl_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->emulation_vectorType.msgtl_number > *emulation_vectorCnt) { memcpy(emulation_vector, OutP->emulation_vector, 4 * *emulation_vectorCnt); *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(emulation_vector, OutP->emulation_vector, 4 * OutP->emulation_vectorType.msgtl_number); } *emulation_vectorCnt = OutP->emulation_vectorType.msgtl_number; return KERN_SUCCESS; } /* Routine xxx_task_set_emulation_vector */ mig_external kern_return_t xxx_task_set_emulation_vector ( mach_port_t task, int vector_start, emulation_vector_t emulation_vector, mach_msg_type_number_t emulation_vectorCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t vector_startType; int vector_start; mach_msg_type_long_t emulation_vectorType; vm_offset_t emulation_vector[1024]; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; auto const mach_msg_type_t vector_startType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t emulation_vectorType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ TRUE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 2, /* msgtl_size = */ 32, /* msgtl_number = */ 1024, }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->vector_startType = vector_startType; InP->vector_start = vector_start; InP->emulation_vectorType = emulation_vectorType; if (emulation_vectorCnt > 1024) { return MIG_ARRAY_TOO_LARGE; } else { memcpy(InP->emulation_vector, emulation_vector, 4 * emulation_vectorCnt); } InP->emulation_vectorType.msgtl_number = emulation_vectorCnt; msgh_size = 44 + (4 * emulation_vectorCnt); InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2046; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2146) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine xxx_host_info */ mig_external kern_return_t xxx_host_info ( mach_port_t target_task, machine_info_data_t *info ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t infoType; machine_info_data_t info; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t infoCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 5, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2047; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2147) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 56) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->infoType, &infoCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *info = OutP->info; return KERN_SUCCESS; } /* Routine xxx_slot_info */ mig_external kern_return_t xxx_slot_info ( mach_port_t target_task, int slot, machine_slot_data_t *info ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t slotType; int slot; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t infoType; machine_slot_data_t info; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t slotType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t infoCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 8, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->slotType = slotType; InP->slot = slot; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2048; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2148) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 68) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->infoType, &infoCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *info = OutP->info; return KERN_SUCCESS; } /* Routine xxx_cpu_control */ mig_external kern_return_t xxx_cpu_control ( mach_port_t target_task, int cpu, boolean_t running ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t cpuType; int cpu; mach_msg_type_t runningType; boolean_t running; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t cpuType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t runningType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->cpuType = cpuType; InP->cpu = cpu; InP->runningType = runningType; InP->running = running; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2049; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2149) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_suspend */ mig_external kern_return_t task_suspend ( mach_port_t target_task ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2056; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2156) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_resume */ mig_external kern_return_t task_resume ( mach_port_t target_task ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2057; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2157) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_get_special_port */ mig_external kern_return_t task_get_special_port ( mach_port_t task, int which_port, mach_port_t *special_port ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t which_portType; int which_port; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t special_portType; mach_port_t special_port; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t which_portType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t special_portCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->which_portType = which_portType; InP->which_port = which_port; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2058; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2158) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 40) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->special_portType, &special_portCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *special_port = OutP->special_port; return KERN_SUCCESS; } /* Routine task_set_special_port */ mig_external kern_return_t task_set_special_port ( mach_port_t task, int which_port, mach_port_t special_port ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t which_portType; int which_port; mach_msg_type_t special_portType; mach_port_t special_port; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t which_portType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t special_portType = { /* msgt_name = */ 19, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->which_portType = which_portType; InP->which_port = which_port; InP->special_portType = special_portType; InP->special_port = special_port; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2059; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2159) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine xxx_task_info */ mig_external kern_return_t xxx_task_info ( mach_port_t target_task, int flavor, task_info_t task_info_out, mach_msg_type_number_t *task_info_outCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t task_info_outType; natural_t task_info_out[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2060; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2160) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 44) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->task_info_outType.msgtl_header.msgt_inline != TRUE) || (OutP->task_info_outType.msgtl_header.msgt_longform != TRUE) || (OutP->task_info_outType.msgtl_name != 2) || (OutP->task_info_outType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 44 + (4 * OutP->task_info_outType.msgtl_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->task_info_outType.msgtl_number > *task_info_outCnt) { memcpy(task_info_out, OutP->task_info_out, 4 * *task_info_outCnt); *task_info_outCnt = OutP->task_info_outType.msgtl_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(task_info_out, OutP->task_info_out, 4 * OutP->task_info_outType.msgtl_number); } *task_info_outCnt = OutP->task_info_outType.msgtl_number; return KERN_SUCCESS; } /* Routine thread_create */ mig_external kern_return_t thread_create ( mach_port_t parent_task, mach_port_t *child_thread ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t child_threadType; mach_port_t child_thread; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t child_threadCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = parent_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2061; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2161) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 40) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->child_threadType, &child_threadCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *child_thread = OutP->child_thread; return KERN_SUCCESS; } /* Routine thread_suspend */ mig_external kern_return_t thread_suspend ( mach_port_t target_thread ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2062; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2162) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine thread_resume */ mig_external kern_return_t thread_resume ( mach_port_t target_thread ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2063; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2163) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine thread_abort */ mig_external kern_return_t thread_abort ( mach_port_t target_thread ) { typedef struct { mach_msg_header_t Head; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2064; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 24, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2164) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine xxx_thread_get_state */ mig_external kern_return_t xxx_thread_get_state ( mach_port_t target_thread, int flavor, thread_state_t old_state, mach_msg_type_number_t *old_stateCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t old_stateType; natural_t old_state[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2065; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2165) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 44) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->old_stateType.msgtl_header.msgt_inline != TRUE) || (OutP->old_stateType.msgtl_header.msgt_longform != TRUE) || (OutP->old_stateType.msgtl_name != 2) || (OutP->old_stateType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 44 + (4 * OutP->old_stateType.msgtl_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->old_stateType.msgtl_number > *old_stateCnt) { memcpy(old_state, OutP->old_state, 4 * *old_stateCnt); *old_stateCnt = OutP->old_stateType.msgtl_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(old_state, OutP->old_state, 4 * OutP->old_stateType.msgtl_number); } *old_stateCnt = OutP->old_stateType.msgtl_number; return KERN_SUCCESS; } /* Routine xxx_thread_set_state */ mig_external kern_return_t xxx_thread_set_state ( mach_port_t target_thread, int flavor, thread_state_t new_state, mach_msg_type_number_t new_stateCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; mach_msg_type_long_t new_stateType; natural_t new_state[1024]; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t new_stateType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ TRUE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 2, /* msgtl_size = */ 32, /* msgtl_number = */ 1024, }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->new_stateType = new_stateType; if (new_stateCnt > 1024) { return MIG_ARRAY_TOO_LARGE; } else { memcpy(InP->new_state, new_state, 4 * new_stateCnt); } InP->new_stateType.msgtl_number = new_stateCnt; msgh_size = 44 + (4 * new_stateCnt); InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2066; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2166) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine thread_get_special_port */ mig_external kern_return_t thread_get_special_port ( mach_port_t thread, int which_port, mach_port_t *special_port ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t which_portType; int which_port; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t special_portType; mach_port_t special_port; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck boolean_t msgh_simple; #endif /* TypeCheck */ #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t which_portType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t special_portCheck = { /* msgt_name = */ 17, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->which_portType = which_portType; InP->which_port = which_port; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2067; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2167) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); if (((msgh_size != 40) || msgh_simple) && ((msgh_size != sizeof(mig_reply_header_t)) || !msgh_simple || (OutP->RetCode == KERN_SUCCESS))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->special_portType, &special_portCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *special_port = OutP->special_port; return KERN_SUCCESS; } /* Routine thread_set_special_port */ mig_external kern_return_t thread_set_special_port ( mach_port_t thread, int which_port, mach_port_t special_port ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t which_portType; int which_port; mach_msg_type_t special_portType; mach_port_t special_port; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t which_portType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t special_portType = { /* msgt_name = */ 19, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->which_portType = which_portType; InP->which_port = which_port; InP->special_portType = special_portType; InP->special_port = special_port; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2068; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2168) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine xxx_thread_info */ mig_external kern_return_t xxx_thread_info ( mach_port_t target_thread, int flavor, thread_info_t thread_info_out, mach_msg_type_number_t *thread_info_outCnt ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t flavorType; int flavor; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_long_t thread_info_outType; natural_t thread_info_out[1024]; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->flavorType = flavorType; InP->flavor = flavor; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_thread; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2069; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 32, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2169) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size < 44) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if ((OutP->thread_info_outType.msgtl_header.msgt_inline != TRUE) || (OutP->thread_info_outType.msgtl_header.msgt_longform != TRUE) || (OutP->thread_info_outType.msgtl_name != 2) || (OutP->thread_info_outType.msgtl_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (msgh_size != 44 + (4 * OutP->thread_info_outType.msgtl_number)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->thread_info_outType.msgtl_number > *thread_info_outCnt) { memcpy(thread_info_out, OutP->thread_info_out, 4 * *thread_info_outCnt); *thread_info_outCnt = OutP->thread_info_outType.msgtl_number; return MIG_ARRAY_TOO_LARGE; } else { memcpy(thread_info_out, OutP->thread_info_out, 4 * OutP->thread_info_outType.msgtl_number); } *thread_info_outCnt = OutP->thread_info_outType.msgtl_number; return KERN_SUCCESS; } /* Routine task_set_emulation */ mig_external kern_return_t task_set_emulation ( mach_port_t target_port, vm_address_t routine_entry_pt, int routine_number ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t routine_entry_ptType; vm_address_t routine_entry_pt; mach_msg_type_t routine_numberType; int routine_number; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t routine_entry_ptType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t routine_numberType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->routine_entry_ptType = routine_entry_ptType; InP->routine_entry_pt = routine_entry_pt; InP->routine_numberType = routine_numberType; InP->routine_number = routine_number; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_port; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2070; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 40, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2170) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine task_ras_control */ mig_external kern_return_t task_ras_control ( mach_port_t target_task, vm_address_t basepc, vm_address_t boundspc, int flavor ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t basepcType; vm_address_t basepc; mach_msg_type_t boundspcType; vm_address_t boundspc; mach_msg_type_t flavorType; int flavor; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; auto const mach_msg_type_t basepcType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t boundspcType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t flavorType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->basepcType = basepcType; InP->basepc = basepc; InP->boundspcType = boundspcType; InP->boundspc = boundspc; InP->flavorType = flavorType; InP->flavor = flavor; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2071; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 48, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2171) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || (OutP->Head.msgh_size != 32)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ return OutP->RetCode; } /* Routine vm_map */ mig_external kern_return_t vm_map ( mach_port_t target_task, vm_address_t *address, vm_size_t size, vm_address_t mask, boolean_t anywhere, mach_port_t memory_object, vm_offset_t offset, boolean_t copy, vm_prot_t cur_protection, vm_prot_t max_protection, vm_inherit_t inheritance ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t maskType; vm_address_t mask; mach_msg_type_t anywhereType; boolean_t anywhere; mach_msg_type_t memory_objectType; mach_port_t memory_object; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_t copyType; boolean_t copy; mach_msg_type_t cur_protectionType; vm_prot_t cur_protection; mach_msg_type_t max_protectionType; vm_prot_t max_protection; mach_msg_type_t inheritanceType; vm_inherit_t inheritance; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t addressType; vm_address_t address; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t maskType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t anywhereType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t memory_objectType = { /* msgt_name = */ 19, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t copyType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t cur_protectionType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t max_protectionType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t inheritanceType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t addressCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = *address; InP->sizeType = sizeType; InP->size = size; InP->maskType = maskType; InP->mask = mask; InP->anywhereType = anywhereType; InP->anywhere = anywhere; InP->memory_objectType = memory_objectType; InP->memory_object = memory_object; InP->offsetType = offsetType; InP->offset = offset; InP->copyType = copyType; InP->copy = copy; InP->cur_protectionType = cur_protectionType; InP->cur_protection = cur_protection; InP->max_protectionType = max_protectionType; InP->max_protection = max_protection; InP->inheritanceType = inheritanceType; InP->inheritance = inheritance; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2089; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 104, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2189) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 40) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->addressType, &addressCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *address = OutP->address; return KERN_SUCCESS; } /* SimpleRoutine memory_object_data_error */ mig_external kern_return_t memory_object_data_error ( mach_port_t memory_control, vm_offset_t offset, vm_size_t size, kern_return_t error_value ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t error_valueType; kern_return_t error_value; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t error_valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->sizeType = sizeType; InP->size = size; InP->error_valueType = error_valueType; InP->error_value = error_value; InP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2090; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_set_attributes */ mig_external kern_return_t memory_object_set_attributes ( mach_port_t memory_control, boolean_t object_ready, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t object_readyType; boolean_t object_ready; mach_msg_type_t may_cacheType; boolean_t may_cache; mach_msg_type_t copy_strategyType; memory_object_copy_strategy_t copy_strategy; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t object_readyType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t may_cacheType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t copy_strategyType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->object_readyType = object_readyType; InP->object_ready = object_ready; InP->may_cacheType = may_cacheType; InP->may_cache = may_cache; InP->copy_strategyType = copy_strategyType; InP->copy_strategy = copy_strategy; InP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2091; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_destroy */ mig_external kern_return_t memory_object_destroy ( mach_port_t memory_control, kern_return_t reason ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t reasonType; kern_return_t reason; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t reasonType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->reasonType = reasonType; InP->reason = reason; InP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2092; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 32, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_data_supply */ mig_external kern_return_t memory_object_data_supply ( mach_port_t memory_control, vm_offset_t offset, vm_offset_t data, mach_msg_type_number_t dataCnt, boolean_t dataDealloc, vm_prot_t lock_value, boolean_t precious, mach_port_t reply_to ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t offsetType; vm_offset_t offset; mach_msg_type_long_t dataType; vm_offset_t data; mach_msg_type_t lock_valueType; vm_prot_t lock_value; mach_msg_type_t preciousType; boolean_t precious; mach_msg_type_t reply_toType; mach_port_t reply_to; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t offsetType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_long_t dataType = { { /* msgt_name = */ 0, /* msgt_size = */ 0, /* msgt_number = */ 0, /* msgt_inline = */ FALSE, /* msgt_longform = */ TRUE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }, /* msgtl_name = */ 9, /* msgtl_size = */ 8, /* msgtl_number = */ 0, }; auto const mach_msg_type_t lock_valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t preciousType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t reply_toType = { /* msgt_name = */ 21, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->offsetType = offsetType; InP->offset = offset; InP->dataType = dataType; InP->data = data; InP->dataType.msgtl_number = dataCnt; InP->dataType.msgtl_header.msgt_deallocate = dataDealloc; InP->lock_valueType = lock_valueType; InP->lock_value = lock_value; InP->preciousType = preciousType; InP->precious = precious; InP->reply_toType = reply_toType; InP->reply_to = reply_to; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2093; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 72, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_ready */ mig_external kern_return_t memory_object_ready ( mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t may_cacheType; boolean_t may_cache; mach_msg_type_t copy_strategyType; memory_object_copy_strategy_t copy_strategy; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t may_cacheType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t copy_strategyType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->may_cacheType = may_cacheType; InP->may_cache = may_cache; InP->copy_strategyType = copy_strategyType; InP->copy_strategy = copy_strategy; InP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2094; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 40, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* SimpleRoutine memory_object_change_attributes */ mig_external kern_return_t memory_object_change_attributes ( mach_port_t memory_control, boolean_t may_cache, memory_object_copy_strategy_t copy_strategy, mach_port_t reply_to ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t may_cacheType; boolean_t may_cache; mach_msg_type_t copy_strategyType; memory_object_copy_strategy_t copy_strategy; mach_msg_type_t reply_toType; mach_port_t reply_to; } Request; union { Request In; } Mess; register Request *InP = &Mess.In; auto const mach_msg_type_t may_cacheType = { /* msgt_name = */ 0, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t copy_strategyType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t reply_toType = { /* msgt_name = */ 21, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->may_cacheType = may_cacheType; InP->may_cache = may_cache; InP->copy_strategyType = copy_strategyType; InP->copy_strategy = copy_strategy; InP->reply_toType = reply_toType; InP->reply_to = reply_to; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, 0); /* msgh_size passed as argument */ InP->Head.msgh_request_port = memory_control; InP->Head.msgh_reply_port = MACH_PORT_NULL; InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2095; return mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, 48, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); } /* Routine vm_machine_attribute */ mig_external kern_return_t vm_machine_attribute ( mach_port_t target_task, vm_address_t address, vm_size_t size, vm_machine_attribute_t attribute, vm_machine_attribute_val_t *value ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t addressType; vm_address_t address; mach_msg_type_t sizeType; vm_size_t size; mach_msg_type_t attributeType; vm_machine_attribute_t attribute; mach_msg_type_t valueType; vm_machine_attribute_val_t value; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; mach_msg_type_t valueType; vm_machine_attribute_val_t value; } Reply; union { Request In; Reply Out; } Mess; register Request *InP = &Mess.In; register Reply *OutP = &Mess.Out; mach_msg_return_t msg_result; #if TypeCheck unsigned int msgh_size; #endif /* TypeCheck */ auto const mach_msg_type_t addressType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t sizeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t attributeType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t valueType = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t RetCodeCheck = { /* msgt_name = */ MACH_MSG_TYPE_INTEGER_32, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; auto const mach_msg_type_t valueCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; InP->addressType = addressType; InP->address = address; InP->sizeType = sizeType; InP->size = size; InP->attributeType = attributeType; InP->attribute = attribute; InP->valueType = valueType; InP->value = *value; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = target_task; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 2099; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 56, sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); if (msg_result != MACH_MSG_SUCCESS) { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return msg_result; } mig_put_reply_port(InP->Head.msgh_reply_port); if (OutP->Head.msgh_id != 2199) { if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; else { mig_dealloc_reply_port(InP->Head.msgh_reply_port); return MIG_REPLY_MISMATCH; } } #if TypeCheck msgh_size = OutP->Head.msgh_size; if ((OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || ((msgh_size != 40) && ((msgh_size != sizeof(mig_reply_header_t)) || (OutP->RetCode == KERN_SUCCESS)))) return MIG_TYPE_ERROR; #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK (&OutP->RetCodeType, &RetCodeCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ if (OutP->RetCode != KERN_SUCCESS) return OutP->RetCode; #if TypeCheck if (BAD_TYPECHECK (&OutP->valueType, &valueCheck)) return MIG_TYPE_ERROR; #endif /* TypeCheck */ *value = OutP->value; return KERN_SUCCESS; }