- NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL...
[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 #undef WIN32_NO_STATUS
23 #define NTOS_MODE_USER
24
25 //
26 // Dependencies
27 //
28 #include <winioctl.h>
29 #include <ntnls.h>
30 #include <ntstatus.h>
31
32 //
33 // Compiler Definitions
34 //
35 #ifndef _MANAGED
36 #if defined(_M_IX86)
37 #define FASTCALL _fastcall
38 #else
39 #define FASTCALL
40 #endif
41 #else
42 #define FASTCALL NTAPI
43 #endif
44
45 #if !defined(_M_CEE_PURE)
46 #define NTAPI_INLINE NTAPI
47 #else
48 #define NTAPI_INLINE
49 #endif
50
51 //
52 // Alignment Macros
53 //
54 #define ALIGN_DOWN(s, t) \
55 ((ULONG)(s) & ~(sizeof(t) - 1))
56
57 #define ALIGN_UP(s, t) \
58 (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
59
60 #define ALIGN_DOWN_POINTER(p, t) \
61 ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
62
63 #define ALIGN_UP_POINTER(p, t) \
64 (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
65
66 //
67 // Native API Return Value Macros
68 //
69 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
70 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
71 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
72 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
73
74 //
75 // Limits
76 //
77 #define MINCHAR 0x80
78 #define MAXCHAR 0x7f
79 #define MINSHORT 0x8000
80 #define MAXSHORT 0x7fff
81 #define MINLONG 0x80000000
82 #define MAXLONG 0x7fffffff
83 #define MAXUCHAR 0xff
84 #define MAXUSHORT 0xffff
85 #define MAXULONG 0xffffffff
86
87 //
88 // CSR Macros
89 //
90 #define CSR_MAKE_OPCODE(s,m) ((s) << 16) | (m)
91 #define CSR_API_ID_FROM_OPCODE(n) ((ULONG)((USHORT)(n)))
92 #define CSR_SERVER_ID_FROM_OPCODE(n) (ULONG)((n) >> 16)
93
94 //
95 // Basic Types that aren't defined in User-Mode Headers
96 //
97 typedef CONST int CINT;
98 typedef CONST char *PCSZ;
99 typedef ULONG CLONG;
100 typedef short CSHORT;
101 typedef CSHORT *PCSHORT;
102 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
103 typedef LONG KPRIORITY;
104 typedef LONG NTSTATUS, *PNTSTATUS;
105
106 //
107 // Basic NT Types
108 //
109 #if !defined(_NTSECAPI_H) && !defined(_SUBAUTH_H) && !defined(_NTSECAPI_)
110
111 typedef struct _UNICODE_STRING
112 {
113 USHORT Length;
114 USHORT MaximumLength;
115 PWSTR Buffer;
116 } UNICODE_STRING, *PUNICODE_STRING;
117
118 typedef struct _STRING
119 {
120 USHORT Length;
121 USHORT MaximumLength;
122 PCHAR Buffer;
123 } STRING, *PSTRING;
124
125 #endif
126
127 typedef struct _OBJECT_ATTRIBUTES
128 {
129 ULONG Length;
130 HANDLE RootDirectory;
131 PUNICODE_STRING ObjectName;
132 ULONG Attributes;
133 PVOID SecurityDescriptor;
134 PVOID SecurityQualityOfService;
135 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
136
137 typedef const UNICODE_STRING* PCUNICODE_STRING;
138 typedef STRING ANSI_STRING;
139 typedef PSTRING PANSI_STRING;
140 typedef STRING OEM_STRING;
141 typedef PSTRING POEM_STRING;
142 typedef CONST STRING* PCOEM_STRING;
143 typedef STRING CANSI_STRING;
144 typedef PSTRING PCANSI_STRING;
145
146 #endif