ReactOS 0.4.15-dev-7961-gdcf9eb0
main.c
Go to the documentation of this file.
1#include "DriverTester.h"
2
3static BOOL
4Initialize(LPCWSTR lpDriverPath)
5{
6 if (!RegisterDriver(DRIVER_NAME, lpDriverPath))
7 {
8 wprintf(L"[%lu] Failed to install %s\n", GetLastError(), DRIVER_NAME);
9 return FALSE;
10 }
11
12 return TRUE;
13}
14
15static BOOL
16Uninitialize(LPCWSTR lpDriverPath)
17{
19 {
20 wprintf(L"[%lu] Failed to unregister %s\n", GetLastError(), DRIVER_NAME);
21 return FALSE;
22 }
23
24 return TRUE;
25}
26
27static BOOL
29{
30 wprintf(L"\nStarting %s.sys via the SCM\n", DRIVER_NAME);
31
33 {
34 wprintf(L"[%lu] Failed to start %s\n", GetLastError(), DRIVER_NAME);
36 return FALSE;
37 }
38
39 wprintf(L"\tStarted\n");
40
41 wprintf(L"Stopping %s.sys via the SCM\n", DRIVER_NAME);
42
44 {
45 wprintf(L"[%lu] Failed to stop %s\n", GetLastError(), DRIVER_NAME);
47 return FALSE;
48 }
49
50 wprintf(L"\tStopped\n");
51
52 return TRUE;
53}
54
55static BOOL
57{
58 wprintf(L"\nStarting %s.sys via native API\n", DRIVER_NAME);
59
61 {
62 wprintf(L"[%lu] Failed to start %s\n", GetLastError(), DRIVER_NAME);
64 return FALSE;
65 }
66
67 wprintf(L"\tStarted\n");
68
69 wprintf(L"Stopping %s.sys via native API\n", DRIVER_NAME);
70
72 {
73 wprintf(L"[%lu] Failed to stop %s\n", GetLastError(), DRIVER_NAME);
75 return FALSE;
76 }
77
78 wprintf(L"\tStopped\n");
79
80 return TRUE;
81}
82
83
84static BOOL
86{
87 WCHAR szDevice[MAX_PATH];
88
89 if (ConvertPath(lpDriverPath, szDevice))
90 {
91 wprintf(L"\nStarting %s.sys via NtSetSystemInformation with SystemLoadGdiDriverInformation\n", DRIVER_NAME);
93 {
94 wprintf(L"\tStarted\n");
95
97 }
98
99 wprintf(L"\nStarting %s.sys via NtSetSystemInformation with SystemExtendServiceTableInformation\n", DRIVER_NAME);
101 {
102 wprintf(L"\tStarted\n");
103
105 }
106
107 return TRUE;
108 }
109
110 return FALSE;
111}
112
113
114int __cdecl wmain(int argc, wchar_t *argv[])
115{
117
118 if (argc != 2)
119 {
120 wprintf(L"Usage: DriverTester.exe <path>");
121 return -1;
122 }
123
124 if (!SearchPathW(NULL,
125 argv[1],
126 L".sys",
127 MAX_PATH,
128 buf,
129 NULL))
130 {
131 wprintf(L"%s does not exist", argv[1]);
132 return -1;
133 }
134
135 if (Initialize(argv[1]))
136 {
137 //
138 // Load using conventional SCM methods
139 //
141
142 //
143 // Load using undocumented NtLoad/UnloadDriver
144 //
146
147 //
148 // Load using hidden unknown methods
149 //
151
152 Uninitialize(argv[1]);
153 }
154
155 return 0;
156}
157
BOOL RegisterDriver(LPCWSTR lpDriverName, LPCWSTR lpPathName)
Definition: umode.c:5
BOOL NtStopDriver(LPCWSTR lpService)
Definition: undoc.c:164
BOOL ConvertPath(LPCWSTR lpPath, LPWSTR lpDevice)
Definition: undoc.c:56
BOOL LoadVia_SystemExtendServiceTableInformation(LPWSTR lpDriverPath)
Definition: undoc.c:240
BOOL NtStartDriver(LPCWSTR lpService)
Definition: undoc.c:133
BOOL LoadVia_SystemLoadGdiDriverInformation(LPWSTR lpDriverPath)
Definition: undoc.c:199
BOOL UnregisterDriver(LPCWSTR lpDriverName)
Definition: umode.c:135
static int argc
Definition: ServiceArgs.c:12
#define __cdecl
Definition: accygwin.h:79
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
#define DRIVER_NAME
Definition: ext2fs.h:136
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL SneakyUndocumentedMethods(LPCWSTR lpDriverPath)
Definition: main.c:85
static BOOL Uninitialize(LPCWSTR lpDriverPath)
Definition: main.c:16
static BOOL UsermodeMethod(LPCWSTR lpDriverPath)
Definition: main.c:28
static BOOL UndocumentedMethod(LPCWSTR lpDriverPath)
Definition: main.c:56
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
int wmain()
BOOLEAN StartDriver(VOID)
Definition: vcdcli.c:85
static VOID StopDriver(VOID)
#define wprintf(...)
Definition: whoami.c:18
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static void Initialize()
Definition: xlate.c:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185