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