/* Module exc */ #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif #define EXPORT_BOOLEAN #include #include #include #include #include #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_local_port #define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) #define msgh_reply_port msgh_remote_port #define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) #include /* Routine exception_raise */ mig_internal void _Xexception_raise (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) { typedef struct { mach_msg_header_t Head; mach_msg_type_t threadType; mach_port_t thread; mach_msg_type_t taskType; mach_port_t task; mach_msg_type_t exceptionType; integer_t exception; mach_msg_type_t codeType; integer_t code; mach_msg_type_t subcodeType; integer_t subcode; } Request; typedef struct { mach_msg_header_t Head; mach_msg_type_t RetCodeType; kern_return_t RetCode; } Reply; register Request *In0P = (Request *) InHeadP; register Reply *OutP = (Reply *) OutHeadP; mig_external kern_return_t catch_exception_raise (mach_port_t exception_port, mach_port_t thread, mach_port_t task, integer_t exception, integer_t code, integer_t subcode); auto const mach_msg_type_t threadCheck = { /* 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 taskCheck = { /* 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 exceptionCheck = { /* 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 codeCheck = { /* 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 subcodeCheck = { /* msgt_name = */ 2, /* msgt_size = */ 32, /* msgt_number = */ 1, /* msgt_inline = */ TRUE, /* msgt_longform = */ FALSE, /* msgt_deallocate = */ FALSE, /* msgt_unused = */ 0 }; #if TypeCheck if ((In0P->Head.msgh_size != 64) || !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK(&In0P->threadType, &threadCheck)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK(&In0P->taskType, &taskCheck)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK(&In0P->exceptionType, &exceptionCheck)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK(&In0P->codeType, &codeCheck)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ #if TypeCheck if (BAD_TYPECHECK(&In0P->subcodeType, &subcodeCheck)) { OutP->RetCode = MIG_BAD_ARGUMENTS; return; } #endif /* TypeCheck */ OutP->RetCode = catch_exception_raise(In0P->Head.msgh_request_port, In0P->thread, In0P->task, In0P->exception, In0P->code, In0P->subcode); } static mig_routine_t exc_server_routines[] = { _Xexception_raise, }; mig_external boolean_t exc_server (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) { register mach_msg_header_t *InP = InHeadP; register mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; auto const mach_msg_type_t RetCodeType = { /* 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 }; register mig_routine_t routine; OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0); OutP->Head.msgh_size = sizeof *OutP; OutP->Head.msgh_remote_port = InP->msgh_reply_port; OutP->Head.msgh_local_port = MACH_PORT_NULL; OutP->Head.msgh_seqno = 0; OutP->Head.msgh_id = InP->msgh_id + 100; OutP->RetCodeType = RetCodeType; if ((InP->msgh_id > 2400) || (InP->msgh_id < 2400) || ((routine = exc_server_routines[InP->msgh_id - 2400]) == 0)) { OutP->RetCode = MIG_BAD_ID; return FALSE; } (*routine) (InP, &OutP->Head); return TRUE; } mig_external mig_routine_t exc_server_routine (const mach_msg_header_t *InHeadP) { register int msgh_id; msgh_id = InHeadP->msgh_id - 2400; if ((msgh_id > 0) || (msgh_id < 0)) return 0; return exc_server_routines[msgh_id]; }