static mach_msg_return_t Start(mach_port_t shark_port, uint32_t name) { mach_port_t reply_port = mig_get_reply_port(); struct chud_client_start_msg msg; msg.hdr.msgh_bits = 0x80001513; msg.hdr.msgh_size = sizeof(mach_msg_header_t); msg.hdr.msgh_remote_port = shark_port; msg.hdr.msgh_local_port = reply_port; msg.hdr.msgh_reserved = 0; msg.hdr.msgh_id = SHARK_MSG_START; msg.unk0 = 1; msg.name0 = name; msg.arg2 = 6; msg.unk1 = 0; msg.unk2 = 1; msg.unk3 = 0; msg.unk4 = 1; msg.unk5 = 0; msg.unk6 = 1; msg.name1 = name; JS_ASSERT(sizeof(msg) == 0x34); mach_msg_return_t result = mach_msg(&msg.hdr, MACH_SEND_MSG | MACH_RCV_MSG, sizeof(msg), 0x30, reply_port, 0, 0); mig_dealloc_reply_port(reply_port); return result; }
// // Subsidiary process management. // This does not go through the generic securityd-client setup. // void ClientSession::childCheckIn(Port serverPort, Port taskPort) { Port securitydPort = findSecurityd(); mach_port_t originPort = MACH_PORT_NULL; IPCN(ucsp_client_verifyPrivileged2(securitydPort.port(), mig_get_reply_port(), &securitydCreds, &rcode, &originPort)); if (originPort != securitydPort.port()) CssmError::throwMe(CSSM_ERRCODE_VERIFICATION_FAILURE); mach_port_mod_refs(mach_task_self(), originPort, MACH_PORT_RIGHT_SEND, -1); check(ucsp_client_childCheckIn(securitydPort, serverPort, taskPort)); }
int main(int argc, char** argv) { Request req = {0}; Request* InP = &req; mach_port_t ports[1]; ports[0] = MACH_PORT_NULL; // any mach port // from old 10.9.5 launchd MIG .defs: InP->msgh_body.msgh_descriptor_count = 3; InP->request.address = (void *)(NULL); InP->request.size = 0; InP->request.deallocate = FALSE; InP->request.copy = MACH_MSG_VIRTUAL_COPY; InP->request.type = MACH_MSG_OOL_DESCRIPTOR; InP->request_fds.address = (void *)(&ports[0]); InP->request_fds.count = 1; InP->request_fds.disposition = 17; InP->request_fds.deallocate = FALSE; InP->request_fds.type = MACH_MSG_OOL_PORTS_DESCRIPTOR; InP->asport.name = MACH_PORT_NULL; InP->asport.disposition = 19; InP->asport.type = MACH_MSG_PORT_DESCRIPTOR; InP->NDR = NDR_record; InP->requestCnt = 0; InP->request_fdsCnt = 0x2000/4; InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); InP->Head.msgh_remote_port = bootstrap_port; InP->Head.msgh_local_port = mig_get_reply_port(); InP->Head.msgh_id = 437; kern_return_t msg_result; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG/*|MACH_RCV_MSG*/|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), 0,//(mach_msg_size_t)sizeof(Reply), InP->Head.msgh_local_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); return InP; }
mach_msg_return_t Stop(mach_port_t shark_port) { mach_port_t reply_port = mig_get_reply_port(); struct chud_client_stop_msg msg; msg.hdr.msgh_bits = 0x1513; msg.hdr.msgh_size = sizeof(mach_msg_header_t); msg.hdr.msgh_remote_port = shark_port; msg.hdr.msgh_local_port = reply_port; msg.hdr.msgh_reserved = 0; msg.hdr.msgh_id = SHARK_MSG_STOP; JS_ASSERT(RECV_SIZEOF(struct chud_client_stop_msg) == 0x18); JS_ASSERT(sizeof(msg) == 0x2c); mach_msg_return_t result = mach_msg(&msg.hdr, MACH_SEND_MSG | MACH_RCV_MSG, RECV_SIZEOF(struct chud_client_stop_msg), sizeof(msg), reply_port, 0, 0); mig_dealloc_reply_port(reply_port); return result; }
static mach_msg_return_t Connect(mach_port_t shark_port) { mach_port_t reply_port = mig_get_reply_port(); struct chud_client_acquire_msg msg; msg.hdr.msgh_bits = 0x1513; msg.hdr.msgh_size = sizeof(mach_msg_header_t); msg.hdr.msgh_remote_port = shark_port; msg.hdr.msgh_local_port = reply_port; msg.hdr.msgh_reserved = 0; msg.hdr.msgh_id = SHARK_MSG_ACQUIRE; msg.unk0 = 0; msg.unk1 = 1; msg.pid = getpid(); JS_ASSERT(RECV_SIZEOF(struct chud_client_acquire_msg) == 0x24); JS_ASSERT(sizeof(msg) == 0x2c); mach_msg_return_t result = mach_msg(&msg.hdr, MACH_SEND_MSG | MACH_RCV_MSG, RECV_SIZEOF(struct chud_client_acquire_msg), sizeof(msg), reply_port, 0, 0); mig_dealloc_reply_port(reply_port); return result; }
// // Construct the process-global state object. // The ModuleNexus construction magic will ensure that this happens uniquely // even if the face of multithreaded attack. // ClientSession::Global::Global() { // find server port serverPort = findSecurityd(); mach_port_t originPort = MACH_PORT_NULL; IPCN(ucsp_client_verifyPrivileged2(serverPort.port(), mig_get_reply_port(), &securitydCreds, &rcode, &originPort)); if (originPort != serverPort.port()) CssmError::throwMe(CSSM_ERRCODE_VERIFICATION_FAILURE); mach_port_mod_refs(mach_task_self(), originPort, MACH_PORT_RIGHT_SEND, -1); // send identification/setup message static const char extForm[] = "?:obsolete"; ClientSetupInfo info = { 0x1234, SSPROTOVERSION }; // cannot use UCSP_ARGS here because it uses mGlobal() -> deadlock Thread &thread = this->thread(); IPCN(ucsp_client_setup(serverPort, thread.replyPort, &securitydCreds, &rcode, mach_task_self(), info, extForm)); thread.registered = true; // as a side-effect of setup call above IFDEBUG(serverPort.requestNotify(thread.replyPort)); secdebug("SSclnt", "contact with %s established", mContactName); }
/* Routine Query */ mig_external kern_return_t libinfoDSmig_Query ( mach_port_t server, int32_t proc, inline_data_t request, mach_msg_type_number_t requestCnt, inline_data_t reply, mach_msg_type_number_t *replyCnt, vm_offset_t *ooreply, mach_msg_type_number_t *ooreplyCnt, security_token_t *usertoken ) { #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; int32_t proc; mach_msg_type_number_t requestCnt; char request[16384]; } Request; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t ooreply; /* end of the kernel processed data */ NDR_record_t NDR; mach_msg_type_number_t replyCnt; char reply[16384]; mach_msg_type_number_t ooreplyCnt; mach_msg_max_trailer_t trailer; } Reply; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_ool_descriptor_t ooreply; /* end of the kernel processed data */ NDR_record_t NDR; mach_msg_type_number_t replyCnt; char reply[16384]; mach_msg_type_number_t ooreplyCnt; } __Reply; #ifdef __MigPackStructs #pragma pack() #endif /* * typedef struct { * mach_msg_header_t Head; * NDR_record_t NDR; * kern_return_t RetCode; * } mig_reply_error_t; */ union { Request In; Reply Out; } Mess; Request *InP = &Mess.In; Reply *Out0P = &Mess.Out; Reply *Out1P = NULL; mach_msg_return_t msg_result; unsigned int msgh_size; mach_msg_max_trailer_t *TrailerP; #if __MigTypeCheck unsigned int trailer_size; #endif /* __MigTypeCheck */ #ifdef __MIG_check__Reply__Query_t__defined kern_return_t check_result; #endif /* __MIG_check__Reply__Query_t__defined */ __DeclareSendRpc(50001, "Query") InP->NDR = NDR_record; InP->proc = proc; if (requestCnt > 16384) { { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) InP->request, (const char *) request, requestCnt); InP->requestCnt = requestCnt; msgh_size = (mach_msg_size_t)(sizeof(Request) - 16384) + (_WALIGN_(requestCnt)); InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = server; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_id = 50001; __BeforeSendRpc(50001, "Query") msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)|MACH_MSG_OPTION_NONE|MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SENDER), msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); __AfterSendRpc(50001, "Query") if (msg_result != MACH_MSG_SUCCESS) { __MachMsgErrorWithoutTimeout(msg_result); { return msg_result; } } #if defined(__MIG_check__Reply__Query_t__defined) check_result = __MIG_check__Reply__Query_t((__Reply__Query_t *)Out0P, (__Reply__Query_t **)&Out1P); if (check_result != MACH_MSG_SUCCESS) { return check_result; } #endif /* defined(__MIG_check__Reply__Query_t__defined) */ TrailerP = (mach_msg_max_trailer_t *)((vm_offset_t)Out0P + round_msg(Out0P->Head.msgh_size)); if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) { return MIG_TRAILER_ERROR ; } #if __MigTypeCheck trailer_size = TrailerP->msgh_trailer_size - (mach_msg_size_t)(sizeof(mach_msg_trailer_type_t) - sizeof(mach_msg_trailer_size_t)); #endif /* __MigTypeCheck */ #if __MigTypeCheck if (trailer_size < (mach_msg_size_t)sizeof(security_token_t)) { return MIG_TRAILER_ERROR ; } trailer_size -= (mach_msg_size_t)sizeof(security_token_t); #endif /* __MigTypeCheck */ if (Out0P->replyCnt > 16384) { (void)memcpy((char *) reply, (const char *) Out0P->reply, 16384); *replyCnt = Out0P->replyCnt; { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) reply, (const char *) Out0P->reply, Out0P->replyCnt); *replyCnt = Out0P->replyCnt; *ooreply = (vm_offset_t)(Out0P->ooreply.address); *ooreplyCnt = Out1P->ooreplyCnt; *usertoken = TrailerP->msgh_sender; return KERN_SUCCESS; }
/* Routine GetProcedureNumber */ mig_external kern_return_t libinfoDSmig_GetProcedureNumber ( mach_port_t server, proc_name_t name, int32_t *procno, security_token_t *usertoken ) { #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; mach_msg_type_number_t nameOffset; /* MiG doesn't use it */ mach_msg_type_number_t nameCnt; char name[256]; } Request; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int32_t procno; mach_msg_max_trailer_t trailer; } Reply; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int32_t procno; } __Reply; #ifdef __MigPackStructs #pragma pack() #endif /* * typedef struct { * mach_msg_header_t Head; * NDR_record_t NDR; * kern_return_t RetCode; * } mig_reply_error_t; */ union { Request In; Reply Out; } Mess; Request *InP = &Mess.In; Reply *Out0P = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; mach_msg_max_trailer_t *TrailerP; #if __MigTypeCheck unsigned int trailer_size; #endif /* __MigTypeCheck */ #ifdef __MIG_check__Reply__GetProcedureNumber_t__defined kern_return_t check_result; #endif /* __MIG_check__Reply__GetProcedureNumber_t__defined */ __DeclareSendRpc(50000, "GetProcedureNumber") InP->NDR = NDR_record; InP->nameCnt = mig_strncpy(InP->name, name, 256); msgh_size = (mach_msg_size_t)(sizeof(Request) - 256) + (_WALIGN_(InP->nameCnt)); InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = server; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_id = 50000; __BeforeSendRpc(50000, "GetProcedureNumber") msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0)|MACH_MSG_OPTION_NONE|MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_SENDER), msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); __AfterSendRpc(50000, "GetProcedureNumber") if (msg_result != MACH_MSG_SUCCESS) { __MachMsgErrorWithoutTimeout(msg_result); { return msg_result; } } #if defined(__MIG_check__Reply__GetProcedureNumber_t__defined) check_result = __MIG_check__Reply__GetProcedureNumber_t((__Reply__GetProcedureNumber_t *)Out0P); if (check_result != MACH_MSG_SUCCESS) { return check_result; } #endif /* defined(__MIG_check__Reply__GetProcedureNumber_t__defined) */ TrailerP = (mach_msg_max_trailer_t *)((vm_offset_t)Out0P + round_msg(Out0P->Head.msgh_size)); if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) { return MIG_TRAILER_ERROR ; } #if __MigTypeCheck trailer_size = TrailerP->msgh_trailer_size - (mach_msg_size_t)(sizeof(mach_msg_trailer_type_t) - sizeof(mach_msg_trailer_size_t)); #endif /* __MigTypeCheck */ #if __MigTypeCheck if (trailer_size < (mach_msg_size_t)sizeof(security_token_t)) { return MIG_TRAILER_ERROR ; } trailer_size -= (mach_msg_size_t)sizeof(security_token_t); #endif /* __MigTypeCheck */ *procno = Out0P->procno; *usertoken = TrailerP->msgh_sender; return KERN_SUCCESS; }
/* Routine send_message */ mig_external kern_return_t Cache_send_message ( mach_port_t send_port, string_t message ) { typedef struct { mach_msg_header_t Head; mach_msg_type_t messageType; string_t message; } 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 messageType = { /* msgt_name = */ MACH_MSG_TYPE_STRING_C, /* msgt_size = */ 8, /* 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->messageType = messageType; (void) mig_strncpy(InP->message, message, 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 = send_port; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_seqno = 0; InP->Head.msgh_id = 4066; msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, 1052, 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 != 4166) { 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_exception_raise_state_identity */ mig_external kern_return_t mach_exception_raise_state_identity ( mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt ) { #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_port_descriptor_t thread; mach_msg_port_descriptor_t task; /* end of the kernel processed data */ NDR_record_t NDR; exception_type_t exception; mach_msg_type_number_t codeCnt; int64_t code[2]; int flavor; mach_msg_type_number_t old_stateCnt; natural_t old_state[224]; } Request; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int flavor; mach_msg_type_number_t new_stateCnt; natural_t new_state[224]; mach_msg_trailer_t trailer; } Reply; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int flavor; mach_msg_type_number_t new_stateCnt; natural_t new_state[224]; } __Reply; #ifdef __MigPackStructs #pragma pack() #endif /* * typedef struct { * mach_msg_header_t Head; * NDR_record_t NDR; * kern_return_t RetCode; * } mig_reply_error_t; */ union { Request In; Reply Out; } Mess; Request *InP = &Mess.In; Reply *Out0P = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; unsigned int msgh_size_delta; #ifdef __MIG_check__Reply__mach_exception_raise_state_identity_t__defined kern_return_t check_result; #endif /* __MIG_check__Reply__mach_exception_raise_state_identity_t__defined */ __DeclareSendRpc(2407, "mach_exception_raise_state_identity") #if UseStaticTemplates const static mach_msg_port_descriptor_t threadTemplate = { /* name = */ MACH_PORT_NULL, /* pad1 = */ 0, /* pad2 = */ 0, /* disp = */ 19, /* type = */ MACH_MSG_PORT_DESCRIPTOR, }; #endif /* UseStaticTemplates */ #if UseStaticTemplates const static mach_msg_port_descriptor_t taskTemplate = { /* name = */ MACH_PORT_NULL, /* pad1 = */ 0, /* pad2 = */ 0, /* disp = */ 19, /* type = */ MACH_MSG_PORT_DESCRIPTOR, }; #endif /* UseStaticTemplates */ InP->msgh_body.msgh_descriptor_count = 2; #if UseStaticTemplates InP->thread = threadTemplate; InP->thread.name = thread; #else /* UseStaticTemplates */ InP->thread.name = thread; InP->thread.disposition = 19; InP->thread.type = MACH_MSG_PORT_DESCRIPTOR; #endif /* UseStaticTemplates */ #if UseStaticTemplates InP->task = taskTemplate; InP->task.name = task; #else /* UseStaticTemplates */ InP->task.name = task; InP->task.disposition = 19; InP->task.type = MACH_MSG_PORT_DESCRIPTOR; #endif /* UseStaticTemplates */ InP->NDR = NDR_record; InP->exception = exception; if (codeCnt > 2) { { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt); InP->codeCnt = codeCnt; msgh_size_delta = (8 * codeCnt); msgh_size = (mach_msg_size_t)(sizeof(Request) - 912) + msgh_size_delta; InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16); InP->flavor = *flavor; if (old_stateCnt > 224) { { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt); InP->old_stateCnt = old_stateCnt; msgh_size += (4 * old_stateCnt); InP = &Mess.In; 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 = exception_port; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_id = 2407; /* BEGIN VOUCHER CODE */ #ifdef USING_VOUCHERS if (voucher_mach_msg_set != NULL) { voucher_mach_msg_set(&InP->Head); } #endif // USING_VOUCHERS /* END VOUCHER CODE */ __BeforeSendRpc(2407, "mach_exception_raise_state_identity") msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); __AfterSendRpc(2407, "mach_exception_raise_state_identity") if (msg_result != MACH_MSG_SUCCESS) { __MachMsgErrorWithoutTimeout(msg_result); { return msg_result; } } #if defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) check_result = __MIG_check__Reply__mach_exception_raise_state_identity_t((__Reply__mach_exception_raise_state_identity_t *)Out0P); if (check_result != MACH_MSG_SUCCESS) { return check_result; } #endif /* defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) */ *flavor = Out0P->flavor; if (Out0P->new_stateCnt > 224) { (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 224); *new_stateCnt = Out0P->new_stateCnt; { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt); *new_stateCnt = Out0P->new_stateCnt; return KERN_SUCCESS; }
/* Routine mach_exception_raise_state */ mig_external kern_return_t mach_exception_raise_state ( mach_port_t exception_port, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt ) { #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; exception_type_t exception; mach_msg_type_number_t codeCnt; int64_t code[2]; int flavor; mach_msg_type_number_t old_stateCnt; natural_t old_state[224]; } Request; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int flavor; mach_msg_type_number_t new_stateCnt; natural_t new_state[224]; mach_msg_trailer_t trailer; } Reply; #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; int flavor; mach_msg_type_number_t new_stateCnt; natural_t new_state[224]; } __Reply; #ifdef __MigPackStructs #pragma pack() #endif /* * typedef struct { * mach_msg_header_t Head; * NDR_record_t NDR; * kern_return_t RetCode; * } mig_reply_error_t; */ union { Request In; Reply Out; } Mess; Request *InP = &Mess.In; Reply *Out0P = &Mess.Out; mach_msg_return_t msg_result; unsigned int msgh_size; unsigned int msgh_size_delta; #ifdef __MIG_check__Reply__mach_exception_raise_state_t__defined kern_return_t check_result; #endif /* __MIG_check__Reply__mach_exception_raise_state_t__defined */ __DeclareSendRpc(2406, "mach_exception_raise_state") InP->NDR = NDR_record; InP->exception = exception; if (codeCnt > 2) { { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt); InP->codeCnt = codeCnt; msgh_size_delta = (8 * codeCnt); msgh_size = (mach_msg_size_t)(sizeof(Request) - 912) + msgh_size_delta; InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16); InP->flavor = *flavor; if (old_stateCnt > 224) { { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt); InP->old_stateCnt = old_stateCnt; msgh_size += (4 * old_stateCnt); InP = &Mess.In; InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); /* msgh_size passed as argument */ InP->Head.msgh_request_port = exception_port; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_id = 2406; /* BEGIN VOUCHER CODE */ #ifdef USING_VOUCHERS if (voucher_mach_msg_set != NULL) { voucher_mach_msg_set(&InP->Head); } #endif // USING_VOUCHERS /* END VOUCHER CODE */ __BeforeSendRpc(2406, "mach_exception_raise_state") msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); __AfterSendRpc(2406, "mach_exception_raise_state") if (msg_result != MACH_MSG_SUCCESS) { __MachMsgErrorWithoutTimeout(msg_result); { return msg_result; } } #if defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) check_result = __MIG_check__Reply__mach_exception_raise_state_t((__Reply__mach_exception_raise_state_t *)Out0P); if (check_result != MACH_MSG_SUCCESS) { return check_result; } #endif /* defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) */ *flavor = Out0P->flavor; if (Out0P->new_stateCnt > 224) { (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 224); *new_stateCnt = Out0P->new_stateCnt; { return MIG_ARRAY_TOO_LARGE; } } (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt); *new_stateCnt = Out0P->new_stateCnt; return KERN_SUCCESS; }
/* Routine substrated_mark */ mig_external kern_return_t substrated_mark ( mach_port_t server, vm_map_t task, mach_vm_address_t source_address, mach_vm_size_t source_size, mach_vm_address_t *target_address ) { #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; /* start of the kernel processed data */ mach_msg_body_t msgh_body; mach_msg_port_descriptor_t task; /* end of the kernel processed data */ NDR_record_t NDR; mach_vm_address_t source_address; mach_vm_size_t source_size; mach_vm_address_t target_address; } Request __attribute__((unused)); #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; mach_vm_address_t target_address; mach_msg_trailer_t trailer; } Reply __attribute__((unused)); #ifdef __MigPackStructs #pragma pack() #endif #ifdef __MigPackStructs #pragma pack(4) #endif typedef struct { mach_msg_header_t Head; NDR_record_t NDR; kern_return_t RetCode; mach_vm_address_t target_address; } __Reply __attribute__((unused)); #ifdef __MigPackStructs #pragma pack() #endif /* * typedef struct { * mach_msg_header_t Head; * NDR_record_t NDR; * kern_return_t RetCode; * } mig_reply_error_t; */ union { Request In; Reply Out; } Mess; Request *InP = &Mess.In; Reply *Out0P = &Mess.Out; mach_msg_return_t msg_result; #ifdef __MIG_check__Reply__substrated_mark_t__defined kern_return_t check_result; #endif /* __MIG_check__Reply__substrated_mark_t__defined */ __DeclareSendRpc(9000, "substrated_mark") #if UseStaticTemplates const static mach_msg_port_descriptor_t taskTemplate = { /* name = */ MACH_PORT_NULL, /* pad1 = */ 0, /* pad2 = */ 0, /* disp = */ 19, /* type = */ MACH_MSG_PORT_DESCRIPTOR, }; #endif /* UseStaticTemplates */ InP->msgh_body.msgh_descriptor_count = 1; #if UseStaticTemplates InP->task = taskTemplate; InP->task.name = task; #else /* UseStaticTemplates */ InP->task.name = task; InP->task.disposition = 19; InP->task.type = MACH_MSG_PORT_DESCRIPTOR; #endif /* UseStaticTemplates */ InP->NDR = NDR_record; InP->source_address = source_address; InP->source_size = source_size; InP->target_address = *target_address; 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 = server; InP->Head.msgh_reply_port = mig_get_reply_port(); InP->Head.msgh_id = 9000; InP->Head.msgh_reserved = 0; /* BEGIN VOUCHER CODE */ #ifdef USING_VOUCHERS if (voucher_mach_msg_set != NULL) { voucher_mach_msg_set(&InP->Head); } #endif // USING_VOUCHERS /* END VOUCHER CODE */ __BeforeSendRpc(9000, "substrated_mark") msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, (mach_msg_size_t)sizeof(Request), (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); __AfterSendRpc(9000, "substrated_mark") if (msg_result != MACH_MSG_SUCCESS) { __MachMsgErrorWithoutTimeout(msg_result); { return msg_result; } } #if defined(__MIG_check__Reply__substrated_mark_t__defined) check_result = __MIG_check__Reply__substrated_mark_t((__Reply__substrated_mark_t *)Out0P); if (check_result != MACH_MSG_SUCCESS) { return check_result; } #endif /* defined(__MIG_check__Reply__substrated_mark_t__defined) */ *target_address = Out0P->target_address; return KERN_SUCCESS; }