ddk.pas 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {
  2. Driver Development Kit for Native NT
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2009 by Sven Barth
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$IFNDEF FPC_DOTTEDUNITS}
  12. unit DDK;
  13. {$ENDIF FPC_DOTTEDUNITS}
  14. interface
  15. {$IFDEF FPC_DOTTEDUNITS}
  16. uses
  17. NTApi.NDK;
  18. {$ELSE FPC_DOTTEDUNITS}
  19. uses
  20. NDK;
  21. {$ENDIF FPC_DOTTEDUNITS}
  22. const
  23. // we distinguish the user- AND kernel-mode imports (NDK.ntdll) from the pure
  24. // kernel mode imports (ntkrnl)
  25. ntkrnl = 'ntoskrnl.exe';
  26. {$include ddktypes.inc}
  27. // these two only return not Nil in main routine of a device driver
  28. function RegistryPath: PNtUnicodeString; inline;
  29. function DriverObject: PDriverObject; inline;
  30. function DbgPrint(aFormat: PAnsiChar): LongWord; cdecl; varargs; external ntkrnl name 'DbgPrint';
  31. function PoolTag(aTag: TTagString): LongWord;
  32. {$include ddkex.inc}
  33. implementation
  34. function RegistryPath: PNtUnicodeString; inline;
  35. begin
  36. RegistryPath := SysRegistryPath;
  37. end;
  38. function DriverObject: PDriverObject; inline;
  39. begin
  40. DriverObject := SysDriverObject;
  41. end;
  42. function PoolTag(aTag: TTagString): LongWord;
  43. begin
  44. PoolTag := Ord(aTag[1]) + Ord(aTag[2]) shl 8 +
  45. Ord(aTag[3]) shl 16 + Ord(aTag[4]) shl 24;
  46. end;
  47. end.