[笔记]windows驱动开发入门《一》helloworld 以及双机调试配置

本文详细介绍了如何使用VS2019和WDK10搭建Windows驱动开发环境,包括创建虚拟机、配置调试管道、解决安装和调试过程中遇到的问题,以及驱动的创建、签名和安装。同时,还涵盖了使用WinDbg进行双机调试的方法和技巧。
摘要由CSDN通过智能技术生成

vs2019+wdk10开发xp,win7,win10驱动
Windows驱动开发入门 – HelloWorld
WIN10 + VS2015 + WDK10 + SDK10 + VM虚拟机驱动开发调试环境搭建
《Windows驱动开发技术详解》学习笔记
为sys/cat文件生成测试签名
learn-windows-drivers

驱动签名

双机调试配置
官方 helloworld


前言

环境搭建

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。

  1. 检查管道名是否正确,我虚拟机的我换成com2,

4. vsInstaller 提示更新失败

参考

5.VMware安装win10失败

VMWare安装Windows10出现以下问题

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

总结

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

二进制怪兽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值