VS2008 、WDK 和DDKWizard搭建Win7驱动开发环境

Published 23/03/2010 | By obaby

一、安装VS2008
二、安装Visual Assist (这不是必需的)但它确是我们开发时不可多得的好工具
三、安装WDK
四、安装DDKWizard
下载地址:http://ddkwizard.assarbad.net/
需要下载的文件有
1、ddkwizard_setup.exe
2、ddkbuild_bat.zip
3、ddkbuild_cmd.zip
安装第一个文件跟安装普通程序一样只需要按默认设置即可
2、3两个文件只需要解压copy到我们的wdk所有的根目录即可

接下来的我们便要设置环境变量了
需要设置的地方有两个
1、path
需将D:\WinDDK添加到Path变量中
否则编译时会出现找不到命令的错误

2、新建系统变量
变量名:WLHBASE
变量值为:J:\WinDDK\7600.16385.0 修改为你安装的wdk路径
如下图
                             

五、打开VS2008

工具》》选项》》项目和解决方案》VC++目录 ,增加WDK的根目录

到目此所有的设置工作都已完成。

六、编写简单的驱动程序并测试我们的驱动开发环境
1、新建一个project
选择DDK Project 中的 Empty driver
如图

接下来会跳了一个DDKWizard向导的一个对话框

这里可以保持默认设置 我这里只选择了 Windows7/2008 Server R2 WDK
Finish 后就可以开始写我们的驱动程序了
这里为了演示..我们什么也不做只打印输出”Hello”
简单驱动程序代码如下
注意保存为*.c格式 我这里保存为test.c

1

2

3

4

5

6

7

8

9

10

11

#include<ntddk .h>

VOID DriverUnload(PDRIVER_OBJECT  driver)

{

      DbgPrint("Hello\r\n");

}

NTSTATUS DriverEntry(PDRIVER_OBJECT  driver,PUNICODE_STRING reg_path)

{

      DbgPrint("Hello,Eping!");

      driver->DriverUnload=DriverUnload;

      return STATUS_SUCCESS; 

}</ntddk>

注意:sources文件中TARGETTYPE= 默认生成的代码
需要改为TARGETTYPE=DRIVER SOURCES=默认也为空 我把它改成SOURCES=test.c即可成功编译出 否则编译成功后你会发现找不到驱动文件

最后按F7在J:\Users\obaby\Documents\Visual Studio2008\Projects\EmptyDriver1\EmptyDriver1\objchk_win7_x86\i386就找到相关的驱动文件了:

  :)到此就大功告成了~

我试了一下,在环境变量设置的时候有些问题,比如,如果要编译win7的驱动,需要设置变量名为W7BASE的变量,我只设置WLHBASE的环境变量无法编译,返回3号错误,经过查看ddkbuild.cmd文件,发现错误是:
NT4BASE, W2KBASE, WXPBASE, WNETBASE and/or W7BASE environment variable(s) notset.
所以我觉得应该是要编译哪个平台的驱动,就设置相应的环境变量。

 

