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