vs2019+wdk10开发xp,win7,win10驱动
Windows驱动开发入门 – HelloWorld
WIN10 + VS2015 + WDK10 + SDK10 + VM虚拟机驱动开发调试环境搭建
《Windows驱动开发技术详解》学习笔记
为sys/cat文件生成测试签名
learn-windows-drivers
前言
环境搭建
vs2019 professional:https://docs.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloads
wdk10 19041:https://docs.microsoft.com/zh-cn/windows-hardware/drivers/other-wdk-downloads
vm16:
win10 2004版本
winSDK 2004(19041):https://developer.microsoft.com/zh-cn/windows/downloads/sdk-archive/
安装
安装vs2019 略
安装winsdk 略
安装wdk 启动setup 一路确定 然后安装就ok
过程
创建win10 虚拟机
配置win10虚拟机
配置vs调试管道
WinDbg测试双机调试
代码
main.c
#include <ntddk.h>
#include <wdf.h>
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;
}
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;
}
安装调试驱动
结果
kmdf_hello_world.sys - 内核模式驱动程序文件
kmdf_hello_world.inf - 在安装驱动程序时 Windows 使用的信息文件
kmdf_hello_world.cat - 安装程序验证驱动程序的测试签名所使用的目录文件
问题
1.此项目需要缓解了 Spectre 漏洞的库。从 Visual Studio 安装程序(单个组件选项卡)为正在使用的任何工具集和体系结构安装它们。
VisitualInstaller.exe -> 单个组件 搜索’14 最新’ ->把Spectre 相关 x86x64的勾选中
2.error LNK2019: 无法解析的外部符号 DriverEntry错误原因
把main.cpp 改为.c后缀
3.无法附加到进程。不支持操作。未知错误:0x80004005。
- 检查管道名是否正确,我虚拟机的我换成com2,
4. vsInstaller 提示更新失败
5.VMware安装win10失败
6. error MSB4018: “SignTask
管理员权限启动vs2019 再运行 即可
7.Inf2Cat, signability test failed错误解决办法
8.注意不可达 虚拟机串口选项要选择应用程序
9.双机调试失败原因
1.vs调试配置 port写命名管道名字
2.wait reconnect的时候记得重启虚拟机
3.虚拟机执行驱动之前vs 先all break 卡一阵子 再键入g 再虚拟机start 一下 才能进入断点
Windbg 调试Win10
打开windbg
文件-》Kernal Debug
选择Com
选择pipe
port 输入 命名管道名字
点击确定
windbg显示Refreshing KD connection
https://www.52pojie.cn/thread-1056935-1-1.html