Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing drivers in C#

Tags:

c#

driver

drivers

I have written earlier in C/C++ but currently, I need it to convert into C#.

Can anyone tell me the code/way How to write drivers in C#?

Actually currently I have some problems with my old application written in C++ and we have to write the drivers of our LPT1,COM Printers and other USB drivers in C#.

like image 839
Gaurav Arora Avatar asked Jun 15 '09 05:06

Gaurav Arora


3 Answers

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++.

like image 103
Sergey Podobry Avatar answered Nov 15 '22 22:11

Sergey Podobry


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.

like image 37
No hay Problema Avatar answered Nov 15 '22 22:11

No hay Problema


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?

like image 12
Robert Horvick Avatar answered Nov 15 '22 22:11

Robert Horvick