本文介绍了编写Windows驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近问了,我是否可以通过像NetLimiter和NetBalancer这样的C#WinForms应用程序来限制带宽。有人告诉我有两种方法可以做到这一点。通过适当的。使用QoS不是我想要的方法。因此,我查找了一些编写驱动程序所需的内容,并发现了一些有趣的观点。诸如对C / C ++的深入了解之类的要点,因为所执行的代码非常容易出现BSOD,因为它可以在内核模式下运行。我还找到了一个GitHub

I recently asked the question if I could limit bandwidth via a C# WinForms applications much like NetLimiter and NetBalancer. I was told that there's two ways to do this. Either via proper QoS or writing something along the lines of an "NDIS Network Filter Driver". Using QoS isn't the way I want to take. So I've looked up some of the stuff required to write drivers and found some interesting points. Points such as a good understanding of C/C++, because the executed code being very prone to BSODs since it could be run in something called "Kernel mode". I also found a GitHub "dump" which looks interesting and tempts me to investigate and look around in.

如您所见,我的专业水平还远远不够。忽略这一点,这将是开始我的冒险,开始编写驱动程序以进行监视的好起点,然后进一步操纵网络以引入节流。

As you can see I'm no where near advanced enough to delve into this on a professional level. Ignoring that, what would be a good start to start my adventures into writing drivers to monitor - and further down the line manipulate the network to introduce throttling.

任何帮助,指南

PS:我不确定这是否太广泛(如前面对我之前问题的评论中所述)一个有关堆栈溢出的问题。如果是这样,我该去哪里问这个问题?

PS: I am unsure as to whether this is (as afore mentioned in a comment to my previous question) too broad a question to be answered on Stack Overflow. If so, where would I go to ask this?

推荐答案

实际上,这太广泛了。驱动程序编写是一件复杂的事情,需要对计算机和操作系统的工作方式有充分的了解。此外,C#(和.NET本身)确实在内核模式下不可用,因此C / C ++是首选方式。尽管从理论上讲,任何非托管语言(例如Pascal)都可以做到,但我还没有听说有人在其中编写驱动程序。微软自己的开发人员资源也考虑到了C / C ++。

Indeed, this would be too broad. Driver writing is a complicated thing which requires a good understanding of how a computer and the OS works. Also, C# (and .NET itself) indeed isn't available in Kernel Mode, so C/C++ is the preferred way. Although theoretically any unmanaged language (like Pascal) could do, I haven't heard of anyone writing drivers in them. Microsoft's own developer resources are also written with C/C++ in mind.

这使我们想到了为什么要做的问题。

Which brings us to the question of why you want to do it.

如果您需要工作,而且有最后期限,那就算了。找一个已经知道这些东西的人。或者可能有一个图书馆可以满足需要。这些选择中的任何一个都会比您花时间学习所有这些东西便宜。

If you need it for work and there's a deadline - forget it. Get someone else who already knows this stuff. Or there might be a library out there that fills the need. Any of these options will be cheaper than your time spent learning all this stuff.

但是,如果这是出于您自己的好奇心,那就去吧!我建议先开始学习C。不是C ++,这更复杂,而且对于驱动程序而言,无论如何使用C都会更容易。但是您以后也可以使用C ++,这是好东西。 C ++主要与C兼容,因此您可以从C开始,然后继续使用C ++。

If it's for your own curiosity however - go for it! I'd advise by starting to learn C first. Not C++, that's more complicated and for drivers it will be easier with C anyway. But you can pick up C++ later too, it's good stuff. C++ is mostly compatible with C, so you can start with C and then continue with C++.

同时,获得一本有关OS的好书设计。不是因为您想设计一个操作系统,而是要了解它所基于的基本概念。您应该对内核模式/用户模式,虚拟内存,中断,进程调度等事物有很好的了解。

In parallel, get a good book about OS design. Not because you want to design an OS, but to understand the basic concepts that it is built upon. You should get a good understanding of things such as Kernel Mode/User Mode, virtual memory, interrupts, process scheduling, etc.

学习一些汇编可能也很有用(尽管不是必需的。)

Learning a bit of assembly might be useful too (albeit not required).

最后,当您觉得自己已经掌握了以上内容时,请转到并开始阅读有关驱动程序开发的信息。会有长篇文章和示例程序可以帮助您入门。调整它们并在虚拟机中播放,直到获得所需的内容为止。

Finally, when you feel like you've got a good grasp of the above, head over to MSDN and start reading about driver development. There will be long articles and example programs to get you started. Tweak them and play around in a virtual machine until you get what you need.

还有...阅读。

这篇关于编写Windows驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:45