driver.h

来自「WinBond W83627 看门狗驱动」· C头文件 代码 · 共 101 行

H
101
字号

//#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 + =
减小字号Ctrl + -
显示快捷键?