mach_excUser.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. /*
  2. * IDENTIFICATION:
  3. * stub generated Tue Apr 7 09:10:21 2020
  4. * with a MiG generated by bootstrap_cmds-116
  5. * OPTIONS:
  6. */
  7. #ifdef __x86_64__
  8. #define __MIG_check__Reply__mach_exc_subsystem__ 1
  9. #include "mach_exc.h"
  10. /* TODO: #include <mach/mach.h> */
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif /* __cplusplus */
  14. extern void mach_msg_destroy(mach_msg_header_t *);
  15. #ifdef __cplusplus
  16. }
  17. #endif /* __cplusplus */
  18. #ifndef mig_internal
  19. #define mig_internal static __inline__
  20. #endif /* mig_internal */
  21. #ifndef mig_external
  22. #define mig_external
  23. #endif /* mig_external */
  24. #if !defined(__MigTypeCheck) && defined(TypeCheck)
  25. #define __MigTypeCheck TypeCheck /* Legacy setting */
  26. #endif /* !defined(__MigTypeCheck) */
  27. #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
  28. #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
  29. #endif /* !defined(__MigKernelSpecificCode) */
  30. #ifndef LimitCheck
  31. #define LimitCheck 0
  32. #endif /* LimitCheck */
  33. #ifndef min
  34. #define min(a,b) ( ((a) < (b))? (a): (b) )
  35. #endif /* min */
  36. #if !defined(_WALIGN_)
  37. #define _WALIGN_(x) (((x) + 3) & ~3)
  38. #endif /* !defined(_WALIGN_) */
  39. #if !defined(_WALIGNSZ_)
  40. #define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
  41. #endif /* !defined(_WALIGNSZ_) */
  42. #ifndef UseStaticTemplates
  43. #define UseStaticTemplates 0
  44. #endif /* UseStaticTemplates */
  45. #ifndef MIG_SERVER_ROUTINE
  46. #define MIG_SERVER_ROUTINE
  47. #endif
  48. #ifndef __MachMsgErrorWithTimeout
  49. #define __MachMsgErrorWithTimeout(_R_) { \
  50. switch (_R_) { \
  51. case MACH_SEND_INVALID_DATA: \
  52. case MACH_SEND_INVALID_DEST: \
  53. case MACH_SEND_INVALID_HEADER: \
  54. mig_put_reply_port(InP->Head.msgh_reply_port); \
  55. break; \
  56. case MACH_SEND_TIMED_OUT: \
  57. case MACH_RCV_TIMED_OUT: \
  58. default: \
  59. mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
  60. } \
  61. }
  62. #endif /* __MachMsgErrorWithTimeout */
  63. #ifndef __MachMsgErrorWithoutTimeout
  64. #define __MachMsgErrorWithoutTimeout(_R_) { \
  65. switch (_R_) { \
  66. case MACH_SEND_INVALID_DATA: \
  67. case MACH_SEND_INVALID_DEST: \
  68. case MACH_SEND_INVALID_HEADER: \
  69. mig_put_reply_port(InP->Head.msgh_reply_port); \
  70. break; \
  71. default: \
  72. mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
  73. } \
  74. }
  75. #endif /* __MachMsgErrorWithoutTimeout */
  76. #ifndef __DeclareSendRpc
  77. #define __DeclareSendRpc(_NUM_, _NAME_)
  78. #endif /* __DeclareSendRpc */
  79. #ifndef __BeforeSendRpc
  80. #define __BeforeSendRpc(_NUM_, _NAME_)
  81. #endif /* __BeforeSendRpc */
  82. #ifndef __AfterSendRpc
  83. #define __AfterSendRpc(_NUM_, _NAME_)
  84. #endif /* __AfterSendRpc */
  85. #ifndef __DeclareSendSimple
  86. #define __DeclareSendSimple(_NUM_, _NAME_)
  87. #endif /* __DeclareSendSimple */
  88. #ifndef __BeforeSendSimple
  89. #define __BeforeSendSimple(_NUM_, _NAME_)
  90. #endif /* __BeforeSendSimple */
  91. #ifndef __AfterSendSimple
  92. #define __AfterSendSimple(_NUM_, _NAME_)
  93. #endif /* __AfterSendSimple */
  94. #define msgh_request_port msgh_remote_port
  95. #define msgh_reply_port msgh_local_port
  96. #if ( __MigTypeCheck )
  97. #if __MIG_check__Reply__mach_exc_subsystem__
  98. #if !defined(__MIG_check__Reply__mach_exception_raise_t__defined)
  99. #define __MIG_check__Reply__mach_exception_raise_t__defined
  100. mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_t(__Reply__mach_exception_raise_t *Out0P)
  101. {
  102. typedef __Reply__mach_exception_raise_t __Reply __attribute__((unused));
  103. if (Out0P->Head.msgh_id != 2505) {
  104. if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
  105. { return MIG_SERVER_DIED; }
  106. else
  107. { return MIG_REPLY_MISMATCH; }
  108. }
  109. #if __MigTypeCheck
  110. if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
  111. (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
  112. { return MIG_TYPE_ERROR ; }
  113. #endif /* __MigTypeCheck */
  114. #if __MigTypeCheck
  115. if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) {
  116. return MIG_TYPE_ERROR;
  117. }
  118. #endif /* __MigTypeCheck */
  119. {
  120. return Out0P->RetCode;
  121. }
  122. }
  123. #endif /* !defined(__MIG_check__Reply__mach_exception_raise_t__defined) */
  124. #endif /* __MIG_check__Reply__mach_exc_subsystem__ */
  125. #endif /* ( __MigTypeCheck ) */
  126. /* Routine mach_exception_raise */
  127. mig_external kern_return_t mach_exception_raise
  128. (
  129. mach_port_t exception_port,
  130. mach_port_t thread,
  131. mach_port_t task,
  132. exception_type_t exception,
  133. mach_exception_data_t code,
  134. mach_msg_type_number_t codeCnt
  135. )
  136. {
  137. #ifdef __MigPackStructs
  138. #pragma pack(push, 4)
  139. #endif
  140. typedef struct {
  141. mach_msg_header_t Head;
  142. /* start of the kernel processed data */
  143. mach_msg_body_t msgh_body;
  144. mach_msg_port_descriptor_t thread;
  145. mach_msg_port_descriptor_t task;
  146. /* end of the kernel processed data */
  147. NDR_record_t NDR;
  148. exception_type_t exception;
  149. mach_msg_type_number_t codeCnt;
  150. int64_t code[2];
  151. } Request __attribute__((unused));
  152. #ifdef __MigPackStructs
  153. #pragma pack(pop)
  154. #endif
  155. #ifdef __MigPackStructs
  156. #pragma pack(push, 4)
  157. #endif
  158. typedef struct {
  159. mach_msg_header_t Head;
  160. NDR_record_t NDR;
  161. kern_return_t RetCode;
  162. mach_msg_trailer_t trailer;
  163. } Reply __attribute__((unused));
  164. #ifdef __MigPackStructs
  165. #pragma pack(pop)
  166. #endif
  167. #ifdef __MigPackStructs
  168. #pragma pack(push, 4)
  169. #endif
  170. typedef struct {
  171. mach_msg_header_t Head;
  172. NDR_record_t NDR;
  173. kern_return_t RetCode;
  174. } __Reply __attribute__((unused));
  175. #ifdef __MigPackStructs
  176. #pragma pack(pop)
  177. #endif
  178. /*
  179. * typedef struct {
  180. * mach_msg_header_t Head;
  181. * NDR_record_t NDR;
  182. * kern_return_t RetCode;
  183. * } mig_reply_error_t;
  184. */
  185. union {
  186. Request In;
  187. Reply Out;
  188. } Mess;
  189. Request *InP = &Mess.In;
  190. Reply *Out0P = &Mess.Out;
  191. mach_msg_return_t msg_result;
  192. unsigned int msgh_size;
  193. #ifdef __MIG_check__Reply__mach_exception_raise_t__defined
  194. kern_return_t check_result;
  195. #endif /* __MIG_check__Reply__mach_exception_raise_t__defined */
  196. __DeclareSendRpc(2405, "mach_exception_raise")
  197. #if UseStaticTemplates
  198. const static mach_msg_port_descriptor_t threadTemplate = {
  199. /* name = */ MACH_PORT_NULL,
  200. /* pad1 = */ 0,
  201. /* pad2 = */ 0,
  202. /* disp = */ 19,
  203. /* type = */ MACH_MSG_PORT_DESCRIPTOR,
  204. };
  205. #endif /* UseStaticTemplates */
  206. #if UseStaticTemplates
  207. const static mach_msg_port_descriptor_t taskTemplate = {
  208. /* name = */ MACH_PORT_NULL,
  209. /* pad1 = */ 0,
  210. /* pad2 = */ 0,
  211. /* disp = */ 19,
  212. /* type = */ MACH_MSG_PORT_DESCRIPTOR,
  213. };
  214. #endif /* UseStaticTemplates */
  215. InP->msgh_body.msgh_descriptor_count = 2;
  216. #if UseStaticTemplates
  217. InP->thread = threadTemplate;
  218. InP->thread.name = thread;
  219. #else /* UseStaticTemplates */
  220. InP->thread.name = thread;
  221. InP->thread.disposition = 19;
  222. InP->thread.type = MACH_MSG_PORT_DESCRIPTOR;
  223. #endif /* UseStaticTemplates */
  224. #if UseStaticTemplates
  225. InP->task = taskTemplate;
  226. InP->task.name = task;
  227. #else /* UseStaticTemplates */
  228. InP->task.name = task;
  229. InP->task.disposition = 19;
  230. InP->task.type = MACH_MSG_PORT_DESCRIPTOR;
  231. #endif /* UseStaticTemplates */
  232. InP->NDR = NDR_record;
  233. InP->exception = exception;
  234. if (codeCnt > 2) {
  235. { return MIG_ARRAY_TOO_LARGE; }
  236. }
  237. (void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
  238. InP->codeCnt = codeCnt;
  239. msgh_size = (mach_msg_size_t)(sizeof(Request) - 16) + ((8 * codeCnt));
  240. InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
  241. MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
  242. /* msgh_size passed as argument */
  243. InP->Head.msgh_request_port = exception_port;
  244. InP->Head.msgh_reply_port = mig_get_reply_port();
  245. InP->Head.msgh_id = 2405;
  246. InP->Head.msgh_reserved = 0;
  247. /* BEGIN VOUCHER CODE */
  248. #ifdef USING_VOUCHERS
  249. if (voucher_mach_msg_set != NULL) {
  250. voucher_mach_msg_set(&InP->Head);
  251. }
  252. #endif // USING_VOUCHERS
  253. /* END VOUCHER CODE */
  254. __BeforeSendRpc(2405, "mach_exception_raise")
  255. 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);
  256. __AfterSendRpc(2405, "mach_exception_raise")
  257. if (msg_result != MACH_MSG_SUCCESS) {
  258. __MachMsgErrorWithoutTimeout(msg_result);
  259. }
  260. if (msg_result != MACH_MSG_SUCCESS) {
  261. { return msg_result; }
  262. }
  263. #if defined(__MIG_check__Reply__mach_exception_raise_t__defined)
  264. check_result = __MIG_check__Reply__mach_exception_raise_t((__Reply__mach_exception_raise_t *)Out0P);
  265. if (check_result != MACH_MSG_SUCCESS) {
  266. mach_msg_destroy(&Out0P->Head);
  267. { return check_result; }
  268. }
  269. #endif /* defined(__MIG_check__Reply__mach_exception_raise_t__defined) */
  270. return KERN_SUCCESS;
  271. }
  272. #if ( __MigTypeCheck )
  273. #if __MIG_check__Reply__mach_exc_subsystem__
  274. #if !defined(__MIG_check__Reply__mach_exception_raise_state_t__defined)
  275. #define __MIG_check__Reply__mach_exception_raise_state_t__defined
  276. mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_state_t(__Reply__mach_exception_raise_state_t *Out0P)
  277. {
  278. typedef __Reply__mach_exception_raise_state_t __Reply __attribute__((unused));
  279. #if __MigTypeCheck
  280. unsigned int msgh_size;
  281. #endif /* __MigTypeCheck */
  282. if (Out0P->Head.msgh_id != 2506) {
  283. if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
  284. { return MIG_SERVER_DIED; }
  285. else
  286. { return MIG_REPLY_MISMATCH; }
  287. }
  288. #if __MigTypeCheck
  289. msgh_size = Out0P->Head.msgh_size;
  290. if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
  291. ((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 2456)) &&
  292. (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
  293. Out0P->RetCode == KERN_SUCCESS)))
  294. { return MIG_TYPE_ERROR ; }
  295. #endif /* __MigTypeCheck */
  296. #if __MigTypeCheck
  297. if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) {
  298. return MIG_TYPE_ERROR;
  299. }
  300. #endif /* __MigTypeCheck */
  301. if (Out0P->RetCode != KERN_SUCCESS) {
  302. return ((mig_reply_error_t *)Out0P)->RetCode;
  303. }
  304. #if __MigTypeCheck
  305. if ( Out0P->new_stateCnt > 614 )
  306. return MIG_TYPE_ERROR;
  307. if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 2456)) / 4< Out0P->new_stateCnt) ||
  308. (msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 2456) + Out0P->new_stateCnt * 4))
  309. { return MIG_TYPE_ERROR ; }
  310. #endif /* __MigTypeCheck */
  311. return MACH_MSG_SUCCESS;
  312. }
  313. #endif /* !defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) */
  314. #endif /* __MIG_check__Reply__mach_exc_subsystem__ */
  315. #endif /* ( __MigTypeCheck ) */
  316. /* Routine mach_exception_raise_state */
  317. mig_external kern_return_t mach_exception_raise_state
  318. (
  319. mach_port_t exception_port,
  320. exception_type_t exception,
  321. const mach_exception_data_t code,
  322. mach_msg_type_number_t codeCnt,
  323. int *flavor,
  324. const thread_state_t old_state,
  325. mach_msg_type_number_t old_stateCnt,
  326. thread_state_t new_state,
  327. mach_msg_type_number_t *new_stateCnt
  328. )
  329. {
  330. #ifdef __MigPackStructs
  331. #pragma pack(push, 4)
  332. #endif
  333. typedef struct {
  334. mach_msg_header_t Head;
  335. NDR_record_t NDR;
  336. exception_type_t exception;
  337. mach_msg_type_number_t codeCnt;
  338. int64_t code[2];
  339. int flavor;
  340. mach_msg_type_number_t old_stateCnt;
  341. natural_t old_state[614];
  342. } Request __attribute__((unused));
  343. #ifdef __MigPackStructs
  344. #pragma pack(pop)
  345. #endif
  346. #ifdef __MigPackStructs
  347. #pragma pack(push, 4)
  348. #endif
  349. typedef struct {
  350. mach_msg_header_t Head;
  351. NDR_record_t NDR;
  352. kern_return_t RetCode;
  353. int flavor;
  354. mach_msg_type_number_t new_stateCnt;
  355. natural_t new_state[614];
  356. mach_msg_trailer_t trailer;
  357. } Reply __attribute__((unused));
  358. #ifdef __MigPackStructs
  359. #pragma pack(pop)
  360. #endif
  361. #ifdef __MigPackStructs
  362. #pragma pack(push, 4)
  363. #endif
  364. typedef struct {
  365. mach_msg_header_t Head;
  366. NDR_record_t NDR;
  367. kern_return_t RetCode;
  368. int flavor;
  369. mach_msg_type_number_t new_stateCnt;
  370. natural_t new_state[614];
  371. } __Reply __attribute__((unused));
  372. #ifdef __MigPackStructs
  373. #pragma pack(pop)
  374. #endif
  375. /*
  376. * typedef struct {
  377. * mach_msg_header_t Head;
  378. * NDR_record_t NDR;
  379. * kern_return_t RetCode;
  380. * } mig_reply_error_t;
  381. */
  382. union {
  383. Request In;
  384. Reply Out;
  385. } Mess;
  386. Request *InP = &Mess.In;
  387. Reply *Out0P = &Mess.Out;
  388. mach_msg_return_t msg_result;
  389. unsigned int msgh_size;
  390. unsigned int msgh_size_delta;
  391. #ifdef __MIG_check__Reply__mach_exception_raise_state_t__defined
  392. kern_return_t check_result;
  393. #endif /* __MIG_check__Reply__mach_exception_raise_state_t__defined */
  394. __DeclareSendRpc(2406, "mach_exception_raise_state")
  395. InP->NDR = NDR_record;
  396. InP->exception = exception;
  397. if (codeCnt > 2) {
  398. { return MIG_ARRAY_TOO_LARGE; }
  399. }
  400. (void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
  401. InP->codeCnt = codeCnt;
  402. msgh_size_delta = (8 * codeCnt);
  403. msgh_size = (mach_msg_size_t)(sizeof(Request) - 2472) + msgh_size_delta;
  404. InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16);
  405. InP->flavor = *flavor;
  406. if (old_stateCnt > 614) {
  407. { return MIG_ARRAY_TOO_LARGE; }
  408. }
  409. (void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt);
  410. InP->old_stateCnt = old_stateCnt;
  411. msgh_size += (4 * old_stateCnt);
  412. InP = &Mess.In;
  413. InP->Head.msgh_bits =
  414. MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
  415. /* msgh_size passed as argument */
  416. InP->Head.msgh_request_port = exception_port;
  417. InP->Head.msgh_reply_port = mig_get_reply_port();
  418. InP->Head.msgh_id = 2406;
  419. InP->Head.msgh_reserved = 0;
  420. /* BEGIN VOUCHER CODE */
  421. #ifdef USING_VOUCHERS
  422. if (voucher_mach_msg_set != NULL) {
  423. voucher_mach_msg_set(&InP->Head);
  424. }
  425. #endif // USING_VOUCHERS
  426. /* END VOUCHER CODE */
  427. __BeforeSendRpc(2406, "mach_exception_raise_state")
  428. 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);
  429. __AfterSendRpc(2406, "mach_exception_raise_state")
  430. if (msg_result != MACH_MSG_SUCCESS) {
  431. __MachMsgErrorWithoutTimeout(msg_result);
  432. }
  433. if (msg_result != MACH_MSG_SUCCESS) {
  434. { return msg_result; }
  435. }
  436. #if defined(__MIG_check__Reply__mach_exception_raise_state_t__defined)
  437. check_result = __MIG_check__Reply__mach_exception_raise_state_t((__Reply__mach_exception_raise_state_t *)Out0P);
  438. if (check_result != MACH_MSG_SUCCESS) {
  439. mach_msg_destroy(&Out0P->Head);
  440. { return check_result; }
  441. }
  442. #endif /* defined(__MIG_check__Reply__mach_exception_raise_state_t__defined) */
  443. *flavor = Out0P->flavor;
  444. if (Out0P->new_stateCnt > 614) {
  445. (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 614);
  446. *new_stateCnt = Out0P->new_stateCnt;
  447. { return MIG_ARRAY_TOO_LARGE; }
  448. }
  449. (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt);
  450. *new_stateCnt = Out0P->new_stateCnt;
  451. return KERN_SUCCESS;
  452. }
  453. #if ( __MigTypeCheck )
  454. #if __MIG_check__Reply__mach_exc_subsystem__
  455. #if !defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined)
  456. #define __MIG_check__Reply__mach_exception_raise_state_identity_t__defined
  457. mig_internal kern_return_t __MIG_check__Reply__mach_exception_raise_state_identity_t(__Reply__mach_exception_raise_state_identity_t *Out0P)
  458. {
  459. typedef __Reply__mach_exception_raise_state_identity_t __Reply __attribute__((unused));
  460. #if __MigTypeCheck
  461. unsigned int msgh_size;
  462. #endif /* __MigTypeCheck */
  463. if (Out0P->Head.msgh_id != 2507) {
  464. if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
  465. { return MIG_SERVER_DIED; }
  466. else
  467. { return MIG_REPLY_MISMATCH; }
  468. }
  469. #if __MigTypeCheck
  470. msgh_size = Out0P->Head.msgh_size;
  471. if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
  472. ((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 2456)) &&
  473. (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) ||
  474. Out0P->RetCode == KERN_SUCCESS)))
  475. { return MIG_TYPE_ERROR ; }
  476. #endif /* __MigTypeCheck */
  477. #if __MigTypeCheck
  478. if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) {
  479. return MIG_TYPE_ERROR;
  480. }
  481. #endif /* __MigTypeCheck */
  482. if (Out0P->RetCode != KERN_SUCCESS) {
  483. return ((mig_reply_error_t *)Out0P)->RetCode;
  484. }
  485. #if __MigTypeCheck
  486. if ( Out0P->new_stateCnt > 614 )
  487. return MIG_TYPE_ERROR;
  488. if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 2456)) / 4< Out0P->new_stateCnt) ||
  489. (msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 2456) + Out0P->new_stateCnt * 4))
  490. { return MIG_TYPE_ERROR ; }
  491. #endif /* __MigTypeCheck */
  492. return MACH_MSG_SUCCESS;
  493. }
  494. #endif /* !defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) */
  495. #endif /* __MIG_check__Reply__mach_exc_subsystem__ */
  496. #endif /* ( __MigTypeCheck ) */
  497. /* Routine mach_exception_raise_state_identity */
  498. mig_external kern_return_t mach_exception_raise_state_identity
  499. (
  500. mach_port_t exception_port,
  501. mach_port_t thread,
  502. mach_port_t task,
  503. exception_type_t exception,
  504. mach_exception_data_t code,
  505. mach_msg_type_number_t codeCnt,
  506. int *flavor,
  507. thread_state_t old_state,
  508. mach_msg_type_number_t old_stateCnt,
  509. thread_state_t new_state,
  510. mach_msg_type_number_t *new_stateCnt
  511. )
  512. {
  513. #ifdef __MigPackStructs
  514. #pragma pack(push, 4)
  515. #endif
  516. typedef struct {
  517. mach_msg_header_t Head;
  518. /* start of the kernel processed data */
  519. mach_msg_body_t msgh_body;
  520. mach_msg_port_descriptor_t thread;
  521. mach_msg_port_descriptor_t task;
  522. /* end of the kernel processed data */
  523. NDR_record_t NDR;
  524. exception_type_t exception;
  525. mach_msg_type_number_t codeCnt;
  526. int64_t code[2];
  527. int flavor;
  528. mach_msg_type_number_t old_stateCnt;
  529. natural_t old_state[614];
  530. } Request __attribute__((unused));
  531. #ifdef __MigPackStructs
  532. #pragma pack(pop)
  533. #endif
  534. #ifdef __MigPackStructs
  535. #pragma pack(push, 4)
  536. #endif
  537. typedef struct {
  538. mach_msg_header_t Head;
  539. NDR_record_t NDR;
  540. kern_return_t RetCode;
  541. int flavor;
  542. mach_msg_type_number_t new_stateCnt;
  543. natural_t new_state[614];
  544. mach_msg_trailer_t trailer;
  545. } Reply __attribute__((unused));
  546. #ifdef __MigPackStructs
  547. #pragma pack(pop)
  548. #endif
  549. #ifdef __MigPackStructs
  550. #pragma pack(push, 4)
  551. #endif
  552. typedef struct {
  553. mach_msg_header_t Head;
  554. NDR_record_t NDR;
  555. kern_return_t RetCode;
  556. int flavor;
  557. mach_msg_type_number_t new_stateCnt;
  558. natural_t new_state[614];
  559. } __Reply __attribute__((unused));
  560. #ifdef __MigPackStructs
  561. #pragma pack(pop)
  562. #endif
  563. /*
  564. * typedef struct {
  565. * mach_msg_header_t Head;
  566. * NDR_record_t NDR;
  567. * kern_return_t RetCode;
  568. * } mig_reply_error_t;
  569. */
  570. union {
  571. Request In;
  572. Reply Out;
  573. } Mess;
  574. Request *InP = &Mess.In;
  575. Reply *Out0P = &Mess.Out;
  576. mach_msg_return_t msg_result;
  577. unsigned int msgh_size;
  578. unsigned int msgh_size_delta;
  579. #ifdef __MIG_check__Reply__mach_exception_raise_state_identity_t__defined
  580. kern_return_t check_result;
  581. #endif /* __MIG_check__Reply__mach_exception_raise_state_identity_t__defined */
  582. __DeclareSendRpc(2407, "mach_exception_raise_state_identity")
  583. #if UseStaticTemplates
  584. const static mach_msg_port_descriptor_t threadTemplate = {
  585. /* name = */ MACH_PORT_NULL,
  586. /* pad1 = */ 0,
  587. /* pad2 = */ 0,
  588. /* disp = */ 19,
  589. /* type = */ MACH_MSG_PORT_DESCRIPTOR,
  590. };
  591. #endif /* UseStaticTemplates */
  592. #if UseStaticTemplates
  593. const static mach_msg_port_descriptor_t taskTemplate = {
  594. /* name = */ MACH_PORT_NULL,
  595. /* pad1 = */ 0,
  596. /* pad2 = */ 0,
  597. /* disp = */ 19,
  598. /* type = */ MACH_MSG_PORT_DESCRIPTOR,
  599. };
  600. #endif /* UseStaticTemplates */
  601. InP->msgh_body.msgh_descriptor_count = 2;
  602. #if UseStaticTemplates
  603. InP->thread = threadTemplate;
  604. InP->thread.name = thread;
  605. #else /* UseStaticTemplates */
  606. InP->thread.name = thread;
  607. InP->thread.disposition = 19;
  608. InP->thread.type = MACH_MSG_PORT_DESCRIPTOR;
  609. #endif /* UseStaticTemplates */
  610. #if UseStaticTemplates
  611. InP->task = taskTemplate;
  612. InP->task.name = task;
  613. #else /* UseStaticTemplates */
  614. InP->task.name = task;
  615. InP->task.disposition = 19;
  616. InP->task.type = MACH_MSG_PORT_DESCRIPTOR;
  617. #endif /* UseStaticTemplates */
  618. InP->NDR = NDR_record;
  619. InP->exception = exception;
  620. if (codeCnt > 2) {
  621. { return MIG_ARRAY_TOO_LARGE; }
  622. }
  623. (void)memcpy((char *) InP->code, (const char *) code, 8 * codeCnt);
  624. InP->codeCnt = codeCnt;
  625. msgh_size_delta = (8 * codeCnt);
  626. msgh_size = (mach_msg_size_t)(sizeof(Request) - 2472) + msgh_size_delta;
  627. InP = (Request *) ((pointer_t) InP + msgh_size_delta - 16);
  628. InP->flavor = *flavor;
  629. if (old_stateCnt > 614) {
  630. { return MIG_ARRAY_TOO_LARGE; }
  631. }
  632. (void)memcpy((char *) InP->old_state, (const char *) old_state, 4 * old_stateCnt);
  633. InP->old_stateCnt = old_stateCnt;
  634. msgh_size += (4 * old_stateCnt);
  635. InP = &Mess.In;
  636. InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX|
  637. MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
  638. /* msgh_size passed as argument */
  639. InP->Head.msgh_request_port = exception_port;
  640. InP->Head.msgh_reply_port = mig_get_reply_port();
  641. InP->Head.msgh_id = 2407;
  642. InP->Head.msgh_reserved = 0;
  643. /* BEGIN VOUCHER CODE */
  644. #ifdef USING_VOUCHERS
  645. if (voucher_mach_msg_set != NULL) {
  646. voucher_mach_msg_set(&InP->Head);
  647. }
  648. #endif // USING_VOUCHERS
  649. /* END VOUCHER CODE */
  650. __BeforeSendRpc(2407, "mach_exception_raise_state_identity")
  651. 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);
  652. __AfterSendRpc(2407, "mach_exception_raise_state_identity")
  653. if (msg_result != MACH_MSG_SUCCESS) {
  654. __MachMsgErrorWithoutTimeout(msg_result);
  655. }
  656. if (msg_result != MACH_MSG_SUCCESS) {
  657. { return msg_result; }
  658. }
  659. #if defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined)
  660. check_result = __MIG_check__Reply__mach_exception_raise_state_identity_t((__Reply__mach_exception_raise_state_identity_t *)Out0P);
  661. if (check_result != MACH_MSG_SUCCESS) {
  662. mach_msg_destroy(&Out0P->Head);
  663. { return check_result; }
  664. }
  665. #endif /* defined(__MIG_check__Reply__mach_exception_raise_state_identity_t__defined) */
  666. *flavor = Out0P->flavor;
  667. if (Out0P->new_stateCnt > 614) {
  668. (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * 614);
  669. *new_stateCnt = Out0P->new_stateCnt;
  670. { return MIG_ARRAY_TOO_LARGE; }
  671. }
  672. (void)memcpy((char *) new_state, (const char *) Out0P->new_state, 4 * Out0P->new_stateCnt);
  673. *new_stateCnt = Out0P->new_stateCnt;
  674. return KERN_SUCCESS;
  675. }
  676. #endif