user32: Get rid of 16-bit handles in the driver clipboard interface.
[wine] / dlls / user32 / driver.c
1 /*
2  * USER driver support
3  *
4  * Copyright 2000, 2005 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 #include <stdarg.h>
22 #include <stdio.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wine/debug.h"
27
28 #include "user_private.h"
29
30 static USER_DRIVER null_driver, lazy_load_driver;
31
32 const USER_DRIVER *USER_Driver = &lazy_load_driver;
33 static DWORD driver_load_error;
34
35 /* load the graphics driver */
36 static const USER_DRIVER *load_driver(void)
37 {
38     char buffer[MAX_PATH], libname[32], *name, *next;
39     HKEY hkey;
40     void *ptr;
41     HMODULE graphics_driver;
42     USER_DRIVER *driver, *prev;
43
44     strcpy( buffer, "x11" );  /* default value */
45     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
46     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
47     {
48         DWORD type, count = sizeof(buffer);
49         RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
50         RegCloseKey( hkey );
51     }
52
53     name = buffer;
54     while (name)
55     {
56         next = strchr( name, ',' );
57         if (next) *next++ = 0;
58
59         snprintf( libname, sizeof(libname), "wine%s.drv", name );
60         if ((graphics_driver = LoadLibraryA( libname )) != 0) break;
61         name = next;
62     }
63
64     if (!graphics_driver)
65         driver_load_error = GetLastError();
66
67     driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
68     *driver = null_driver;
69
70     if (graphics_driver)
71     {
72 #define GET_USER_FUNC(name) \
73     do { if ((ptr = GetProcAddress( graphics_driver, #name ))) driver->p##name = ptr; } while(0)
74
75         GET_USER_FUNC(ActivateKeyboardLayout);
76         GET_USER_FUNC(Beep);
77         GET_USER_FUNC(GetAsyncKeyState);
78         GET_USER_FUNC(GetKeyNameText);
79         GET_USER_FUNC(GetKeyboardLayout);
80         GET_USER_FUNC(GetKeyboardLayoutName);
81         GET_USER_FUNC(LoadKeyboardLayout);
82         GET_USER_FUNC(MapVirtualKeyEx);
83         GET_USER_FUNC(SendInput);
84         GET_USER_FUNC(ToUnicodeEx);
85         GET_USER_FUNC(UnloadKeyboardLayout);
86         GET_USER_FUNC(VkKeyScanEx);
87         GET_USER_FUNC(SetCursor);
88         GET_USER_FUNC(GetCursorPos);
89         GET_USER_FUNC(SetCursorPos);
90         GET_USER_FUNC(ClipCursor);
91         GET_USER_FUNC(GetScreenSaveActive);
92         GET_USER_FUNC(SetScreenSaveActive);
93         GET_USER_FUNC(AcquireClipboard);
94         GET_USER_FUNC(EmptyClipboard);
95         GET_USER_FUNC(SetClipboardData);
96         GET_USER_FUNC(GetClipboardData);
97         GET_USER_FUNC(CountClipboardFormats);
98         GET_USER_FUNC(EnumClipboardFormats);
99         GET_USER_FUNC(IsClipboardFormatAvailable);
100         GET_USER_FUNC(RegisterClipboardFormat);
101         GET_USER_FUNC(GetClipboardFormatName);
102         GET_USER_FUNC(EndClipboardUpdate);
103         GET_USER_FUNC(ChangeDisplaySettingsEx);
104         GET_USER_FUNC(EnumDisplayMonitors);
105         GET_USER_FUNC(EnumDisplaySettingsEx);
106         GET_USER_FUNC(GetMonitorInfo);
107         GET_USER_FUNC(CreateDesktopWindow);
108         GET_USER_FUNC(CreateWindow);
109         GET_USER_FUNC(DestroyWindow);
110         GET_USER_FUNC(GetDC);
111         GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
112         GET_USER_FUNC(ReleaseDC);
113         GET_USER_FUNC(ScrollDC);
114         GET_USER_FUNC(SetCapture);
115         GET_USER_FUNC(SetFocus);
116         GET_USER_FUNC(SetLayeredWindowAttributes);
117         GET_USER_FUNC(SetParent);
118         GET_USER_FUNC(SetWindowRgn);
119         GET_USER_FUNC(SetWindowIcon);
120         GET_USER_FUNC(SetWindowStyle);
121         GET_USER_FUNC(SetWindowText);
122         GET_USER_FUNC(ShowWindow);
123         GET_USER_FUNC(SysCommand);
124         GET_USER_FUNC(WindowMessage);
125         GET_USER_FUNC(WindowPosChanging);
126         GET_USER_FUNC(WindowPosChanged);
127 #undef GET_USER_FUNC
128     }
129
130     prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
131     if (prev != &lazy_load_driver)
132     {
133         /* another thread beat us to it */
134         HeapFree( GetProcessHeap(), 0, driver );
135         FreeLibrary( graphics_driver );
136         driver = prev;
137     }
138     return driver;
139 }
140
141 /* unload the graphics driver on process exit */
142 void USER_unload_driver(void)
143 {
144     USER_DRIVER *prev;
145     /* make sure we don't try to call the driver after it has been detached */
146     prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver );
147     if (prev != &lazy_load_driver && prev != &null_driver)
148         HeapFree( GetProcessHeap(), 0, prev );
149 }
150
151
152 /**********************************************************************
153  * Null user driver
154  *
155  * These are fallbacks for entry points that are not implemented in the real driver.
156  */
157
158 static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
159 {
160     return 0;
161 }
162
163 static void CDECL nulldrv_Beep(void)
164 {
165 }
166
167 static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
168 {
169     return 0;
170 }
171
172 static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
173 {
174     return 0;
175 }
176
177 static HKL CDECL nulldrv_GetKeyboardLayout( DWORD layout )
178 {
179     return 0;
180 }
181
182 static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name )
183 {
184     return FALSE;
185 }
186
187 static HKL CDECL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
188 {
189     return 0;
190 }
191
192 static UINT CDECL nulldrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
193 {
194     return 0;
195 }
196
197 static UINT CDECL nulldrv_SendInput( UINT count, LPINPUT inputs, int size )
198 {
199     return 0;
200 }
201
202 static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
203                                       int size, UINT flags, HKL layout )
204 {
205     return 0;
206 }
207
208 static BOOL CDECL nulldrv_UnloadKeyboardLayout( HKL layout )
209 {
210     return 0;
211 }
212
213 static SHORT CDECL nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
214 {
215     return -1;
216 }
217
218 static void CDECL nulldrv_SetCursor( struct tagCURSORICONINFO *info )
219 {
220 }
221
222 static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt )
223 {
224     return FALSE;
225 }
226
227 static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
228 {
229     return FALSE;
230 }
231
232 static BOOL CDECL nulldrv_ClipCursor( LPCRECT clip )
233 {
234     return FALSE;
235 }
236
237 static BOOL CDECL nulldrv_GetScreenSaveActive(void)
238 {
239     return FALSE;
240 }
241
242 static void CDECL nulldrv_SetScreenSaveActive( BOOL on )
243 {
244 }
245
246 static INT CDECL nulldrv_AcquireClipboard( HWND hwnd )
247 {
248     return 0;
249 }
250
251 static BOOL CDECL nulldrv_CountClipboardFormats(void)
252 {
253     return 0;
254 }
255
256 static void CDECL nulldrv_EmptyClipboard( BOOL keepunowned )
257 {
258 }
259
260 static void CDECL nulldrv_EndClipboardUpdate(void)
261 {
262 }
263
264 static UINT CDECL nulldrv_EnumClipboardFormats( UINT format )
265 {
266     return 0;
267 }
268
269 static HANDLE CDECL nulldrv_GetClipboardData( UINT format )
270 {
271     return 0;
272 }
273
274 static INT CDECL nulldrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
275 {
276     return FALSE;
277 }
278
279 static BOOL CDECL nulldrv_IsClipboardFormatAvailable( UINT format )
280 {
281     return FALSE;
282 }
283
284 static UINT CDECL nulldrv_RegisterClipboardFormat( LPCWSTR name )
285 {
286     return 0;
287 }
288
289 static BOOL CDECL nulldrv_SetClipboardData( UINT format, HANDLE handle, BOOL owner )
290 {
291     return FALSE;
292 }
293
294 static LONG CDECL nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
295                                              DWORD flags, LPVOID lparam )
296 {
297     return DISP_CHANGE_FAILED;
298 }
299
300 static BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
301 {
302     return FALSE;
303 }
304
305 static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
306 {
307     return FALSE;
308 }
309
310 static BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
311 {
312     return FALSE;
313 }
314
315 static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
316 {
317     return TRUE;
318 }
319
320 static BOOL CDECL nulldrv_CreateWindow( HWND hwnd )
321 {
322     static int warned;
323
324     /* HWND_MESSAGE windows don't need a graphics driver */
325     if (GetAncestor( hwnd, GA_PARENT ) == get_user_thread_info()->msg_window) return TRUE;
326     if (warned++) return FALSE;
327
328     MESSAGE( "Application tried to create a window, but no driver could be loaded.\n");
329     switch (driver_load_error)
330     {
331     case ERROR_MOD_NOT_FOUND:
332         MESSAGE( "The X11 driver is missing.  Check your build!\n" );
333         break;
334     case ERROR_DLL_INIT_FAILED:
335         MESSAGE( "Make sure that your X server is running and that $DISPLAY is set correctly.\n" );
336         break;
337     default:
338         MESSAGE( "Unknown error (%d).\n", driver_load_error );
339     }
340
341     return FALSE;
342 }
343
344 static void CDECL nulldrv_DestroyWindow( HWND hwnd )
345 {
346 }
347
348 static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
349                                  const RECT *top_rect, DWORD flags )
350 {
351 }
352
353 static DWORD CDECL nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
354                                                         DWORD mask, DWORD flags )
355 {
356     return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
357                                      timeout, flags & MWMO_ALERTABLE );
358 }
359
360 static void CDECL nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
361 {
362 }
363
364 static BOOL CDECL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
365                                     HRGN hrgn, LPRECT update )
366 {
367     return FALSE;
368 }
369
370 static void CDECL nulldrv_SetCapture( HWND hwnd, UINT flags )
371 {
372 }
373
374 static void CDECL nulldrv_SetFocus( HWND hwnd )
375 {
376 }
377
378 static void CDECL nulldrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
379 {
380 }
381
382 static void CDECL nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
383 {
384 }
385
386 static int CDECL nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
387 {
388     return 1;
389 }
390
391 static void CDECL nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
392 {
393 }
394
395 static void CDECL nulldrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
396 {
397 }
398
399 static void CDECL nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
400 {
401 }
402
403 static UINT CDECL nulldrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
404 {
405     return swp;
406 }
407
408 static LRESULT CDECL nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
409 {
410     return -1;
411 }
412
413 static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
414 {
415     return 0;
416 }
417
418 static void CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
419                                              const RECT *window_rect, const RECT *client_rect,
420                                              RECT *visible_rect )
421 {
422 }
423
424 static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
425                                             const RECT *window_rect, const RECT *client_rect,
426                                             const RECT *visible_rect, const RECT *valid_rects )
427 {
428 }
429
430 static USER_DRIVER null_driver =
431 {
432     /* keyboard functions */
433     nulldrv_ActivateKeyboardLayout,
434     nulldrv_Beep,
435     nulldrv_GetAsyncKeyState,
436     nulldrv_GetKeyNameText,
437     nulldrv_GetKeyboardLayout,
438     nulldrv_GetKeyboardLayoutName,
439     nulldrv_LoadKeyboardLayout,
440     nulldrv_MapVirtualKeyEx,
441     nulldrv_SendInput,
442     nulldrv_ToUnicodeEx,
443     nulldrv_UnloadKeyboardLayout,
444     nulldrv_VkKeyScanEx,
445     /* mouse functions */
446     nulldrv_SetCursor,
447     nulldrv_GetCursorPos,
448     nulldrv_SetCursorPos,
449     nulldrv_ClipCursor,
450     /* screen saver functions */
451     nulldrv_GetScreenSaveActive,
452     nulldrv_SetScreenSaveActive,
453     /* clipboard functions */
454     nulldrv_AcquireClipboard,
455     nulldrv_CountClipboardFormats,
456     nulldrv_EmptyClipboard,
457     nulldrv_EndClipboardUpdate,
458     nulldrv_EnumClipboardFormats,
459     nulldrv_GetClipboardData,
460     nulldrv_GetClipboardFormatName,
461     nulldrv_IsClipboardFormatAvailable,
462     nulldrv_RegisterClipboardFormat,
463     nulldrv_SetClipboardData,
464     /* display modes */
465     nulldrv_ChangeDisplaySettingsEx,
466     nulldrv_EnumDisplayMonitors,
467     nulldrv_EnumDisplaySettingsEx,
468     nulldrv_GetMonitorInfo,
469     /* windowing functions */
470     nulldrv_CreateDesktopWindow,
471     nulldrv_CreateWindow,
472     nulldrv_DestroyWindow,
473     nulldrv_GetDC,
474     nulldrv_MsgWaitForMultipleObjectsEx,
475     nulldrv_ReleaseDC,
476     nulldrv_ScrollDC,
477     nulldrv_SetCapture,
478     nulldrv_SetFocus,
479     nulldrv_SetLayeredWindowAttributes,
480     nulldrv_SetParent,
481     nulldrv_SetWindowRgn,
482     nulldrv_SetWindowIcon,
483     nulldrv_SetWindowStyle,
484     nulldrv_SetWindowText,
485     nulldrv_ShowWindow,
486     nulldrv_SysCommand,
487     nulldrv_WindowMessage,
488     nulldrv_WindowPosChanging,
489     nulldrv_WindowPosChanged
490 };
491
492
493 /**********************************************************************
494  * Lazy loading user driver
495  *
496  * Initial driver used before another driver is loaded.
497  * Each entry point simply loads the real driver and chains to it.
498  */
499
500 static HKL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
501 {
502     return load_driver()->pActivateKeyboardLayout( layout, flags );
503 }
504
505 static void CDECL loaderdrv_Beep(void)
506 {
507     load_driver()->pBeep();
508 }
509
510 static SHORT CDECL loaderdrv_GetAsyncKeyState( INT key )
511 {
512     return load_driver()->pGetAsyncKeyState( key );
513 }
514
515 static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
516 {
517     return load_driver()->pGetKeyNameText( lparam, buffer, size );
518 }
519
520 static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD layout )
521 {
522     return load_driver()->pGetKeyboardLayout( layout );
523 }
524
525 static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
526 {
527     return load_driver()->pGetKeyboardLayoutName( name );
528 }
529
530 static HKL CDECL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
531 {
532     return load_driver()->pLoadKeyboardLayout( name, flags );
533 }
534
535 static UINT CDECL loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
536 {
537     return load_driver()->pMapVirtualKeyEx( code, type, layout );
538 }
539
540 static UINT CDECL loaderdrv_SendInput( UINT count, LPINPUT inputs, int size )
541 {
542     return load_driver()->pSendInput( count, inputs, size );
543 }
544
545 static INT CDECL loaderdrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
546                                   int size, UINT flags, HKL layout )
547 {
548     return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
549 }
550
551 static BOOL CDECL loaderdrv_UnloadKeyboardLayout( HKL layout )
552 {
553     return load_driver()->pUnloadKeyboardLayout( layout );
554 }
555
556 static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
557 {
558     return load_driver()->pVkKeyScanEx( ch, layout );
559 }
560
561 static void CDECL loaderdrv_SetCursor( struct tagCURSORICONINFO *info )
562 {
563     load_driver()->pSetCursor( info );
564 }
565
566 static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
567 {
568     return load_driver()->pGetCursorPos( pt );
569 }
570
571 static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
572 {
573     return load_driver()->pSetCursorPos( x, y );
574 }
575
576 static BOOL CDECL loaderdrv_ClipCursor( LPCRECT clip )
577 {
578     return load_driver()->pClipCursor( clip );
579 }
580
581 static BOOL CDECL loaderdrv_GetScreenSaveActive(void)
582 {
583     return load_driver()->pGetScreenSaveActive();
584 }
585
586 static void CDECL loaderdrv_SetScreenSaveActive( BOOL on )
587 {
588     load_driver()->pSetScreenSaveActive( on );
589 }
590
591 static INT CDECL loaderdrv_AcquireClipboard( HWND hwnd )
592 {
593     return load_driver()->pAcquireClipboard( hwnd );
594 }
595
596 static BOOL CDECL loaderdrv_CountClipboardFormats(void)
597 {
598     return load_driver()->pCountClipboardFormats();
599 }
600
601 static void CDECL loaderdrv_EmptyClipboard( BOOL keepunowned )
602 {
603     load_driver()->pEmptyClipboard( keepunowned );
604 }
605
606 static void CDECL loaderdrv_EndClipboardUpdate(void)
607 {
608     load_driver()->pEndClipboardUpdate();
609 }
610
611 static UINT CDECL loaderdrv_EnumClipboardFormats( UINT format )
612 {
613     return load_driver()->pEnumClipboardFormats( format );
614 }
615
616 static HANDLE CDECL loaderdrv_GetClipboardData( UINT format )
617 {
618     return load_driver()->pGetClipboardData( format );
619 }
620
621 static INT CDECL loaderdrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
622 {
623     return load_driver()->pGetClipboardFormatName( format, buffer, len );
624 }
625
626 static BOOL CDECL loaderdrv_IsClipboardFormatAvailable( UINT format )
627 {
628     return load_driver()->pIsClipboardFormatAvailable( format );
629 }
630
631 static UINT CDECL loaderdrv_RegisterClipboardFormat( LPCWSTR name )
632 {
633     return load_driver()->pRegisterClipboardFormat( name );
634 }
635
636 static BOOL CDECL loaderdrv_SetClipboardData( UINT format, HANDLE handle, BOOL owner )
637 {
638     return load_driver()->pSetClipboardData( format, handle, owner );
639 }
640
641 static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
642                                                      DWORD flags, LPVOID lparam )
643 {
644     return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
645 }
646
647 static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
648 {
649     return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
650 }
651
652 static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
653 {
654     return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
655 }
656
657 static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
658 {
659     return load_driver()->pGetMonitorInfo( handle, info );
660 }
661
662 static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
663 {
664     return load_driver()->pCreateDesktopWindow( hwnd );
665 }
666
667 static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd )
668 {
669     return load_driver()->pCreateWindow( hwnd );
670 }
671
672 static void CDECL loaderdrv_DestroyWindow( HWND hwnd )
673 {
674     load_driver()->pDestroyWindow( hwnd );
675 }
676
677 static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
678                                    const RECT *top_rect, DWORD flags )
679 {
680     load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
681 }
682
683 static DWORD CDECL loaderdrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
684                                                           DWORD mask, DWORD flags )
685 {
686     return load_driver()->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
687 }
688
689 static void CDECL loaderdrv_ReleaseDC( HWND hwnd, HDC hdc )
690 {
691     load_driver()->pReleaseDC( hwnd, hdc );
692 }
693
694 static BOOL CDECL loaderdrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
695                                       HRGN hrgn, LPRECT update )
696 {
697     return load_driver()->pScrollDC( hdc, dx, dy, scroll, clip, hrgn, update );
698 }
699
700 static void CDECL loaderdrv_SetCapture( HWND hwnd, UINT flags )
701 {
702     load_driver()->pSetCapture( hwnd, flags );
703 }
704
705 static void CDECL loaderdrv_SetFocus( HWND hwnd )
706 {
707     load_driver()->pSetFocus( hwnd );
708 }
709
710 static void CDECL loaderdrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
711 {
712     load_driver()->pSetLayeredWindowAttributes( hwnd, key, alpha, flags );
713 }
714
715 static void CDECL loaderdrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
716 {
717     load_driver()->pSetParent( hwnd, parent, old_parent );
718 }
719
720 static int CDECL loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
721 {
722     return load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
723 }
724
725 static void CDECL loaderdrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
726 {
727     load_driver()->pSetWindowIcon( hwnd, type, icon );
728 }
729
730 static void CDECL loaderdrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
731 {
732     load_driver()->pSetWindowStyle( hwnd, offset, style );
733 }
734
735 static void CDECL loaderdrv_SetWindowText( HWND hwnd, LPCWSTR text )
736 {
737     load_driver()->pSetWindowText( hwnd, text );
738 }
739
740 static UINT CDECL loaderdrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
741 {
742     return load_driver()->pShowWindow( hwnd, cmd, rect, swp );
743 }
744
745 static LRESULT CDECL loaderdrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
746 {
747     return load_driver()->pSysCommand( hwnd, wparam, lparam );
748 }
749
750 static LRESULT CDECL loaderdrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
751 {
752     return load_driver()->pWindowMessage( hwnd, msg, wparam, lparam );
753 }
754
755 static void CDECL loaderdrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
756                                                const RECT *window_rect, const RECT *client_rect,
757                                                RECT *visible_rect )
758 {
759     load_driver()->pWindowPosChanging( hwnd, insert_after, swp_flags,
760                                        window_rect, client_rect, visible_rect );
761 }
762
763 static void CDECL loaderdrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
764                                               const RECT *window_rect, const RECT *client_rect,
765                                               const RECT *visible_rect, const RECT *valid_rects )
766 {
767     load_driver()->pWindowPosChanged( hwnd, insert_after, swp_flags, window_rect,
768                                       client_rect, visible_rect, valid_rects );
769 }
770
771 static USER_DRIVER lazy_load_driver =
772 {
773     /* keyboard functions */
774     loaderdrv_ActivateKeyboardLayout,
775     loaderdrv_Beep,
776     loaderdrv_GetAsyncKeyState,
777     loaderdrv_GetKeyNameText,
778     loaderdrv_GetKeyboardLayout,
779     loaderdrv_GetKeyboardLayoutName,
780     loaderdrv_LoadKeyboardLayout,
781     loaderdrv_MapVirtualKeyEx,
782     loaderdrv_SendInput,
783     loaderdrv_ToUnicodeEx,
784     loaderdrv_UnloadKeyboardLayout,
785     loaderdrv_VkKeyScanEx,
786     /* mouse functions */
787     loaderdrv_SetCursor,
788     loaderdrv_GetCursorPos,
789     loaderdrv_SetCursorPos,
790     loaderdrv_ClipCursor,
791     /* screen saver functions */
792     loaderdrv_GetScreenSaveActive,
793     loaderdrv_SetScreenSaveActive,
794     /* clipboard functions */
795     loaderdrv_AcquireClipboard,
796     loaderdrv_CountClipboardFormats,
797     loaderdrv_EmptyClipboard,
798     loaderdrv_EndClipboardUpdate,
799     loaderdrv_EnumClipboardFormats,
800     loaderdrv_GetClipboardData,
801     loaderdrv_GetClipboardFormatName,
802     loaderdrv_IsClipboardFormatAvailable,
803     loaderdrv_RegisterClipboardFormat,
804     loaderdrv_SetClipboardData,
805     /* display modes */
806     loaderdrv_ChangeDisplaySettingsEx,
807     loaderdrv_EnumDisplayMonitors,
808     loaderdrv_EnumDisplaySettingsEx,
809     loaderdrv_GetMonitorInfo,
810     /* windowing functions */
811     loaderdrv_CreateDesktopWindow,
812     loaderdrv_CreateWindow,
813     loaderdrv_DestroyWindow,
814     loaderdrv_GetDC,
815     loaderdrv_MsgWaitForMultipleObjectsEx,
816     loaderdrv_ReleaseDC,
817     loaderdrv_ScrollDC,
818     loaderdrv_SetCapture,
819     loaderdrv_SetFocus,
820     loaderdrv_SetLayeredWindowAttributes,
821     loaderdrv_SetParent,
822     loaderdrv_SetWindowRgn,
823     loaderdrv_SetWindowIcon,
824     loaderdrv_SetWindowStyle,
825     loaderdrv_SetWindowText,
826     loaderdrv_ShowWindow,
827     loaderdrv_SysCommand,
828     loaderdrv_WindowMessage,
829     loaderdrv_WindowPosChanging,
830     loaderdrv_WindowPosChanged
831 };