/* 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; }