1#include "TestIOUserClient2022Entitlements.h"
2#include <IOKit/IOService.h>
3#include <IOKit/IOUserClient.h>
4#include <IOKit/IOKitServer.h>
5#include <kern/ipc_kobject.h>
6
7#if (DEVELOPMENT || DEBUG)
8
9OSDefineMetaClassAndStructors(TestIOUserClient2022Entitlements, IOService);
10
11OSDefineMetaClassAndStructors(TestIOUserClient2022EntitlementsUserClient, IOUserClient2022);
12
13bool
14TestIOUserClient2022Entitlements::start(IOService * provider)
15{
16 OSString * str = OSString::withCStringNoCopy("TestIOUserClient2022EntitlementsUserClient");
17 bool ret = IOService::start(provider);
18 if (ret && str != NULL) {
19 setProperty(gIOUserClientClassKey, str);
20 registerService();
21 }
22 OSSafeReleaseNULL(str);
23 return ret;
24}
25
26bool
27TestIOUserClient2022EntitlementsUserClient::start(IOService * provider)
28{
29 if (!IOUserClient2022::start(provider)) {
30 return false;
31 }
32 setProperty(kIOUserClientDefaultLockingKey, kOSBooleanTrue);
33 setProperty(kIOUserClientDefaultLockingSetPropertiesKey, kOSBooleanTrue);
34 setProperty(kIOUserClientDefaultLockingSingleThreadExternalMethodKey, kOSBooleanTrue);
35
36 setProperty(kIOUserClientEntitlementsKey, "com.apple.iokit.test-check-entitlement-open");
37
38 return true;
39}
40
41IOReturn
42TestIOUserClient2022EntitlementsUserClient::clientClose()
43{
44 terminate();
45 return kIOReturnSuccess;
46}
47
48IOReturn
49TestIOUserClient2022EntitlementsUserClient::extBasicMethod(OSObject * target, void * reference, IOExternalMethodArguments * arguments)
50{
51 return kIOReturnSuccess;
52}
53
54IOReturn
55TestIOUserClient2022EntitlementsUserClient::extPerSelectorCheck(OSObject * target, void * reference, IOExternalMethodArguments * arguments)
56{
57 return kIOReturnSuccess;
58}
59
60IOReturn
61TestIOUserClient2022EntitlementsUserClient::externalMethod(uint32_t selector, IOExternalMethodArgumentsOpaque * args)
62{
63 static const IOExternalMethodDispatch2022 dispatchArray[] = {
64 [0] {
65 .function = &TestIOUserClient2022EntitlementsUserClient::extBasicMethod,
66 .checkScalarInputCount = 0,
67 .checkStructureInputSize = 0,
68 .checkScalarOutputCount = 0,
69 .checkStructureOutputSize = 0,
70 .allowAsync = false,
71 .checkEntitlement = NULL,
72 },
73 [1] {
74 .function = &TestIOUserClient2022EntitlementsUserClient::extPerSelectorCheck,
75 .checkScalarInputCount = 0,
76 .checkStructureInputSize = 0,
77 .checkScalarOutputCount = 0,
78 .checkStructureOutputSize = 0,
79 .allowAsync = false,
80 .checkEntitlement = "com.apple.iokit.test-check-entitlement-per-selector",
81 },
82 };
83
84 return dispatchExternalMethod(selector, args, dispatchArray, sizeof(dispatchArray) / sizeof(dispatchArray[0]), this, NULL);
85}
86
87#endif /* (DEVELOPMENT || DEBUG) */
88