win7 64位驱动开发经验(1- 好工具站长分享平台

我的驱动测试环境:win7 64 U 版,win7 x64 checked build编译的驱动文件。

首先管理元身份启动 DebugView ,配置:菜单capture capture kernel Enable Verbose kerenl Outptutcapture Event打勾,

其次管理元身份启动 InstDrv.exe 填写正确路径,安装、启动。。。。

顺利的话看到DebugView 输出想要的字符串

问题---解决方法:

1.安装驱动,无法获得句柄

没有管理员身份启动InstDrv工具

2.安装成功,启动失败
强制驱动签名导致:

解决办法:

关闭强制驱动签名的命令如下: bcdedit/set testsigning on 用管理员身份打开CMD命令行,输入上面的命令,完成以后将电脑重启。。进入系统以后,打开设备管理器一看,原先那个警告没有了。查看其状态,为正常启用。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
DDKWizard is a so-called project creation wizard that allows you to create projects that use the DDKBUILD scripts from OSR (also available in the download section from this site). The wizard will give you several options to configure your project prior to the creation. Have a look at figure 1. Figure 2: Project creation dialog (click to enlarge) Instead of forcing you to use a subset of options and specific DDKs this wizard lets you choose what you want. Of course the template files are predefined and so is the content of the project(s) within certain limits. However, I tried to choose the best options that I could think of and provide a way to create quickly and easily the DDKBUILD project you want. This means that I tried to leave out those things that may limit your choice lateron and add other options that will give you the flexibility to change options quickly long after the project was created. DDKWizard adds a new subfolder in the project creation wizard - see figure 2 - and presents all supported project types there. Currently these are Driver, Empty Driver, Native Application, Win32 console application and Win32 DLL. In either case you just choose the type of project to create, give the name of the project and/or solution as well as other options (at the bottom) and you are being presented the wizard dialog (see figure 1). From the wizard dialog you choose the DDKBUILD script you want to use, the DDK or multiple DDKs as well as the other options. If you are curious about the Property Sheet feature, please download the manual and read the respective section there. Compatibility DDKWizard (1.2.0a) has been tested on the following configurations: Visual Studio Professional .NET with WNET DDK and DDKBUILD.CMD on Windows 2003 Server R2 Standard Visual Studio Professional .NET 2003 with WNET DDK and DDKBUILD.CMD on Windows 2003 Server R2 Standard Visual C++ 2005 Express with WNET DDK and DDKBUILD.CMD on Windows 2003 Server R2 Standard Visual Studio 2005 Professional with WNET DDK and DDKBUILD.CMD on Windows 2003 Server R2 Standard Visual Studio 2008 Professional with WNET DDK and DDKBUILD.CMD on Windows XP From this list one can deduce that it is supposed to also run if you got the respective "non-Express" Visual C++ version. Also if there has been some Visual C++ .NET 2003 Express DDKWizard is prepared for it. Download You could go watch the demo or download right away: Manual: contains the detailed description of how to configure DDKBUILD and use DDKWizard. If you are unsure whether you should download and install DDKWizard grab this file and skim over it. Download: ddkwiz_manual.pdf (~513kB, 2009-12-05@20-11-55, downloaded 31666 times) Installer (incl. manual) of DDKWizard 1.3.0a: this is the setup program which will install DDKWizard along with the manual on your computer and register it with Visual Studio. Download: ddkwizard_setup.exe (~557kB, 2009-12-05@20-12-37, downloaded 72787 times) DDKBUILD.CMD: Stable version 7.4/r60 of OSRs DDKBUILD NT script version. Feedback for this version can be sent to me directly. Download: ddkbuild_cmd.zip (~12kB, 2009-11-28@04-38-36, downloaded 20707 times) DDKBUILD.BAT (obsoleted by the above!): Version 6.12 of OSRs DDKBUILD batch script version. Download: ddkbuild_bat.zip (~6kB, 2008-03-21@15-59-07, downloaded 17226 times) Trunk version of DDKBUILD.CMD The version from trunk is available as well. Please note that this is not necessarily the same version as offered in the ZIP archive above. It may be in a better shape (e.g. reported bugs fixed) or slightly worse (e.g. new feature that is not yet stable). So use this version only if you want to test the latest development version and are able to provide feedback. Here is the link to the prettier ViewVC URL: ddkbuild/trunk - SVN clients get read-only access here. License All projects created by DDKWizard can be put under whatever license you like to put them. The scripts and HTML files which contain the DDKWizard logic are subject to the zlib license starting with version 1.2.0, before it was released under the GPL v2 from 1991. The zlib license is a lot more liberal and allows just about any kind of use for the script and "user interface" part of DDKWizard. The DDKBUILD scripts are mirrored with the permission of OSR. I will try to keep it synchronized at all times. Everything else Contact me here and also visit my blog and my website. Note that I usually announce new versions of DDKWizard and DDKBUILD on my blog - you also might want to subscribe to the RSS feed for DDKWizard and DDKBUILD. This page will be extended whenever I deem it necessary.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值