windows 编写设备驱动程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5820610/
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 16:44:37  来源:igfitidea点击:

Writing device driver?

windowsdevice-driver

提问by King

I wonder if I understand correctly...

我想知道我是否理解正确...

Say, if I want to control how my mouse work, i.e Left Button open window, Right Button send keystroke 'A' etc.

说,如果我想控制鼠标的工作方式,即左键打开窗口,右键发送击键“A”等。

But I am not talking about writting something like follows in an application:

但我不是在谈论在应用程序中编写如下内容:

void MouseDown(xxxxEventArgs e, sender object)
{

}

I want to completely controls how the device work, then I will need to write a driver for it? From what I learn in assembly before, controlling a device I should need to know their port to communicate with the device. But say if I buy a Logitech mouse, is it possible to write a mouse driver myself to use it?

我想完全控制设备的工作方式,那么我需要为它编写驱动程序吗?根据我之前在组装中学到的知识,控制设备我需要知道它们的端口才能与设备进行通信。但是说如果我买罗技鼠标,是不是可以自己写个鼠标驱动来使用呢?

Because I saw some project that they buy a usb web cam from store, and they could able to control the web came to rotate, recevie the image from the web cam, I wonder if that's because the web cam has API provided them?

因为我看到一些他们从商店购买了一个USB网络摄像头的项目,他们可以控制网络来旋转,从网络摄像头接收图像,我想知道这是不是因为网络摄像头有API提供给他们?

Thanks in advance.

提前致谢。

回答by Tony The Lion

If you want to control the device in it's entirety, then you need to write a device driver indeed. This is a non-trivial task and you should read up on it. There is a tutorial on it hereand there a book for windows driver development here.

如果您想完整地控制设备,那么您确实需要编写设备驱动程序。这是一项重要的任务,您应该仔细阅读。还有它的教程这里有一本书对Windows驱动程序开发这里

If you want to write device drivers, you should be very well versed with C and/or C++.

如果您想编写设备驱动程序,您应该非常精通 C 和/或 C++。

回答by Registered User

You do not need to write a device driver for what you are trying to do.The device driver has nothing but as per the data sheet of the device address of registers where it can read,write,do IOMMU etc or some other stuff.What you will need is some kind of hacking the application programming part of the thing which you are trying to achieve.

您不需要为您要执行的操作编写设备驱动程序。设备驱动程序除了可以读取、写入、执行 IOMMU 等或其他一些东西的寄存器设备地址的数据表外,什么都没有。您将需要对您试图实现的应用程序编程部分进行某种黑客攻击。

Because device driver code just reads the data from device and writes back it is the application which is concerned for it.Though in some case device driver programmer provide a method (function) to application programmer so that they can write their application and invoke those methods.In your case you need to just understand how the application code is talking to device driver. In case you want to write a device driver check this http://www.freesoftwaremagazine.com/articles/drivers_linux?page=0%2C0

因为设备驱动程序代码只是从设备读取数据并写回它是关心它的应用程序。尽管在某些情况下设备驱动程序程序员向应用程序程序员提供了一个方法(函数),以便他们可以编写他们的应用程序并调用这些方法.在您的情况下,您只需要了解应用程序代码如何与设备驱动程序对话。如果您想编写设备驱动程序,请检查此 http://www.freesoftwaremagazine.com/articles/drivers_linux?page=0%2C0

回答by Shiwangini

In such kind of cases you can proceed with writing your own device driver by C++ and assemb lyem

在这种情况下,您可以继续通过 C++ 和汇编 lyem 编写自己的设备驱动程序