886617134ff6452d5ced8b17f735632cd7a7763d
[reactos.git] / reactos / subsystems / win32 / win32k / w32k.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 <ntifs.h>
17 #include <ntddk.h>
18 #include <ntddmou.h>
19 #include <ntndk.h>
20
21 /* Win32 Headers */
22 /* FIXME: Defines in winbase.h that we need... */
23 typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
24 #define WINBASEAPI
25 #define STARTF_USESIZE 2
26 #define STARTF_USEPOSITION 4
27 #include <stdarg.h>
28 #include <windef.h>
29 #include <winerror.h>
30 #include <wingdi.h>
31 #include <winddi.h>
32 #include <winuser.h>
33 #include <prntfont.h>
34 #include <dde.h>
35 #include <wincon.h>
36 #define _NOCSECT_TYPE
37 #include <ddrawi.h>
38
39 /* SEH Support with PSEH */
40 #include <pseh/pseh.h>
41
42 /* CSRSS Header */
43 #include <csrss/csrss.h>
44
45 /* Helper Header */
46 #include <reactos/helper.h>
47
48 /* Probe and capture */
49 #include <reactos/probe.h>
50
51 /* Public Win32K Headers */
52 #include <win32k/callback.h>
53 #include <win32k/ntusrtyp.h>
54 #include <win32k/ntuser.h>
55 #include <win32k/ntgdityp.h>
56 #include <win32k/ntgdibad.h>
57 #include <ntgdi.h>
58
59 /* For access to SECTION_OBJECT. FIXME: Once compatible with NT, use NDK! */
60 #include <internal/mm.h>
61
62 /* Internal Win32K Header */
63 #include "include/win32k.h"
64
65 /* Undocumented stuff */
66 typedef DRIVEROBJ *PDRIVEROBJ;
67 #define WM_SYSTIMER 280
68 #ifndef M_PI
69 #define M_PI 3.14159265358979323846f
70 #define M_PI_2 1.57079632679489661923
71 #endif
72
73 /* User heap */
74 extern HANDLE GlobalUserHeap;
75
76 HANDLE
77 UserCreateHeap(OUT PSECTION_OBJECT *SectionObject,
78 IN OUT PVOID *SystemBase,
79 IN ULONG HeapSize);
80
81 static __inline PVOID
82 UserHeapAlloc(SIZE_T Bytes)
83 {
84 return RtlAllocateHeap(GlobalUserHeap,
85 HEAP_NO_SERIALIZE,
86 Bytes);
87 }
88
89 static __inline BOOL
90 UserHeapFree(PVOID lpMem)
91 {
92 return RtlFreeHeap(GlobalUserHeap,
93 HEAP_NO_SERIALIZE,
94 lpMem);
95 }
96
97 static __inline PVOID
98 UserHeapReAlloc(PVOID lpMem,
99 SIZE_T Bytes)
100 {
101 #if 0
102 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
103 return RtlReAllocateHeap(GlobalUserHeap,
104 HEAP_NO_SERIALIZE,
105 lpMem,
106 Bytes);
107 #else
108 SIZE_T PrevSize;
109 PVOID pNew;
110
111 PrevSize = RtlSizeHeap(GlobalUserHeap,
112 HEAP_NO_SERIALIZE,
113 lpMem);
114
115 if (PrevSize == Bytes)
116 return lpMem;
117
118 pNew = RtlAllocateHeap(GlobalUserHeap,
119 HEAP_NO_SERIALIZE,
120 Bytes);
121 if (pNew != NULL)
122 {
123 if (PrevSize < Bytes)
124 Bytes = PrevSize;
125
126 RtlCopyMemory(pNew,
127 lpMem,
128 Bytes);
129
130 RtlFreeHeap(GlobalUserHeap,
131 HEAP_NO_SERIALIZE,
132 lpMem);
133 }
134
135 return pNew;
136 #endif
137 }
138
139 static __inline PVOID
140 UserHeapAddressToUser(PVOID lpMem)
141 {
142 return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
143 (ULONG_PTR)PsGetWin32Process()->HeapMappings.UserMapping);
144 }
145
146 #endif /* __W32K_H */