[PSDK][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 // 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 #ifndef __BCRYPT_H__
132 typedef LONG NTSTATUS, *PNTSTATUS;
133 #endif
134
135 typedef struct _UNICODE_STRING
136 {
137 USHORT Length;
138 USHORT MaximumLength;
139 PWSTR Buffer;
140 } UNICODE_STRING, *PUNICODE_STRING;
141
142 typedef struct _STRING
143 {
144 USHORT Length;
145 USHORT MaximumLength;
146 PCHAR Buffer;
147 } STRING, *PSTRING;
148
149 typedef struct _CSTRING
150 {
151 USHORT Length;
152 USHORT MaximumLength;
153 CONST CHAR *Buffer;
154 } CSTRING, *PCSTRING;
155
156 #endif
157
158 typedef struct _STRING32 {
159 USHORT Length;
160 USHORT MaximumLength;
161 ULONG Buffer;
162 } STRING32, *PSTRING32,
163 UNICODE_STRING32, *PUNICODE_STRING32,
164 ANSI_STRING32, *PANSI_STRING32;
165
166 typedef struct _STRING64 {
167 USHORT Length;
168 USHORT MaximumLength;
169 ULONGLONG Buffer;
170 } STRING64, *PSTRING64,
171 UNICODE_STRING64, *PUNICODE_STRING64,
172 ANSI_STRING64, *PANSI_STRING64;
173
174
175 typedef struct _OBJECT_ATTRIBUTES
176 {
177 ULONG Length;
178 HANDLE RootDirectory;
179 PUNICODE_STRING ObjectName;
180 ULONG Attributes;
181 PVOID SecurityDescriptor;
182 PVOID SecurityQualityOfService;
183 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
184
185 //
186 // ClientID Structure
187 //
188 typedef struct _CLIENT_ID
189 {
190 HANDLE UniqueProcess;
191 HANDLE UniqueThread;
192 } CLIENT_ID, *PCLIENT_ID;
193
194 typedef const UNICODE_STRING* PCUNICODE_STRING;
195 typedef STRING ANSI_STRING;
196 typedef PSTRING PANSI_STRING;
197 typedef STRING OEM_STRING;
198 typedef PSTRING POEM_STRING;
199 typedef CONST STRING* PCOEM_STRING;
200 typedef STRING CANSI_STRING;
201 typedef PSTRING PCANSI_STRING;
202
203 #endif