| 1 | /* |
| 2 | * IDENTIFICATION: |
| 3 | * stub generated Tue Apr 9 11:33:40 2019 |
| 4 | * with a MiG generated by bootstrap_cmds-96.20.2.200.4 |
| 5 | * OPTIONS: |
| 6 | * KernelUser |
| 7 | */ |
| 8 | #define __MIG_check__Reply__task_access_subsystem__ 1 |
| 9 | |
| 10 | #include "task_access.h" |
| 11 | |
| 12 | |
| 13 | #ifndef mig_internal |
| 14 | #define mig_internal static __inline__ |
| 15 | #endif /* mig_internal */ |
| 16 | |
| 17 | #ifndef mig_external |
| 18 | #define mig_external |
| 19 | #endif /* mig_external */ |
| 20 | |
| 21 | #if !defined(__MigTypeCheck) && defined(TypeCheck) |
| 22 | #define __MigTypeCheck TypeCheck /* Legacy setting */ |
| 23 | #endif /* !defined(__MigTypeCheck) */ |
| 24 | |
| 25 | #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) |
| 26 | #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ |
| 27 | #endif /* !defined(__MigKernelSpecificCode) */ |
| 28 | |
| 29 | #ifndef LimitCheck |
| 30 | #define LimitCheck 0 |
| 31 | #endif /* LimitCheck */ |
| 32 | |
| 33 | #ifndef min |
| 34 | #define min(a,b) ( ((a) < (b))? (a): (b) ) |
| 35 | #endif /* min */ |
| 36 | |
| 37 | #if !defined(_WALIGN_) |
| 38 | #define _WALIGN_(x) (((x) + 3) & ~3) |
| 39 | #endif /* !defined(_WALIGN_) */ |
| 40 | |
| 41 | #if !defined(_WALIGNSZ_) |
| 42 | #define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) |
| 43 | #endif /* !defined(_WALIGNSZ_) */ |
| 44 | |
| 45 | #ifndef UseStaticTemplates |
| 46 | #define UseStaticTemplates 0 |
| 47 | #endif /* UseStaticTemplates */ |
| 48 | |
| 49 | #ifndef __MachMsgErrorWithTimeout |
| 50 | #define __MachMsgErrorWithTimeout(_R_) { \ |
| 51 | switch (_R_) { \ |
| 52 | case MACH_SEND_INVALID_DATA: \ |
| 53 | case MACH_SEND_INVALID_DEST: \ |
| 54 | case MACH_SEND_INVALID_HEADER: \ |
| 55 | mig_put_reply_port(InP->Head.msgh_reply_port); \ |
| 56 | break; \ |
| 57 | case MACH_SEND_TIMED_OUT: \ |
| 58 | case MACH_RCV_TIMED_OUT: \ |
| 59 | default: \ |
| 60 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ |
| 61 | } \ |
| 62 | } |
| 63 | #endif /* __MachMsgErrorWithTimeout */ |
| 64 | |
| 65 | #ifndef __MachMsgErrorWithoutTimeout |
| 66 | #define __MachMsgErrorWithoutTimeout(_R_) { \ |
| 67 | switch (_R_) { \ |
| 68 | case MACH_SEND_INVALID_DATA: \ |
| 69 | case MACH_SEND_INVALID_DEST: \ |
| 70 | case MACH_SEND_INVALID_HEADER: \ |
| 71 | mig_put_reply_port(InP->Head.msgh_reply_port); \ |
| 72 | break; \ |
| 73 | default: \ |
| 74 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ |
| 75 | } \ |
| 76 | } |
| 77 | #endif /* __MachMsgErrorWithoutTimeout */ |
| 78 | |
| 79 | #ifndef __DeclareSendRpc |
| 80 | #define __DeclareSendRpc(_NUM_, _NAME_) |
| 81 | #endif /* __DeclareSendRpc */ |
| 82 | |
| 83 | #ifndef __BeforeSendRpc |
| 84 | #define __BeforeSendRpc(_NUM_, _NAME_) |
| 85 | #endif /* __BeforeSendRpc */ |
| 86 | |
| 87 | #ifndef __AfterSendRpc |
| 88 | #define __AfterSendRpc(_NUM_, _NAME_) |
| 89 | #endif /* __AfterSendRpc */ |
| 90 | |
| 91 | #ifndef __DeclareSendSimple |
| 92 | #define __DeclareSendSimple(_NUM_, _NAME_) |
| 93 | #endif /* __DeclareSendSimple */ |
| 94 | |
| 95 | #ifndef __BeforeSendSimple |
| 96 | #define __BeforeSendSimple(_NUM_, _NAME_) |
| 97 | #endif /* __BeforeSendSimple */ |
| 98 | |
| 99 | #ifndef __AfterSendSimple |
| 100 | #define __AfterSendSimple(_NUM_, _NAME_) |
| 101 | #endif /* __AfterSendSimple */ |
| 102 | |
| 103 | #define msgh_request_port msgh_remote_port |
| 104 | #define msgh_reply_port msgh_local_port |
| 105 | |
| 106 | |
| 107 | |
| 108 | #if ( __MigTypeCheck ) |
| 109 | #if __MIG_check__Reply__task_access_subsystem__ |
| 110 | #if !defined(__MIG_check__Reply__check_task_access_t__defined) |
| 111 | #define __MIG_check__Reply__check_task_access_t__defined |
| 112 | |
| 113 | mig_internal kern_return_t __MIG_check__Reply__check_task_access_t(__Reply__check_task_access_t *Out0P) |
| 114 | { |
| 115 | |
| 116 | typedef __Reply__check_task_access_t __Reply __attribute__((unused)); |
| 117 | if (Out0P->Head.msgh_id != 27100) { |
| 118 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) |
| 119 | { return MIG_SERVER_DIED; } |
| 120 | else |
| 121 | { return MIG_REPLY_MISMATCH; } |
| 122 | } |
| 123 | |
| 124 | #if __MigTypeCheck |
| 125 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || |
| 126 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply))) |
| 127 | { return MIG_TYPE_ERROR ; } |
| 128 | #endif /* __MigTypeCheck */ |
| 129 | |
| 130 | { |
| 131 | return Out0P->RetCode; |
| 132 | } |
| 133 | } |
| 134 | #endif /* !defined(__MIG_check__Reply__check_task_access_t__defined) */ |
| 135 | #endif /* __MIG_check__Reply__task_access_subsystem__ */ |
| 136 | #endif /* ( __MigTypeCheck ) */ |
| 137 | |
| 138 | |
| 139 | /* Routine check_task_access */ |
| 140 | mig_external kern_return_t check_task_access |
| 141 | ( |
| 142 | mach_port_t task_access_port, |
| 143 | int32_t calling_pid, |
| 144 | uint32_t calling_gid, |
| 145 | int32_t target_pid |
| 146 | ) |
| 147 | { |
| 148 | |
| 149 | #ifdef __MigPackStructs |
| 150 | #pragma pack(4) |
| 151 | #endif |
| 152 | typedef struct { |
| 153 | mach_msg_header_t Head; |
| 154 | NDR_record_t NDR; |
| 155 | int32_t calling_pid; |
| 156 | uint32_t calling_gid; |
| 157 | int32_t target_pid; |
| 158 | } Request __attribute__((unused)); |
| 159 | #ifdef __MigPackStructs |
| 160 | #pragma pack() |
| 161 | #endif |
| 162 | |
| 163 | #ifdef __MigPackStructs |
| 164 | #pragma pack(4) |
| 165 | #endif |
| 166 | typedef struct { |
| 167 | mach_msg_header_t Head; |
| 168 | NDR_record_t NDR; |
| 169 | kern_return_t RetCode; |
| 170 | mach_msg_trailer_t trailer; |
| 171 | } Reply __attribute__((unused)); |
| 172 | #ifdef __MigPackStructs |
| 173 | #pragma pack() |
| 174 | #endif |
| 175 | |
| 176 | #ifdef __MigPackStructs |
| 177 | #pragma pack(4) |
| 178 | #endif |
| 179 | typedef struct { |
| 180 | mach_msg_header_t Head; |
| 181 | NDR_record_t NDR; |
| 182 | kern_return_t RetCode; |
| 183 | } __Reply __attribute__((unused)); |
| 184 | #ifdef __MigPackStructs |
| 185 | #pragma pack() |
| 186 | #endif |
| 187 | /* |
| 188 | * typedef struct { |
| 189 | * mach_msg_header_t Head; |
| 190 | * NDR_record_t NDR; |
| 191 | * kern_return_t RetCode; |
| 192 | * } mig_reply_error_t; |
| 193 | */ |
| 194 | |
| 195 | union { |
| 196 | Request In; |
| 197 | Reply Out; |
| 198 | } Mess; |
| 199 | |
| 200 | Request *InP = &Mess.In; |
| 201 | Reply *Out0P = &Mess.Out; |
| 202 | |
| 203 | mach_msg_return_t msg_result; |
| 204 | |
| 205 | #ifdef __MIG_check__Reply__check_task_access_t__defined |
| 206 | kern_return_t check_result; |
| 207 | #endif /* __MIG_check__Reply__check_task_access_t__defined */ |
| 208 | |
| 209 | __DeclareSendRpc(27000, "check_task_access" ) |
| 210 | |
| 211 | InP->NDR = NDR_record; |
| 212 | |
| 213 | InP->calling_pid = calling_pid; |
| 214 | |
| 215 | InP->calling_gid = calling_gid; |
| 216 | |
| 217 | InP->target_pid = target_pid; |
| 218 | |
| 219 | InP->Head.msgh_bits = |
| 220 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); |
| 221 | /* msgh_size passed as argument */ |
| 222 | InP->Head.msgh_request_port = task_access_port; |
| 223 | InP->Head.msgh_reply_port = mig_get_reply_port(); |
| 224 | InP->Head.msgh_id = 27000; |
| 225 | InP->Head.msgh_reserved = 0; |
| 226 | |
| 227 | __BeforeSendRpc(27000, "check_task_access" ) |
| 228 | #if (__MigKernelSpecificCode) || (_MIG_KERNELSPECIFIC_CODE_) |
| 229 | msg_result = mach_msg_rpc_from_kernel(&InP->Head, (mach_msg_size_t)sizeof(Request), (mach_msg_size_t)sizeof(Reply)); |
| 230 | #else |
| 231 | 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); |
| 232 | #endif /* __MigKernelSpecificCode */ |
| 233 | __AfterSendRpc(27000, "check_task_access" ) |
| 234 | if (msg_result != MACH_MSG_SUCCESS) { |
| 235 | __MachMsgErrorWithoutTimeout(msg_result); |
| 236 | { return msg_result; } |
| 237 | } |
| 238 | |
| 239 | |
| 240 | #if defined(__MIG_check__Reply__check_task_access_t__defined) |
| 241 | check_result = __MIG_check__Reply__check_task_access_t((__Reply__check_task_access_t *)Out0P); |
| 242 | if (check_result != MACH_MSG_SUCCESS) |
| 243 | { return check_result; } |
| 244 | #endif /* defined(__MIG_check__Reply__check_task_access_t__defined) */ |
| 245 | |
| 246 | return KERN_SUCCESS; |
| 247 | } |
| 248 | |
| 249 | #if ( __MigTypeCheck ) |
| 250 | #if __MIG_check__Reply__task_access_subsystem__ |
| 251 | #if !defined(__MIG_check__Reply__find_code_signature_t__defined) |
| 252 | #define __MIG_check__Reply__find_code_signature_t__defined |
| 253 | |
| 254 | mig_internal kern_return_t __MIG_check__Reply__find_code_signature_t(__Reply__find_code_signature_t *Out0P) |
| 255 | { |
| 256 | |
| 257 | typedef __Reply__find_code_signature_t __Reply __attribute__((unused)); |
| 258 | if (Out0P->Head.msgh_id != 27101) { |
| 259 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) |
| 260 | { return MIG_SERVER_DIED; } |
| 261 | else |
| 262 | { return MIG_REPLY_MISMATCH; } |
| 263 | } |
| 264 | |
| 265 | #if __MigTypeCheck |
| 266 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || |
| 267 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply))) |
| 268 | { return MIG_TYPE_ERROR ; } |
| 269 | #endif /* __MigTypeCheck */ |
| 270 | |
| 271 | { |
| 272 | return Out0P->RetCode; |
| 273 | } |
| 274 | } |
| 275 | #endif /* !defined(__MIG_check__Reply__find_code_signature_t__defined) */ |
| 276 | #endif /* __MIG_check__Reply__task_access_subsystem__ */ |
| 277 | #endif /* ( __MigTypeCheck ) */ |
| 278 | |
| 279 | |
| 280 | /* Routine find_code_signature */ |
| 281 | mig_external kern_return_t find_code_signature |
| 282 | ( |
| 283 | mach_port_t task_access_port, |
| 284 | int32_t new_pid |
| 285 | ) |
| 286 | { |
| 287 | |
| 288 | #ifdef __MigPackStructs |
| 289 | #pragma pack(4) |
| 290 | #endif |
| 291 | typedef struct { |
| 292 | mach_msg_header_t Head; |
| 293 | NDR_record_t NDR; |
| 294 | int32_t new_pid; |
| 295 | } Request __attribute__((unused)); |
| 296 | #ifdef __MigPackStructs |
| 297 | #pragma pack() |
| 298 | #endif |
| 299 | |
| 300 | #ifdef __MigPackStructs |
| 301 | #pragma pack(4) |
| 302 | #endif |
| 303 | typedef struct { |
| 304 | mach_msg_header_t Head; |
| 305 | NDR_record_t NDR; |
| 306 | kern_return_t RetCode; |
| 307 | mach_msg_trailer_t trailer; |
| 308 | } Reply __attribute__((unused)); |
| 309 | #ifdef __MigPackStructs |
| 310 | #pragma pack() |
| 311 | #endif |
| 312 | |
| 313 | #ifdef __MigPackStructs |
| 314 | #pragma pack(4) |
| 315 | #endif |
| 316 | typedef struct { |
| 317 | mach_msg_header_t Head; |
| 318 | NDR_record_t NDR; |
| 319 | kern_return_t RetCode; |
| 320 | } __Reply __attribute__((unused)); |
| 321 | #ifdef __MigPackStructs |
| 322 | #pragma pack() |
| 323 | #endif |
| 324 | /* |
| 325 | * typedef struct { |
| 326 | * mach_msg_header_t Head; |
| 327 | * NDR_record_t NDR; |
| 328 | * kern_return_t RetCode; |
| 329 | * } mig_reply_error_t; |
| 330 | */ |
| 331 | |
| 332 | union { |
| 333 | Request In; |
| 334 | Reply Out; |
| 335 | } Mess; |
| 336 | |
| 337 | Request *InP = &Mess.In; |
| 338 | Reply *Out0P = &Mess.Out; |
| 339 | |
| 340 | mach_msg_return_t msg_result; |
| 341 | |
| 342 | #ifdef __MIG_check__Reply__find_code_signature_t__defined |
| 343 | kern_return_t check_result; |
| 344 | #endif /* __MIG_check__Reply__find_code_signature_t__defined */ |
| 345 | |
| 346 | __DeclareSendRpc(27001, "find_code_signature" ) |
| 347 | |
| 348 | InP->NDR = NDR_record; |
| 349 | |
| 350 | InP->new_pid = new_pid; |
| 351 | |
| 352 | InP->Head.msgh_bits = |
| 353 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); |
| 354 | /* msgh_size passed as argument */ |
| 355 | InP->Head.msgh_request_port = task_access_port; |
| 356 | InP->Head.msgh_reply_port = mig_get_reply_port(); |
| 357 | InP->Head.msgh_id = 27001; |
| 358 | InP->Head.msgh_reserved = 0; |
| 359 | |
| 360 | __BeforeSendRpc(27001, "find_code_signature" ) |
| 361 | #if (__MigKernelSpecificCode) || (_MIG_KERNELSPECIFIC_CODE_) |
| 362 | msg_result = mach_msg_rpc_from_kernel(&InP->Head, (mach_msg_size_t)sizeof(Request), (mach_msg_size_t)sizeof(Reply)); |
| 363 | #else |
| 364 | 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); |
| 365 | #endif /* __MigKernelSpecificCode */ |
| 366 | __AfterSendRpc(27001, "find_code_signature" ) |
| 367 | if (msg_result != MACH_MSG_SUCCESS) { |
| 368 | __MachMsgErrorWithoutTimeout(msg_result); |
| 369 | { return msg_result; } |
| 370 | } |
| 371 | |
| 372 | |
| 373 | #if defined(__MIG_check__Reply__find_code_signature_t__defined) |
| 374 | check_result = __MIG_check__Reply__find_code_signature_t((__Reply__find_code_signature_t *)Out0P); |
| 375 | if (check_result != MACH_MSG_SUCCESS) |
| 376 | { return check_result; } |
| 377 | #endif /* defined(__MIG_check__Reply__find_code_signature_t__defined) */ |
| 378 | |
| 379 | return KERN_SUCCESS; |
| 380 | } |
| 381 | |