ntdef.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. {%MainUnit ndk.pas}
  2. {
  3. Native Development Kit for Native NT
  4. This file is part of the Free Pascal run time library.
  5. This units contains some basic type definitions used by NT
  6. Copyright (c) 2010 by Sven Barth
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. type
  14. PVOID = Pointer;
  15. PPVOID = ^PVOID;
  16. HANDLE = THandle; // already defined in system unit
  17. PHANDLE = ^HANDLE;
  18. { Upper-Case Versions of Some Standard C Types }
  19. //AnsiChar = AnsiChar;
  20. SHORT = ShortInt;
  21. LONG = LongInt;
  22. //DOUBLE = Double;
  23. { Unsigned Types }
  24. UCHAR = Byte;
  25. PUCHAR = ^Byte;
  26. USHORT = Word;
  27. PUSHORT = ^Word;
  28. ULONG = LongWord;
  29. PULONG = PLongWord;
  30. PCUCHAR = ^UCHAR; { const }
  31. PCUSHORT = ^USHORT; { const }
  32. PCULONG = ^ULONG; { const }
  33. FCHAR = UCHAR;
  34. FSHORT = USHORT;
  35. FLONG = ULONG;
  36. { This type is originaly called BOOLEAN, but that might generate problems
  37. in SysUtils include files, so we prefix it with NT. Also it's originally
  38. defined as UCHAR, but ByteBool allows the use of True/False }
  39. NT_BOOLEAN = ByteBool;
  40. PNT_BOOLEAN = ^NT_BOOLEAN;
  41. LOGICAL = ULONG;
  42. PLOGICAL = ^ULONG;
  43. { Signed Types }
  44. PSHORT = ^SHORT;
  45. PLONG = ^LONG;
  46. NTSTATUS = LONG;
  47. PNTSTATUS = ^NTSTATUS;
  48. SCHAR = SmallInt;
  49. PSCHAR = ^SCHAR;
  50. { types from basetsd.h }
  51. ULONG_PTR = LongWord; // seems to really be a PtrUInt
  52. { Large Integer Unions }
  53. // using Int64 is an alternative (QWord might have unintended side effects)
  54. LARGE_INTEGER = packed record
  55. case Boolean of
  56. True:(u: record
  57. LowPart: LongWord;
  58. HighPart: LongInt;
  59. end);
  60. False:(QuadPart: Int64);
  61. end;
  62. PLARGE_INTEGER = ^LARGE_INTEGER;
  63. { Native API Return Value Macros }
  64. function NT_SUCCESS(Status: NTSTATUS): Boolean; inline; register;
  65. function NT_INFORMATION(Status: NTSTATUS): Boolean; inline; register;
  66. function NT_WARNING(Status: NTSTATUS): Boolean; inline; register;
  67. function NT_ERROR(Status: NTSTATUS): Boolean; inline; register;
  68. type
  69. { String Types }
  70. _UNICODE_STRING = packed record
  71. Length: Word; // used characters in buffer
  72. MaximumLength: Word; // maximum characters in buffer
  73. Buffer: PWideChar;
  74. end;
  75. UNICODE_STRING = _UNICODE_STRING;
  76. PUNICODE_STRING = ^UNICODE_STRING;
  77. // alias to differ from TUnicodeString
  78. TNtUnicodeString = UNICODE_STRING;
  79. PNtUnicodeString = ^TNtUnicodeString;
  80. { Object Attributes }
  81. POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;
  82. _OBJECT_ATTRIBUTES = record
  83. Length: ULONG;
  84. RootDirectory: HANDLE;
  85. ObjectName: PUNICODE_STRING;
  86. Attributes: ULONG;
  87. SecurityDescriptor: PVOID; // PSECURITY_DESCRIPTOR
  88. SecurityQualityOfService: PVOID; // PSECURITY_QUALITY_OF_SERVICE
  89. end;
  90. OBJECT_ATTRIBUTES = _OBJECT_ATTRIBUTES;
  91. procedure InitializeObjectAttributes(var aObjectAttr: OBJECT_ATTRIBUTES;
  92. aName: PUNICODE_STRING; aAttributes: ULONG; aRootDir: HANDLE;
  93. aSecurity: Pointer {PSECURITY_DESCRIPTOR}); inline; register;