[PSDK] and [NDK]
[reactos.git] / reactos / include / ndk / umtypes.h
1 /*++ NDK Version: 0095
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 umtypes.h
8
9 Abstract:
10
11 Type definitions for the basic native types.
12
13 Author:
14
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
16
17 --*/
18
19 #if !defined(_NTDEF_) && !defined(_NTDEF_H)
20 #define _NTDEF_
21 #define _NTDEF_H
22
23 //
24 // Use dummy macros, if SAL 2 is not available
25 //
26 #include <sal.h>
27 #if (_SAL_VERSION < 20)
28 #include <no_sal2.h>
29 #endif
30
31 //
32 // NDK Applications must use Unicode
33 //
34 #ifndef UNICODE
35 #define UNICODE
36 #endif
37
38 //
39 // Don't use the SDK status values
40 //
41 #ifndef WIN32_NO_STATUS
42 #define WIN32_NO_STATUS
43 #endif
44
45 //
46 // Let the NDK know we're in Application Mode
47 //
48 #define NTOS_MODE_USER
49
50 //
51 // Dependencies
52 //
53 #include <windef.h>
54 #undef WIN32_NO_STATUS
55 #include <ntstatus.h>
56 #include <winioctl.h>
57 #include <ntnls.h>
58
59 //
60 // Compiler Definitions
61 //
62 #ifndef _MANAGED
63 #if defined(_M_IX86)
64 #ifndef FASTCALL
65 #define FASTCALL __fastcall
66 #endif
67 #else
68 #define FASTCALL
69 #endif
70 #else
71 #define FASTCALL NTAPI
72 #endif
73
74 #if !defined(_M_CEE_PURE)
75 #define NTAPI_INLINE NTAPI
76 #else
77 #define NTAPI_INLINE
78 #endif
79
80 //
81 // Alignment Macros
82 //
83 #define ALIGN_DOWN(s, t) \
84 ((ULONG)(s) & ~(sizeof(t) - 1))
85
86 #define ALIGN_UP(s, t) \
87 (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
88
89 #define ALIGN_DOWN_POINTER(p, t) \
90 ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
91
92 #define ALIGN_UP_POINTER(p, t) \
93 (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
94
95 //
96 // Native API Return Value Macros
97 //
98 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
99 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
100 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
101 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
102
103 //
104 // Limits
105 //
106 #define MINCHAR 0x80
107 #define MAXCHAR 0x7f
108 #define MINSHORT 0x8000
109 #define MAXSHORT 0x7fff
110 #define MINLONG 0x80000000
111 #define MAXLONG 0x7fffffff
112 #define MAXUCHAR 0xff
113 #define MAXUSHORT 0xffff
114 #define MAXULONG 0xffffffff
115
116 //
117 // Basic Types that aren't defined in User-Mode Headers
118 //
119 typedef CONST int CINT;
120 typedef CONST char *PCSZ;
121 typedef ULONG CLONG;
122 typedef short CSHORT;
123 typedef CSHORT *PCSHORT;
124 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
125 typedef LONG KPRIORITY;
126
127 //
128 // Basic NT Types
129 //
130 #if !defined(_NTSECAPI_H) && !defined(_SUBAUTH_H) && !defined(_NTSECAPI_)
131
132 #if !defined(__BCRYPT_H__) && !defined(__WINE_BCRYPT_H)
133 typedef _Return_type_success_(return >= 0) long NTSTATUS, *PNTSTATUS;
134 #endif
135
136 typedef struct _UNICODE_STRING
137 {
138 USHORT Length;
139 USHORT MaximumLength;
140 PWSTR Buffer;
141 } UNICODE_STRING, *PUNICODE_STRING;
142
143 typedef struct _STRING
144 {
145 USHORT Length;
146 USHORT MaximumLength;
147 PCHAR Buffer;
148 } STRING, *PSTRING;
149
150 typedef struct _CSTRING
151 {
152 USHORT Length;
153 USHORT MaximumLength;
154 CONST CHAR *Buffer;
155 } CSTRING, *PCSTRING;
156
157 #endif
158
159 typedef struct _STRING32 {
160 USHORT Length;
161 USHORT MaximumLength;
162 ULONG Buffer;
163 } STRING32, *PSTRING32,
164 UNICODE_STRING32, *PUNICODE_STRING32,
165 ANSI_STRING32, *PANSI_STRING32;
166
167 typedef struct _STRING64 {
168 USHORT Length;
169 USHORT MaximumLength;
170 ULONGLONG Buffer;
171 } STRING64, *PSTRING64,
172 UNICODE_STRING64, *PUNICODE_STRING64,
173 ANSI_STRING64, *PANSI_STRING64;
174
175
176 typedef struct _OBJECT_ATTRIBUTES
177 {
178 ULONG Length;
179 HANDLE RootDirectory;
180 PUNICODE_STRING ObjectName;
181 ULONG Attributes;
182 PVOID SecurityDescriptor;
183 PVOID SecurityQualityOfService;
184 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
185
186 //
187 // ClientID Structure
188 //
189 typedef struct _CLIENT_ID
190 {
191 HANDLE UniqueProcess;
192 HANDLE UniqueThread;
193 } CLIENT_ID, *PCLIENT_ID;
194
195 typedef const UNICODE_STRING* PCUNICODE_STRING;
196 typedef STRING ANSI_STRING;
197 typedef PSTRING PANSI_STRING;
198 typedef STRING OEM_STRING;
199 typedef PSTRING POEM_STRING;
200 typedef CONST STRING* PCOEM_STRING;
201 typedef STRING CANSI_STRING;
202 typedef PSTRING PCANSI_STRING;
203
204 #endif