WDK包已经不支持
2019,请更新到2022版本搜索
最新全选即可
查看
系统已经安装的SDK, 也可以在 上一步安装过程中安装 SDK,就不用再单独下载安装。注: 检查
系统本身所存在的 环境,版本 过多,和WDK 版本不匹配会导致WDK安装进去 Visual Studio报错版本不匹配.下载链接: https://learn.microsoft.com/zh-cn/windows-hardware/drivers/download-the-wdk
如果在 Visual Studio 中找不到驱动程序项目模板,则表示
WDK Visual Studio扩展未正确安装。 要解决此问题,请从以下位置运行WDK.vsix文件:C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\10.0.26100.1\WDK.vsix。
如果上述方式
安装失败,可以通过,在插件里直接进行安装。如果还是失败? 查看下面的该扩展的版本比 Visual Studio 要求的版本低
WDK的版本要和自身的 系统对应,避免安装之后 出现版本不兼容,失败的问题
以前的 WDK 版本和其他下载 - Windows drivers | Microsoft Learn
Vs2022激活码:
- Pro:
TD244-P4NB7-YQ6XK-Y8MMM-YWV2J- Enterprise:
VHF9H-NXBBB-638P6-6JHCY-88JWH
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\km\ntddk.h确认您的
windows kits目录,加入到C++的附加项即可
严重性 代码 说明 项目 文件 行 禁止显示状态 详细信息
错误 C1083 无法打开包括文件: “ntddk.h”: No such file or directory RealBomIoSys D:\寄存器\RealBom寄存器\RealBomWinIO\WinIo源码\WinRing0Sys\OpenLibSys.c 1
- 打开
Microsoft Visual Studio。 在文件菜单上,选择新建>项目。
生成的
解决方案
在
Source Files文件夹中创建Driver.c文件编写函数
#include <ntddk.h> //包含所有驱动程序的核心Widnows内核定义,
#include <wdf.h> // 基于Windows 驱动程序框架WDF的驱动程序的定义
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfHelloWorldEvtDeviceAdd;
// 驱动程序的入口函数
NTSTATUS
DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
{
// NTSTATUS variable to record success or failure
NTSTATUS status = STATUS_SUCCESS;
// Allocate the driver configuration object
WDF_DRIVER_CONFIG config;
// Print "Hello World" for DriverEntry
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: DriverEntry\n"));
// Initialize the driver configuration object to register the
// entry point for the EvtDeviceAdd callback, KmdfHelloWorldEvtDeviceAdd
WDF_DRIVER_CONFIG_INIT(&config,
KmdfHelloWorldEvtDeviceAdd
);
// Finally, create the driver object
status = WdfDriverCreate(DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE
);
return status;
}
// 系统检查到你的设备已到达时,会调用 EvtDeviceAdd 任务时初始化该设备的结构与资源
NTSTATUS
KmdfHelloWorldEvtDeviceAdd(
_In_ WDFDRIVER Driver,
_Inout_ PWDFDEVICE_INIT DeviceInit
)
{
// We're not using the driver object,
// so we need to mark it as unreferenced
UNREFERENCED_PARAMETER(Driver);
NTSTATUS status;
// Allocate the device object
WDFDEVICE hDevice;
// Print "Hello World"
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: KmdfHelloWorldEvtDeviceAdd\n"));
// Create the device object
status = WdfDeviceCreate(&DeviceInit,
WDF_NO_OBJECT_ATTRIBUTES,
&hDevice
);
return status;
}点击生成之后,就可以查看自己生成的
sys驱动文件。
生成的
驱动文件
HelloDriver.sys- 内核模式驱动程序文件HelloDriver.inf- 在安装驱动程序时 Windows 使用的信息文件HelloDriver.cat- 安装程序验证驱动程序的测试签名所使用的目录文件
以
管理员身份运行DriverMonitor
由于
sys文件,目前系统 都有签名认证要求,对于没有签名认证的,都会默认被Windows系统拦截。
- 启动系统测试模式 cmd中以管理员身份运行执行此指令
bcdedit /set testsigning on然后重启
- 获取打印的测试结果
- 使用
Dbgview工具,它会实时打印当前系统的驱动输出后续章节 进行更新。
















