Sync with trunk r43123
[reactos.git] / reactos / dll / win32 / user32 / include / user32.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS System Libraries
4 * FILE: lib/user32/include/user32.h
5 * PURPOSE: Win32 User Library
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 /* C Headers */
12 #include <assert.h>
13 #include <stdio.h>
14 #include <math.h>
15
16 /* SDK/NDK Headers */
17 #define _USER32_
18 #define OEMRESOURCE
19 #define NTOS_MODE_USER
20 #define WIN32_NO_STATUS
21 #include <windows.h>
22 #include <winuser.h>
23 #include <windowsx.h>
24 #include <winnls32.h>
25 #include <ndk/ntndk.h>
26 #include <ddk/ntstatus.h>
27
28 /* CSRSS Headers */
29 #include <csrss/csrss.h>
30
31 /* Public Win32K Headers */
32 #include <win32k/ntusrtyp.h>
33 #include <win32k/ntuser.h>
34 #include <win32k/callback.h>
35
36 /* WINE Headers */
37 #include <wine/unicode.h>
38
39 /* Internal User32 Headers */
40 #include "user32p.h"
41
42 /* SEH Support with PSEH */
43 #include <pseh/pseh2.h>
44
45 /* Temporarily in here for now. */
46 typedef struct _USERAPIHOOKINFO
47 {
48 DWORD m_size;
49 LPCWSTR m_dllname1;
50 LPCWSTR m_funname1;
51 LPCWSTR m_dllname2;
52 LPCWSTR m_funname2;
53 } USERAPIHOOKINFO,*PUSERAPIHOOKINFO;
54
55 typedef LRESULT(CALLBACK *WNDPROC_OWP)(HWND,UINT,WPARAM,LPARAM,ULONG_PTR,PDWORD);
56
57 typedef struct _UAHOWP
58 {
59 BYTE* MsgBitArray;
60 DWORD Size;
61 } UAHOWP, *PUAHOWP;
62
63 typedef struct tagUSERAPIHOOK
64 {
65 DWORD size;
66 WNDPROC DefWindowProcA;
67 WNDPROC DefWindowProcW;
68 UAHOWP DefWndProcArray;
69 FARPROC GetScrollInfo;
70 FARPROC SetScrollInfo;
71 FARPROC EnableScrollBar;
72 FARPROC AdjustWindowRectEx;
73 FARPROC SetWindowRgn;
74 WNDPROC_OWP PreWndProc;
75 WNDPROC_OWP PostWndProc;
76 UAHOWP WndProcArray;
77 WNDPROC_OWP PreDefDlgProc;
78 WNDPROC_OWP PostDefDlgProc;
79 UAHOWP DlgProcArray;
80 FARPROC GetSystemMetrics;
81 FARPROC SystemParametersInfoA;
82 FARPROC SystemParametersInfoW;
83 FARPROC ForceResetUserApiHook;
84 FARPROC DrawFrameControl;
85 FARPROC DrawCaption;
86 FARPROC MDIRedrawFrame;
87 FARPROC GetRealWindowOwner;
88 } USERAPIHOOK, *PUSERAPIHOOK;
89
90 typedef enum _UAPIHK
91 {
92 uahLoadInit,
93 uahStop,
94 uahShutdown
95 } UAPIHK, *PUAPIHK;
96
97 extern RTL_CRITICAL_SECTION gcsUserApiHook;
98 extern USERAPIHOOK guah;
99 typedef DWORD (CALLBACK * USERAPIHOOKPROC)(UAPIHK State, ULONG_PTR Info);
100 BOOL FASTCALL BeginIfHookedUserApiHook(VOID);
101 BOOL FASTCALL EndUserApiHook(VOID);
102 BOOL FASTCALL IsInsideUserApiHook(VOID);
103 VOID FASTCALL ResetUserApiHook(PUSERAPIHOOK);
104 BOOL FASTCALL IsMsgOverride(UINT,PUAHOWP);
105
106 #define LOADUSERAPIHOOK \
107 if (!gfServerProcess && \
108 !IsInsideUserApiHook() && \
109 (gpsi->dwSRVIFlags & SRVINFO_APIHOOK) && \
110 !RtlIsThreadWithinLoaderCallout()) \
111 { \
112 NtUserCallNoParam(NOPARAM_ROUTINE_LOADUSERAPIHOOK); \
113 } \
114
115 /* FIXME: Use ntgdi.h then cleanup... */
116 LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *);
117 BOOL FASTCALL IsMetaFile(HDC);
118
119 extern PPROCESSINFO g_ppi;
120 extern ULONG_PTR g_ulSharedDelta;
121 extern PSERVERINFO gpsi;
122 extern BOOL gfServerProcess;
123
124 static __inline PVOID
125 SharedPtrToUser(PVOID Ptr)
126 {
127 ASSERT(Ptr != NULL);
128 ASSERT(g_ulSharedDelta != 0);
129 return (PVOID)((ULONG_PTR)Ptr - g_ulSharedDelta);
130 }
131
132 static __inline PVOID
133 DesktopPtrToUser(PVOID Ptr)
134 {
135 PCLIENTINFO pci;
136 PDESKTOPINFO pdi;
137 GetW32ThreadInfo();
138 pci = GetWin32ClientInfo();
139 pdi = pci->pDeskInfo;
140
141 ASSERT(Ptr != NULL);
142 ASSERT(pdi != NULL);
143 if ((ULONG_PTR)Ptr >= (ULONG_PTR)pdi->pvDesktopBase &&
144 (ULONG_PTR)Ptr < (ULONG_PTR)pdi->pvDesktopLimit)
145 {
146 return (PVOID)((ULONG_PTR)Ptr - pci->ulClientDelta);
147 }
148 else
149 {
150 /* NOTE: This is slow as it requires a call to win32k. This should only be
151 neccessary if a thread wants to access an object on a different
152 desktop */
153 return (PVOID)NtUserGetDesktopMapping(Ptr);
154 }
155 }
156
157 static __inline PVOID
158 SharedPtrToKernel(PVOID Ptr)
159 {
160 ASSERT(Ptr != NULL);
161 ASSERT(g_ulSharedDelta != 0);
162 return (PVOID)((ULONG_PTR)Ptr + g_ulSharedDelta);
163 }
164
165 static __inline BOOL
166 IsThreadHooked(PCLIENTINFO pci)
167 {
168 return pci->fsHooks != 0;
169 }
170
171 static __inline PDESKTOPINFO
172 GetThreadDesktopInfo(VOID)
173 {
174 PTHREADINFO ti;
175 PDESKTOPINFO di = NULL;
176
177 ti = GetW32ThreadInfo();
178 if (ti != NULL)
179 di = GetWin32ClientInfo()->pDeskInfo;
180
181 return di;
182 }
183
184 PCALLPROCDATA FASTCALL ValidateCallProc(HANDLE hCallProc);
185 PWND FASTCALL ValidateHwnd(HWND hwnd);
186 PWND FASTCALL ValidateHwndOrDesk(HWND hwnd);
187 PWND FASTCALL GetThreadDesktopWnd(VOID);
188 PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType);
189 PWND FASTCALL ValidateHwndNoErr(HWND hwnd);
190 VOID FASTCALL GetConnected(VOID);
191 BOOL FASTCALL DefSetText(HWND hWnd, PCWSTR String, BOOL Ansi);
192 BOOL FASTCALL TestWindowProcess(PWND);
193 VOID UserGetWindowBorders(DWORD, DWORD, SIZE *, BOOL);