Skip to content

Commit 2ef6566

Browse files
Added user client
Signed-off-by: black.dragon74 <[email protected]>
1 parent 3a3cc38 commit 2ef6566

8 files changed

+126
-7
lines changed

ROG-HID-Driver/Info.plist

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@
114114
</dict>
115115
<key>0b05_1869</key>
116116
<dict>
117+
<key>UserClientProperties</key>
118+
<dict>
119+
<key>IOClass</key>
120+
<string>IOUserUserClient</string>
121+
<key>IOUserClass</key>
122+
<string>ROGHIDUserClient</string>
123+
</dict>
117124
<key>BacklightAutoTurnOff</key>
118125
<integer>1</integer>
119126
<key>CFBundleIdentifier</key>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// ROGHIDUserClient.cpp
3+
// ROG-HID-Driver
4+
//
5+
// Created by Nick on 2/16/21.
6+
// Copyright © 2021 Nick. All rights reserved.
7+
//
8+
9+
#include "RogHIDUserClient.h"
10+
#include "ROG_HID_Driver.h"
11+
12+
bool ROGHIDUserClient::init() {
13+
DBGLOG("Userclient init");
14+
15+
return super::init();
16+
}
17+
18+
void ROGHIDUserClient::free() {
19+
DBGLOG("Userclient free");
20+
super::free();
21+
}
22+
23+
kern_return_t IMPL(ROGHIDUserClient, Start) {
24+
DBGLOG("Userclient start");
25+
26+
return kIOReturnSuccess;
27+
}
28+
29+
kern_return_t IMPL(ROGHIDUserClient, Stop) {
30+
DBGLOG("Userclient stop");
31+
return kIOReturnSuccess;
32+
}
33+
34+
kern_return_t ROGHIDUserClient::ExternalMethod(uint64_t selector, IOUserClientMethodArguments* arguments, const IOUserClientMethodDispatch* dispatch, OSObject* target, void* reference) {
35+
DBGLOG("Userclient external method");
36+
return kIOReturnSuccess;
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// ROGHIDUserClient.iig
3+
// ROG-HID-Driver
4+
//
5+
// Created by Nick on 2/16/21.
6+
// Copyright © 2021 Nick. All rights reserved.
7+
//
8+
9+
#ifndef ROGHIDUserClient_h
10+
#define ROGHIDUserClient_h
11+
12+
#include <DriverKit/IOUserClient.iig>
13+
14+
class ROGHIDUserClient: public IOUserClient {
15+
virtual bool init() override;
16+
virtual void free() override;
17+
18+
virtual kern_return_t Start(IOService* provider) override;
19+
virtual kern_return_t Stop(IOService* provider) override;
20+
21+
virtual kern_return_t ExternalMethod(uint64_t selector,
22+
IOUserClientMethodArguments* arguments,
23+
const IOUserClientMethodDispatch* dispatch,
24+
OSObject* target,
25+
void* reference) override;
26+
};
27+
28+
#endif /* ROGHIDUserClient_h */

ROG-HID-Driver/ROG_HID_Driver.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
// Copyright © 2020 Nick. All rights reserved.
77
//
88

9-
#include <os/log.h>
10-
119
#include <HIDDriverKit/HIDDriverKit.h>
1210

1311
#include "ROG_HID_Driver.h"
@@ -539,3 +537,27 @@ void IMPL(ROG_HID_Driver, asusKbdGetFunctions)
539537
data->release();
540538
return;
541539
}
540+
541+
kern_return_t IMPL(ROG_HID_Driver, NewUserClient) {
542+
IOService *client {nullptr};
543+
544+
auto ret = Create(this, "UserClientProperties", &client);
545+
if (ret != kIOReturnSuccess) {
546+
DBGLOG("Newuserclient create failed");
547+
548+
return ret;
549+
}
550+
551+
DBGLOG("Created user client successfully");
552+
553+
*userClient = OSDynamicCast(IOUserClient, client);
554+
555+
if (!*userClient) {
556+
DBGLOG("Dynamic cast failed");
557+
client->release();
558+
559+
return kIOReturnError;
560+
}
561+
562+
return kIOReturnSuccess;
563+
}

ROG-HID-Driver/ROG_HID_Driver.entitlements

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.application-identifier</key>
6+
<string>com.black-dragon74.ROG-HID-Driver</string>
7+
<key>com.apple.developer.driverkit.userclient-access</key>
8+
<true/>
59
<key>com.apple.developer.driverkit</key>
610
<true/>
711
<key>com.apple.developer.driverkit.builtin</key>

ROG-HID-Driver/ROG_HID_Driver.iig

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef ROG_HID_Driver_h
1010
#define ROG_HID_Driver_h
1111

12+
#include <os/log.h>
13+
1214
#define BIT(nr) (1UL << (nr))
1315
#define STOMS(x) (x * 1000)
1416
#define KBD_FEATURE_REPORT_ID 0x5a
@@ -63,6 +65,8 @@ public:
6365
uint32_t value,
6466
IOOptionBits options,
6567
bool repeat) override;
68+
virtual kern_return_t NewUserClient(uint32_t type,
69+
IOUserClient** userClient) override;
6670

6771
private:
6872
virtual void parseKeyboardElementsHook(OSArray* elements);

