1 | /* iig(DriverKit-286 Mar 29 2024 10:27:09) generated from IOServiceNotificationDispatchSource.iig */ |
2 | |
3 | #undef IIG_IMPLEMENTATION |
4 | #define IIG_IMPLEMENTATION IOServiceNotificationDispatchSource.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/IOServiceNotificationDispatchSource.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 | |
22 | struct IOServiceNotificationDispatchSource_Create_Msg_Content |
23 | { |
24 | IORPCMessage __hdr; |
25 | OSObjectRef __object; |
26 | OSDictionary * matching; |
27 | #if !defined(__LP64__) |
28 | uint32_t __matchingPad; |
29 | #endif /* !defined(__LP64__) */ |
30 | OSObjectRef queue; |
31 | uint64_t options; |
32 | }; |
33 | #pragma pack(4) |
34 | struct IOServiceNotificationDispatchSource_Create_Msg |
35 | { |
36 | IORPCMessageMach mach; |
37 | mach_msg_port_descriptor_t __object__descriptor; |
38 | mach_msg_ool_descriptor_t matching__descriptor; |
39 | mach_msg_port_descriptor_t queue__descriptor; |
40 | IOServiceNotificationDispatchSource_Create_Msg_Content content; |
41 | }; |
42 | #pragma pack() |
43 | #define IOServiceNotificationDispatchSource_Create_Msg_ObjRefs (3) |
44 | |
45 | struct IOServiceNotificationDispatchSource_Create_Rpl_Content |
46 | { |
47 | IORPCMessage __hdr; |
48 | OSObjectRef notification; |
49 | }; |
50 | #pragma pack(4) |
51 | struct IOServiceNotificationDispatchSource_Create_Rpl |
52 | { |
53 | IORPCMessageMach mach; |
54 | mach_msg_port_descriptor_t notification__descriptor; |
55 | IOServiceNotificationDispatchSource_Create_Rpl_Content content; |
56 | }; |
57 | #pragma pack() |
58 | #define IOServiceNotificationDispatchSource_Create_Rpl_ObjRefs (1) |
59 | |
60 | |
61 | typedef union |
62 | { |
63 | const IORPC rpc; |
64 | struct |
65 | { |
66 | const struct IOServiceNotificationDispatchSource_Create_Msg * message; |
67 | struct IOServiceNotificationDispatchSource_Create_Rpl * reply; |
68 | uint32_t sendSize; |
69 | uint32_t replySize; |
70 | }; |
71 | } |
72 | IOServiceNotificationDispatchSource_Create_Invocation; |
73 | struct IOServiceNotificationDispatchSource_SetHandler_Msg_Content |
74 | { |
75 | IORPCMessage __hdr; |
76 | OSObjectRef __object; |
77 | OSObjectRef action; |
78 | }; |
79 | #pragma pack(4) |
80 | struct IOServiceNotificationDispatchSource_SetHandler_Msg |
81 | { |
82 | IORPCMessageMach mach; |
83 | mach_msg_port_descriptor_t __object__descriptor; |
84 | mach_msg_port_descriptor_t action__descriptor; |
85 | IOServiceNotificationDispatchSource_SetHandler_Msg_Content content; |
86 | }; |
87 | #pragma pack() |
88 | #define IOServiceNotificationDispatchSource_SetHandler_Msg_ObjRefs (2) |
89 | |
90 | struct IOServiceNotificationDispatchSource_SetHandler_Rpl_Content |
91 | { |
92 | IORPCMessage __hdr; |
93 | }; |
94 | #pragma pack(4) |
95 | struct IOServiceNotificationDispatchSource_SetHandler_Rpl |
96 | { |
97 | IORPCMessageMach mach; |
98 | IOServiceNotificationDispatchSource_SetHandler_Rpl_Content content; |
99 | }; |
100 | #pragma pack() |
101 | #define IOServiceNotificationDispatchSource_SetHandler_Rpl_ObjRefs (0) |
102 | |
103 | |
104 | typedef union |
105 | { |
106 | const IORPC rpc; |
107 | struct |
108 | { |
109 | const struct IOServiceNotificationDispatchSource_SetHandler_Msg * message; |
110 | struct IOServiceNotificationDispatchSource_SetHandler_Rpl * reply; |
111 | uint32_t sendSize; |
112 | uint32_t replySize; |
113 | }; |
114 | } |
115 | IOServiceNotificationDispatchSource_SetHandler_Invocation; |
116 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg_Content |
117 | { |
118 | IORPCMessage __hdr; |
119 | OSObjectRef __object; |
120 | OSObjectRef action; |
121 | }; |
122 | #pragma pack(4) |
123 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg |
124 | { |
125 | IORPCMessageMach mach; |
126 | mach_msg_port_descriptor_t __object__descriptor; |
127 | mach_msg_port_descriptor_t action__descriptor; |
128 | IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg_Content content; |
129 | }; |
130 | #pragma pack() |
131 | #define IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg_ObjRefs (2) |
132 | |
133 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl_Content |
134 | { |
135 | IORPCMessage __hdr; |
136 | }; |
137 | #pragma pack(4) |
138 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl |
139 | { |
140 | IORPCMessageMach mach; |
141 | IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl_Content content; |
142 | }; |
143 | #pragma pack() |
144 | #define IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl_ObjRefs (0) |
145 | |
146 | |
147 | typedef union |
148 | { |
149 | const IORPC rpc; |
150 | struct |
151 | { |
152 | const struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg * message; |
153 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl * reply; |
154 | uint32_t sendSize; |
155 | uint32_t replySize; |
156 | }; |
157 | } |
158 | IOServiceNotificationDispatchSource_ServiceNotificationReady_Invocation; |
159 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Msg_Content |
160 | { |
161 | IORPCMessage __hdr; |
162 | OSObjectRef __object; |
163 | }; |
164 | #pragma pack(4) |
165 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Msg |
166 | { |
167 | IORPCMessageMach mach; |
168 | mach_msg_port_descriptor_t __object__descriptor; |
169 | IOServiceNotificationDispatchSource_CopyNextNotification_Msg_Content content; |
170 | }; |
171 | #pragma pack() |
172 | #define IOServiceNotificationDispatchSource_CopyNextNotification_Msg_ObjRefs (1) |
173 | |
174 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Rpl_Content |
175 | { |
176 | IORPCMessage __hdr; |
177 | OSObjectRef service; |
178 | unsigned long long type; |
179 | unsigned long long options; |
180 | }; |
181 | #pragma pack(4) |
182 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Rpl |
183 | { |
184 | IORPCMessageMach mach; |
185 | mach_msg_port_descriptor_t service__descriptor; |
186 | IOServiceNotificationDispatchSource_CopyNextNotification_Rpl_Content content; |
187 | }; |
188 | #pragma pack() |
189 | #define IOServiceNotificationDispatchSource_CopyNextNotification_Rpl_ObjRefs (1) |
190 | |
191 | |
192 | typedef union |
193 | { |
194 | const IORPC rpc; |
195 | struct |
196 | { |
197 | const struct IOServiceNotificationDispatchSource_CopyNextNotification_Msg * message; |
198 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Rpl * reply; |
199 | uint32_t sendSize; |
200 | uint32_t replySize; |
201 | }; |
202 | } |
203 | IOServiceNotificationDispatchSource_CopyNextNotification_Invocation; |
204 | #if !KERNEL |
205 | extern OSMetaClass * gOSContainerMetaClass; |
206 | extern OSMetaClass * gOSDataMetaClass; |
207 | extern OSMetaClass * gOSNumberMetaClass; |
208 | extern OSMetaClass * gOSBooleanMetaClass; |
209 | extern OSMetaClass * gOSDictionaryMetaClass; |
210 | extern OSMetaClass * gOSArrayMetaClass; |
211 | extern OSMetaClass * gOSSetMetaClass; |
212 | extern OSMetaClass * gOSOrderedSetMetaClass; |
213 | extern OSMetaClass * gOSStringMetaClass; |
214 | extern OSMetaClass * gIOMemoryDescriptorMetaClass; |
215 | extern OSMetaClass * gIOBufferMemoryDescriptorMetaClass; |
216 | extern OSMetaClass * gIOUserClientMetaClass; |
217 | extern OSMetaClass * gIOServiceStateNotificationDispatchSourceMetaClass; |
218 | #endif /* !KERNEL */ |
219 | |
220 | #if KERNEL |
221 | OSDefineMetaClassAndStructors(IOServiceNotificationDispatchSource, IODispatchSource); |
222 | #endif /* KERNEL */ |
223 | |
224 | #if !KERNEL |
225 | |
226 | #define IOServiceNotificationDispatchSource_QueueNames "" |
227 | |
228 | #define IOServiceNotificationDispatchSource_MethodNames "" |
229 | |
230 | #define IOServiceNotificationDispatchSourceMetaClass_MethodNames "" |
231 | |
232 | struct OSClassDescription_IOServiceNotificationDispatchSource_t |
233 | { |
234 | OSClassDescription base; |
235 | uint64_t methodOptions[2 * 0]; |
236 | uint64_t metaMethodOptions[2 * 0]; |
237 | char queueNames[sizeof(IOServiceNotificationDispatchSource_QueueNames)]; |
238 | char methodNames[sizeof(IOServiceNotificationDispatchSource_MethodNames)]; |
239 | char metaMethodNames[sizeof(IOServiceNotificationDispatchSourceMetaClass_MethodNames)]; |
240 | }; |
241 | |
242 | const struct OSClassDescription_IOServiceNotificationDispatchSource_t |
243 | OSClassDescription_IOServiceNotificationDispatchSource = |
244 | { |
245 | .base = |
246 | { |
247 | .descriptionSize = sizeof(OSClassDescription_IOServiceNotificationDispatchSource_t), |
248 | .name = "IOServiceNotificationDispatchSource" , |
249 | .superName = "IODispatchSource" , |
250 | .methodOptionsSize = 2 * sizeof(uint64_t) * 0, |
251 | .methodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOServiceNotificationDispatchSource_t, methodOptions), |
252 | .metaMethodOptionsSize = 2 * sizeof(uint64_t) * 0, |
253 | .metaMethodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOServiceNotificationDispatchSource_t, metaMethodOptions), |
254 | .queueNamesSize = sizeof(IOServiceNotificationDispatchSource_QueueNames), |
255 | .queueNamesOffset = __builtin_offsetof(struct OSClassDescription_IOServiceNotificationDispatchSource_t, queueNames), |
256 | .methodNamesSize = sizeof(IOServiceNotificationDispatchSource_MethodNames), |
257 | .methodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOServiceNotificationDispatchSource_t, methodNames), |
258 | .metaMethodNamesSize = sizeof(IOServiceNotificationDispatchSourceMetaClass_MethodNames), |
259 | .metaMethodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOServiceNotificationDispatchSource_t, metaMethodNames), |
260 | .flags = 1*kOSClassCanRemote, |
261 | }, |
262 | .methodOptions = |
263 | { |
264 | }, |
265 | .metaMethodOptions = |
266 | { |
267 | }, |
268 | .queueNames = IOServiceNotificationDispatchSource_QueueNames, |
269 | .methodNames = IOServiceNotificationDispatchSource_MethodNames, |
270 | .metaMethodNames = IOServiceNotificationDispatchSourceMetaClass_MethodNames, |
271 | }; |
272 | |
273 | OSMetaClass * gIOServiceNotificationDispatchSourceMetaClass; |
274 | |
275 | static kern_return_t |
276 | IOServiceNotificationDispatchSource_New(OSMetaClass * instance); |
277 | |
278 | const OSClassLoadInformation |
279 | IOServiceNotificationDispatchSource_Class = |
280 | { |
281 | .description = &OSClassDescription_IOServiceNotificationDispatchSource.base, |
282 | .metaPointer = &gIOServiceNotificationDispatchSourceMetaClass, |
283 | .version = 1, |
284 | .instanceSize = sizeof(IOServiceNotificationDispatchSource), |
285 | |
286 | .New = &IOServiceNotificationDispatchSource_New, |
287 | }; |
288 | |
289 | extern const void * const |
290 | gIOServiceNotificationDispatchSource_Declaration; |
291 | const void * const |
292 | gIOServiceNotificationDispatchSource_Declaration |
293 | __attribute__((visibility("hidden" ),section("__DATA_CONST,__osclassinfo,regular,no_dead_strip" ),no_sanitize("address" ))) |
294 | = &IOServiceNotificationDispatchSource_Class; |
295 | |
296 | static kern_return_t |
297 | IOServiceNotificationDispatchSource_New(OSMetaClass * instance) |
298 | { |
299 | if (!new(instance) IOServiceNotificationDispatchSourceMetaClass) return (kIOReturnNoMemory); |
300 | return (kIOReturnSuccess); |
301 | } |
302 | |
303 | kern_return_t |
304 | IOServiceNotificationDispatchSourceMetaClass::New(OSObject * instance) |
305 | { |
306 | if (!new(instance) IOServiceNotificationDispatchSource) return (kIOReturnNoMemory); |
307 | return (kIOReturnSuccess); |
308 | } |
309 | |
310 | #endif /* !KERNEL */ |
311 | |
312 | kern_return_t |
313 | IOServiceNotificationDispatchSource::Dispatch(const IORPC rpc) |
314 | { |
315 | return _Dispatch(self: this, rpc); |
316 | } |
317 | |
318 | kern_return_t |
319 | IOServiceNotificationDispatchSource::_Dispatch(IOServiceNotificationDispatchSource * self, const IORPC rpc) |
320 | { |
321 | kern_return_t ret = kIOReturnUnsupported; |
322 | IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false); |
323 | |
324 | switch (msg->msgid) |
325 | { |
326 | case IODispatchSource_SetEnableWithCompletion_ID: |
327 | { |
328 | ret = IODispatchSource::SetEnableWithCompletion_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODispatchSource::SetEnableWithCompletion_Handler, *self, &IOServiceNotificationDispatchSource::SetEnableWithCompletion_Impl)); |
329 | break; |
330 | } |
331 | case IODispatchSource_Cancel_ID: |
332 | { |
333 | ret = IODispatchSource::Cancel_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODispatchSource::Cancel_Handler, *self, &IOServiceNotificationDispatchSource::Cancel_Impl)); |
334 | break; |
335 | } |
336 | #if KERNEL |
337 | case IOServiceNotificationDispatchSource_SetHandler_ID: |
338 | { |
339 | ret = IOServiceNotificationDispatchSource::SetHandler_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOServiceNotificationDispatchSource::SetHandler_Handler, *self, &IOServiceNotificationDispatchSource::SetHandler_Impl)); |
340 | break; |
341 | } |
342 | #endif /* !KERNEL */ |
343 | case IODispatchSource_CheckForWork_ID: |
344 | { |
345 | ret = IODispatchSource::CheckForWork_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODispatchSource::CheckForWork_Handler, *self, &IOServiceNotificationDispatchSource::CheckForWork_Impl)); |
346 | break; |
347 | } |
348 | #if KERNEL |
349 | case IOServiceNotificationDispatchSource_CopyNextNotification_ID: |
350 | { |
351 | ret = IOServiceNotificationDispatchSource::CopyNextNotification_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOServiceNotificationDispatchSource::CopyNextNotification_Handler, *self, &IOServiceNotificationDispatchSource::CopyNextNotification_Impl)); |
352 | break; |
353 | } |
354 | #endif /* !KERNEL */ |
355 | |
356 | default: |
357 | ret = IODispatchSource::_Dispatch(self, rpc); |
358 | break; |
359 | } |
360 | |
361 | return (ret); |
362 | } |
363 | |
364 | #if KERNEL |
365 | kern_return_t |
366 | IOServiceNotificationDispatchSource::MetaClass::Dispatch(const IORPC rpc) |
367 | { |
368 | #else /* KERNEL */ |
369 | kern_return_t |
370 | IOServiceNotificationDispatchSourceMetaClass::Dispatch(const IORPC rpc) |
371 | { |
372 | #endif /* !KERNEL */ |
373 | |
374 | kern_return_t ret = kIOReturnUnsupported; |
375 | IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false); |
376 | |
377 | switch (msg->msgid) |
378 | { |
379 | #if KERNEL |
380 | case IOServiceNotificationDispatchSource_Create_ID: |
381 | ret = IOServiceNotificationDispatchSource::Create_Invoke(rpc, func: &IOServiceNotificationDispatchSource::Create_Impl); |
382 | break; |
383 | #endif /* !KERNEL */ |
384 | |
385 | default: |
386 | ret = OSMetaClassBase::Dispatch(rpc); |
387 | break; |
388 | } |
389 | |
390 | return (ret); |
391 | } |
392 | |
393 | kern_return_t |
394 | IOServiceNotificationDispatchSource::Create_Call( |
395 | OSDictionary * matching, |
396 | uint64_t options, |
397 | IODispatchQueue * queue, |
398 | IOServiceNotificationDispatchSource ** notification) |
399 | { |
400 | kern_return_t ret; |
401 | union |
402 | { |
403 | IOServiceNotificationDispatchSource_Create_Msg msg; |
404 | struct |
405 | { |
406 | IOServiceNotificationDispatchSource_Create_Rpl rpl; |
407 | mach_msg_max_trailer_t trailer; |
408 | } rpl; |
409 | } buf; |
410 | struct IOServiceNotificationDispatchSource_Create_Msg * msg = &buf.msg; |
411 | struct IOServiceNotificationDispatchSource_Create_Rpl * rpl = &buf.rpl.rpl; |
412 | |
413 | memset(s: msg, c: 0, n: sizeof(struct IOServiceNotificationDispatchSource_Create_Msg)); |
414 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
415 | msg->mach.msgh.msgh_size = sizeof(*msg); |
416 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
417 | | 0*kIORPCMessageSimpleReply |
418 | | 0*kIORPCMessageLocalHost |
419 | | 0*kIORPCMessageOnqueue; |
420 | msg->content.__hdr.msgid = IOServiceNotificationDispatchSource_Create_ID; |
421 | msg->content.__object = (OSObjectRef) OSTypeID(IOServiceNotificationDispatchSource); |
422 | msg->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_Create_Msg_ObjRefs; |
423 | msg->mach.msgh_body.msgh_descriptor_count = 3; |
424 | |
425 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
426 | |
427 | msg->matching__descriptor.type = MACH_MSG_OOL_DESCRIPTOR; |
428 | msg->matching__descriptor.copy = MACH_MSG_VIRTUAL_COPY; |
429 | msg->matching__descriptor.address = (void *) __builtin_offsetof(IOServiceNotificationDispatchSource_Create_Msg_Content, matching); |
430 | msg->content.matching = matching; |
431 | |
432 | msg->content.options = options; |
433 | |
434 | msg->queue__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
435 | msg->content.queue = (OSObjectRef) queue; |
436 | |
437 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
438 | ret = OSMTypeID(IOServiceNotificationDispatchSource)->Invoke(rpc); |
439 | |
440 | if (kIOReturnSuccess == ret) |
441 | do { |
442 | { |
443 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
444 | if (rpl->content.__hdr.msgid != IOServiceNotificationDispatchSource_Create_ID) { ret = kIOReturnIPCError; break; }; |
445 | if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; }; |
446 | if (IOServiceNotificationDispatchSource_Create_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
447 | } |
448 | } |
449 | while (false); |
450 | if (kIOReturnSuccess == ret) |
451 | { |
452 | *notification = OSDynamicCast(IOServiceNotificationDispatchSource, (OSObject *) rpl->content.notification); |
453 | if (rpl->content.notification && !*notification) ret = kIOReturnBadArgument; |
454 | } |
455 | |
456 | |
457 | return (ret); |
458 | } |
459 | |
460 | kern_return_t |
461 | IOServiceNotificationDispatchSource::SetHandler( |
462 | OSAction * action, |
463 | OSDispatchMethod supermethod) |
464 | { |
465 | kern_return_t ret; |
466 | union |
467 | { |
468 | IOServiceNotificationDispatchSource_SetHandler_Msg msg; |
469 | struct |
470 | { |
471 | IOServiceNotificationDispatchSource_SetHandler_Rpl rpl; |
472 | mach_msg_max_trailer_t trailer; |
473 | } rpl; |
474 | } buf; |
475 | struct IOServiceNotificationDispatchSource_SetHandler_Msg * msg = &buf.msg; |
476 | struct IOServiceNotificationDispatchSource_SetHandler_Rpl * rpl = &buf.rpl.rpl; |
477 | |
478 | memset(s: msg, c: 0, n: sizeof(struct IOServiceNotificationDispatchSource_SetHandler_Msg)); |
479 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
480 | msg->mach.msgh.msgh_size = sizeof(*msg); |
481 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
482 | | 1*kIORPCMessageSimpleReply |
483 | | 0*kIORPCMessageLocalHost |
484 | | 0*kIORPCMessageOnqueue; |
485 | msg->content.__hdr.msgid = IOServiceNotificationDispatchSource_SetHandler_ID; |
486 | msg->content.__object = (OSObjectRef) this; |
487 | msg->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_SetHandler_Msg_ObjRefs; |
488 | msg->mach.msgh_body.msgh_descriptor_count = 2; |
489 | |
490 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
491 | |
492 | msg->action__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
493 | msg->content.action = (OSObjectRef) action; |
494 | |
495 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
496 | if (supermethod) ret = supermethod((OSObject *)this, rpc); |
497 | else ret = ((OSObject *)this)->Invoke(rpc); |
498 | |
499 | if (kIOReturnSuccess == ret) |
500 | do { |
501 | { |
502 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
503 | if (rpl->content.__hdr.msgid != IOServiceNotificationDispatchSource_SetHandler_ID) { ret = kIOReturnIPCError; break; }; |
504 | if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; }; |
505 | if (IOServiceNotificationDispatchSource_SetHandler_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
506 | } |
507 | } |
508 | while (false); |
509 | if (kIOReturnSuccess == ret) |
510 | { |
511 | } |
512 | |
513 | |
514 | return (ret); |
515 | } |
516 | |
517 | void |
518 | IOServiceNotificationDispatchSource::ServiceNotificationReady( |
519 | OSAction * action, |
520 | OSDispatchMethod supermethod) |
521 | { |
522 | kern_return_t ret; |
523 | union |
524 | { |
525 | IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg msg; |
526 | } buf; |
527 | struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg * msg = &buf.msg; |
528 | |
529 | memset(s: msg, c: 0, n: sizeof(struct IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg)); |
530 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
531 | msg->mach.msgh.msgh_size = sizeof(*msg); |
532 | msg->content.__hdr.flags = 1*kIORPCMessageOneway |
533 | | 1*kIORPCMessageSimpleReply |
534 | | 0*kIORPCMessageLocalHost |
535 | | 0*kIORPCMessageOnqueue; |
536 | msg->content.__hdr.msgid = IOServiceNotificationDispatchSource_ServiceNotificationReady_ID; |
537 | msg->content.__object = (OSObjectRef) action; |
538 | msg->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg_ObjRefs; |
539 | msg->mach.msgh_body.msgh_descriptor_count = 2; |
540 | |
541 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
542 | |
543 | msg->action__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
544 | msg->content.action = (OSObjectRef) action; |
545 | |
546 | IORPC rpc = { .message = &buf.msg.mach, .reply = NULL, .sendSize = sizeof(*msg), .replySize = 0 }; |
547 | ret = action->Invoke(rpc); |
548 | |
549 | } |
550 | |
551 | kern_return_t |
552 | IOServiceNotificationDispatchSource::CopyNextNotification( |
553 | uint64_t * type, |
554 | IOService ** service, |
555 | uint64_t * options, |
556 | OSDispatchMethod supermethod) |
557 | { |
558 | kern_return_t ret; |
559 | union |
560 | { |
561 | IOServiceNotificationDispatchSource_CopyNextNotification_Msg msg; |
562 | struct |
563 | { |
564 | IOServiceNotificationDispatchSource_CopyNextNotification_Rpl rpl; |
565 | mach_msg_max_trailer_t trailer; |
566 | } rpl; |
567 | } buf; |
568 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Msg * msg = &buf.msg; |
569 | struct IOServiceNotificationDispatchSource_CopyNextNotification_Rpl * rpl = &buf.rpl.rpl; |
570 | |
571 | memset(s: msg, c: 0, n: sizeof(struct IOServiceNotificationDispatchSource_CopyNextNotification_Msg)); |
572 | msg->mach.msgh.msgh_id = kIORPCVersion190615; |
573 | msg->mach.msgh.msgh_size = sizeof(*msg); |
574 | msg->content.__hdr.flags = 0*kIORPCMessageOneway |
575 | | 0*kIORPCMessageSimpleReply |
576 | | 0*kIORPCMessageLocalHost |
577 | | 0*kIORPCMessageOnqueue; |
578 | msg->content.__hdr.msgid = IOServiceNotificationDispatchSource_CopyNextNotification_ID; |
579 | msg->content.__object = (OSObjectRef) this; |
580 | msg->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_CopyNextNotification_Msg_ObjRefs; |
581 | msg->mach.msgh_body.msgh_descriptor_count = 1; |
582 | |
583 | msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
584 | |
585 | IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) }; |
586 | if (supermethod) ret = supermethod((OSObject *)this, rpc); |
587 | else ret = ((OSObject *)this)->Invoke(rpc); |
588 | |
589 | if (kIOReturnSuccess == ret) |
590 | do { |
591 | { |
592 | if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; }; |
593 | if (rpl->content.__hdr.msgid != IOServiceNotificationDispatchSource_CopyNextNotification_ID) { ret = kIOReturnIPCError; break; }; |
594 | if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; }; |
595 | if (IOServiceNotificationDispatchSource_CopyNextNotification_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; }; |
596 | } |
597 | } |
598 | while (false); |
599 | if (kIOReturnSuccess == ret) |
600 | { |
601 | if (type) *type = rpl->content.type; |
602 | *service = OSDynamicCast(IOService, (OSObject *) rpl->content.service); |
603 | if (rpl->content.service && !*service) ret = kIOReturnBadArgument; |
604 | if (options) *options = rpl->content.options; |
605 | } |
606 | |
607 | |
608 | return (ret); |
609 | } |
610 | |
611 | kern_return_t |
612 | IOServiceNotificationDispatchSource::Create_Invoke(const IORPC _rpc, |
613 | Create_Handler func) |
614 | { |
615 | IOServiceNotificationDispatchSource_Create_Invocation rpc = { .rpc: _rpc }; |
616 | kern_return_t ret; |
617 | IODispatchQueue * queue; |
618 | |
619 | if (3 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
620 | if (IOServiceNotificationDispatchSource_Create_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
621 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOServiceNotificationDispatchSource_Create_Msg)) return (kIOReturnIPCError); |
622 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOServiceNotificationDispatchSource_Create_Rpl)) return (kIOReturnIPCError); |
623 | if (((OSObject *) rpc.message->content.matching) != NULL && OSDynamicCast(OSDictionary, (OSObject *) rpc.message->content.matching) == NULL) { return kIOReturnBadArgument; } |
624 | queue = OSDynamicCast(IODispatchQueue, (OSObject *) rpc.message->content.queue); |
625 | if (!queue && rpc.message->content.queue) return (kIOReturnBadArgument); |
626 | |
627 | ret = (*func)( rpc.message->content.matching, |
628 | rpc.message->content.options, |
629 | queue, |
630 | (IOServiceNotificationDispatchSource **)&rpc.reply->content.notification); |
631 | |
632 | if (kIOReturnSuccess != ret) return (ret); |
633 | |
634 | rpc.reply->content.__hdr.msgid = IOServiceNotificationDispatchSource_Create_ID; |
635 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
636 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
637 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
638 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 1; |
639 | rpc.reply->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_Create_Rpl_ObjRefs; |
640 | rpc.reply->notification__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
641 | |
642 | return (ret); |
643 | } |
644 | |
645 | kern_return_t |
646 | IOServiceNotificationDispatchSource::SetHandler_Invoke(const IORPC _rpc, |
647 | OSMetaClassBase * target, |
648 | SetHandler_Handler func) |
649 | { |
650 | IOServiceNotificationDispatchSource_SetHandler_Invocation rpc = { .rpc: _rpc }; |
651 | kern_return_t ret; |
652 | OSAction * action; |
653 | |
654 | if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
655 | if (IOServiceNotificationDispatchSource_SetHandler_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
656 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOServiceNotificationDispatchSource_SetHandler_Msg)) return (kIOReturnIPCError); |
657 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOServiceNotificationDispatchSource_SetHandler_Rpl)) return (kIOReturnIPCError); |
658 | action = OSDynamicCast(OSAction, (OSObject *) rpc.message->content.action); |
659 | if (!action && rpc.message->content.action) return (kIOReturnBadArgument); |
660 | |
661 | ret = (*func)(target, |
662 | action); |
663 | |
664 | if (kIOReturnSuccess != ret) return (ret); |
665 | |
666 | rpc.reply->content.__hdr.msgid = IOServiceNotificationDispatchSource_SetHandler_ID; |
667 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
668 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
669 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
670 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 0; |
671 | rpc.reply->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_SetHandler_Rpl_ObjRefs; |
672 | |
673 | return (ret); |
674 | } |
675 | |
676 | kern_return_t |
677 | IOServiceNotificationDispatchSource::ServiceNotificationReady_Invoke(const IORPC _rpc, |
678 | OSMetaClassBase * target, |
679 | ServiceNotificationReady_Handler func) |
680 | { |
681 | return IOServiceNotificationDispatchSource::ServiceNotificationReady_Invoke(rpc: _rpc, target, func, NULL); |
682 | } |
683 | |
684 | kern_return_t |
685 | IOServiceNotificationDispatchSource::ServiceNotificationReady_Invoke(const IORPC _rpc, |
686 | OSMetaClassBase * target, |
687 | ServiceNotificationReady_Handler func, |
688 | const OSMetaClass * targetActionClass) |
689 | { |
690 | IOServiceNotificationDispatchSource_ServiceNotificationReady_Invocation rpc = { .rpc: _rpc }; |
691 | OSAction * action; |
692 | |
693 | if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
694 | if (IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
695 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOServiceNotificationDispatchSource_ServiceNotificationReady_Msg)) return (kIOReturnIPCError); |
696 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOServiceNotificationDispatchSource_ServiceNotificationReady_Rpl)) return (kIOReturnIPCError); |
697 | if (targetActionClass) { |
698 | action = (OSAction *) OSMetaClassBase::safeMetaCast(anObject: (OSObject *) rpc.message->content.action, toMeta: targetActionClass); |
699 | } else { |
700 | action = OSDynamicCast(OSAction, (OSObject *) rpc.message->content.action); |
701 | } |
702 | if (!action && rpc.message->content.action) return (kIOReturnBadArgument); |
703 | |
704 | (*func)(target, |
705 | action); |
706 | |
707 | |
708 | return (kIOReturnSuccess); |
709 | } |
710 | |
711 | kern_return_t |
712 | IOServiceNotificationDispatchSource::CopyNextNotification_Invoke(const IORPC _rpc, |
713 | OSMetaClassBase * target, |
714 | CopyNextNotification_Handler func) |
715 | { |
716 | IOServiceNotificationDispatchSource_CopyNextNotification_Invocation rpc = { .rpc: _rpc }; |
717 | kern_return_t ret; |
718 | |
719 | if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError); |
720 | if (IOServiceNotificationDispatchSource_CopyNextNotification_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError); |
721 | if (rpc.message != NULL && rpc.sendSize < sizeof(IOServiceNotificationDispatchSource_CopyNextNotification_Msg)) return (kIOReturnIPCError); |
722 | if (rpc.reply != NULL && rpc.replySize < sizeof(IOServiceNotificationDispatchSource_CopyNextNotification_Rpl)) return (kIOReturnIPCError); |
723 | |
724 | ret = (*func)(target, |
725 | &rpc.reply->content.type, |
726 | (IOService **)&rpc.reply->content.service, |
727 | &rpc.reply->content.options); |
728 | |
729 | if (kIOReturnSuccess != ret) return (ret); |
730 | |
731 | rpc.reply->content.__hdr.msgid = IOServiceNotificationDispatchSource_CopyNextNotification_ID; |
732 | rpc.reply->content.__hdr.flags = kIORPCMessageOneway; |
733 | rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply; |
734 | rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply); |
735 | rpc.reply->mach.msgh_body.msgh_descriptor_count = 1; |
736 | rpc.reply->content.__hdr.objectRefs = IOServiceNotificationDispatchSource_CopyNextNotification_Rpl_ObjRefs; |
737 | rpc.reply->service__descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
738 | |
739 | return (ret); |
740 | } |
741 | |
742 | |
743 | |
744 | |