| 1 | /* iig(DriverKit-286 Mar 29 2024 10:27:09) generated from IOUserServer.iig */ |
| 2 | |
| 3 | #undef IIG_IMPLEMENTATION |
| 4 | #define IIG_IMPLEMENTATION IOUserServer.iig |
| 5 | |
| 6 | #if KERNEL |
| 7 | #include <libkern/c++/OSString.h> |
| 8 | #else |
| 9 | #include <DriverKit/DriverKit.h> |
| 10 | #endif /* KERNEL */ |
| 11 | #include <DriverKit/IOReturn.h> |
| 12 | #include <DriverKit/IOUserServer.h> |
| 13 | |
| 14 | /* @iig implementation */ |
| 15 | #include <IOKit/IOUserServer.h> |
| 16 | /* @iig end */ |
| 17 | |
| 18 | |
| 19 | #if __has_builtin(__builtin_load_member_function_pointer) |
| 20 | #define SimpleMemberFunctionCast(cfnty, self, func) (cfnty)__builtin_load_member_function_pointer(self, func) |
| 21 | #else |
| 22 | #define SimpleMemberFunctionCast(cfnty, self, func) ({ union { typeof(func) memfun; cfnty cfun; } pair; pair.memfun = func; pair.cfun; }) |
| 23 | #endif |
| 24 | |
| 25 | |
| 26 | struct IOUserServer_Create_Msg_Content |
| 27 | { |
| 28 | IORPCMessage __hdr; |
| 29 | OSObjectRef __object; |
| 30 | OSString * bundleID; |
| 31 | #if !defined(__LP64__) |
| 32 | uint32_t __bundleIDPad; |
| 33 | #endif /* !defined(__LP64__) */ |
| 34 | const char * name; |
| 35 | #if !defined(__LP64__) |
| 36 | uint32_t __namePad; |
| 37 | #endif /* !defined(__LP64__) */ |
| 38 | char __name[64]; |
| 39 | uint64_t tag; |
| 40 | uint64_t options; |
| 41 | }; |
| 42 | #pragma pack(4) |
| 43 | struct IOUserServer_Create_Msg |
| 44 | { |
| 45 | IORPCMessageMach mach; |
| 46 | mach_msg_port_descriptor_t __object__descriptor; |
| 47 | mach_msg_ool_descriptor_t bundleID__descriptor; |
| 48 | IOUserServer_Create_Msg_Content content; |
| 49 | }; |
| 50 | #pragma pack() |
| 51 | #define IOUserServer_Create_Msg_ObjRefs (2) |
| 52 | |
| 53 | struct IOUserServer_Create_Rpl_Content |
| 54 | { |
| 55 | IORPCMessage __hdr; |
| 56 | OSObjectRef server; |
| 57 | }; |
| 58 | #pragma pack(4) |
| 59 | struct IOUserServer_Create_Rpl |
| 60 | { |
| 61 | IORPCMessageMach mach; |
| 62 | mach_msg_port_descriptor_t server__descriptor; |
| 63 | IOUserServer_Create_Rpl_Content content; |
| 64 | }; |
| 65 | #pragma pack() |
| 66 | #define IOUserServer_Create_Rpl_ObjRefs (1) |
| 67 | |
| 68 | |
| 69 | typedef union |
| 70 | { |
| 71 | const IORPC rpc; |
| 72 | struct |
| 73 | { |
| 74 | const struct IOUserServer_Create_Msg * message; |
| 75 | struct IOUserServer_Create_Rpl * reply; |
| 76 | uint32_t sendSize; |
| 77 | uint32_t replySize; |
| 78 | }; |
| 79 | } |
| 80 | IOUserServer_Create_Invocation; |
| 81 | struct IOUserServer_Exit_Msg_Content |
| 82 | { |
| 83 | IORPCMessage __hdr; |
| 84 | OSObjectRef __object; |
| 85 | const char * reason; |
| 86 | #if !defined(__LP64__) |
| 87 | uint32_t __reasonPad; |
| 88 | #endif /* !defined(__LP64__) */ |
| 89 | char __reason[1024]; |
| 90 | }; |
| 91 | #pragma pack(4) |
| 92 | struct IOUserServer_Exit_Msg |
| 93 | { |
| 94 | IORPCMessageMach mach; |
| 95 | mach_msg_port_descriptor_t __object__descriptor; |
| 96 | IOUserServer_Exit_Msg_Content content; |
| 97 | }; |
| 98 | #pragma pack() |
| 99 | #define IOUserServer_Exit_Msg_ObjRefs (1) |
| 100 | |
| 101 | struct IOUserServer_Exit_Rpl_Content |
| 102 | { |
| 103 | IORPCMessage __hdr; |
| 104 | }; |
| 105 | #pragma pack(4) |
| 106 | struct IOUserServer_Exit_Rpl |
| 107 | { |
| 108 | IORPCMessageMach mach; |
| 109 | IOUserServer_Exit_Rpl_Content content; |
| 110 | }; |
| 111 | #pragma pack() |
| 112 | #define IOUserServer_Exit_Rpl_ObjRefs (0) |
| 113 | |
| 114 | |
| 115 | typedef union |
| 116 | { |
| 117 | const IORPC rpc; |
| 118 | struct |
| 119 | { |
| 120 | const struct IOUserServer_Exit_Msg * message; |
| 121 | struct IOUserServer_Exit_Rpl * reply; |
| 122 | uint32_t sendSize; |
| 123 | uint32_t replySize; |
| 124 | }; |
| 125 | } |
| 126 | IOUserServer_Exit_Invocation; |
| 127 | struct IOUserServer_LoadModule_Msg_Content |
| 128 | { |
| 129 | IORPCMessage __hdr; |
| 130 | OSObjectRef __object; |
| 131 | const char * path; |
| 132 | #if !defined(__LP64__) |
| 133 | uint32_t __pathPad; |
| 134 | #endif /* !defined(__LP64__) */ |
| 135 | char __path[1024]; |
| 136 | }; |
| 137 | #pragma pack(4) |
| 138 | struct IOUserServer_LoadModule_Msg |
| 139 | { |
| 140 | IORPCMessageMach mach; |
| 141 | mach_msg_port_descriptor_t __object__descriptor; |
| 142 | IOUserServer_LoadModule_Msg_Content content; |
| 143 | }; |
| 144 | #pragma pack() |
| 145 | #define IOUserServer_LoadModule_Msg_ObjRefs (1) |
| 146 | |
| 147 | struct IOUserServer_LoadModule_Rpl_Content |
| 148 | { |
| 149 | IORPCMessage __hdr; |
| 150 | }; |
| 151 | #pragma pack(4) |
| 152 | struct IOUserServer_LoadModule_Rpl |
| 153 | { |
| 154 | IORPCMessageMach mach; |
| 155 | IOUserServer_LoadModule_Rpl_Content content; |
| 156 | }; |
| 157 | #pragma pack() |
| 158 | #define IOUserServer_LoadModule_Rpl_ObjRefs (0) |
| 159 | |
| 160 | |
| 161 | typedef union |
| 162 | { |
| 163 | const IORPC rpc; |
| 164 | struct |
| 165 | { |
| 166 | const struct IOUserServer_LoadModule_Msg * message; |
| 167 | struct IOUserServer_LoadModule_Rpl * reply; |
| 168 | uint32_t sendSize; |
| 169 | uint32_t replySize; |
| 170 | }; |
| 171 | } |
| 172 | IOUserServer_LoadModule_Invocation; |
| 173 | #if !KERNEL |
| 174 | extern OSMetaClass * gOSContainerMetaClass; |
| 175 | extern OSMetaClass * gOSDataMetaClass; |
| 176 | extern OSMetaClass * gOSNumberMetaClass; |
| 177 | extern OSMetaClass * gOSBooleanMetaClass; |
| 178 | extern OSMetaClass * gOSDictionaryMetaClass; |
| 179 | extern OSMetaClass * gOSArrayMetaClass; |
| 180 | extern OSMetaClass * gOSSetMetaClass; |
| 181 | extern OSMetaClass * gOSOrderedSetMetaClass; |
| 182 | extern OSMetaClass * gIODispatchQueueMetaClass; |
| 183 | extern OSMetaClass * gOSStringMetaClass; |
| 184 | extern OSMetaClass * gIOMemoryDescriptorMetaClass; |
| 185 | extern OSMetaClass * gIOBufferMemoryDescriptorMetaClass; |
| 186 | extern OSMetaClass * gIOUserClientMetaClass; |
| 187 | extern OSMetaClass * gIOServiceStateNotificationDispatchSourceMetaClass; |
| 188 | #endif /* !KERNEL */ |
| 189 | |
| 190 | #if !KERNEL |
| 191 | |
| 192 | #define IOUserServer_QueueNames "" |
| 193 | |
| 194 | #define IOUserServer_MethodNames "" |
| 195 | |
| 196 | #define IOUserServerMetaClass_MethodNames "" |
| 197 | |
| 198 | struct OSClassDescription_IOUserServer_t |
| 199 | { |
| 200 | OSClassDescription base; |
| 201 | uint64_t methodOptions[2 * 0]; |
| 202 | uint64_t metaMethodOptions[2 * 0]; |
| 203 | char queueNames[sizeof(IOUserServer_QueueNames)]; |
| 204 | char methodNames[sizeof(IOUserServer_MethodNames)]; |
| 205 | char metaMethodNames[sizeof(IOUserServerMetaClass_MethodNames)]; |
| 206 | }; |
| 207 | |
| 208 | const struct OSClassDescription_IOUserServer_t |
| 209 | OSClassDescription_IOUserServer = |
| 210 | { |
| 211 | .base = |
| 212 | { |
| 213 | .descriptionSize = sizeof(OSClassDescription_IOUserServer_t), |
| 214 | .name = "IOUserServer" , |
| 215 | .superName = "IOService" , |
| 216 | .methodOptionsSize = 2 * sizeof(uint64_t) * 0, |
| 217 | .methodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOUserServer_t, methodOptions), |
| 218 | .metaMethodOptionsSize = 2 * sizeof(uint64_t) * 0, |
| 219 | .metaMethodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOUserServer_t, metaMethodOptions), |
| 220 | .queueNamesSize = sizeof(IOUserServer_QueueNames), |
| 221 | .queueNamesOffset = __builtin_offsetof(struct OSClassDescription_IOUserServer_t, queueNames), |
| 222 | .methodNamesSize = sizeof(IOUserServer_MethodNames), |
| 223 | .methodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOUserServer_t, methodNames), |
| 224 | .metaMethodNamesSize = sizeof(IOUserServerMetaClass_MethodNames), |
| 225 | .metaMethodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOUserServer_t, metaMethodNames), |
| 226 | .flags = 1*kOSClassCanRemote, |
| 227 | }, |
| 228 | .methodOptions = |
| 229 | { |
| 230 | }, |
| 231 | .metaMethodOptions = |
| 232 | { |
| 233 | }, |
| 234 | .queueNames = IOUserServer_QueueNames, |
| 235 | .methodNames = IOUserServer_MethodNames, |
| 236 | .metaMethodNames = IOUserServerMetaClass_MethodNames, |
| 237 | }; |
| 238 | |
| 239 | OSMetaClass * gIOUserServerMetaClass; |
| 240 | |
| 241 | static kern_return_t |
| 242 | IOUserServer_New(OSMetaClass * instance); |
| 243 | |
| 244 | const OSClassLoadInformation |
| 245 | IOUserServer_Class = |
| 246 | { |
| 247 | .description = &OSClassDescription_IOUserServer.base, |
| 248 | .metaPointer = &gIOUserServerMetaClass, |
| 249 | .version = 1, |
| 250 | .instanceSize = sizeof(IOUserServer), |
| 251 | |
| 252 | .New = &IOUserServer_New, |
| 253 | }; |
| 254 | |
| 255 | extern const void * const |
| 256 | gIOUserServer_Declaration; |
| 257 | const void * const |
| 258 | gIOUserServer_Declaration |
| 259 | __attribute__((visibility("hidden" ),section("__DATA_CONST,__osclassinfo,regular,no_dead_strip" ),no_sanitize("address" ))) |
| 260 | = &IOUserServer_Class; |
| 261 | |
| 262 | static kern_return_t |
| 263 | IOUserServer_New(OSMetaClass * instance) |
| 264 | { |
| 265 | if (!new(instance) IOUserServerMetaClass) return (kIOReturnNoMemory); |
| 266 | return (kIOReturnSuccess); |
| 267 | } |
| 268 | |
| 269 | kern_return_t |
| 270 | IOUserServerMetaClass::New(OSObject * instance) |
| 271 | { |
| 272 | if (!new(instance) IOUserServer) return (kIOReturnNoMemory); |
| 273 | return (kIOReturnSuccess); |
| 274 | } |
| 275 | |
| 276 | #endif /* !KERNEL */ |
| 277 | |
| 278 | kern_return_t |
| 279 | IOUserServer::Dispatch(const IORPC rpc) |
| 280 | { |
| 281 | return _Dispatch(self: this, rpc); |
| 282 | } |
| 283 | |
| 284 | kern_return_t |
| 285 | IOUserServer::_Dispatch(IOUserServer * self, const IORPC rpc) |
| 286 | { |
| 287 | kern_return_t ret = kIOReturnUnsupported; |
| 288 | IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false); |
| 289 | |
| 290 | switch (msg->msgid) |
| 291 | { |
| 292 | case IOUserServer_Exit_ID: |
| 293 | { |
| 294 | ret = IOUserServer::Exit_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOUserServer::Exit_Handler, *self, &IOUserServer::Exit_Impl)); |
| 295 | break; |
| 296 | } |
| 297 | case IOUserServer_LoadModule_ID: |
| 298 | { |
| 299 | ret = IOUserServer::LoadModule_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOUserServer::LoadModule_Handler, *self, &IOUserServer::LoadModule_Impl)); |
| 300 | break; |
| 301 | } |
| 302 | #if KERNEL |
| 303 | case IOService_RegisterService_ID: |
| 304 | { |
| 305 | ret = IOService::RegisterService_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOService::RegisterService_Handler, *self, &IOUserServer::RegisterService_Impl)); |
| 306 | break; |
| 307 | } |
| 308 | #endif /* !KERNEL */ |
| 309 | |
| 310 | default: |
| 311 | ret = IOService::_Dispatch(self, rpc); |
| 312 | break; |
| 313 | } |
| 314 | |
| 315 | return (ret); |
| 316 | } |
| 317 | |
| 318 | #if KERNEL |
| 319 | kern_return_t |
| 320 | IOUserServer::MetaClass::Dispatch(const IORPC rpc) |
| 321 | { |
| 322 | #else /* KERNEL */ |
| 323 | kern_return_t |
| 324 | IOUserServerMetaClass::Dispatch(const IORPC rpc) |
| 325 | { |
| 326 | #endif /* !KERNEL */ |
| 327 | |
| 328 | kern_return_t ret = kIOReturnUnsupported; |
| 329 | IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false); |
| 330 | |
| 331 | switch (msg->msgid) |
| 332 | { |
| 333 | #if KERNEL |
| 334 | case IOUserServer_Create_ID: |
| 335 | ret = IOUserServer::Create_Invoke(rpc, func: &IOUserServer::Create_Impl); |
| 336 | break; |
| 337 | #endif /* !KERNEL */ |
| 338 | |
| 339 | default: |
| 340 | ret = OSMetaClassBase::Dispatch(rpc); |
| 341 | break; |
| 342 | } |
| 343 | |
| 344 | return (ret); |
| 345 | } |
| 346 | |
| 347 | kern_return_t |
| 348 | IOUserServer::Create( |
| 349 | const char * name, |
| 350 | uint64_t tag, |
| 351 | uint64_t options, |
| 352 | OSString * bundleID, |
| 353 | IOUserServer ** server) |
| 354 | { |
| 355 | kern_return_t ret; |
| 356 | union |
| 357 | { |
| 358 | IOUserServer_Create_Msg msg; |
| 359 | struct |
| 360 | { |
| 361 | IOUserServer_Create_Rpl rpl; |
| 362 | mach_msg_max_trailer_t trailer; |
| 363 | } rpl; |
| 364 | } buf; |
| 365 | struct IOUserServer_Create_Msg * msg = &buf.msg; |
| 366 | struct IOUserServer_Create_Rpl * rpl = &buf.rpl.rpl; |
| 367 | |
| 368 | memset(s: msg, c: 0, n: sizeof(struct IOUserServer_Create_Msg)); |
| 369 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
| 370 | msg->mach.msgh.msgh_size = sizeof(*msg); |
| 371 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
| 372 | | 0*kIORPCMessageSimpleReply |
| 373 | | 0*kIORPCMessageLocalHost |
| 374 | | 0*kIORPCMessageOnqueue; |
| 375 | msg->content.__hdr.msgid = IOUserServer_Create_ID; |
| 376 | msg->content.__object = (OSObjectRef) OSTypeID(IOUserServer); |
| 377 | msg->content.__hdr.objectRefs = IOUserServer_Create_Msg_ObjRefs; |
| 378 | msg->mach.msgh_body.msgh_descriptor_count = 2; |
| 379 | |
| 380 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
| 381 | |
| 382 | msg->content.name = NULL; |
| 383 | |
| 384 | strlcpy(dst: &msg->content.__name[0], src: name, n: sizeof(msg->content.__name)); |
| 385 | |
| 386 | msg->content.tag = tag; |
| 387 | |
| 388 | msg->content.options = options; |
| 389 | |
| 390 | msg->bundleID__descriptor.type = MACH_MSG_OOL_DESCRIPTOR; |
| 391 | msg->bundleID__descriptor.copy = MACH_MSG_VIRTUAL_COPY; |
| 392 | msg->bundleID__descriptor.address = (void *) __builtin_offsetof(IOUserServer_Create_Msg_Content, bundleID); |
| 393 | msg->content.bundleID = bundleID; |
| 394 | |
| 395 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
| 396 | ret = OSMTypeID(IOUserServer)->Invoke(rpc); |
| 397 | |
| 398 | if (kIOReturnSuccess == ret) |
| 399 | do { |
| 400 | { |
| 401 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
| 402 | if (rpl->content.__hdr.msgid != IOUserServer_Create_ID) { ret = kIOReturnIPCError; break; }; |
| 403 | if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; }; |
| 404 | if (IOUserServer_Create_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
| 405 | } |
| 406 | } |
| 407 | while (false); |
| 408 | if (kIOReturnSuccess == ret) |
| 409 | { |
| 410 | *server = OSDynamicCast(IOUserServer, (OSObject *) rpl->content.server); |
| 411 | if (rpl->content.server && !*server) ret = kIOReturnBadArgument; |
| 412 | } |
| 413 | |
| 414 | |
| 415 | return (ret); |
| 416 | } |
| 417 | |
| 418 | kern_return_t |
| 419 | IOUserServer::Exit( |
| 420 | const char * reason, |
| 421 | OSDispatchMethod supermethod) |
| 422 | { |
| 423 | kern_return_t ret; |
| 424 | union |
| 425 | { |
| 426 | IOUserServer_Exit_Msg msg; |
| 427 | struct |
| 428 | { |
| 429 | IOUserServer_Exit_Rpl rpl; |
| 430 | mach_msg_max_trailer_t trailer; |
| 431 | } rpl; |
| 432 | } buf; |
| 433 | struct IOUserServer_Exit_Msg * msg = &buf.msg; |
| 434 | struct IOUserServer_Exit_Rpl * rpl = &buf.rpl.rpl; |
| 435 | |
| 436 | memset(s: msg, c: 0, n: sizeof(struct IOUserServer_Exit_Msg)); |
| 437 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
| 438 | msg->mach.msgh.msgh_size = sizeof(*msg); |
| 439 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
| 440 | | 1*kIORPCMessageSimpleReply |
| 441 | | 0*kIORPCMessageLocalHost |
| 442 | | 0*kIORPCMessageOnqueue; |
| 443 | msg->content.__hdr.msgid = IOUserServer_Exit_ID; |
| 444 | msg->content.__object = (OSObjectRef) this; |
| 445 | msg->content.__hdr.objectRefs = IOUserServer_Exit_Msg_ObjRefs; |
| 446 | msg->mach.msgh_body.msgh_descriptor_count = 1; |
| 447 | |
| 448 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
| 449 | |
| 450 | msg->content.reason = NULL; |
| 451 | |
| 452 | strlcpy(dst: &msg->content.__reason[0], src: reason, n: sizeof(msg->content.__reason)); |
| 453 | |
| 454 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
| 455 | if (supermethod) ret = supermethod((OSObject *)this, rpc); |
| 456 | else ret = ((OSObject *)this)->Invoke(rpc); |
| 457 | |
| 458 | if (kIOReturnSuccess == ret) |
| 459 | do { |
| 460 | { |
| 461 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
| 462 | if (rpl->content.__hdr.msgid != IOUserServer_Exit_ID) { ret = kIOReturnIPCError; break; }; |
| 463 | if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; }; |
| 464 | if (IOUserServer_Exit_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
| 465 | } |
| 466 | } |
| 467 | while (false); |
| 468 | if (kIOReturnSuccess == ret) |
| 469 | { |
| 470 | } |
| 471 | |
| 472 | |
| 473 | return (ret); |
| 474 | } |
| 475 | |
| 476 | kern_return_t |
| 477 | IOUserServer::LoadModule( |
| 478 | const char * path, |
| 479 | OSDispatchMethod supermethod) |
| 480 | { |
| 481 | kern_return_t ret; |
| 482 | union |
| 483 | { |
| 484 | IOUserServer_LoadModule_Msg msg; |
| 485 | struct |
| 486 | { |
| 487 | IOUserServer_LoadModule_Rpl rpl; |
| 488 | mach_msg_max_trailer_t trailer; |
| 489 | } rpl; |
| 490 | } buf; |
| 491 | struct IOUserServer_LoadModule_Msg * msg = &buf.msg; |
| 492 | struct IOUserServer_LoadModule_Rpl * rpl = &buf.rpl.rpl; |
| 493 | |
| 494 | memset(s: msg, c: 0, n: sizeof(struct IOUserServer_LoadModule_Msg)); |
| 495 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
| 496 | msg->mach.msgh.msgh_size = sizeof(*msg); |
| 497 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
| 498 | | 1*kIORPCMessageSimpleReply |
| 499 | | 0*kIORPCMessageLocalHost |
| 500 | | 0*kIORPCMessageOnqueue; |
| 501 | msg->content.__hdr.msgid = IOUserServer_LoadModule_ID; |
| 502 | msg->content.__object = (OSObjectRef) this; |
| 503 | msg->content.__hdr.objectRefs = IOUserServer_LoadModule_Msg_ObjRefs; |
| 504 | msg->mach.msgh_body.msgh_descriptor_count = 1; |
| 505 | |
| 506 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
| 507 | |
| 508 | msg->content.path = NULL; |
| 509 | |
| 510 | strlcpy(dst: &msg->content.__path[0], src: path, n: sizeof(msg->content.__path)); |
| 511 | |
| 512 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
| 513 | if (supermethod) ret = supermethod((OSObject *)this, rpc); |
| 514 | else ret = ((OSObject *)this)->Invoke(rpc); |
| 515 | |
| 516 | if (kIOReturnSuccess == ret) |
| 517 | do { |
| 518 | { |
| 519 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
| 520 | if (rpl->content.__hdr.msgid != IOUserServer_LoadModule_ID) { ret = kIOReturnIPCError; break; }; |
| 521 | if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; }; |
| 522 | if (IOUserServer_LoadModule_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
| 523 | } |
| 524 | } |
| 525 | while (false); |
| 526 | if (kIOReturnSuccess == ret) |
| 527 | { |
| 528 | } |
| 529 | |
| 530 | |
| 531 | return (ret); |
| 532 | } |
| 533 | |
| 534 | kern_return_t |
| 535 | IOUserServer::Create_Invoke(const IORPC _rpc, |
| 536 | Create_Handler func) |
| 537 | { |
| 538 | IOUserServer_Create_Invocation rpc = { .rpc: _rpc }; |
| 539 | kern_return_t ret; |
| 540 | |
| 541 | if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
| 542 | if (IOUserServer_Create_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
| 543 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOUserServer_Create_Msg)) return (kIOReturnIPCError); |
| 544 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOUserServer_Create_Rpl)) return (kIOReturnIPCError); |
| 545 | if (((OSObject *) rpc.message->content.bundleID) != NULL && OSDynamicCast(OSString, (OSObject *) rpc.message->content.bundleID) == NULL) { return kIOReturnBadArgument; } |
| 546 | if (strnlen(s: &rpc.message->content.__name[0], n: sizeof(rpc.message->content.__name)) >= sizeof(rpc.message->content.__name)) return kIOReturnBadArgument; |
| 547 | |
| 548 | ret = (*func)( &rpc.message->content.__name[0], |
| 549 | rpc.message->content.tag, |
| 550 | rpc.message->content.options, |
| 551 | rpc.message->content.bundleID, |
| 552 | (IOUserServer **)&rpc.reply->content.server); |
| 553 | |
| 554 | if (kIOReturnSuccess != ret) return (ret); |
| 555 | |
| 556 | rpc.reply->content.__hdr.msgid = IOUserServer_Create_ID; |
| 557 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
| 558 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
| 559 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
| 560 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 1; |
| 561 | rpc.reply->content.__hdr.objectRefs = IOUserServer_Create_Rpl_ObjRefs; |
| 562 | rpc.reply->server__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
| 563 | |
| 564 | return (ret); |
| 565 | } |
| 566 | |
| 567 | kern_return_t |
| 568 | IOUserServer::Exit_Invoke(const IORPC _rpc, |
| 569 | OSMetaClassBase * target, |
| 570 | Exit_Handler func) |
| 571 | { |
| 572 | IOUserServer_Exit_Invocation rpc = { .rpc: _rpc }; |
| 573 | kern_return_t ret; |
| 574 | |
| 575 | if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
| 576 | if (IOUserServer_Exit_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
| 577 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOUserServer_Exit_Msg)) return (kIOReturnIPCError); |
| 578 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOUserServer_Exit_Rpl)) return (kIOReturnIPCError); |
| 579 | if (strnlen(s: &rpc.message->content.__reason[0], n: sizeof(rpc.message->content.__reason)) >= sizeof(rpc.message->content.__reason)) return kIOReturnBadArgument; |
| 580 | |
| 581 | ret = (*func)(target, |
| 582 | &rpc.message->content.__reason[0]); |
| 583 | |
| 584 | if (kIOReturnSuccess != ret) return (ret); |
| 585 | |
| 586 | rpc.reply->content.__hdr.msgid = IOUserServer_Exit_ID; |
| 587 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
| 588 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
| 589 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
| 590 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 0; |
| 591 | rpc.reply->content.__hdr.objectRefs = IOUserServer_Exit_Rpl_ObjRefs; |
| 592 | |
| 593 | return (ret); |
| 594 | } |
| 595 | |
| 596 | kern_return_t |
| 597 | IOUserServer::LoadModule_Invoke(const IORPC _rpc, |
| 598 | OSMetaClassBase * target, |
| 599 | LoadModule_Handler func) |
| 600 | { |
| 601 | IOUserServer_LoadModule_Invocation rpc = { .rpc: _rpc }; |
| 602 | kern_return_t ret; |
| 603 | |
| 604 | if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
| 605 | if (IOUserServer_LoadModule_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
| 606 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOUserServer_LoadModule_Msg)) return (kIOReturnIPCError); |
| 607 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOUserServer_LoadModule_Rpl)) return (kIOReturnIPCError); |
| 608 | if (strnlen(s: &rpc.message->content.__path[0], n: sizeof(rpc.message->content.__path)) >= sizeof(rpc.message->content.__path)) return kIOReturnBadArgument; |
| 609 | |
| 610 | ret = (*func)(target, |
| 611 | &rpc.message->content.__path[0]); |
| 612 | |
| 613 | if (kIOReturnSuccess != ret) return (ret); |
| 614 | |
| 615 | rpc.reply->content.__hdr.msgid = IOUserServer_LoadModule_ID; |
| 616 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
| 617 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
| 618 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
| 619 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 0; |
| 620 | rpc.reply->content.__hdr.objectRefs = IOUserServer_LoadModule_Rpl_ObjRefs; |
| 621 | |
| 622 | return (ret); |
| 623 | } |
| 624 | |
| 625 | |
| 626 | |
| 627 | |