Writing Drivers in Delphi

Driver development has always been the privilege of C/C++ and Assembler programmers. If someone needs to write a device driver in Delphi, he has to settle for “adapter” drivers that would allow their user-mode program some ability to interface with kernel-mode functions. There are also “wizards” that (supposedly) allow one to create a driver without much driver-development knowledge. Both of these are often commercial software.

For some tasks one could also use a service (which can be written in Delphi). Well, either that or learn to program C/C++. With older Delphi versions you could still use the Microsoft linker included in DDK to link the object files produced by the Delphi compiler to get a valid .sys file, but newer Delphi versions have a different .obj file format. Is there any hope? Well, yes there is!

The main reasons why you can’t usually create drivers in Delphi are such :

  • It’s compiler/linker can’t produce .sys files.
  • The object file format incompatibility mentioned above.
  • DDK isn’t generally available in languages other than C/C++.
  • Some essential units (RTL) aren’t intended for use in kernel-mode and might crash a driver (and the whole system along with it).

The solution I recently discovered is the Delphi Driver Development Kit v0.0.4 (local mirror) that addresses most of these issues and lets you create kernel-mode drivers even in Delphi 7! It includes translated DDK headers, an utility to convert Delphi OBJ files to a format compatible with the Microsoft linker and some other things. And the best thing is it’s free! I compiled and run one of the samples on my Windows XP machine using Delphi 7 and it worked OK 🙂

DDDK 0.0.4 was created by The Hacker Defender Project team. Take a look at their site, they also have some other interesting programs and articles there.

Update 04.07.2007 : Looks like “The Hacker Defender Project” is down. You can still get the DDK at http://w-shadow.com/files/DDDK004.zip

Related posts :

22 Responses to “Writing Drivers in Delphi”

  1. Lex Dean says:

    I think a usefull example to demonstate would be nice.
    How about a printer driver that that makes its own a jpeg file.
    for a few people this could be usefull utilty.

  2. […] recently read a blog post online that may indicate a possible solution for writing drivers with Delphi, but it’s 3 years old and I don’t know how accurate this information […]

Leave a Reply