1/* iig(DriverKit-286 Mar 29 2024 10:27:09) generated from IODispatchQueue.iig */
2
3#undef IIG_IMPLEMENTATION
4#define IIG_IMPLEMENTATION IODispatchQueue.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/IODispatchQueue.h>
13
14
15#if __has_builtin(__builtin_load_member_function_pointer)
16#define SimpleMemberFunctionCast(cfnty, self, func) (cfnty)__builtin_load_member_function_pointer(self, func)
17#else
18#define SimpleMemberFunctionCast(cfnty, self, func) ({ union { typeof(func) memfun; cfnty cfun; } pair; pair.memfun = func; pair.cfun; })
19#endif
20
21
22struct IODispatchQueue_SetPort_Msg_Content
23{
24 IORPCMessage __hdr;
25 OSObjectRef __object;
26};
27#pragma pack(4)
28struct IODispatchQueue_SetPort_Msg
29{
30 IORPCMessageMach mach;
31 mach_msg_port_descriptor_t __object__descriptor;
32 mach_msg_port_descriptor_t port__descriptor;
33 IODispatchQueue_SetPort_Msg_Content content;
34};
35#pragma pack()
36#define IODispatchQueue_SetPort_Msg_ObjRefs (1)
37
38struct IODispatchQueue_SetPort_Rpl_Content
39{
40 IORPCMessage __hdr;
41};
42#pragma pack(4)
43struct IODispatchQueue_SetPort_Rpl
44{
45 IORPCMessageMach mach;
46 IODispatchQueue_SetPort_Rpl_Content content;
47};
48#pragma pack()
49#define IODispatchQueue_SetPort_Rpl_ObjRefs (0)
50
51
52typedef union
53{
54 const IORPC rpc;
55 struct
56 {
57 const struct IODispatchQueue_SetPort_Msg * message;
58 struct IODispatchQueue_SetPort_Rpl * reply;
59 uint32_t sendSize;
60 uint32_t replySize;
61 };
62}
63IODispatchQueue_SetPort_Invocation;
64struct IODispatchQueue_Create_Msg_Content
65{
66 IORPCMessage __hdr;
67 OSObjectRef __object;
68 const char * name;
69#if !defined(__LP64__)
70 uint32_t __namePad;
71#endif /* !defined(__LP64__) */
72 char __name[256];
73 uint64_t options;
74 uint64_t priority;
75};
76#pragma pack(4)
77struct IODispatchQueue_Create_Msg
78{
79 IORPCMessageMach mach;
80 mach_msg_port_descriptor_t __object__descriptor;
81 IODispatchQueue_Create_Msg_Content content;
82};
83#pragma pack()
84#define IODispatchQueue_Create_Msg_ObjRefs (1)
85
86struct IODispatchQueue_Create_Rpl_Content
87{
88 IORPCMessage __hdr;
89 OSObjectRef queue;
90};
91#pragma pack(4)
92struct IODispatchQueue_Create_Rpl
93{
94 IORPCMessageMach mach;
95 mach_msg_port_descriptor_t queue__descriptor;
96 IODispatchQueue_Create_Rpl_Content content;
97};
98#pragma pack()
99#define IODispatchQueue_Create_Rpl_ObjRefs (1)
100
101
102typedef union
103{
104 const IORPC rpc;
105 struct
106 {
107 const struct IODispatchQueue_Create_Msg * message;
108 struct IODispatchQueue_Create_Rpl * reply;
109 uint32_t sendSize;
110 uint32_t replySize;
111 };
112}
113IODispatchQueue_Create_Invocation;
114#if !KERNEL
115extern OSMetaClass * gOSContainerMetaClass;
116extern OSMetaClass * gOSDataMetaClass;
117extern OSMetaClass * gOSNumberMetaClass;
118extern OSMetaClass * gOSBooleanMetaClass;
119extern OSMetaClass * gOSDictionaryMetaClass;
120extern OSMetaClass * gOSArrayMetaClass;
121extern OSMetaClass * gOSSetMetaClass;
122extern OSMetaClass * gOSOrderedSetMetaClass;
123extern OSMetaClass * gOSStringMetaClass;
124#endif /* !KERNEL */
125
126#if KERNEL
127OSDefineMetaClassAndStructors(IODispatchQueue, OSObject);
128#endif /* KERNEL */
129
130#if !KERNEL
131
132#define IODispatchQueue_QueueNames ""
133
134#define IODispatchQueue_MethodNames ""
135
136#define IODispatchQueueMetaClass_MethodNames ""
137
138struct OSClassDescription_IODispatchQueue_t
139{
140 OSClassDescription base;
141 uint64_t methodOptions[2 * 0];
142 uint64_t metaMethodOptions[2 * 0];
143 char queueNames[sizeof(IODispatchQueue_QueueNames)];
144 char methodNames[sizeof(IODispatchQueue_MethodNames)];
145 char metaMethodNames[sizeof(IODispatchQueueMetaClass_MethodNames)];
146};
147
148const struct OSClassDescription_IODispatchQueue_t
149OSClassDescription_IODispatchQueue =
150{
151 .base =
152 {
153 .descriptionSize = sizeof(OSClassDescription_IODispatchQueue_t),
154 .name = "IODispatchQueue",
155 .superName = "OSObject",
156 .methodOptionsSize = 2 * sizeof(uint64_t) * 0,
157 .methodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IODispatchQueue_t, methodOptions),
158 .metaMethodOptionsSize = 2 * sizeof(uint64_t) * 0,
159 .metaMethodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IODispatchQueue_t, metaMethodOptions),
160 .queueNamesSize = sizeof(IODispatchQueue_QueueNames),
161 .queueNamesOffset = __builtin_offsetof(struct OSClassDescription_IODispatchQueue_t, queueNames),
162 .methodNamesSize = sizeof(IODispatchQueue_MethodNames),
163 .methodNamesOffset = __builtin_offsetof(struct OSClassDescription_IODispatchQueue_t, methodNames),
164 .metaMethodNamesSize = sizeof(IODispatchQueueMetaClass_MethodNames),
165 .metaMethodNamesOffset = __builtin_offsetof(struct OSClassDescription_IODispatchQueue_t, metaMethodNames),
166 .flags = 1*kOSClassCanRemote,
167 },
168 .methodOptions =
169 {
170 },
171 .metaMethodOptions =
172 {
173 },
174 .queueNames = IODispatchQueue_QueueNames,
175 .methodNames = IODispatchQueue_MethodNames,
176 .metaMethodNames = IODispatchQueueMetaClass_MethodNames,
177};
178
179OSMetaClass * gIODispatchQueueMetaClass;
180
181static kern_return_t
182IODispatchQueue_New(OSMetaClass * instance);
183
184const OSClassLoadInformation
185IODispatchQueue_Class =
186{
187 .description = &OSClassDescription_IODispatchQueue.base,
188 .metaPointer = &gIODispatchQueueMetaClass,
189 .version = 1,
190 .instanceSize = sizeof(IODispatchQueue),
191
192 .New = &IODispatchQueue_New,
193};
194
195extern const void * const
196gIODispatchQueue_Declaration;
197const void * const
198gIODispatchQueue_Declaration
199__attribute__((visibility("hidden"),section("__DATA_CONST,__osclassinfo,regular,no_dead_strip"),no_sanitize("address")))
200 = &IODispatchQueue_Class;
201
202static kern_return_t
203IODispatchQueue_New(OSMetaClass * instance)
204{
205 if (!new(instance) IODispatchQueueMetaClass) return (kIOReturnNoMemory);
206 return (kIOReturnSuccess);
207}
208
209kern_return_t
210IODispatchQueueMetaClass::New(OSObject * instance)
211{
212 if (!new(instance) IODispatchQueue) return (kIOReturnNoMemory);
213 return (kIOReturnSuccess);
214}
215
216#endif /* !KERNEL */
217
218kern_return_t
219IODispatchQueue::Dispatch(const IORPC rpc)
220{
221 return _Dispatch(self: this, rpc);
222}
223
224kern_return_t
225IODispatchQueue::_Dispatch(IODispatchQueue * self, const IORPC rpc)
226{
227 kern_return_t ret = kIOReturnUnsupported;
228 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
229
230 switch (msg->msgid)
231 {
232#if KERNEL
233 case IODispatchQueue_SetPort_ID:
234 {
235 ret = IODispatchQueue::SetPort_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODispatchQueue::SetPort_Handler, *self, &IODispatchQueue::SetPort_Impl));
236 break;
237 }
238#endif /* !KERNEL */
239
240 default:
241 ret = OSObject::_Dispatch(self, rpc);
242 break;
243 }
244
245 return (ret);
246}
247
248#if KERNEL
249kern_return_t
250IODispatchQueue::MetaClass::Dispatch(const IORPC rpc)
251{
252#else /* KERNEL */
253kern_return_t
254IODispatchQueueMetaClass::Dispatch(const IORPC rpc)
255{
256#endif /* !KERNEL */
257
258 kern_return_t ret = kIOReturnUnsupported;
259 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
260
261 switch (msg->msgid)
262 {
263#if KERNEL
264 case IODispatchQueue_Create_ID:
265 ret = IODispatchQueue::Create_Invoke(rpc, func: &IODispatchQueue::Create_Impl);
266 break;
267#endif /* !KERNEL */
268
269 default:
270 ret = OSMetaClassBase::Dispatch(rpc);
271 break;
272 }
273
274 return (ret);
275}
276
277kern_return_t
278IODispatchQueue::SetPort(
279 mach_port_t port,
280 OSDispatchMethod supermethod)
281{
282 kern_return_t ret;
283 union
284 {
285 IODispatchQueue_SetPort_Msg msg;
286 struct
287 {
288 IODispatchQueue_SetPort_Rpl rpl;
289 mach_msg_max_trailer_t trailer;
290 } rpl;
291 } buf;
292 struct IODispatchQueue_SetPort_Msg * msg = &buf.msg;
293 struct IODispatchQueue_SetPort_Rpl * rpl = &buf.rpl.rpl;
294
295 memset(s: msg, c: 0, n: sizeof(struct IODispatchQueue_SetPort_Msg));
296 msg->mach.msgh.msgh_id = kIORPCVersion190615;
297 msg->mach.msgh.msgh_size = sizeof(*msg);
298 msg->content.__hdr.flags = 0*kIORPCMessageOneway
299 | 1*kIORPCMessageSimpleReply
300 | 0*kIORPCMessageLocalHost
301 | 0*kIORPCMessageOnqueue;
302 msg->content.__hdr.msgid = IODispatchQueue_SetPort_ID;
303 msg->content.__object = (OSObjectRef) this;
304 msg->content.__hdr.objectRefs = IODispatchQueue_SetPort_Msg_ObjRefs;
305 msg->mach.msgh_body.msgh_descriptor_count = 2;
306
307 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
308
309 msg->port__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
310 msg->port__descriptor.disposition = MACH_MSG_TYPE_MAKE_SEND;
311 msg->port__descriptor.name = port;
312 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
313 if (supermethod) ret = supermethod((OSObject *)this, rpc);
314 else ret = ((OSObject *)this)->Invoke(rpc);
315
316 if (kIOReturnSuccess == ret)
317 do {
318 {
319 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
320 if (rpl->content.__hdr.msgid != IODispatchQueue_SetPort_ID) { ret = kIOReturnIPCError; break; };
321 if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; };
322 if (IODispatchQueue_SetPort_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
323 }
324 }
325 while (false);
326 if (kIOReturnSuccess == ret)
327 {
328 }
329
330
331 return (ret);
332}
333
334kern_return_t
335IODispatchQueue::Create_Call(
336 const char * name,
337 uint64_t options,
338 uint64_t priority,
339 IODispatchQueue ** queue)
340{
341 kern_return_t ret;
342 union
343 {
344 IODispatchQueue_Create_Msg msg;
345 struct
346 {
347 IODispatchQueue_Create_Rpl rpl;
348 mach_msg_max_trailer_t trailer;
349 } rpl;
350 } buf;
351 struct IODispatchQueue_Create_Msg * msg = &buf.msg;
352 struct IODispatchQueue_Create_Rpl * rpl = &buf.rpl.rpl;
353
354 memset(s: msg, c: 0, n: sizeof(struct IODispatchQueue_Create_Msg));
355 msg->mach.msgh.msgh_id = kIORPCVersion190615;
356 msg->mach.msgh.msgh_size = sizeof(*msg);
357 msg->content.__hdr.flags = 0*kIORPCMessageOneway
358 | 0*kIORPCMessageSimpleReply
359 | 0*kIORPCMessageLocalHost
360 | 0*kIORPCMessageOnqueue;
361 msg->content.__hdr.msgid = IODispatchQueue_Create_ID;
362 msg->content.__object = (OSObjectRef) OSTypeID(IODispatchQueue);
363 msg->content.__hdr.objectRefs = IODispatchQueue_Create_Msg_ObjRefs;
364 msg->mach.msgh_body.msgh_descriptor_count = 1;
365
366 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
367
368 msg->content.name = NULL;
369
370 strlcpy(dst: &msg->content.__name[0], src: name, n: sizeof(msg->content.__name));
371
372 msg->content.options = options;
373
374 msg->content.priority = priority;
375
376 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
377 ret = OSMTypeID(IODispatchQueue)->Invoke(rpc);
378
379 if (kIOReturnSuccess == ret)
380 do {
381 {
382 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
383 if (rpl->content.__hdr.msgid != IODispatchQueue_Create_ID) { ret = kIOReturnIPCError; break; };
384 if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; };
385 if (IODispatchQueue_Create_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
386 }
387 }
388 while (false);
389 if (kIOReturnSuccess == ret)
390 {
391 *queue = OSDynamicCast(IODispatchQueue, (OSObject *) rpl->content.queue);
392 if (rpl->content.queue && !*queue) ret = kIOReturnBadArgument;
393 }
394
395
396 return (ret);
397}
398
399kern_return_t
400IODispatchQueue::SetPort_Invoke(const IORPC _rpc,
401 OSMetaClassBase * target,
402 SetPort_Handler func)
403{
404 IODispatchQueue_SetPort_Invocation rpc = { .rpc: _rpc };
405 kern_return_t ret;
406
407 if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
408 if (IODispatchQueue_SetPort_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
409 if (rpc.message != NULL && rpc.sendSize < sizeof(IODispatchQueue_SetPort_Msg)) return (kIOReturnIPCError);
410 if (rpc.reply != NULL && rpc.replySize < sizeof(IODispatchQueue_SetPort_Rpl)) return (kIOReturnIPCError);
411
412 ret = (*func)(target,
413 rpc.message->port__descriptor.name);
414
415 if (kIOReturnSuccess != ret) return (ret);
416
417 rpc.reply->content.__hdr.msgid = IODispatchQueue_SetPort_ID;
418 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
419 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
420 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
421 rpc.reply->mach.msgh_body.msgh_descriptor_count = 0;
422 rpc.reply->content.__hdr.objectRefs = IODispatchQueue_SetPort_Rpl_ObjRefs;
423
424 return (ret);
425}
426
427kern_return_t
428IODispatchQueue::Create_Invoke(const IORPC _rpc,
429 Create_Handler func)
430{
431 IODispatchQueue_Create_Invocation rpc = { .rpc: _rpc };
432 kern_return_t ret;
433
434 if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
435 if (IODispatchQueue_Create_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
436 if (rpc.message != NULL && rpc.sendSize < sizeof(IODispatchQueue_Create_Msg)) return (kIOReturnIPCError);
437 if (rpc.reply != NULL && rpc.replySize < sizeof(IODispatchQueue_Create_Rpl)) return (kIOReturnIPCError);
438 if (strnlen(s: &rpc.message->content.__name[0], n: sizeof(rpc.message->content.__name)) >= sizeof(rpc.message->content.__name)) return kIOReturnBadArgument;
439
440 ret = (*func)( &rpc.message->content.__name[0],
441 rpc.message->content.options,
442 rpc.message->content.priority,
443 (IODispatchQueue **)&rpc.reply->content.queue);
444
445 if (kIOReturnSuccess != ret) return (ret);
446
447 rpc.reply->content.__hdr.msgid = IODispatchQueue_Create_ID;
448 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
449 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
450 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
451 rpc.reply->mach.msgh_body.msgh_descriptor_count = 1;
452 rpc.reply->content.__hdr.objectRefs = IODispatchQueue_Create_Rpl_ObjRefs;
453 rpc.reply->queue__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
454
455 return (ret);
456}
457
458
459
460