Writing drivers in C#

こ雲淡風輕ζ 提交于 2019-11-28 06:48:18

Simply you can't. C# produces intermediate language that is interpreted by a virtual machine (.NET). All these stuff runs in user mode and WDM drivers run in kernel mode.

There is a DDK but it is not supported in VStudio either (but you can make a makefile project for compilation though).

Driver development is complex, prone to blue screen and requires a good understanding of C , kernel structures and mem manipulation. None of those skills are required for C# and .NET therefore there is a long and painful training path.

Actually, you can write some drivers in C# if you use UMDF because it runs in usermode (see Getting Started with UMDF). But my recommendation is to use C/C++.

Robert Horvick

You cannot write kernel mode drivers in C# (the runtime executes in user mode therefore you can't get into ring0). This SO Q/A provides some links you may find helpful:

C# driver development?

It's unclear from your description whether you intend to develop Windows device drivers or to interact with hardware through existing device drivers.

For example, to interact with devices connected to your serial port, you don't need to write your own driver and in fact, you can access it through .NET's SerialPort class.

Even USB devices can be accessed from user space (and, ultimately, managed code) through frameworks such as libusb-win32, WinUSB etc.

You can't write drivers in C#; drivers need to run with elevated privilege to be able to talk to hardware; managed code cannot be run in the appropriate environment.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!