summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/nativent/ndk/ntdef.inc
blob: 337af9c911805df77f876b55857d217698a83798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{%MainUnit ndk.pas}
{
    Native Development Kit for Native NT

    This file is part of the Free Pascal run time library.
    This units contains some basic type definitions used by NT
    Copyright (c) 2010 by Sven Barth

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

type
  PVOID = Pointer;
  PPVOID = ^PVOID;

  HANDLE = THandle; // already defined in system unit
  PHANDLE = ^HANDLE;

  { Upper-Case Versions of Some Standard C Types }
  //CHAR = Char;
  SHORT = ShortInt;
  LONG = LongInt;
  //DOUBLE = Double;

  { Unsigned Types }
  UCHAR = Byte;
  PUCHAR = ^Byte;
  USHORT = Word;
  PUSHORT = ^Word;
  ULONG = LongWord;
  PULONG = PLongWord;
  PCUCHAR = ^UCHAR; { const }
  PCUSHORT = ^USHORT; { const }
  PCULONG = ^ULONG; { const }
  FCHAR = UCHAR;
  FSHORT = USHORT;
  FLONG = ULONG;
  { This type is originaly called BOOLEAN, but that might generate problems
    in SysUtils include files, so we prefix it with NT. Also it's originally
    defined as UCHAR, but ByteBool allows the use of True/False }
  NT_BOOLEAN = ByteBool;
  PNT_BOOLEAN = ^NT_BOOLEAN;
  LOGICAL = ULONG;
  PLOGICAL = ^ULONG;

  { Signed Types }
  PSHORT = ^SHORT;
  PLONG = ^LONG;
  NTSTATUS = LONG;
  PNTSTATUS = ^NTSTATUS;
  SCHAR = SmallInt;
  PSCHAR = ^SCHAR;

  { types from basetsd.h }
  ULONG_PTR = LongWord; // seems to really be a PtrUInt

  { Large Integer Unions }
  // using Int64 is an alternative (QWord might have unintended side effects)
  LARGE_INTEGER = packed record
    case Boolean of
      True:(u: record
              LowPart: LongWord;
              HighPart: LongInt;
            end);
      False:(QuadPart: Int64);
  end;
  PLARGE_INTEGER = ^LARGE_INTEGER;

  { Native API Return Value Macros }
function NT_SUCCESS(Status: NTSTATUS): Boolean; inline; register;
function NT_INFORMATION(Status: NTSTATUS): Boolean; inline; register;
function NT_WARNING(Status: NTSTATUS): Boolean; inline; register;
function NT_ERROR(Status: NTSTATUS): Boolean; inline; register;

type
  { String Types }
  _UNICODE_STRING = packed record
    Length: Word;        // used characters in buffer
    MaximumLength: Word; // maximum characters in buffer
    Buffer: PWideChar;
  end;
  UNICODE_STRING = _UNICODE_STRING;
  PUNICODE_STRING = ^UNICODE_STRING;
  // alias to differ from TUnicodeString
  TNtUnicodeString = UNICODE_STRING;
  PNtUnicodeString = ^TNtUnicodeString;

  { Object Attributes }
  POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;
  _OBJECT_ATTRIBUTES = record
    Length: ULONG;
    RootDirectory: HANDLE;
    ObjectName: PUNICODE_STRING;
    Attributes: ULONG;
    SecurityDescriptor: PVOID;       // PSECURITY_DESCRIPTOR
    SecurityQualityOfService: PVOID; // PSECURITY_QUALITY_OF_SERVICE
  end;
  OBJECT_ATTRIBUTES = _OBJECT_ATTRIBUTES;

procedure InitializeObjectAttributes(var aObjectAttr: OBJECT_ATTRIBUTES;
    aName: PUNICODE_STRING; aAttributes: ULONG; aRootDir: HANDLE;
    aSecurity: Pointer {PSECURITY_DESCRIPTOR}); inline; register;