ROG-HID.xcodeproj/project.pbxproj

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
0118C9AA24C6121500C1C663 /* ROG_HID_Driver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0118C9A924C6121500C1C663 /* ROG_HID_Driver.cpp */; };
2121
0118C9AC24C6121500C1C663 /* ROG_HID_Driver.iig in Sources */ = {isa = PBXBuildFile; fileRef = 0118C9AB24C6121500C1C663 /* ROG_HID_Driver.iig */; };
2222
0118C9B124C6121500C1C663 /* com.black-dragon74.ROG-HID-Driver.dext in Embed System Extensions */ = {isa = PBXBuildFile; fileRef = 0118C9A424C6121500C1C663 /* com.black-dragon74.ROG-HID-Driver.dext */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
23+
012617D625DBB8F100B563E0 /* ROGHIDUserClient.iig in Sources */ = {isa = PBXBuildFile; fileRef = 012617D525DBB8F100B563E0 /* ROGHIDUserClient.iig */; };
24+
012617DA25DBB90000B563E0 /* ROGHIDUserClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 012617D925DBB90000B563E0 /* ROGHIDUserClient.cpp */; };
2325
/* End PBXBuildFile section */
2426

2527
/* Begin PBXContainerItemProxy section */
@@ -65,6 +67,8 @@
6567
0118C9AB24C6121500C1C663 /* ROG_HID_Driver.iig */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.iig; path = ROG_HID_Driver.iig; sourceTree = "<group>"; };
6668
0118C9AD24C6121500C1C663 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6769
0118C9AE24C6121500C1C663 /* ROG_HID_Driver.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ROG_HID_Driver.entitlements; sourceTree = "<group>"; };
70+
012617D525DBB8F100B563E0 /* ROGHIDUserClient.iig */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.iig; path = ROGHIDUserClient.iig; sourceTree = "<group>"; };
71+
012617D925DBB90000B563E0 /* ROGHIDUserClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ROGHIDUserClient.cpp; sourceTree = "<group>"; };
6872
0176196324C77846007D4278 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
6973
/* End PBXFileReference section */
7074

@@ -143,6 +147,7 @@
143147
0118C9A824C6121500C1C663 /* ROG-HID-Driver */ = {
144148
isa = PBXGroup;
145149
children = (
150+
012617D425DBB8A100B563E0 /* ROGHIDUserClient */,
146151
0118C9A924C6121500C1C663 /* ROG_HID_Driver.cpp */,
147152
01056BCF24C614FE0087FD10 /* IOBufferMemoryDescriptorUtility.h */,
148153
0118C9AB24C6121500C1C663 /* ROG_HID_Driver.iig */,
@@ -153,6 +158,15 @@
153158
path = "ROG-HID-Driver";
154159
sourceTree = "<group>";
155160
};
161+
012617D425DBB8A100B563E0 /* ROGHIDUserClient */ = {
162+
isa = PBXGroup;
163+
children = (
164+
012617D525DBB8F100B563E0 /* ROGHIDUserClient.iig */,
165+
012617D925DBB90000B563E0 /* ROGHIDUserClient.cpp */,
166+
);
167+
path = ROGHIDUserClient;
168+
sourceTree = "<group>";
169+
};
156170
/* End PBXGroup section */
157171

158172
/* Begin PBXHeadersBuildPhase section */
@@ -277,7 +291,9 @@
277291
isa = PBXSourcesBuildPhase;
278292
buildActionMask = 2147483647;
279293
files = (
294+
012617DA25DBB90000B563E0 /* ROGHIDUserClient.cpp in Sources */,
280295
0118C9AC24C6121500C1C663 /* ROG_HID_Driver.iig in Sources */,
296+
012617D625DBB8F100B563E0 /* ROGHIDUserClient.iig in Sources */,
281297
0118C9AA24C6121500C1C663 /* ROG_HID_Driver.cpp in Sources */,
282298
);
283299
runOnlyForDeploymentPostprocessing = 0;

codesign.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# Created by Nick on 7/20/20.
77
# Copyright © 2020 Nick. All rights reserved.
88

9-
readonly CODE_SIGN_IDENTITY=2FB6A1000899D1646EB5ECA45606F1522A05EFF9
9+
readonly CODE_SIGN_IDENTITY=79DBEC750D31EC17BA9F4E4A1FD2FFDBC9359D0A
10+
1011
flavor="Release"
1112

1213
if [[ $1 == "Debug" ]];
@@ -23,22 +24,22 @@ echo "Signing Dext..."
2324
codesign --sign $CODE_SIGN_IDENTITY \
2425
--entitlements ROG-HID-Driver/ROG_HID_Driver.entitlements \
2526
--options runtime --verbose --force \
26-
build/$flavor/ROG-HID.app/Contents/Library/SystemExtensions/com.black-dragon74.ROG-HID-Driver.dext &>/dev/null || exit
27+
build/$flavor/ROG-HID.app/Contents/Library/SystemExtensions/com.black-dragon74.ROG-HID-Driver.dext || exit
2728

2829
echo "Verifying Dext..."
2930
codesign --verify --verbose \
30-
build/$flavor/ROG-HID.app/Contents/Library/SystemExtensions/com.black-dragon74.ROG-HID-Driver.dext &>/dev/null || exit
31+
build/$flavor/ROG-HID.app/Contents/Library/SystemExtensions/com.black-dragon74.ROG-HID-Driver.dext || exit
3132

3233
echo "Signing App..."
3334
codesign --sign $CODE_SIGN_IDENTITY \
3435
--entitlements ROG-HID/ROG_HID.entitlements \
3536
--options runtime --verbose --force \
36-
build/$flavor/ROG-HID.app &>/dev/null || exit
37+
build/$flavor/ROG-HID.app || exit
3738

3839
echo "Verifying App..."
3940
codesign \
4041
--verify --verbose \
41-
build/$flavor/ROG-HID.app &>/dev/null || exit
42+
build/$flavor/ROG-HID.app || exit
4243

4344
echo
4445
echo "** SIGNING SUCCEEDED **"

0 commit comments

Comments
 (0)