[CMAKE]
[reactos.git] / subsystems / win32 / win32k / pch.h
1 #ifndef __W32K_H
2 #define __W32K_H
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS Graphics Subsystem
6 * FILE: subsys/win32k/w32k.h
7 * PURPOSE: Main Win32K Header
8 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #define _NO_COM
14
15 /* DDK/NDK/SDK Headers */
16 #include <ntddk.h>
17 #include <ntddmou.h>
18 #include <ntifs.h>
19 #include <tvout.h>
20 #include <ntndk.h>
21
22 /* Win32 Headers */
23 /* FIXME: Defines in winbase.h that we need... */
24 typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
25 #define WINBASEAPI
26 #define STARTF_USESIZE 2
27 #define STARTF_USEPOSITION 4
28 #include <stdarg.h>
29 #include <windef.h>
30
31 /* Avoid type casting, by defining RECT to RECTL */
32 #define RECT RECTL
33 #define PRECT PRECTL
34 #define LPRECT LPRECTL
35 #define LPCRECT LPCRECTL
36 #define POINT POINTL
37 #define LPPOINT PPOINTL
38 #define PPOINT PPOINTL
39
40 #include <winerror.h>
41 #include <wingdi.h>
42 #define NT_BUILD_ENVIRONMENT
43 #include <winddi.h>
44 #include <winuser.h>
45 #include <prntfont.h>
46 #include <dde.h>
47 #include <wincon.h>
48 #define _NOCSECT_TYPE
49 #include <ddrawi.h>
50
51 /* SEH Support with PSEH */
52 #include <pseh/pseh2.h>
53
54 /* CSRSS Header */
55 #include <csrss/csrss.h>
56
57 /* Public Win32K Headers */
58 #include <win32k/callback.h>
59 #include <win32k/ntusrtyp.h>
60 #include <win32k/ntuser.h>
61 #include <win32k/ntgdityp.h>
62 #include <win32k/ntgdibad.h>
63 #include <ntgdi.h>
64
65 /* Undocumented user definitions */
66 #include <undocuser.h>
67
68 /* Internal Win32K Header */
69 #include "include/win32kp.h"
70
71 /* Undocumented stuff */
72 typedef DRIVEROBJ *PDRIVEROBJ;
73
74 /* User heap */
75 extern HANDLE GlobalUserHeap;
76
77 PWIN32HEAP
78 UserCreateHeap(OUT PSECTION_OBJECT *SectionObject,
79 IN OUT PVOID *SystemBase,
80 IN SIZE_T HeapSize);
81
82 static __inline PVOID
83 UserHeapAlloc(SIZE_T Bytes)
84 {
85 return RtlAllocateHeap(GlobalUserHeap,
86 HEAP_NO_SERIALIZE,
87 Bytes);
88 }
89
90 static __inline BOOL
91 UserHeapFree(PVOID lpMem)
92 {
93 return RtlFreeHeap(GlobalUserHeap,
94 HEAP_NO_SERIALIZE,
95 lpMem);
96 }
97
98 static __inline PVOID
99 UserHeapReAlloc(PVOID lpMem,
100 SIZE_T Bytes)
101 {
102 #if 0
103 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
104 return RtlReAllocateHeap(GlobalUserHeap,
105 HEAP_NO_SERIALIZE,
106 lpMem,
107 Bytes);
108 #else
109 SIZE_T PrevSize;
110 PVOID pNew;
111
112 PrevSize = RtlSizeHeap(GlobalUserHeap,
113 HEAP_NO_SERIALIZE,
114 lpMem);
115
116 if (PrevSize == Bytes)
117 return lpMem;
118
119 pNew = RtlAllocateHeap(GlobalUserHeap,
120 HEAP_NO_SERIALIZE,
121 Bytes);
122 if (pNew != NULL)
123 {
124 if (PrevSize < Bytes)
125 Bytes = PrevSize;
126
127 RtlCopyMemory(pNew,
128 lpMem,
129 Bytes);
130
131 RtlFreeHeap(GlobalUserHeap,
132 HEAP_NO_SERIALIZE,
133 lpMem);
134 }
135
136 return pNew;
137 #endif
138 }
139
140 static __inline PVOID
141 UserHeapAddressToUser(PVOID lpMem)
142 {
143 PPROCESSINFO W32Process = PsGetCurrentProcessWin32Process();
144 return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
145 (ULONG_PTR)W32Process->HeapMappings.UserMapping);
146 }
147
148 #define ROUND_DOWN(n, align) \
149 (((ULONG)n) & ~((align) - 1l))
150
151 #define ROUND_UP(n, align) \
152 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
153
154 #define LIST_FOR_EACH(elem, list, type, field) \
155 for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \
156 &(elem)->field != (list) && ((&((elem)->field)) != NULL); \
157 (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field))
158
159 #define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \
160 for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \
161 (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \
162 &(cursor)->field != (list) && ((&((cursor)->field)) != NULL); \
163 (cursor) = (cursor2), \
164 (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field))
165
166 #endif /* __W32K_H */