-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathdriver.cpp
103 lines (96 loc) · 1.93 KB
/
driver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "driver.h"
#include <stdio.h>
driver::driver()
{
hDriver = CreateFileA("\\\\.\\NMH1313", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (hDriver == INVALID_HANDLE_VALUE)
{
printf("[!] Driver Install Failed\n");
}
else
{
printf("[!] Driver Install Successed\n");
}
}
driver::~driver()
{
if (hDriver != INVALID_HANDLE_VALUE)
{
CloseHandle(hDriver);
printf("[!] Driver UnInstall Successed\n");
}
}
unsigned long long driver::GetGameModule()
{
if (hDriver == INVALID_HANDLE_VALUE) return 0;
unsigned long long readBuffer;
unsigned long Bytes;
_IOBUFFER ReadRequest
{
(unsigned long long) & readBuffer,
(unsigned long long)0x0,
sizeof(unsigned long long),
(unsigned long)GetCurrentProcessId(),
0
};
int stat = DeviceIoControl(
hDriver,
IOCTL_IO_MOUDLE,
&ReadRequest,
sizeof(ReadRequest),
&ReadRequest,
sizeof(ReadRequest),
&Bytes,
0);
return stat ? readBuffer : 0;
}
unsigned long driver::GetGamePid()
{
if (hDriver == INVALID_HANDLE_VALUE) return 0;
unsigned long readBuffer;
unsigned long Bytes;
_IOBUFFER ReadRequest
{
(unsigned long long) & readBuffer,
(unsigned long long)0x0,
sizeof(unsigned long long),
(unsigned long)GetCurrentProcessId(),
0
};
int stat = DeviceIoControl(
hDriver,
IOCTL_IO_PID,
&ReadRequest,
sizeof(ReadRequest),
&ReadRequest,
sizeof(ReadRequest),
&Bytes,
0);
return stat ? readBuffer : 0;
}
unsigned long long driver::GetImageSize()
{
if (hDriver == INVALID_HANDLE_VALUE) return 0;
unsigned long long readBuffer;
unsigned long Bytes;
_IOBUFFER ReadRequest
{
(unsigned long long) & readBuffer,
(unsigned long long)0x0,
sizeof(unsigned long long),
(unsigned long)GetCurrentProcessId(),
0
};
int stat = DeviceIoControl(
hDriver,
IOCTL_IO_IMAGESIZE,
&ReadRequest,
sizeof(ReadRequest),
&ReadRequest,
sizeof(ReadRequest),
&Bytes,
0);
return stat ? readBuffer : 0;
}
driver drv;