windows10 驱动开发环境 VS2019+WDK10

2023-05-16

windows10 驱动开发环境

 

1、下载SDK 

https://developer.microsoft.com/zh-cn/windows/downloads/windows-10-sdk

通用驱动demo:

https://github.com/microsoft/Windows-driver-samples

2、下载VS2019

https://visualstudio.microsoft.com/zh-hans/vs/

安装 Visual Studio 时,选择“使用 C++ 的桌面开发” 工作负载

3、下载WDK

https://docs.microsoft.com/zh-cn/windows-hardware/drivers/download-the-wdk

安装 WDK 时将安装 WDK Visual Studio 扩展。 必须完成此操作,才能使 WDK VS 集成正常工作。

4、打开VS2019

参考:https://docs.microsoft.com/zh-cn/windows-hardware/drivers/gettingstarted/writing-a-very-small-kmdf--driver

新建KMDF项目:

 

编写第一个驱动程序代码

#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;
}

生成驱动程序

 

 

SDK 版本原因,编译未通过。

解决方法1:重定向解决方案目标,选择正确版本。

不能选择...

解决方法2:

找到“使用C++的桌面开发”,勾掉左上角的勾选,然后再重新勾选上

取消勾选再选上,之后更新一下,再重试选择“重定解决方案目标”来更改 SDK 版本

还是不能选择...

解决方法3:

重新下个新的SDK

error MSB8040: Spectre-mitigated libraries are required for this project.

增加组件:可能还需要其他依赖库,将相关库都选择上。

 

编译成功。

 

  • KmdfHelloWorld.sys - 内核模式驱动程序文件
  • KmdfHelloWorld.inf - 在安装驱动程序时 Windows 使用的信息文件
  • KmdfHelloWorld.cat - 安装程序验证驱动程序的测试签名所使用的目录文件

 

 

 

 

 

 

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

windows10 驱动开发环境 VS2019+WDK10 的相关文章

随机推荐

  • Keil工程添加源文件和头文件(.c和.h)的方法

    在此把Keil项目添加源文件和头文件的方法做个记录 xff1a 1 Keil项目添加源文件和头文件的方法之一 1 1 右键点击项目名称 xff0c 弹出菜单中选择Add Group xff0c 我们把所有需要添加的源文件都放在这个Group
  • 漂亮的html表格

    原文 xff1a http www textfixer com resources css tables php css table01 一个像素边框的表格 xff1a Info Header 1 Info Header 2 Info He
  • SIPp之认证注册

    欢迎大家转载 xff0c 为保留作者成果 xff0c 转载请注明出处 xff0c http blog csdn net netluoriver xff0c 有些文件在资源中也可以下载 xff01 如果你没有积分 xff0c 可以联系我 xf
  • HTTP:DIGEST认证的请求和响应报文

    以下是HTTP DIGEST认证的请求和响应报文的例子 xff0c 供以后参考 IE first request GET boe checkedServlet HTTP 1 1 Accept image gif image jpeg ima
  • Linux配置篇 | Ubuntu配置apt镜像源

    以下以 Ubuntu18 04 LTS 为例 xff0c 也适用于 Ubuntu 其他版本 一 修改apt镜像源 xff08 1 xff09 备份apt配置文件 xff1a cp etc apt sources list etc apt s
  • STC89C52RC单片机额外篇 | 04 - 认识头文件<intrins.h>与_nop_函数

    1 lt intrins h gt 头文件 头文件 lt intrins h gt 在我们51单片机日常开发中经常使用 xff0c 特别是 nop 函数 xff0c 以下是 lt intrins h gt 的内容 xff1a span cl
  • HTTP协议详解 - 通过C++实现HTTP服务剖析HTTP协议

    前言 C C 43 43 程序员一般很少会接触到HTTP服务端的东西 xff0c 所以对HTTP的理解一般停留在理论 本文章实现通过C 43 43 实现了一个http服务 xff0c 可以通过代码对HTTP协议有更深的理解 xff0c 并且
  • GIT 中如何打标签

    前言0x1 GIT 标签常用指令0x2 轻量标签0x3 附注标签0x4 远程仓库中的标签 前言 在我们开发的过程中 xff0c 可能经过多次 commit 提交才会确定一个版本 xff0c 那么除了用 commit comments 来标识
  • 用VSCode开发C++项目

    写在前面 最近在新学C 43 43 xff0c 又不想用VisualStudio那么庞大的IDE xff0c VS体量稍微有那么点笨重 xff08 主要还是因为穷 xff0c 没钱换电脑 xff0c 目前的电脑开个VS要个两三分钟 xff0
  • petalinux2018.3 error 记录

    petalinux config get hw description 61 报错 INFO sourcing bitbake ERROR Failed to source bitbake ERROR Failed to config pr
  • petalinux 编译,源码编译

    1 测试环境 Ubuntu 16 04PetaLinux 2019 1PetaLinux 2019 1 ZCU106 BSPZCU106 2 PetaLinux介绍 PetaLinux是Xilinx基于Yocto推出的Linux开发工具 Y
  • Optitrack Motive软件安装及使用说明

    Motive 软件安装程序 http www naturalpoint com optitrack downloads motive html 安装Motive需要安装两个底层插件 xff0c Directx aug2009 redist
  • Failed to get convolution algorithm. This is probably because cuDNN failed to initialize

    Failed to get convolution algorithm This is probably because cuDNN failed to initialize from tensorflow compat v1 import
  • C语言---整型字符串转换

    C语言提供了几个标准库函数 xff0c 可以将任意类型 整型 长整型 浮点型等 的数字转换为字符串 以下是用itoa 函数将整数转 换为字符串的一个例子 xff1a include lt stdio h gt include lt stdl
  • 约瑟夫环(C语言单项循环链表)

    约瑟夫环 C 语言单项循环链表 约瑟夫环 问题描述 xff1a 约瑟夫问题的一种描述是 xff1a 编号为1 xff0c 2 xff0c xff0c n 的n 个人按顺时针方向围坐一圈 xff0c 每人持一个密码 xff08 正整数 xff
  • 交换机VLAN的定义、意义以及划分方式

    什么是VLAN 虚拟网技术 xff08 VLAN xff0c Virtual Local Area Network xff09 的诞生主要源于广播 广播在网络中起着非常重要的作用 xff0c 如发现新设备 调整网络路径 IP地址租赁等等 x
  • coredump简介与coredump原因总结

    coredump简介与coredump原因总结 什么是coredump xff1f 通常情况下coredmp包含了程序运行时的内存 xff0c 寄存器状态 xff0c 堆栈指针 xff0c 内存管理信息等 可以理解为把程序工作的当前状态存储
  • 嵌入式设备web服务器比较

    现在在嵌入式设备中所使用的web服务器主要有 xff1a boa thttpd mini httpd shttpd lighttpd goaheand appweb和apache等 Boa 1 介绍 Boa诞生于1991年 xff0c 作者
  • memfd.c:40:12: error: static declaration of ‘memfd_create’ follows non-static declaration

    qemu编译安装出错 xff1a memfd c 40 12 error static declaration of memfd create follows non static declaration 修改 xff1a a util m
  • windows10 驱动开发环境 VS2019+WDK10

    windows10 驱动开发环境 1 下载SDK https developer microsoft com zh cn windows downloads windows 10 sdk 通用驱动demo xff1a https githu