Delphi Driver Development Kit

posted 21 Mar 2010, 19:42 by Delphi Basics   [ updated 8 Jun 2010, 19:09 ]

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.

With older Delphi versions [Delphi 3 and below] the Microsoft linker included in DDDK could be used 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.

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.
  • Driver Developement Kit 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 is the Delphi Driver Development Kit which addresses most of these issues and allows creation of kernel-mode drivers even in Delphi 2007. It includes translated DDK headers, and a utility to convert Delphi OBJ files to a format compatible with the Microsoft linker.  I compiled and ran one of the samples on my Windows XP machine using Delphi 2007 and it worked.

DDDK 0.0.4 was created by The Hacker Defender Project team.

Instructions
To get .sys driver you have to run compile.but first and then build.bat. Compile.bat runs Delphi part of the work creating .obj files which will be linked to produced the final executable. Build.bat then converts this object file to MS supported format of OMF using OMF2D 1.02 written by EliCZ and then uses MS linker link.exe assemble final .sys kernel mode driver.

As you can notice making drivers in Delphi is not supported by default so several hacks are made to make it working. One of these hacks is ignoring
several linker errors and warnings which are received during linking. Despite this, the final .sys is working well. Do not take these warnings seriously; however, if you are making your own driver there can be lot of other warnings and errors you should care about.

In samples directory you've got some of our samples. Each example includes its own compile and build scripts. To compile debug version run compile.debug.bat instead of compile.bat.

Versions
0.0.4 - Third release comes with few more supported functions and hook3 from Driver coding tutorial.
0.0.3 - Third release comes with more supported functions, types, constants exports and also with new example - hook2 from Driver coding tutorial.
0.0.2 - Second release comes with major changes in design.
           There are two samples now including hook1 from Driver coding tutorial.
           DDDK.pas ensures easy driver coding, you only need to add DDDK to project uses to get easy access to all supported functions.
0.0.1 - This is very first release of DDDK. It is just proof of concept showing the possibility of making working Delphi driver.

The archive contains executable files as well as delphi source code.

This page was moved because an arabic forum was hotlinking to the attached file.
NO HOTLINKING.
ċ
DelphiDriverDevelopmentKit.7z
(876k)
Delphi Basics,
21 Mar 2010, 20:08
Comments