setupapi: Implement SetupDiCreateDeviceInfoW.
[wine] / dlls / user32 / user_private.h
1 /*
2  * USER private definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_USER_PRIVATE_H
22 #define __WINE_USER_PRIVATE_H
23
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"
33
34 extern WORD USER_HeapSel;
35
36 static inline HLOCAL16 LOCAL_Alloc( HANDLE16 ds, UINT16 flags, WORD size )
37 {
38     STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
39     HANDLE16 oldDS = stack16->ds;
40     HLOCAL16 ret;
41
42     stack16->ds = ds;
43     ret = LocalAlloc16 (flags, size);
44     stack16->ds = oldDS;
45     return ret;
46 }
47
48 static inline  HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, WORD size, UINT16 flags )
49 {
50     STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
51     HANDLE16 oldDS = stack16->ds;
52     HLOCAL16 ret;
53
54     stack16->ds = ds;
55     ret = LocalReAlloc16 (handle, size, flags);
56     stack16->ds = oldDS;
57     return ret;
58 }
59
60 static inline HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle )
61 {
62     STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
63     HANDLE16 oldDS = stack16->ds;
64     HLOCAL16 ret;
65
66     stack16->ds = ds;
67     ret = LocalFree16 (handle);
68     stack16->ds = oldDS;
69     return ret;
70 }
71
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)
80
81 #define GET_WORD(ptr)  (*(const WORD *)(ptr))
82 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
83
84 #define WM_SYSTIMER         0x0118
85
86 /* internal messages codes */
87 enum wine_internal_message
88 {
89     WM_WINE_DESTROYWINDOW = 0x80000000,
90     WM_WINE_SETWINDOWPOS,
91     WM_WINE_SHOWWINDOW,
92     WM_WINE_SETPARENT,
93     WM_WINE_SETWINDOWLONG,
94     WM_WINE_ENABLEWINDOW,
95     WM_WINE_SETACTIVEWINDOW,
96     WM_WINE_KEYBOARD_LL_HOOK,
97     WM_WINE_MOUSE_LL_HOOK,
98     WM_WINE_FIRST_DRIVER_MSG = 0x80001000,  /* range of messages reserved for the USER driver */
99     WM_WINE_LAST_DRIVER_MSG = 0x80001fff
100 };
101
102 struct tagCURSORICONINFO;
103
104 typedef struct tagUSER_DRIVER {
105     /* keyboard functions */
106     HKL    (*pActivateKeyboardLayout)(HKL, UINT);
107     void   (*pBeep)(void);
108     SHORT  (*pGetAsyncKeyState)(INT);
109     INT    (*pGetKeyNameText)(LONG, LPWSTR, INT);
110     HKL    (*pGetKeyboardLayout)(DWORD);
111     UINT   (*pGetKeyboardLayoutList)(INT, HKL *);
112     BOOL   (*pGetKeyboardLayoutName)(LPWSTR);
113     HKL    (*pLoadKeyboardLayout)(LPCWSTR, UINT);
114     UINT   (*pMapVirtualKeyEx)(UINT, UINT, HKL);
115     UINT   (*pSendInput)(UINT, LPINPUT, int);
116     INT    (*pToUnicodeEx)(UINT, UINT, LPBYTE, LPWSTR, int, UINT, HKL);
117     BOOL   (*pUnloadKeyboardLayout)(HKL);
118     SHORT  (*pVkKeyScanEx)(WCHAR, HKL);
119     /* mouse functions */
120     void   (*pSetCursor)(struct tagCURSORICONINFO *);
121     BOOL   (*pGetCursorPos)(LPPOINT);
122     BOOL   (*pSetCursorPos)(INT,INT);
123     BOOL   (*pClipCursor)(LPCRECT);
124     /* screen saver functions */
125     BOOL   (*pGetScreenSaveActive)(void);
126     void   (*pSetScreenSaveActive)(BOOL);
127     /* clipboard functions */
128     INT    (*pAcquireClipboard)(HWND);                     /* Acquire selection */
129     BOOL   (*pCountClipboardFormats)(void);                /* Count available clipboard formats */
130     void   (*pEmptyClipboard)(BOOL);                       /* Empty clipboard data */
131     void   (*pEndClipboardUpdate)(void);                   /* End clipboard update */
132     UINT   (*pEnumClipboardFormats)(UINT);                 /* Enumerate clipboard formats */
133     BOOL   (*pGetClipboardData)(UINT, HANDLE16*, HANDLE*); /* Get specified selection data */
134     INT    (*pGetClipboardFormatName)(UINT, LPWSTR, UINT); /* Get a clipboard format name */
135     BOOL   (*pIsClipboardFormatAvailable)(UINT);           /* Check if specified format is available */
136     UINT   (*pRegisterClipboardFormat)(LPCWSTR);           /* Register a clipboard format */
137     BOOL   (*pSetClipboardData)(UINT, HANDLE16, HANDLE, BOOL);   /* Set specified selection data */
138     /* display modes */
139     LONG   (*pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
140     BOOL   (*pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
141     BOOL   (*pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
142     BOOL   (*pGetMonitorInfo)(HMONITOR,MONITORINFO*);
143     /* windowing functions */
144     BOOL   (*pCreateDesktopWindow)(HWND);
145     BOOL   (*pCreateWindow)(HWND,CREATESTRUCTA*,BOOL);
146     void   (*pDestroyWindow)(HWND);
147     HDC    (*pGetDCEx)(HWND,HRGN,DWORD);
148     DWORD  (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
149     INT    (*pReleaseDC)(HWND,HDC,BOOL);
150     BOOL   (*pScrollDC)(HDC, INT, INT, const RECT *, const RECT *, HRGN, LPRECT);
151     void   (*pSetFocus)(HWND);
152     void   (*pSetParent)(HWND,HWND,HWND);
153     BOOL   (*pSetWindowPos)(HWND,HWND,const RECT *,const RECT *,UINT,const RECT *);
154     int    (*pSetWindowRgn)(HWND,HRGN,BOOL);
155     void   (*pSetWindowIcon)(HWND,UINT,HICON);
156     void   (*pSetWindowStyle)(HWND,DWORD);
157     void   (*pSetWindowText)(HWND,LPCWSTR);
158     BOOL   (*pShowWindow)(HWND,INT);
159     void   (*pSysCommandSizeMove)(HWND,WPARAM);
160     HWND   (*pWindowFromDC)(HDC);
161     LRESULT (*pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
162 } USER_DRIVER;
163
164 extern const USER_DRIVER *USER_Driver;
165
166 extern void USER_unload_driver(void);
167
168 struct received_message_info;
169 struct hook16_queue_info;
170
171 /* type of message-sending functions that need special WM_CHAR handling */
172 enum wm_char_mapping
173 {
174     WMCHAR_MAP_POSTMESSAGE,
175     WMCHAR_MAP_SENDMESSAGE,
176     WMCHAR_MAP_SENDMESSAGETIMEOUT,
177     WMCHAR_MAP_RECVMESSAGE,
178     WMCHAR_MAP_DISPATCHMESSAGE,
179     WMCHAR_MAP_CALLWINDOWPROC,
180     WMCHAR_MAP_COUNT,
181     WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT
182 };
183
184 /* data to store state for A/W mappings of WM_CHAR */
185 struct wm_char_mapping_data
186 {
187     BYTE lead_byte[WMCHAR_MAP_COUNT];
188     MSG  get_msg;
189 };
190
191 /* this is the structure stored in TEB->Win32ClientInfo */
192 /* no attempt is made to keep the layout compatible with the Windows one */
193 struct user_thread_info
194 {
195     HANDLE                        server_queue;           /* Handle to server-side queue */
196     DWORD                         recursion_count;        /* SendMessage recursion counter */
197     BOOL                          hook_unicode;           /* Is current hook unicode? */
198     HHOOK                         hook;                   /* Current hook */
199     struct received_message_info *receive_info;           /* Message being currently received */
200     struct hook16_queue_info     *hook16_info;            /* Opaque pointer for 16-bit hook support */
201     struct wm_char_mapping_data  *wmchar_data;            /* Data for WM_CHAR mappings */
202     DWORD                         GetMessageTimeVal;      /* Value for GetMessageTime */
203     DWORD                         GetMessagePosVal;       /* Value for GetMessagePos */
204     ULONG_PTR                     GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
205     HCURSOR                       cursor;                 /* Current cursor */
206     INT                           cursor_count;           /* Cursor show count */
207     UINT                          active_hooks;           /* Bitmap of active hooks */
208     HWND                          desktop;                /* Desktop window */
209
210     ULONG                         pad[10];                /* Available for more data */
211 };
212
213 struct hook_extra_info
214 {
215     HHOOK handle;
216     LPARAM lparam;
217 };
218
219 static inline struct user_thread_info *get_user_thread_info(void)
220 {
221     return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
222 }
223
224 /* check if hwnd is a broadcast magic handle */
225 static inline BOOL is_broadcast( HWND hwnd )
226 {
227     return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
228 }
229
230 extern HMODULE user32_module;
231 extern DWORD USER16_AlertableWait;
232 extern HBRUSH SYSCOLOR_55AABrush;
233
234 extern BOOL CLIPBOARD_ReleaseOwner(void);
235 extern BOOL FOCUS_MouseActivate( HWND hwnd );
236 extern BOOL HOOK_IsHooked( INT id );
237 extern void erase_now( HWND hwnd, UINT rdw_flags );
238 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam );
239 extern BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping );
240 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
241                                                UINT msg, WPARAM wparam, LPARAM lparam,
242                                                UINT flags, UINT timeout, PDWORD_PTR res_ptr );
243 extern HPEN SYSCOLOR_GetPen( INT index );
244 extern void SYSPARAMS_Init(void);
245 extern void USER_CheckNotLock(void);
246 extern BOOL USER_IsExitingThread( DWORD tid );
247
248 extern BOOL USER_SetWindowPos( WINDOWPOS * winpos );
249
250 typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
251                                        LRESULT *result, void *arg );
252 typedef LRESULT (*winproc_callback16_t)( HWND16 hwnd, UINT16 msg, WPARAM16 wp, LPARAM lp,
253                                          LRESULT *result, void *arg );
254
255 extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode );
256 extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func );
257 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode );
258 extern WNDPROC WINPROC_AllocProc( WNDPROC funcA, WNDPROC funcW );
259 extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val );
260
261 extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
262                                      WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
263                                      enum wm_char_mapping mapping );
264 extern LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd, UINT16 msg,
265                                         WPARAM16 wParam, LPARAM lParam, LRESULT *result, void *arg );
266 extern LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT msg,
267                                         WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg );
268
269 extern INT_PTR WINPROC_CallDlgProc16( DLGPROC16 func, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam );
270 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
271 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
272 extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
273                                  LRESULT *result, BOOL unicode, enum wm_char_mapping mapping );
274
275 /* message spy definitions */
276
277 #define SPY_DISPATCHMESSAGE16     0x0100
278 #define SPY_DISPATCHMESSAGE       0x0101
279 #define SPY_SENDMESSAGE16         0x0102
280 #define SPY_SENDMESSAGE           0x0103
281 #define SPY_DEFWNDPROC16          0x0104
282 #define SPY_DEFWNDPROC            0x0105
283
284 #define SPY_RESULT_OK16           0x0000
285 #define SPY_RESULT_OK             0x0001
286 #define SPY_RESULT_INVALIDHWND16  0x0002
287 #define SPY_RESULT_INVALIDHWND    0x0003
288 #define SPY_RESULT_DEFWND16       0x0004
289 #define SPY_RESULT_DEFWND         0x0005
290
291 extern const char *SPY_GetClassLongOffsetName( INT offset );
292 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd );
293 extern const char *SPY_GetVKeyName(WPARAM wParam);
294 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
295 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
296                              LRESULT lReturn, WPARAM wParam, LPARAM lParam );
297 extern int SPY_Init(void);
298
299 /* HANDLE16 <-> HANDLE conversions */
300 #define HCURSOR_16(h32)    (LOWORD(h32))
301 #define HICON_16(h32)      (LOWORD(h32))
302 #define HINSTANCE_16(h32)  (LOWORD(h32))
303
304 #define HCURSOR_32(h16)    ((HCURSOR)(ULONG_PTR)(h16))
305 #define HICON_32(h16)      ((HICON)(ULONG_PTR)(h16))
306 #define HINSTANCE_32(h16)  ((HINSTANCE)(ULONG_PTR)(h16))
307 #define HMODULE_32(h16)    ((HMODULE)(ULONG_PTR)(h16))
308
309 #include "pshpack1.h"
310
311 typedef struct
312 {
313     BYTE   bWidth;
314     BYTE   bHeight;
315     BYTE   bColorCount;
316     BYTE   bReserved;
317 } ICONRESDIR;
318
319 typedef struct
320 {
321     WORD   wWidth;
322     WORD   wHeight;
323 } CURSORDIR;
324
325 typedef struct
326 {   union
327     { ICONRESDIR icon;
328       CURSORDIR  cursor;
329     } ResInfo;
330     WORD   wPlanes;
331     WORD   wBitCount;
332     DWORD  dwBytesInRes;
333     WORD   wResId;
334 } CURSORICONDIRENTRY;
335
336 typedef struct
337 {
338     WORD                idReserved;
339     WORD                idType;
340     WORD                idCount;
341     CURSORICONDIRENTRY  idEntries[1];
342 } CURSORICONDIR;
343
344 #include "poppack.h"
345
346 extern void CURSORICON_FreeModuleIcons( HMODULE16 hModule );
347
348 #endif /* __WINE_USER_PRIVATE_H */