- Add DDK alignment macros and move/rename the ones in the NDK for user-mode only...
[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 #if !defined(_NTSYSTEM_)
52 #define NTSYSAPI DECLSPEC_IMPORT
53 #define NTSYSCALLAPI DECLSPEC_IMPORT
54 #else
55 #define NTSYSAPI
56 #if defined(_NTDLLBUILD_)
57 #define NTSYSCALLAPI
58 #else
59 #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
60 #endif
61 #endif
62
63 //
64 // Alignment Macros
65 //
66 #define ALIGN_DOWN(s, t) \
67 ((ULONG)(s) & ~(sizeof(t) - 1))
68
69 #define ALIGN_UP(s, t) \
70 (ALIGN_DOWN(((ULONG)(s) + sizeof(t) - 1), t))
71
72 #define ALIGN_DOWN_POINTER(p, t) \
73 ((PVOID)((ULONG_PTR)(p) & ~((ULONG_PTR)sizeof(t) - 1)))
74
75 #define ALIGN_UP_POINTER(p, t) \
76 (ALIGN_DOWN_POINTER(((ULONG_PTR)(p) + sizeof(t) - 1), t))
77
78 //
79 // Native API Return Value Macros
80 //
81 #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
82 #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1)
83 #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2)
84 #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3)
85
86 //
87 // Limits
88 //
89 #define MINCHAR 0x80
90 #define MAXCHAR 0x7f
91 #define MINSHORT 0x8000
92 #define MAXSHORT 0x7fff
93 #define MINLONG 0x80000000
94 #define MAXLONG 0x7fffffff
95 #define MAXUCHAR 0xff
96 #define MAXUSHORT 0xffff
97 #define MAXULONG 0xffffffff
98
99 //
100 // Basic Types that aren't defined in User-Mode Headers
101 //
102 typedef CONST int CINT;
103 typedef CONST char *PCSZ;
104 typedef ULONG CLONG;
105 typedef short CSHORT;
106 typedef CSHORT *PCSHORT;
107 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
108 typedef LONG KPRIORITY;
109 typedef LONG NTSTATUS, *PNTSTATUS;
110
111 //
112 // Basic NT Types
113 //
114 #if !defined(_NTSECAPI_H) && !defined(_SUBAUTH_H)
115
116 typedef struct _UNICODE_STRING
117 {
118 USHORT Length;
119 USHORT MaximumLength;
120 PWSTR Buffer;
121 } UNICODE_STRING, *PUNICODE_STRING;
122 typedef const UNICODE_STRING* PCUNICODE_STRING;
123
124 typedef struct _STRING
125 {
126 USHORT Length;
127 USHORT MaximumLength;
128 PCHAR Buffer;
129 } STRING, *PSTRING;
130
131 typedef struct _OBJECT_ATTRIBUTES
132 {
133 ULONG Length;
134 HANDLE RootDirectory;
135 PUNICODE_STRING ObjectName;
136 ULONG Attributes;
137 PVOID SecurityDescriptor;
138 PVOID SecurityQualityOfService;
139 } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
140 #endif
141
142 typedef STRING ANSI_STRING;
143 typedef PSTRING PANSI_STRING;
144 typedef STRING OEM_STRING;
145 typedef PSTRING POEM_STRING;
146 typedef CONST STRING* PCOEM_STRING;
147 typedef STRING CANSI_STRING;
148 typedef PSTRING PCANSI_STRING;
149
150 #endif