/*
最简单的wdf内核驱动,参考一下资料:
http://msdn.microsoft.com/zh-cn/library/hh439665.aspx
http://msdn.microsoft.com/en-us/library/hh439665.aspx
没有用vc2012编译成功,用wdk7600.16385.1编译成功,但是没有加载和调试。
不敢说原创,以此记载。
*/
#include <ntddk.h>
#include <wdf.h>
#define _In_
#define _Inout_
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfSmallEvtDeviceAdd;
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
WDF_DRIVER_CONFIG config;
KdPrintEx(( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfSmall: DriverEntry\n" ));
WDF_DRIVER_CONFIG_INIT(&config, KmdfSmallEvtDeviceAdd);
status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);
return status;
}
NTSTATUS KmdfSmallEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
{
NTSTATUS status;
WDFDEVICE hDevice;
UNREFERENCED_PARAMETER(Driver);
KdPrintEx(( DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfSmall: KmdfSmallEvtDeviceAdd\n" ));
status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &hDevice);
return status;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
source文件如下:
TARGETNAME=c
TARGETTYPE=DRIVER
#error C1083: Cannot open include file: 'wdf.h': No such file or directory的解决办法:
#KMDF_VERSION = 1
KMDF_VERSION_MAJOR=1
#另一种是:没有试验。
#$(WLHBASE)\lib\wdf\kmdf\i386\1.9;
#$(WLHBASE)\inc\wdf\kmdf\1.9
LINKER_FLAGS = $(LINKER_FLAGS)/INTEGRITYCHECK
SOURCES=c.c
TARGETPATH=obj
没有评论:
发表评论