1 #define _WIN32_WINNT 0x0500
2 #include <windows.h>
3 #include <stdio.h>
4 #include <winternl.h>
5 
6 #define DRIVER_NAME L"TestDriver"
7 
8 #define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
9 #define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L)
10 
11 typedef LONG NTSTATUS;
12 
13 //
14 // umode methods
15 //
16 BOOL RegisterDriver(LPCWSTR lpDriverName, LPCWSTR lpPathName);
17 BOOL StartDriver(LPCWSTR lpDriverName);
18 BOOL StopDriver(LPCWSTR lpDriverName);
19 BOOL UnregisterDriver(LPCWSTR lpDriverName);
20 
21 //
22 // undoc methods
23 //
24 BOOL ConvertPath(LPCWSTR lpPath, LPWSTR lpDevice);
25 BOOL LoadVia_SystemLoadGdiDriverInformation(LPWSTR lpDriverPath);
26 BOOL LoadVia_SystemExtendServiceTableInformation(LPWSTR lpDriverPath);
27 BOOL NtStartDriver(LPCWSTR lpService);
28 BOOL NtStopDriver(LPCWSTR lpService);
29 
30 
31 //
32 // undocumented stuff
33 //
34 #define SystemLoadGdiDriverInformation 26
35 #define SystemExtendServiceTableInformation 38
36 NTSYSAPI NTSTATUS NTAPI
37 NtSetSystemInformation(IN INT SystemInformationClass,
38                        IN PVOID SystemInformation,
39                        IN ULONG SystemInformationLength );
40 NTSTATUS
41 NtUnloadDriver(IN PUNICODE_STRING DriverServiceName);
42 
43 typedef struct _SYSTEM_GDI_DRIVER_INFORMATION
44 {
45     UNICODE_STRING DriverName;
46     PVOID ImageAddress;
47     PVOID SectionPointer;
48     PVOID EntryPoint;
49     PIMAGE_EXPORT_DIRECTORY ExportSectionPointer;
50     ULONG ImageLength;
51 } SYSTEM_GDI_DRIVER_INFORMATION, *PSYSTEM_GDI_DRIVER_INFORMATION;
52 
53 typedef enum _OBJECT_INFORMATION_CLASS {
54     ObjectBasicInformation,
55     ObjectNameInformation,
56     ObjectTypeInformation,
57     ObjectAllTypesInformation,
58     ObjectHandleInformation
59 } OBJECT_INFO_CLASS;
60 
61 NTSTATUS NtQueryObject(IN HANDLE Handle,
62                        IN OBJECT_INFO_CLASS ObjectInformationClass,
63                        OUT PVOID ObjectInformation,
64                        IN ULONG ObjectInformationLength,
65                        OUT PULONG ReturnLength);
66 
67 
68 typedef struct _OBJECT_NAME_INFORMATION {
69     UNICODE_STRING Name;
70 } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
71 
72 
73