windows 驱动程序开发入门

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/876155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:30:50  来源:igfitidea点击:

Getting Started on Driver Development

c++windowsdriver

提问by Billy ONeal

Does anyone have any books/tutorials which may be useful in getting started in Windows device driver development?

有没有人有任何书籍/教程可能对开始 Windows 设备驱动程序开发有用?

For plain Win32/GUI development, Petzold's book seems to be the essential reference. Does such exist for drivers?

对于普通的 Win32/GUI 开发,Petzold 的书似乎是必不可少的参考。驱动程序是否存在这种情况?

I would like to note that I'm not actually talking to hardware -- I actually want to emulate a piece of hardware in software, but I'd like to see how things work in general first.

我想指出的是,我实际上并不是在与硬件交谈——我实际上想在软件中模拟一个硬件,但我想先看看一般情况下是如何工作的。

Billy3

比利3

采纳答案by ChrisW

One thing to beware of is the device driver development (architecture and tools) changes more than Win32 development ... so while Petzold's book from the 1990s is fine for Win32 and may be considered a timeless classic, the architecture for many kinds of drivers (printer drivers, network drivers, etc.) has varied in various O/S releases.

需要注意的一件事是设备驱动程序开发(体系结构和工具)的变化比 Win32 开发要多……因此,尽管 Petzold 1990 年代的书对 Win32 很好,并且可能被认为是永恒的经典,但许多驱动程序的体系结构(打印机驱动程序、网络驱动程序等)在各种 O/S 版本中有所不同。

Here's a blog entry which reviews various books: Windows Device Drivers Book Reviews.

这是一篇评论各种书籍的博客条目:Windows 设备驱动程序书评

Don't forget the microsoft documentation included with the DDK: and, most importantly, the sample drivers (source code) included with the DDK. When I wanted to write a mock serial port driver, for example, I found the sample serial driver documentation combined with the DDK documentation was invaluable (and sufficient).

不要忘记包含在 DDK 中的微软文档:最重要的是,包含在 DDK 中的示例驱动程序(源代码)。例如,当我想编写一个模拟串口驱动程序时,我发现结合 DDK 文档的示例串口驱动程序文档非常宝贵(而且足够了)。

回答by Peter Teoh

To learn kernel development well:

学好内核开发:

a. lots of samples kernel programs:

一种。许多示例内核程序:

Windows DDK sample:

Windows DDK 示例:

http://social.msdn.microsoft.com/Forums/en-US/softwaretesting/thread/08690203-1757-4129-b59a-6bae10bcdce8/

http://social.msdn.microsoft.com/Forums/en-US/softwaretesting/thread/08690203-1757-4129-b59a-6bae10bcdce8/

WDK samples:

WDK 示例:

http://msdn.microsoft.com/en-us/windows/hardware/gg487428

http://msdn.microsoft.com/en-us/windows/hardware/gg487428

Or just search:

或者只是搜索:

http://www.google.com/search?q=windows+ddk+samples

http://www.google.com/search?q=windows+ddk+samples

(because above URL may change, but Google will likely to return u the most appropriate/reachable one)

(因为上面的 URL 可能会改变,但谷歌可能会返回给你最合适/可达的)

b. lots of debugging techniques, and among which I found the best is VMware (or VirtualBox) + windbg + serial port debugging:

湾 调试技巧很多,其中我发现最好的是VMware(或VirtualBox)+windbg+串口调试:

http://www.google.com/search?q=windbg+vmware+kernel+debug

http://www.google.com/search?q=windbg+vmware+kernel+debug

and this paper is classic for using VMWare + windbg (Lord of the Ring0):

这篇论文是使用VMWare + windbg(指环王0)的经典之作:

http://silverstr.ufies.org/lotr0/windbg-vmware.html

http://silverstr.ufies.org/lotr0/windbg-vmware.html

c. as well as system admin tools which others have built:

C。以及其他人构建的系统管理工具:

http://technet.microsoft.com/en-us/sysinternals/bb545021

http://technet.microsoft.com/en-us/sysinternals/bb545021

(In the past called SysInternals built by Mark Russinovich, co-author of "Windows Internal" - MUST READ!!)

