jailbreak_daemonUser.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * IDENTIFICATION:
  3. * stub generated Tue Mar 6 23:07:11 2018
  4. * with a MiG generated by bootstrap_cmds-96.20.2
  5. * OPTIONS:
  6. */
  7. #define __MIG_check__Reply__jailbreak_daemon_subsystem__ 1
  8. #include "jailbreak_daemonUser.h"
  9. #ifndef mig_internal
  10. #define mig_internal static __inline__
  11. #endif /* mig_internal */
  12. #ifndef mig_external
  13. #define mig_external
  14. #endif /* mig_external */
  15. #if !defined(__MigTypeCheck) && defined(TypeCheck)
  16. #define __MigTypeCheck TypeCheck /* Legacy setting */
  17. #endif /* !defined(__MigTypeCheck) */
  18. #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_)
  19. #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */
  20. #endif /* !defined(__MigKernelSpecificCode) */
  21. #ifndef LimitCheck
  22. #define LimitCheck 0
  23. #endif /* LimitCheck */
  24. #ifndef min
  25. #define min(a,b) ( ((a) < (b))? (a): (b) )
  26. #endif /* min */
  27. #if !defined(_WALIGN_)
  28. #define _WALIGN_(x) (((x) + 3) & ~3)
  29. #endif /* !defined(_WALIGN_) */
  30. #if !defined(_WALIGNSZ_)
  31. #define _WALIGNSZ_(x) _WALIGN_(sizeof(x))
  32. #endif /* !defined(_WALIGNSZ_) */
  33. #ifndef UseStaticTemplates
  34. #define UseStaticTemplates 0
  35. #endif /* UseStaticTemplates */
  36. #ifndef __MachMsgErrorWithTimeout
  37. #define __MachMsgErrorWithTimeout(_R_) { \
  38. switch (_R_) { \
  39. case MACH_SEND_INVALID_DATA: \
  40. case MACH_SEND_INVALID_DEST: \
  41. case MACH_SEND_INVALID_HEADER: \
  42. mig_put_reply_port(InP->Head.msgh_reply_port); \
  43. break; \
  44. case MACH_SEND_TIMED_OUT: \
  45. case MACH_RCV_TIMED_OUT: \
  46. default: \
  47. mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
  48. } \
  49. }
  50. #endif /* __MachMsgErrorWithTimeout */
  51. #ifndef __MachMsgErrorWithoutTimeout
  52. #define __MachMsgErrorWithoutTimeout(_R_) { \
  53. switch (_R_) { \
  54. case MACH_SEND_INVALID_DATA: \
  55. case MACH_SEND_INVALID_DEST: \
  56. case MACH_SEND_INVALID_HEADER: \
  57. mig_put_reply_port(InP->Head.msgh_reply_port); \
  58. break; \
  59. default: \
  60. mig_dealloc_reply_port(InP->Head.msgh_reply_port); \
  61. } \
  62. }
  63. #endif /* __MachMsgErrorWithoutTimeout */
  64. #ifndef __DeclareSendRpc
  65. #define __DeclareSendRpc(_NUM_, _NAME_)
  66. #endif /* __DeclareSendRpc */
  67. #ifndef __BeforeSendRpc
  68. #define __BeforeSendRpc(_NUM_, _NAME_)
  69. #endif /* __BeforeSendRpc */
  70. #ifndef __AfterSendRpc
  71. #define __AfterSendRpc(_NUM_, _NAME_)
  72. #endif /* __AfterSendRpc */
  73. #ifndef __DeclareSendSimple
  74. #define __DeclareSendSimple(_NUM_, _NAME_)
  75. #endif /* __DeclareSendSimple */
  76. #ifndef __BeforeSendSimple
  77. #define __BeforeSendSimple(_NUM_, _NAME_)
  78. #endif /* __BeforeSendSimple */
  79. #ifndef __AfterSendSimple
  80. #define __AfterSendSimple(_NUM_, _NAME_)
  81. #endif /* __AfterSendSimple */
  82. #define msgh_request_port msgh_remote_port
  83. #define msgh_reply_port msgh_local_port
  84. #if ( __MigTypeCheck )
  85. #if __MIG_check__Reply__jailbreak_daemon_subsystem__
  86. #if !defined(__MIG_check__Reply__call_t__defined)
  87. #define __MIG_check__Reply__call_t__defined
  88. mig_internal kern_return_t __MIG_check__Reply__call_t(__Reply__call_t *Out0P)
  89. {
  90. typedef __Reply__call_t __Reply __attribute__((unused));
  91. if (Out0P->Head.msgh_id != 600) {
  92. if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
  93. { return MIG_SERVER_DIED; }
  94. else
  95. { return MIG_REPLY_MISMATCH; }
  96. }
  97. #if __MigTypeCheck
  98. if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) ||
  99. (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply)))
  100. { return MIG_TYPE_ERROR ; }
  101. #endif /* __MigTypeCheck */
  102. {
  103. return Out0P->RetCode;
  104. }
  105. }
  106. #endif /* !defined(__MIG_check__Reply__call_t__defined) */
  107. #endif /* __MIG_check__Reply__jailbreak_daemon_subsystem__ */
  108. #endif /* ( __MigTypeCheck ) */
  109. /* Routine call */
  110. mig_external kern_return_t jbd_call
  111. (
  112. mach_port_t server_port,
  113. uint8_t command,
  114. uint32_t pid
  115. )
  116. {
  117. #ifdef __MigPackStructs
  118. #pragma pack(4)
  119. #endif
  120. typedef struct {
  121. mach_msg_header_t Head;
  122. NDR_record_t NDR;
  123. uint8_t command;
  124. char commandPad[3];
  125. uint32_t pid;
  126. } Request __attribute__((unused));
  127. #ifdef __MigPackStructs
  128. #pragma pack()
  129. #endif
  130. #ifdef __MigPackStructs
  131. #pragma pack(4)
  132. #endif
  133. typedef struct {
  134. mach_msg_header_t Head;
  135. NDR_record_t NDR;
  136. kern_return_t RetCode;
  137. mach_msg_trailer_t trailer;
  138. } Reply __attribute__((unused));
  139. #ifdef __MigPackStructs
  140. #pragma pack()
  141. #endif
  142. #ifdef __MigPackStructs
  143. #pragma pack(4)
  144. #endif
  145. typedef struct {
  146. mach_msg_header_t Head;
  147. NDR_record_t NDR;
  148. kern_return_t RetCode;
  149. } __Reply __attribute__((unused));
  150. #ifdef __MigPackStructs
  151. #pragma pack()
  152. #endif
  153. /*
  154. * typedef struct {
  155. * mach_msg_header_t Head;
  156. * NDR_record_t NDR;
  157. * kern_return_t RetCode;
  158. * } mig_reply_error_t;
  159. */
  160. union {
  161. Request In;
  162. Reply Out;
  163. } Mess;
  164. Request *InP = &Mess.In;
  165. Reply *Out0P = &Mess.Out;
  166. mach_msg_return_t msg_result;
  167. #ifdef __MIG_check__Reply__call_t__defined
  168. kern_return_t check_result;
  169. #endif /* __MIG_check__Reply__call_t__defined */
  170. __DeclareSendRpc(500, "call")
  171. InP->NDR = NDR_record;
  172. InP->command = command;
  173. InP->pid = pid;
  174. InP->Head.msgh_bits =
  175. MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
  176. /* msgh_size passed as argument */
  177. InP->Head.msgh_request_port = server_port;
  178. InP->Head.msgh_reply_port = mig_get_reply_port();
  179. InP->Head.msgh_id = 500;
  180. InP->Head.msgh_reserved = 0;
  181. /* BEGIN VOUCHER CODE */
  182. #ifdef USING_VOUCHERS
  183. if (voucher_mach_msg_set != NULL) {
  184. voucher_mach_msg_set(&InP->Head);
  185. }
  186. #endif // USING_VOUCHERS
  187. /* END VOUCHER CODE */
  188. __BeforeSendRpc(500, "call")
  189. 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);
  190. __AfterSendRpc(500, "call")
  191. if (msg_result != MACH_MSG_SUCCESS) {
  192. __MachMsgErrorWithoutTimeout(msg_result);
  193. { return msg_result; }
  194. }
  195. #if defined(__MIG_check__Reply__call_t__defined)
  196. check_result = __MIG_check__Reply__call_t((__Reply__call_t *)Out0P);
  197. if (check_result != MACH_MSG_SUCCESS)
  198. { return check_result; }
  199. #endif /* defined(__MIG_check__Reply__call_t__defined) */
  200. return KERN_SUCCESS;
  201. }