-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdriver.c
More file actions
40 lines (30 loc) · 1.17 KB
/
Copy pathdriver.c
File metadata and controls
40 lines (30 loc) · 1.17 KB
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
#include "driver.h"
//Function prototypes --------------------------------------------
void on_driver_unload(PDRIVER_OBJECT DriverObject);
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath);
//----------------------------------------------------------------
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath) {
UNREFERENCED_PARAMETER(RegistryPath);
DriverObject->DriverUnload = on_driver_unload;
unsigned int i;
for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
DriverObject->MajorFunction[i] = Io_Unsupported;
}
DriverObject->MajorFunction[IRP_MJ_CREATE] = Create_DeviceIo;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = Close_DeviceIo;
DriverObject->MajorFunction[IRP_MJ_WRITE] = Buffered_Write;
init_unicode_strings();
if (SetupIoDevice(DriverObject) == 1) {
DbgPrint("SetupIoDevice() succeed!");
}
else {
DbgPrint("SetupIoDevice() failed!");
}
DbgPrint("Driver loaded!");
return STATUS_SUCCESS;
}
void on_driver_unload(PDRIVER_OBJECT DriverObject) {
UNREFERENCED_PARAMETER(DriverObject);
disable_protection();
DbgPrint("Driver unloaded.");
}