ReactOS  r76032
typedefs.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Host Headers
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Type definitions and useful macros for host tools
5  * COPYRIGHT: Copyright 2007 Hervé Poussineau (hpoussin@reactos.org)
6  * Copyright 2007 Colin Finck (colin@reactos.org)
7  */
8 
9 #ifndef _TYPEDEFS_HOST_H
10 #define _TYPEDEFS_HOST_H
11 
12 #include <assert.h>
13 #include <stdlib.h>
14 #include <limits.h>
15 #include <stdint.h>
16 
17 /* Function attributes for GCC */
18 #if !defined(_MSC_VER) && !defined(__fastcall)
19 #define __fastcall __attribute__((fastcall))
20 #endif
21 #if !defined(_MSC_VER) && !defined(__cdecl)
22 #define __cdecl __attribute__((cdecl))
23 #endif
24 #if !defined(_MSC_VER) && !defined(__stdcall)
25 #define __stdcall __attribute__((stdcall))
26 #endif
27 
28 /* Basic definitions */
29 #define UNIMPLEMENTED { printf("%s unimplemented\n", __FUNCTION__); exit(1); }
30 #define ASSERT(x) assert(x)
31 #define ASSERTMSG(m, x) assert(x)
32 #define DPRINT if (0) printf
33 #define DPRINT1 printf
34 
35 #define NTAPI
36 #define WINAPI
37 
38 #define IN
39 #define OUT
40 #define OPTIONAL
41 
42 #define FALSE 0
43 #define TRUE 1
44 
45 #define ANYSIZE_ARRAY 1
46 
47 /* Basic types
48  Emulate a LLP64 memory model using a LP64 compiler */
49 typedef void VOID, *PVOID, *LPVOID;
50 typedef char CHAR, CCHAR, *PCHAR, *PSTR, *LPSTR;
51 typedef const char *PCSTR, *LPCSTR;
52 typedef unsigned char UCHAR, *PUCHAR, BYTE, *LPBYTE, BOOLEAN, *PBOOLEAN;
53 typedef int16_t SHORT, *PSHORT;
55 typedef const uint16_t *PCWSTR, *LPCWSTR;
58 #if defined(_LP64) || defined(_WIN64)
61 #else
64 #endif
67 typedef float FLOAT;
68 typedef double DOUBLE;
69 
70 /* Derived types */
71 typedef PVOID HANDLE;
72 #ifndef _HAVE_HKEY
73 typedef HANDLE HKEY, *PHKEY;
74 #endif
77 typedef LONG HRESULT;
79 typedef WORD LANGID;
80 
81 #define MAXUSHORT USHRT_MAX
82 
83 /* Widely used structures */
84 #include <pshpack4.h>
85 #ifndef _HAVE_RTL_BITMAP
86 typedef struct _RTL_BITMAP
87 {
91 
92 typedef struct _RTL_BITMAP_RUN
93 {
97 #endif
98 
99 #ifndef _HAVE_LARGE_INTEGER
100 typedef union _LARGE_INTEGER
101 {
102  struct
103  {
106  };
107  struct
108  {
109  ULONG LowPart;
110  LONG HighPart;
111  } u;
114 #endif
115 
116 #ifndef _HAVE_LIST_ENTRY
117 typedef struct _LIST_ENTRY
118 {
122 #endif
123 
124 #ifndef _HAVE_ANSI_STRING
125 typedef struct _ANSI_STRING
126 {
127  USHORT Length;
129  PSTR Buffer;
131 
132 typedef struct _UNICODE_STRING
133 {
134  USHORT Length;
136  PWSTR Buffer;
138 #endif
139 
140 #include <poppack.h>
141 
142 #ifndef _HAVE_LIST_ENTRY
143 /* List Functions */
144 static __inline
145 VOID
147  IN PLIST_ENTRY ListHead
148  )
149 {
150  ListHead->Flink = ListHead->Blink = ListHead;
151 }
152 
153 static __inline
154 VOID
156  IN PLIST_ENTRY ListHead,
157  IN PLIST_ENTRY Entry
158  )
159 {
160  PLIST_ENTRY OldFlink;
161  OldFlink = ListHead->Flink;
162  Entry->Flink = OldFlink;
163  Entry->Blink = ListHead;
164  OldFlink->Blink = Entry;
165  ListHead->Flink = Entry;
166 }
167 
168 static __inline
169 VOID
171  IN PLIST_ENTRY ListHead,
172  IN PLIST_ENTRY Entry
173  )
174 {
175  PLIST_ENTRY OldBlink;
176  OldBlink = ListHead->Blink;
177  Entry->Flink = ListHead;
178  Entry->Blink = OldBlink;
179  OldBlink->Flink = Entry;
180  ListHead->Blink = Entry;
181 }
182 
183 static __inline
184 BOOLEAN
186  IN const LIST_ENTRY * ListHead
187  )
188 {
189  return (BOOLEAN)(ListHead->Flink == ListHead);
190 }
191 
192 static __inline
193 BOOLEAN
195  IN PLIST_ENTRY Entry)
196 {
197  PLIST_ENTRY OldFlink;
198  PLIST_ENTRY OldBlink;
199 
200  OldFlink = Entry->Flink;
201  OldBlink = Entry->Blink;
202  OldFlink->Blink = OldBlink;
203  OldBlink->Flink = OldFlink;
204  return (BOOLEAN)(OldFlink == OldBlink);
205 }
206 
207 static __inline
208 PLIST_ENTRY
210  IN PLIST_ENTRY ListHead)
211 {
212  PLIST_ENTRY Flink;
213  PLIST_ENTRY Entry;
214 
215  Entry = ListHead->Flink;
216  Flink = Entry->Flink;
217  ListHead->Flink = Flink;
218  Flink->Blink = ListHead;
219  return Entry;
220 }
221 
222 static __inline
223 PLIST_ENTRY
225  IN PLIST_ENTRY ListHead)
226 {
227  PLIST_ENTRY Blink;
228  PLIST_ENTRY Entry;
229 
230  Entry = ListHead->Blink;
231  Blink = Entry->Blink;
232  ListHead->Blink = Blink;
233  Blink->Flink = ListHead;
234  return Entry;
235 }
236 #endif
237 
238 #ifndef _HAVE_ANSI_STRING
240 #endif
241 
242 /* Widely used macros */
243 #define LOBYTE(w) ((BYTE)(w))
244 #define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF))
245 #define LOWORD(l) ((WORD)((DWORD_PTR)(l)))
246 #define HIWORD(l) ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF))
247 #define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
248 #define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
249 
250 #define MAXULONG 0xFFFFFFFF
251 
252 #define NT_SUCCESS(x) ((x)>=0)
253 #if !defined(__GNUC__)
254 #define FIELD_OFFSET(t,f) ((LONG)(LONG_PTR)&(((t*) 0)->f))
255 #else
256 #define FIELD_OFFSET(t,f) ((LONG)__builtin_offsetof(t,f))
257 #endif
258 #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
259 #define CONTAINING_RECORD(address, type, field) ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field))))
260 
261 #define RtlZeroMemory(Destination, Length) memset(Destination, 0, Length)
262 #define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
263 #define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
264 
265 #define MAKELANGID(p,s) ((((WORD)(s))<<10)|(WORD)(p))
266 #define PRIMARYLANGID(l) ((WORD)(l)&0x3ff)
267 #define SUBLANGID(l) ((WORD)(l)>>10)
268 #define SUBLANG_NEUTRAL 0x00
269 
270 /* Prevent inclusion of some other headers */
271 #define __INTERNAL_DEBUG
272 #define RTL_H
273 
274 #endif
275 
struct _LIST_ENTRY * PLIST_ENTRY
DWORD *typedef PVOID
Definition: winlogon.h:52
char * PSTR
Definition: typedefs.h:50
PULONG Buffer
Definition: typedefs.h:89
int32_t * PLONG
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
static __inline VOID InsertTailList(IN PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry)
Definition: typedefs.h:170
unsigned short WORD
Definition: ntddk_ex.h:93
uint32_t UINT32
Definition: typedefs.h:57
int32_t BOOL
Definition: typedefs.h:56
struct _RTL_BITMAP RTL_BITMAP
struct _Entry Entry
Definition: kefuncs.h:640
struct _UNICODE_STRING * PUNICODE_STRING
uint32_t UINT
Definition: typedefs.h:57
USHORT MaximumLength
Definition: env_spec_w32.h:370
struct _LIST_ENTRY LIST_ENTRY
void VOID
Definition: typedefs.h:49
uint32_t DWORD
Definition: typedefs.h:57
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
uint32_t * PULONG
Definition: typedefs.h:57
const char * PCSTR
Definition: typedefs.h:51
int16_t SHORT
Definition: typedefs.h:53
unsigned char * LPBYTE
Definition: typedefs.h:52
struct _RTL_BITMAP_RUN RTL_BITMAP_RUN
uint16_t * PWORD
Definition: typedefs.h:54
HANDLE * PHKEY
Definition: typedefs.h:73
PVOID *typedef PWSTR
Definition: winlogon.h:57
char CHAR
Definition: typedefs.h:50
uint32_t * LPUINT
Definition: typedefs.h:57
int32_t * PLONG_PTR
Definition: typedefs.h:62
static __inline PLIST_ENTRY RemoveHeadList(IN PLIST_ENTRY ListHead)
Definition: typedefs.h:209
unsigned char BOOLEAN
Definition: typedefs.h:52
WORD LANGID
Definition: typedefs.h:79
uint16_t * PWCHAR
Definition: typedefs.h:54
unsigned short int uint16_t
Definition: acefiex.h:54
int32_t INT_PTR
Definition: typedefs.h:62
char * PCHAR
Definition: typedefs.h:50
uint16_t * LPWSTR
Definition: typedefs.h:54
int32_t LONG
Definition: typedefs.h:56
uint16_t WCHAR
Definition: typedefs.h:54
struct _RTL_BITMAP_RUN * PRTL_BITMAP_RUN
int32_t INT
Definition: typedefs.h:56
struct _LARGE_INTEGER::@2037 u
uint32_t ULONG_PTR
Definition: typedefs.h:63
static __inline VOID InsertHeadList(IN PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry)
Definition: typedefs.h:155
struct _UNICODE_STRING UNICODE_STRING
uint16_t UINT16
Definition: typedefs.h:54
uint16_t * PUSHORT
Definition: typedefs.h:54
ULONG_PTR * PSIZE_T
Definition: typedefs.h:78
unsigned char * PUCHAR
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
uint32_t * PUINT_PTR
Definition: typedefs.h:63
uint64_t ULONG64
Definition: typedefs.h:65
const char * LPCSTR
Definition: typedefs.h:51
void * PVOID
Definition: typedefs.h:49
void * LPVOID
Definition: typedefs.h:49
USHORT MaximumLength
Definition: env_spec_w32.h:377
int64_t LONGLONG
Definition: typedefs.h:66
unsigned char UCHAR
Definition: typedefs.h:52
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
int64_t LONG64
Definition: typedefs.h:66
unsigned char BOOLEAN
static __inline BOOLEAN IsListEmpty(IN const LIST_ENTRY *ListHead)
Definition: typedefs.h:185
int32_t WINBOOL
Definition: typedefs.h:56
LONG HRESULT
Definition: typedefs.h:77
char CCHAR
Definition: typedefs.h:50
INT POOL_TYPE
Definition: typedefs.h:76
uint64_t UINT64
Definition: typedefs.h:65
uint64_t ULONGLONG
Definition: typedefs.h:65
int16_t * PSHORT
Definition: typedefs.h:53
ULONG NumberOfBits
Definition: typedefs.h:95
HANDLE HINSTANCE
Definition: typedefs.h:75
union _LARGE_INTEGER LARGE_INTEGER
uint32_t * PUINT
Definition: typedefs.h:57
uint16_t WORD
Definition: typedefs.h:54
INT NTSTATUS
Definition: typedefs.h:76
ULONG SizeOfBitMap
Definition: typedefs.h:88
ULONG LowPart
Definition: typedefs.h:104
Definition: typedefs.h:117
uint32_t DWORD_PTR
Definition: typedefs.h:63
unsigned char * PBOOLEAN
Definition: typedefs.h:52
ULONG StartingIndex
Definition: typedefs.h:94
INT32 int32_t
Definition: types.h:71
uint16_t * LPWORD
Definition: typedefs.h:54
ULONG_PTR SIZE_T
Definition: typedefs.h:78
uint32_t UINT_PTR
Definition: typedefs.h:63
int32_t * LPLONG
Definition: typedefs.h:56
DWORD *typedef HANDLE
Definition: winlogon.h:52
PVOID HANDLE
Definition: typedefs.h:71
UINT64 uint64_t
Definition: types.h:77
uint64_t DWORD64
Definition: typedefs.h:65
struct _ANSI_STRING * PANSI_STRING
unsigned short USHORT
Definition: pedump.c:61
signed char * PSTR
Definition: retypes.h:7
uint16_t * PWSTR
Definition: typedefs.h:54
static __inline PLIST_ENTRY RemoveTailList(IN PLIST_ENTRY ListHead)
Definition: typedefs.h:224
unsigned int * PULONG
Definition: retypes.h:1
struct _RTL_BITMAP * PRTL_BITMAP
const uint16_t * LPCWSTR
Definition: typedefs.h:55
UINT32 uint32_t
Definition: types.h:75
struct _ANSI_STRING ANSI_STRING
HANDLE HMODULE
Definition: typedefs.h:75
unsigned char BYTE
Definition: typedefs.h:52
const UNICODE_STRING * PCUNICODE_STRING
Definition: typedefs.h:239
static __inline VOID InitializeListHead(IN PLIST_ENTRY ListHead)
Definition: typedefs.h:146
float FLOAT
Definition: typedefs.h:67
uint32_t * LPDWORD
Definition: typedefs.h:57
uint32_t * PDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
static __inline BOOLEAN RemoveEntryList(IN PLIST_ENTRY Entry)
Definition: typedefs.h:194
uint64_t * PDWORD64
Definition: typedefs.h:65
double DOUBLE
Definition: typedefs.h:68
HANDLE HKEY
Definition: typedefs.h:73
uint32_t * PULONG_PTR
Definition: typedefs.h:63
INT16 int16_t
Definition: types.h:70
uint32_t ULONG
Definition: typedefs.h:57
int32_t LONG_PTR
Definition: typedefs.h:62
INT64 int64_t
Definition: types.h:72
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:82
base of all file and directory entries
Definition: entries.h:82
uint16_t USHORT
Definition: typedefs.h:54
int32_t * PINT_PTR
Definition: typedefs.h:62
LONGLONG QuadPart
Definition: typedefs.h:112
char * LPSTR
Definition: typedefs.h:50