Main Driver Entry in the case of driver load.
Load & Unload.
27{
28 NTSTATUS Ntstatus = STATUS_SUCCESS;
30 PDEVICE_OBJECT DeviceObject =
NULL;
31 UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L
"\\Device\\HyperDbgDebuggerDevice");
32 UNICODE_STRING DosDeviceName = RTL_CONSTANT_STRING(L
"\\DosDevices\\HyperDbgDebuggerDevice");
33
34 UNREFERENCED_PARAMETER(RegistryPath);
35 UNREFERENCED_PARAMETER(DriverObject);
36
37
38
39
40
41 ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
42
43
44
45
46 Ntstatus = IoCreateDevice(DriverObject,
47 0,
48 &DriverName,
50 FILE_DEVICE_SECURE_OPEN,
52 &DeviceObject);
53
54 if (Ntstatus == STATUS_SUCCESS)
55 {
56 for (Index = 0; Index < IRP_MJ_MAXIMUM_FUNCTION; Index++)
58
59
60
61
62 DbgPrint("Setting device major functions");
63
64 DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DrvClose;
65 DriverObject->MajorFunction[IRP_MJ_CREATE] =
DrvCreate;
66 DriverObject->MajorFunction[IRP_MJ_READ] =
DrvRead;
67 DriverObject->MajorFunction[IRP_MJ_WRITE] =
DrvWrite;
69
71 IoCreateSymbolicLink(&DosDeviceName, &DriverName);
72 }
73
74
75
76
77 DeviceObject->Flags |= DO_BUFFERED_IO;
78
79
80
81
82 DbgPrint("HyperDbg's device and major functions are loaded");
83
84 ASSERT(NT_SUCCESS(Ntstatus));
85 return Ntstatus;
86}
#define FALSE
Definition BasicTypes.h:54
unsigned __int64 UINT64
Definition BasicTypes.h:21
#define FILE_DEVICE_UNKNOWN
Definition Ioctls.h:52
NTSTATUS DrvWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_WRITE Function handler.
Definition Driver.c:213
NTSTATUS DrvUnsupported(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Unsupported message for all other IRP_MJ_* handlers.
Definition Driver.c:263
NTSTATUS DrvRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_READ Function handler.
Definition Driver.c:189
NTSTATUS DrvClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_CLOSE Function handler.
Definition Driver.c:237
VOID DrvUnload(PDRIVER_OBJECT DriverObject)
Run in the case of driver unload to unregister the devices.
Definition Driver.c:95
NTSTATUS DrvCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_CREATE Function handler.
Definition Driver.c:117
NTSTATUS DrvDispatchIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Driver IOCTL Dispatcher.
Definition Ioctl.c:23
NULL()
Definition test-case-generator.py:530
Definition casting.cpp:25