使用 Visual Studio 2010 进行驱动程序编程时第一个程序出现问题
我最近开始学习这种类型的编程(驱动程序编程)。
我开始使用传统方式_>我的意思是,我只使用 WDK 来构建和编译驱动程序,并且可以使用简单的项目方法正常工作,但是当我想开始扩展我的程序或制作一个稍微开发的程序时,我在高级中遇到了一些小问题。
所以,我开始在Windows 7中使用VS2010,我确实遇到了很多问题,因为我没有背景如何才能尽可能好地使用它。
最后,我到达一个很好的点,这一点是说(如果你想在VS2010中开始驱动程序编程,1-你应该安装WDK 2-安装VS2010 3-将WDK头文件目录的路径输入到VS2010目录中以兼容4-开始创建新项目并继续
makefile项目
最后,我真的不确定这是否是正确的方法,我只是初学者,
但我确实这样做了,我发现了一个很好的结果
#include "wdm.h"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath )
{
DbgPrint("Hello World!");
return STATUS_SUCCESS;
}
,我得到了:
1>------ Build started: Project: 1, Configuration: Debug Win32 ------ 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping... ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
我的 。问题是:
这是正确的方法吗?我如何知道该程序是否正常工作? 我应该做些什么来让我的程序在内核模式下正常工作吗?
I am starting to learn this type of programming (driver programming) since a short while of the time.
I started by using the traditional way _> I mean I only used WDK to bulid and compiled driver and was working properly with simple method of projects but I faced small problems in advanced when i wanted to start to expand my program or make a little developed one.
So, I started using VS2010 in windows 7, I really faced a lot of problems because i do not have a background how can i used it as good as possible.
Finally, I reach to a good point, this point is say (If you want to start with driver programming in VS2010, 1- you should install WDK 2- install VS2010 3- Enter the paths of WDK headers dirctories into VS2010 Dirctories to be compatiple. 4- Start tor create new project and go on.
makefile project
Finally, I am really not sure, it is a correct way or not I am just beginner.
But I did like this and i found a good results
#include "wdm.h"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath )
{
DbgPrint("Hello World!");
return STATUS_SUCCESS;
}
And i got:
1>------ Build started: Project: 1, Configuration: Debug Win32 ------ 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping... ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
My question is:
Is this the correct way? How can I know this program is working properly?
Should I do something else to make my program work correctly in kernal mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看DDKWizard。它准确地解决了您正在处理的问题,并且做得很好。
Look into DDKWizard. It tackles exactly the issue you're handling, and does it well.
您不应该使用 Visual Studio 的编译器。 WDK 编译器可能包含对标准 WinSDK 或 Visual Studio 编译器的更改。
另一方面,使用 makefile 步骤中的构建宏是利用 Visual Studio 开发驱动程序并使用 WDK 使用的构建工具包构建驱动程序的好方法。
有一个很好的 batch 文件,它调用必要的构建环境并重定向错误输出到 Visual Studio 输出窗格。
为了澄清这一点,我在 Visual Studio 中使用了一个 makefile 项目,其中添加了所有源文件,在构建时我调用一个批处理文件,该文件依次使用正确的参数调用 ddkbuild 。
注意:上述陈述在 XP DDK 和 Windows 7 WDK 之间均属正确。自 Windows 8 WDK 与 Visual Studio 集成并使用其工具链以来,情况已不再如此。同样,在 XP DDK 之前,Visual Studio 需要使用 DDK 进行构建。
You shouldn't use the compiler of Visual Studio. The WDK compiler may contain changes to the standard WinSDK or Visual Studio compiler.
On the other hand, using a build macro from the makefile step is a nice enough way to utilize Visual Studio for developing the driver, and building it with the build toolkit used by the WDK.
There is a nice batch file which calls the necessary build environment and redirects the error outputs to the Visual Studio output pane.
To clarify, I use a makefile project in visual studio where all source files are added, when building I call a batch file which calls in turn
ddkbuild
with the right parameters.NB: the above statements were true between the XP DDK and Windows 7 WDK inclusive. It is no longer true since the Windows 8 WDK, which integrates with Visual Studio and uses its toolchain. Similarly, prior to the XP DDK, Visual Studio was required to build with the DDKs.
切勿在 Visual Studio 中构建驱动程序!
构建驱动程序的唯一方法是:打开WDK构建环境命令提示符,cd到驱动程序项目目录,然后输入“build”。
您只能使用 Visual Studio 作为源代码编辑器,但不能用它构建驱动程序!有多种方法可以做到这一点,并在不同的编程站点上发布,但专业驱动程序开发人员强烈建议仅使用 WDK 构建来实现此目的。
要打开 WDK 构建环境,请单击 Windows 主菜单 - 程序 - Windows 驱动程序套件 - WDK - 构建环境 - 选择目标操作系统 - 根据目标计算机处理器类型选择构建环境。检查的构建环境意味着调试,免费的构建环境意味着发布。
注意:上述陈述在 XP DDK 和 Windows 7 WDK 之间均属正确。自 Windows 8 WDK 与 Visual Studio 集成并使用其工具链以来,情况已不再如此。同样,在 XP DDK 之前,Visual Studio 需要使用 DDK 进行构建。
Never build drivers in Visual Studio!
The only way to build driver is: open WDK Build Environment command prompt, cd to the driver project directory, and type "build".
You can use Visual Studio only as source code editor, but don't build driver with it! There are number of ways to do this, published in different programming sites, but professional driver developers strongly recommend to use only WDK build for this.
To open WDK build environment, click main Windows menu - Programs - Windows Driver Kits - WDK - Build Environments - select target OS - select build environment, according to target computer processor type. Checked build environment means Debug, free build environment means Release.
NB: the above statements were true between the XP DDK and Windows 7 WDK inclusive. It is no longer true since the Windows 8 WDK, which integrates with Visual Studio and uses its toolchain. Similarly, prior to the XP DDK, Visual Studio was required to build with the DDKs.