📄 driver.h
字号:
//#include <wdm.h>
#include <ntddk.h>
#include <stdio.h>
#include "ioctl.h"
#if !defined(__DRIVER_H__)
#define __DRIVER_H__
typedef struct _DEVICE_EXTENSION {
UCHAR HardwareID;
ULONG PortNumber;
UCHAR PortIndex;
UCHAR PortData;
USHORT ShortPortIndex;
USHORT ShortPortData;
ULONG PortMemoryType; // HalTranslateBusAddress MemoryType.
PDEVICE_OBJECT StackDeviceObject; // The top of the stack.
PKINTERRUPT InterruptObject; // interruput Object.
BOOLEAN ConnectedToInterrupt;
ULONG Irq;
KIRQL Irql;
KINTERRUPT_MODE Mode;
ULONG Vector;
KAFFINITY Affinity;
BOOLEAN started; //StartDevice will be true.
BOOLEAN removing; //StopDevice will be true.
BOOLEAN ResourcesClaimed;
ULONG opencount;
ULONG usage;
IO_REMOVE_LOCK RemoveLock; // Remove lock to avoid abnormal device removal
PKEVENT pEvent; // the shared event.
HANDLE hEvent;
UNICODE_STRING EventName;
BOOLEAN EventCreated; // Record the create event count.
} DEVICE_EXTENSION, * PDEVICE_EXTENSION;
#if DBG
#define DebugPrint(_x_) \
DbgPrint ("WatchDog:"); \
DbgPrint _x_;
#define TRAP() DbgBreakPoint()
#else
#define DebugPrint(_x_)
#define TRAP()
#endif
/********************* function prototypes ***********************************/
//
NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath);
NTSTATUS
DRV_AddDevice(IN PDRIVER_OBJECT DriverObject,IN PDEVICE_OBJECT pdo);
NTSTATUS
DRV_Close(IN PDEVICE_OBJECT fdo,IN PIRP Irp);
NTSTATUS
DRV_Open(IN PDEVICE_OBJECT fdo,IN PIRP Irp);
NTSTATUS
DRV_IoCtrl(IN PDEVICE_OBJECT fdo, IN PIRP Irp);
NTSTATUS \
DRV_PnPDispatch(IN PDEVICE_OBJECT fdo,IN PIRP Irp);
void DRV_Unload(IN PDRIVER_OBJECT DriverObject);
NTSTATUS
CompleteIoReq(IN PIRP Irp,IN NTSTATUS status,IN ULONG info);
BOOLEAN
DisableInterrupt(PVOID context);
BOOLEAN
EnableInterrupt(PVOID context);
BOOLEAN
OnInterrupt(PKINTERRUPT InterruputObject,PDEVICE_EXTENSION pde);
void UnclaimResources( IN PDEVICE_OBJECT fdo);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -