Load & Unload.
Main Driver Entry in the case of driver load.
Load & Unload.
26{
27 NTSTATUS Ntstatus = STATUS_SUCCESS;
28 UINT64 Index = 0;
29 PDEVICE_OBJECT DeviceObject =
NULL;
30 UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L
"\\Device\\HyperDbgReversingMachineDevice");
31 UNICODE_STRING DosDeviceName = RTL_CONSTANT_STRING(L
"\\DosDevices\\HyperDbgReversingMachineDevice");
32
33 UNREFERENCED_PARAMETER(RegistryPath);
34 UNREFERENCED_PARAMETER(DriverObject);
35
36
37
38
39
40 ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
41
42
43
44
45 Ntstatus = IoCreateDevice(DriverObject,
46 0,
47 &DriverName,
49 FILE_DEVICE_SECURE_OPEN,
51 &DeviceObject);
52
53 if (Ntstatus == STATUS_SUCCESS)
54 {
55 for (Index = 0; Index < IRP_MJ_MAXIMUM_FUNCTION; Index++)
57
58
59
60
61 DbgPrint("Setting device major functions");
62
63 DriverObject->MajorFunction[IRP_MJ_CLOSE] =
DrvClose;
64 DriverObject->MajorFunction[IRP_MJ_CREATE] =
DrvCreate;
65 DriverObject->MajorFunction[IRP_MJ_READ] =
DrvRead;
66 DriverObject->MajorFunction[IRP_MJ_WRITE] =
DrvWrite;
68
70 IoCreateSymbolicLink(&DosDeviceName, &DriverName);
71 }
72
73
74
75
76 if (DeviceObject != NULL)
77 {
78 DeviceObject->Flags |= DO_BUFFERED_IO;
79 }
80
81
82
83
84 DbgPrint("HyperDbg's device and major functions are loaded");
85
86
87 ASSERT(NT_SUCCESS(Ntstatus));
88 return Ntstatus;
89}
struct _UNICODE_STRING UNICODE_STRING
NTSTATUS DrvWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_WRITE Function handler.
Definition Driver.c:216
NTSTATUS DrvUnsupported(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Unsupported message for all other IRP_MJ_* handlers.
Definition Driver.c:266
NTSTATUS DrvRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_READ Function handler.
Definition Driver.c:192
NTSTATUS DrvClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_CLOSE Function handler.
Definition Driver.c:240
VOID DrvUnload(PDRIVER_OBJECT DriverObject)
Run in the case of driver unload to unregister the devices.
Definition Driver.c:98
NTSTATUS DrvCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
IRP_MJ_CREATE Function handler.
Definition Driver.c:120
NTSTATUS DrvDispatchIoControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Driver IOCTL Dispatcher.
Definition Ioctl.c:23
NULL()
Definition test-case-generator.py:530