Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Windows drivers be written in Python?

Can Windows drivers be written in Python?

like image 762
Armageddon Avatar asked Jun 11 '09 13:06

Armageddon


3 Answers

A good way to gain insight why this is practically impossible is by reading Microsoft's advice on the use of C++ in drivers. As a derivative of C, the use of C++ appears to be straightforward. In practice, not so.

For instance, you must decide for every function (and really every assembly instruction) whether it's in pageable or non-pageable memory. This requires extensions to C, careful use of new C++ features, or in this case a special extension to the Python language and VM. In addition, your driver-compatible VM would also have to deal with the different IRQLs - there's a hierarchy of "levels" which restrict what you can and cannot do.

like image 96
MSalters Avatar answered Oct 24 '22 06:10

MSalters


The definitive answer is not without embedding an interpreter in your otherwise C/assembly driver. Unless someone has a framework available, then the answer is no. Once you have the interpreter and bindings in place then the rest of the logic could be done in Python.

However, writing drivers is one of the things for which C is best suited. I imagine the resulting Python code would look a whole lot like C code and defeat the purpose of the interpreter overhead.

like image 32
Judge Maygarden Avatar answered Oct 24 '22 06:10

Judge Maygarden


Python runs in a virtual machine, so no.

BUT:

You could write a compiler that translates Python code to machine language. Once you've done that, you can do it.

like image 1
Mark Lutton Avatar answered Oct 24 '22 07:10

Mark Lutton