(过去称为 SysInternals 由“Windows Internal”的合著者 Mark Russinovich 构建 - 必须阅读!!)

http://technet.microsoft.com/en-us/sysinternals/bb963901

http://technet.microsoft.com/en-us/sysinternals/bb963901

from these tools u have will immense debugging options.

从这些工具中,您将拥有巨大的调试选项。

d. Join the OSR mailing list (ntdev especially is very active, but there are others like windbg):

d. 加入 OSR 邮件列表(尤其是 ntdev 非常活跃,但还有其他的,比如 windbg):

http://www.osronline.com/page.cfm?name=ListServer

http://www.osronline.com/page.cfm?name=ListServer

e. Watch lots of video related to windows + kernel at channel9 (google returned over 1000 links):

e. 在 channel9 观看大量与 windows + kernel 相关的视频(google 返回了 1000 多个链接):

http://www.google.com/search?q=site:channel9.msdn.com+kernel+video&num=100

http://www.google.com/search?q=site:channel9.msdn.com+kernel+video&num=100

f. Discussion forum like:

F。论坛如:

http://social.microsoft.com/Forums/en-us/kernel/threads

http://social.microsoft.com/Forums/en-us/kernel/threads

http://social.msdn.microsoft.com/Forums/en-US/wdk/threads

http://social.msdn.microsoft.com/Forums/en-US/wdk/threads

Subscribed to the free OSR magazine too (hardcopy). I have received mine since 1998 till now - and it is delivered half-way round the earth!

也订阅了免费的 OSR 杂志(硬拷贝)。我从 1998 年到现在一直收到我的 - 它被送到了地球的一半!

回答by LordDoskias

Personally the best way to start developing is by real-world exposure. Having this in mind I'd recomment this book

就个人而言,开始开发的最佳方式是接触现实世界。考虑到这一点,我会推荐这本书

The Rootkit Arsenal: Escape and Evasion in the Dark Corners of the System

Rootkit 军械库:系统黑暗角落的逃脱

The Rootkit Arsenal Cover

Rootkit 阿森纳封面

It should be enough to get you started to have some code running which does "something" then after you have the general picture you might dwell on topics such as - Difference between Buffered/Neither/Direct methods and the peculiarities associated with them.

它应该足以让您开始运行一些执行“某事”的代码,然后在您了解一般情况后,您可能会专注于诸如 - 缓冲/两者都不/直接方法之间的差异以及与它们相关的特性之类的主题。

"Programming the windows driver model, 2nd edition" is also a great help when you need details regarding some specific topics. But first I believe the most important thing is to put things into context and then build on that.

当您需要有关某些特定主题的详细信息时,“对 Windows 驱动程序模型进行编程,第 2 版”也很有帮助。但首先我认为最重要的是把事情放在上下文中,然后在此基础上再接再厉。

回答by LordDoskias

I would search for tutorials with rich examples, like this one. The essence in windows driver development is to get the picture about layers and IRPs, IRQLs, and also to know terms like filter drivers. If you are looking for example codes, here is my Spodek driver code: sf.net link. You will find there a filter driver (for keyboard, keyb.c), kernel space queue (queue.c) and techniques to hide presence in system. It's a legacy (sys) driver though.

我会搜索具有丰富示例的教程,例如这个。Windows 驱动程序开发的本质是了解层和 IRP、IRQL,以及了解过滤器驱动程序等术语。如果您正在寻找示例代码,这里是我的 Spodek 驱动程序代码:sf.net link。您会在那里找到过滤器驱动程序(用于键盘,keyb.c)、内核空间队列 (queue.c) 和隐藏系统中存在的技术。不过,它是一个传统 (sys) 驱动程序。

回答by Taneli Waltari

You should probably use the quite recent Windows Driver Foundation (WDF) framework instead of the older WDM framework. A good starting point is reading the WDF Overview Word documents.

您可能应该使用最新的 Windows Driver Foundation (WDF) 框架而不是旧的 WDM 框架。一个好的起点是阅读WDF 概述 Word 文档

If you want to read a book, "Developing Drivers with the Windows Driver Foundation"is the one you are looking for.

如果您想阅读一本书,“使用 Windows 驱动程序基础开发驱动程序”就是您要找的书。