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