We should always allocate in NdrConformantStringUnmarshal if the
[wine.git] / dlls / user / user_private.h
blob5d205aa8a1284581ed1eaac75c223f6ef57694a8
1 /*
2 * USER private definitions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_USER_PRIVATE_H
22 #define __WINE_USER_PRIVATE_H
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "winternl.h"
31 #include "wine/windef16.h"
32 #include "wine/winbase16.h"
34 extern WORD USER_HeapSel;
36 static inline HLOCAL16 LOCAL_Alloc( HANDLE16 ds, UINT16 flags, WORD size )
38 STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
39 HANDLE16 oldDS = stack16->ds;
40 HLOCAL16 ret;
42 stack16->ds = ds;
43 ret = LocalAlloc16 (flags, size);
44 stack16->ds = oldDS;
45 return ret;
48 static inline HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, WORD size, UINT16 flags )
50 STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
51 HANDLE16 oldDS = stack16->ds;
52 HLOCAL16 ret;
54 stack16->ds = ds;
55 ret = LocalReAlloc16 (handle, size, flags);
56 stack16->ds = oldDS;
57 return ret;
60 static inline HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle )
62 STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
63 HANDLE16 oldDS = stack16->ds;
64 HLOCAL16 ret;
66 stack16->ds = ds;
67 ret = LocalFree16 (handle);
68 stack16->ds = oldDS;
69 return ret;
72 #define USER_HEAP_ALLOC(size) \
73 ((HANDLE)(ULONG_PTR)LOCAL_Alloc( USER_HeapSel, LMEM_FIXED, (size) ))
74 #define USER_HEAP_REALLOC(handle,size) \
75 ((HANDLE)(ULONG_PTR)LOCAL_ReAlloc( USER_HeapSel, LOWORD(handle), (size), LMEM_FIXED ))
76 #define USER_HEAP_FREE(handle) \
77 LOCAL_Free( USER_HeapSel, LOWORD(handle) )
78 #define USER_HEAP_LIN_ADDR(handle) \
79 ((handle) ? MapSL(MAKESEGPTR(USER_HeapSel, LOWORD(handle))) : NULL)
81 #define GET_WORD(ptr) (*(const WORD *)(ptr))
82 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
84 /* internal messages codes */
85 enum wine_internal_message
87 WM_WINE_DESTROYWINDOW = 0x80000000,
88 WM_WINE_SETWINDOWPOS,
89 WM_WINE_SHOWWINDOW,
90 WM_WINE_SETPARENT,
91 WM_WINE_SETWINDOWLONG,
92 WM_WINE_ENABLEWINDOW,
93 WM_WINE_SETACTIVEWINDOW,
94 WM_WINE_KEYBOARD_LL_HOOK,
95 WM_WINE_MOUSE_LL_HOOK,
96 WM_WINE_FIRST_DRIVER_MSG = 0x80001000, /* range of messages reserved for the USER driver */
97 WM_WINE_LAST_DRIVER_MSG = 0x80001fff
100 struct tagCURSORICONINFO;
102 typedef struct tagUSER_DRIVER {
103 /* keyboard functions */
104 HKL (*pActivateKeyboardLayout)(HKL, UINT);
105 void (*pBeep)(void);
106 SHORT (*pGetAsyncKeyState)(INT);
107 INT (*pGetKeyNameText)(LONG, LPWSTR, INT);
108 HKL (*pGetKeyboardLayout)(DWORD);
109 UINT (*pGetKeyboardLayoutList)(INT, HKL *);
110 BOOL (*pGetKeyboardLayoutName)(LPWSTR);
111 HKL (*pLoadKeyboardLayout)(LPCWSTR, UINT);
112 UINT (*pMapVirtualKeyEx)(UINT, UINT, HKL);
113 UINT (*pSendInput)(UINT, LPINPUT, int);
114 INT (*pToUnicodeEx)(UINT, UINT, LPBYTE, LPWSTR, int, UINT, HKL);
115 BOOL (*pUnloadKeyboardLayout)(HKL);
116 SHORT (*pVkKeyScanEx)(WCHAR, HKL);
117 /* mouse functions */
118 void (*pSetCursor)(struct tagCURSORICONINFO *);
119 BOOL (*pGetCursorPos)(LPPOINT);
120 BOOL (*pSetCursorPos)(INT,INT);
121 /* screen saver functions */
122 BOOL (*pGetScreenSaveActive)(void);
123 void (*pSetScreenSaveActive)(BOOL);
124 /* clipboard functions */
125 void (*pAcquireClipboard)(HWND); /* Acquire selection */
126 BOOL (*pCountClipboardFormats)(void); /* Count available clipboard formats */
127 void (*pEmptyClipboard)(BOOL); /* Empty clipboard data */
128 void (*pEndClipboardUpdate)(void); /* End clipboard update */
129 UINT (*pEnumClipboardFormats)(UINT); /* Enumerate clipboard formats */
130 BOOL (*pGetClipboardData)(UINT, HANDLE16*, HANDLE*); /* Get specified selection data */
131 INT (*pGetClipboardFormatName)(UINT, LPWSTR, UINT); /* Get a clipboard format name */
132 BOOL (*pIsClipboardFormatAvailable)(UINT); /* Check if specified format is available */
133 UINT (*pRegisterClipboardFormat)(LPCWSTR); /* Register a clipboard format */
134 void (*pResetSelectionOwner)(HWND, BOOL);
135 BOOL (*pSetClipboardData)(UINT, HANDLE16, HANDLE, BOOL); /* Set specified selection data */
136 /* display modes */
137 LONG (*pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
138 BOOL (*pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
139 /* windowing functions */
140 BOOL (*pCreateDesktopWindow)(HWND);
141 BOOL (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL);
142 void (*pDestroyWindow)(HWND);
143 HDC (*pGetDCEx)(HWND,HRGN,DWORD);
144 DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
145 INT (*pReleaseDC)(HWND,HDC,BOOL);
146 BOOL (*pScrollDC)(HDC, INT, INT, const RECT *, const RECT *, HRGN, LPRECT);
147 void (*pSetFocus)(HWND);
148 HWND (*pSetParent)(HWND,HWND);
149 BOOL (*pSetWindowPos)(WINDOWPOS *);
150 int (*pSetWindowRgn)(HWND,HRGN,BOOL);
151 void (*pSetWindowIcon)(HWND,UINT,HICON);
152 void (*pSetWindowStyle)(HWND,DWORD);
153 void (*pSetWindowText)(HWND,LPCWSTR);
154 BOOL (*pShowWindow)(HWND,INT);
155 void (*pSysCommandSizeMove)(HWND,WPARAM);
156 HWND (*pWindowFromDC)(HDC);
157 LRESULT (*pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
158 } USER_DRIVER;
160 extern const USER_DRIVER *USER_Driver;
162 extern void USER_unload_driver(void);
164 struct received_message_info;
165 struct hook16_queue_info;
167 /* this is the structure stored in TEB->Win32ClientInfo */
168 /* no attempt is made to keep the layout compatible with the Windows one */
169 struct user_thread_info
171 HANDLE server_queue; /* 00 Handle to server-side queue */
172 DWORD recursion_count; /* 04 SendMessage recursion counter */
173 HHOOK hook; /* 08 Current hook */
174 struct received_message_info *receive_info; /* 0c Message being currently received */
175 struct hook16_queue_info *hook16_info; /* 10 Opaque pointer for 16-bit hook support */
176 DWORD GetMessageTimeVal; /* 14 Value for GetMessageTime */
177 DWORD GetMessagePosVal; /* 18 Value for GetMessagePos */
178 DWORD GetMessageExtraInfoVal; /* 1c Value for GetMessageExtraInfo */
179 HCURSOR cursor; /* 20 Current cursor */
180 INT cursor_count; /* 24 Cursor show count */
181 UINT active_hooks; /* 28 Bitmap of active hooks */
182 HWND desktop; /* 2c Desktop window */
183 /* 30-7c Available for more data */
186 static inline struct user_thread_info *get_user_thread_info(void)
188 return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
191 /* check if hwnd is a broadcast magic handle */
192 static inline BOOL is_broadcast( HWND hwnd )
194 return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
197 extern HMODULE user32_module;
198 extern DWORD USER16_AlertableWait;
199 extern HBRUSH SYSCOLOR_55AABrush;
201 extern BOOL CLIPBOARD_ReleaseOwner(void);
202 extern BOOL FOCUS_MouseActivate( HWND hwnd );
203 extern BOOL HOOK_IsHooked( INT id );
204 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
205 UINT msg, WPARAM wparam, LPARAM lparam,
206 UINT flags, UINT timeout, PDWORD_PTR res_ptr );
207 extern HPEN SYSCOLOR_GetPen( INT index );
208 extern void SYSPARAMS_Init(void);
209 extern void USER_CheckNotLock(void);
210 extern BOOL USER_IsExitingThread( DWORD tid );
212 /* message spy definitions */
214 #define SPY_DISPATCHMESSAGE16 0x0100
215 #define SPY_DISPATCHMESSAGE 0x0101
216 #define SPY_SENDMESSAGE16 0x0102
217 #define SPY_SENDMESSAGE 0x0103
218 #define SPY_DEFWNDPROC16 0x0104
219 #define SPY_DEFWNDPROC 0x0105
221 #define SPY_RESULT_OK16 0x0000
222 #define SPY_RESULT_OK 0x0001
223 #define SPY_RESULT_INVALIDHWND16 0x0002
224 #define SPY_RESULT_INVALIDHWND 0x0003
225 #define SPY_RESULT_DEFWND16 0x0004
226 #define SPY_RESULT_DEFWND 0x0005
228 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd );
229 extern const char *SPY_GetVKeyName(WPARAM wParam);
230 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
231 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
232 LRESULT lReturn, WPARAM wParam, LPARAM lParam );
233 extern int SPY_Init(void);
235 /* HANDLE16 <-> HANDLE conversions */
236 #define HCURSOR_16(h32) (LOWORD(h32))
237 #define HICON_16(h32) (LOWORD(h32))
238 #define HINSTANCE_16(h32) (LOWORD(h32))
240 #define HCURSOR_32(h16) ((HCURSOR)(ULONG_PTR)(h16))
241 #define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
242 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
243 #define HMODULE_32(h16) ((HMODULE)(ULONG_PTR)(h16))
245 #include "pshpack1.h"
247 typedef struct
249 BYTE bWidth;
250 BYTE bHeight;
251 BYTE bColorCount;
252 BYTE bReserved;
253 } ICONRESDIR;
255 typedef struct
257 WORD wWidth;
258 WORD wHeight;
259 } CURSORDIR;
261 typedef struct
262 { union
263 { ICONRESDIR icon;
264 CURSORDIR cursor;
265 } ResInfo;
266 WORD wPlanes;
267 WORD wBitCount;
268 DWORD dwBytesInRes;
269 WORD wResId;
270 } CURSORICONDIRENTRY;
272 typedef struct
274 WORD idReserved;
275 WORD idType;
276 WORD idCount;
277 CURSORICONDIRENTRY idEntries[1];
278 } CURSORICONDIR;
280 #include "poppack.h"
282 extern void CURSORICON_FreeModuleIcons( HMODULE16 hModule );
284 #endif /* __WINE_USER_PRIVATE_H */