📄 driver.h
字号:
// Declarations for notify driver
// Copyright (C) 1999 by Walter Oney
// All rights reserved
#ifndef DRIVER_H
#define DRIVER_H
#define DRIVERNAME "NOTIFY" // for use in messages
#define LDRIVERNAME L"NOTIFY" // for use in UNICODE string constants
///////////////////////////////////////////////////////////////////////////////
// Device extension structure
enum DEVSTATE {
STOPPED, // device stopped
WORKING, // started and working
PENDINGSTOP, // stop pending
PENDINGREMOVE, // remove pending
SURPRISEREMOVED, // removed by surprise
REMOVED, // removed
};
typedef struct _DEVICE_EXTENSION {
PDEVICE_OBJECT DeviceObject; // device object this extension belongs to
PDEVICE_OBJECT LowerDeviceObject; // next lower driver in same stack
PDEVICE_OBJECT Pdo; // the PDO
IO_REMOVE_LOCK RemoveLock; // removal control locking structure
UNICODE_STRING ifname; // interface name
DEVSTATE state; // current state of device
DEVSTATE prevstate; // state prior to removal query
DEVICE_POWER_STATE devpower; // current device power state
SYSTEM_POWER_STATE syspower; // current system power state
DEVICE_CAPABILITIES devcaps; // copy of most recent device capabilities
LIST_ENTRY PendingIoctlList; // listing of pending async IOCTLs
KSPIN_LOCK IoctlListLock; // spin lock to guard PendingIoctlList
NTSTATUS IoctlAbortStatus; // status being used to abort pending IOCTLs
LONG handles; // # open handles
PIRP NotifyIrp; // pending notification IRP
} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
///////////////////////////////////////////////////////////////////////////////
// Global functions
VOID RemoveDevice(IN PDEVICE_OBJECT fdo);
NTSTATUS CompleteRequest(IN PIRP Irp, IN NTSTATUS status, IN ULONG_PTR info);
NTSTATUS CompleteRequest(IN PIRP Irp, IN NTSTATUS status);
NTSTATUS ForwardAndWait(IN PDEVICE_OBJECT fdo, IN PIRP Irp);
NTSTATUS SendDeviceSetPower(PDEVICE_EXTENSION fdo, DEVICE_POWER_STATE state, BOOLEAN wait = FALSE);
VOID SendAsyncNotification(PVOID context);
VOID EnableAllInterfaces(PDEVICE_EXTENSION pdx, BOOLEAN enable);
VOID DeregisterAllInterfaces(PDEVICE_EXTENSION pdx);
VOID AbortPendingIoctls(PDEVICE_EXTENSION pdx, NTSTATUS status);
VOID CleanupControlRequests(PDEVICE_EXTENSION pdx, NTSTATUS status, PFILE_OBJECT fop);
PIRP UncacheControlRequest(PDEVICE_EXTENSION pdx, PIRP* pIrp);
NTSTATUS StartDevice(PDEVICE_OBJECT fdo, PCM_PARTIAL_RESOURCE_LIST raw, PCM_PARTIAL_RESOURCE_LIST translated);
VOID StopDevice(PDEVICE_OBJECT fdo, BOOLEAN oktouch = FALSE);
// I/O request handlers
NTSTATUS DispatchCreate(PDEVICE_OBJECT fdo, PIRP Irp);
NTSTATUS DispatchClose(PDEVICE_OBJECT fdo, PIRP Irp);
NTSTATUS DispatchControl(PDEVICE_OBJECT fdo, PIRP Irp);
NTSTATUS DispatchCleanup(PDEVICE_OBJECT fdo, PIRP Irp);
NTSTATUS DispatchPower(PDEVICE_OBJECT fdo, PIRP Irp);
NTSTATUS DispatchPnp(PDEVICE_OBJECT fdo, PIRP Irp);
extern BOOLEAN win98;
extern UNICODE_STRING servkey;
#endif // DRIVER_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -