driver.c 23.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * USER driver support
 *
 * Copyright 2000, 2005 Alexandre Julliard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22 23 24
 */

#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
25
#include "wingdi.h"
26 27
#include "winuser.h"
#include "wine/debug.h"
28
#include "wine/gdi_driver.h"
29
#include "wine/unicode.h"
30

31
#include "user_private.h"
32
#include "controls.h"
33

34 35
WINE_DEFAULT_DEBUG_CHANNEL(user);

36
static USER_DRIVER null_driver, lazy_load_driver;
37 38

const USER_DRIVER *USER_Driver = &lazy_load_driver;
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
static char driver_load_error[80];

static HMODULE load_desktop_driver( HWND hwnd )
{
    static const WCHAR display_device_guid_propW[] = {
        '_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
        'd','e','v','i','c','e','_','g','u','i','d',0 };
    static const WCHAR key_pathW[] = {
        'S','y','s','t','e','m','\\',
        'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
        'C','o','n','t','r','o','l','\\',
        'V','i','d','e','o','\\','{',0};
    static const WCHAR displayW[] = {'}','\\','0','0','0','0',0};
    static const WCHAR driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
    HMODULE ret = 0;
    HKEY hkey;
    DWORD size;
    WCHAR path[MAX_PATH];
    WCHAR key[(sizeof(key_pathW) + sizeof(displayW)) / sizeof(WCHAR) + 40];
    UINT guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));

60 61
    USER_CheckNotLock();

62 63
    strcpy( driver_load_error, "The explorer process failed to start." );  /* default error */

64 65 66 67 68
    if (!guid_atom)
    {
        SendMessageW( hwnd, WM_NULL, 0, 0 );  /* wait for the desktop process to be ready */
        guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));
    }
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    memcpy( key, key_pathW, sizeof(key_pathW) );
    if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
    strcatW( key, displayW );
    if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
    size = sizeof(path);
    if (!RegQueryValueExW( hkey, driverW, NULL, NULL, (BYTE *)path, &size ))
    {
        if (!(ret = LoadLibraryW( path ))) ERR( "failed to load %s\n", debugstr_w(path) );
        TRACE( "%s %p\n", debugstr_w(path), ret );
    }
    else
    {
        size = sizeof(driver_load_error);
        RegQueryValueExA( hkey, "DriverError", NULL, NULL, (BYTE *)driver_load_error, &size );
    }
    RegCloseKey( hkey );
    return ret;
}
87 88 89 90 91 92 93 94 95

/* load the graphics driver */
static const USER_DRIVER *load_driver(void)
{
    void *ptr;
    HMODULE graphics_driver;
    USER_DRIVER *driver, *prev;

    driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
96
    *driver = null_driver;
97

98
    graphics_driver = load_desktop_driver( GetDesktopWindow() );
99 100
    if (graphics_driver)
    {
101 102 103
#define GET_USER_FUNC(name) \
    do { if ((ptr = GetProcAddress( graphics_driver, #name ))) driver->p##name = ptr; } while(0)

104 105 106 107 108
        GET_USER_FUNC(ActivateKeyboardLayout);
        GET_USER_FUNC(Beep);
        GET_USER_FUNC(GetAsyncKeyState);
        GET_USER_FUNC(GetKeyNameText);
        GET_USER_FUNC(GetKeyboardLayout);
109
        GET_USER_FUNC(GetKeyboardLayoutList);
110 111 112
        GET_USER_FUNC(GetKeyboardLayoutName);
        GET_USER_FUNC(LoadKeyboardLayout);
        GET_USER_FUNC(MapVirtualKeyEx);
113
        GET_USER_FUNC(RegisterHotKey);
114 115
        GET_USER_FUNC(ToUnicodeEx);
        GET_USER_FUNC(UnloadKeyboardLayout);
116
        GET_USER_FUNC(UnregisterHotKey);
117
        GET_USER_FUNC(VkKeyScanEx);
118
        GET_USER_FUNC(DestroyCursorIcon);
119 120 121
        GET_USER_FUNC(SetCursor);
        GET_USER_FUNC(GetCursorPos);
        GET_USER_FUNC(SetCursorPos);
122
        GET_USER_FUNC(ClipCursor);
123 124 125 126 127 128 129 130 131
        GET_USER_FUNC(AcquireClipboard);
        GET_USER_FUNC(EmptyClipboard);
        GET_USER_FUNC(SetClipboardData);
        GET_USER_FUNC(GetClipboardData);
        GET_USER_FUNC(CountClipboardFormats);
        GET_USER_FUNC(EnumClipboardFormats);
        GET_USER_FUNC(IsClipboardFormatAvailable);
        GET_USER_FUNC(EndClipboardUpdate);
        GET_USER_FUNC(ChangeDisplaySettingsEx);
132
        GET_USER_FUNC(EnumDisplayMonitors);
133
        GET_USER_FUNC(EnumDisplaySettingsEx);
134
        GET_USER_FUNC(GetMonitorInfo);
135 136 137
        GET_USER_FUNC(CreateDesktopWindow);
        GET_USER_FUNC(CreateWindow);
        GET_USER_FUNC(DestroyWindow);
138
        GET_USER_FUNC(GetDC);
139 140 141
        GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
        GET_USER_FUNC(ReleaseDC);
        GET_USER_FUNC(ScrollDC);
142
        GET_USER_FUNC(SetCapture);
143
        GET_USER_FUNC(SetFocus);
144
        GET_USER_FUNC(SetLayeredWindowAttributes);
145 146 147 148 149
        GET_USER_FUNC(SetParent);
        GET_USER_FUNC(SetWindowRgn);
        GET_USER_FUNC(SetWindowIcon);
        GET_USER_FUNC(SetWindowStyle);
        GET_USER_FUNC(SetWindowText);
150
        GET_USER_FUNC(ShowWindow);
151
        GET_USER_FUNC(SysCommand);
152
        GET_USER_FUNC(UpdateLayeredWindow);
153
        GET_USER_FUNC(WindowMessage);
154 155
        GET_USER_FUNC(WindowPosChanging);
        GET_USER_FUNC(WindowPosChanged);
156
        GET_USER_FUNC(SystemParametersInfo);
157
#undef GET_USER_FUNC
158
    }
159

160
    prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
161 162 163 164 165 166
    if (prev != &lazy_load_driver)
    {
        /* another thread beat us to it */
        HeapFree( GetProcessHeap(), 0, driver );
        driver = prev;
    }
167 168
    else LdrAddRefDll( 0, graphics_driver );

169
    __wine_set_display_driver( graphics_driver );
170 171
    register_builtin_classes();

172 173 174
    return driver;
}

175 176 177
/* unload the graphics driver on process exit */
void USER_unload_driver(void)
{
178
    USER_DRIVER *prev;
179
    /* make sure we don't try to call the driver after it has been detached */
180 181 182
    prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver );
    if (prev != &lazy_load_driver && prev != &null_driver)
        HeapFree( GetProcessHeap(), 0, prev );
183 184
}

185 186 187 188 189 190 191

/**********************************************************************
 * Null user driver
 *
 * These are fallbacks for entry points that are not implemented in the real driver.
 */

192
static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
193 194 195 196
{
    return 0;
}

197
static void CDECL nulldrv_Beep(void)
198 199 200
{
}

201
static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
202
{
203
    return -1;
204 205
}

206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
    HKEY hKeyKeyboard;
    DWORD rc;
    INT count = 0;
    ULONG_PTR baselayout;
    LANGID langid;
    static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};

    baselayout = GetUserDefaultLCID();
    langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
    if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
        baselayout |= 0xe001 << 16; /* IME */
    else
        baselayout |= baselayout << 16;

    /* Enumerate the Registry */
    rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
    if (rc == ERROR_SUCCESS)
    {
        do {
            WCHAR szKeyName[9];
            HKL layout;
            rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
            if (rc == ERROR_SUCCESS)
            {
                layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
                if (baselayout != 0 && layout == (HKL)baselayout)
                    baselayout = 0; /* found in the registry do not add again */
                if (size && layouts)
                {
                    if (count >= size ) break;
                    layouts[count] = layout;
                }
                count ++;
            }
        } while (rc == ERROR_SUCCESS);
        RegCloseKey(hKeyKeyboard);
    }

    /* make sure our base layout is on the list */
    if (baselayout != 0)
    {
        if (size && layouts)
        {
            if (count < size)
            {
                layouts[count] = (HKL)baselayout;
                count++;
            }
        }
        else
            count++;
    }

    return count;
}

264
static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
265 266 267 268
{
    return 0;
}

269
static HKL CDECL nulldrv_GetKeyboardLayout( DWORD thread_id )
270 271 272 273
{
    return 0;
}

274
static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name )
275 276 277 278
{
    return FALSE;
}

279
static HKL CDECL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
280 281 282 283
{
    return 0;
}

284
static UINT CDECL nulldrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
285 286 287 288
{
    return 0;
}

289 290 291 292 293
static BOOL CDECL nulldrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    return TRUE;
}

294 295
static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
                                      int size, UINT flags, HKL layout )
296 297 298 299
{
    return 0;
}

300
static BOOL CDECL nulldrv_UnloadKeyboardLayout( HKL layout )
301 302 303 304
{
    return 0;
}

305 306 307 308
static void CDECL nulldrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
}

309
static SHORT CDECL nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
310 311 312 313
{
    return -1;
}

314 315 316 317
static void CDECL nulldrv_DestroyCursorIcon( HCURSOR cursor )
{
}

318
static void CDECL nulldrv_SetCursor( HCURSOR cursor )
319 320 321
{
}

322
static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt )
323 324 325 326
{
    return FALSE;
}

327
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
328 329 330 331
{
    return FALSE;
}

332
static BOOL CDECL nulldrv_ClipCursor( LPCRECT clip )
333 334 335 336
{
    return FALSE;
}

337
static INT CDECL nulldrv_AcquireClipboard( HWND hwnd )
338
{
339
    return 0;
340 341
}

342
static BOOL CDECL nulldrv_CountClipboardFormats(void)
343 344 345 346
{
    return 0;
}

347
static void CDECL nulldrv_EmptyClipboard( BOOL keepunowned )
348 349 350
{
}

351
static void CDECL nulldrv_EndClipboardUpdate(void)
352 353 354
{
}

355
static UINT CDECL nulldrv_EnumClipboardFormats( UINT format )
356 357 358 359
{
    return 0;
}

360
static HANDLE CDECL nulldrv_GetClipboardData( UINT format )
361
{
362
    return 0;
363 364
}

365
static BOOL CDECL nulldrv_IsClipboardFormatAvailable( UINT format )
366 367 368 369
{
    return FALSE;
}

370
static BOOL CDECL nulldrv_SetClipboardData( UINT format, HANDLE handle, BOOL owner )
371 372 373 374
{
    return FALSE;
}

375
static LONG CDECL nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
376 377 378 379 380
                                             DWORD flags, LPVOID lparam )
{
    return DISP_CHANGE_FAILED;
}

381
static BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
382 383 384 385
{
    return FALSE;
}

386
static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
387 388 389 390
{
    return FALSE;
}

391
static BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
392 393 394 395
{
    return FALSE;
}

396
static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
397 398 399 400
{
    return TRUE;
}

401
static BOOL CDECL nulldrv_CreateWindow( HWND hwnd )
402
{
403
    static int warned;
404
    HWND parent = GetAncestor( hwnd, GA_PARENT );
405 406

    /* HWND_MESSAGE windows don't need a graphics driver */
407
    if (!parent || parent == get_user_thread_info()->msg_window) return TRUE;
408
    if (warned++) return FALSE;
409 410

    MESSAGE( "Application tried to create a window, but no driver could be loaded.\n");
411
    if (driver_load_error[0]) MESSAGE( "%s\n", driver_load_error );
412
    return FALSE;
413 414
}

415
static void CDECL nulldrv_DestroyWindow( HWND hwnd )
416 417 418
{
}

419 420
static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
                                 const RECT *top_rect, DWORD flags )
421 422 423
{
}

424 425
static DWORD CDECL nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
                                                        DWORD mask, DWORD flags )
426 427 428 429 430
{
    return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
                                     timeout, flags & MWMO_ALERTABLE );
}

431
static void CDECL nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
432 433 434
{
}

435
static BOOL CDECL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update )
436
{
437 438 439 440 441
    RECT rect;

    GetClipBox( hdc, &rect );
    return BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
                   hdc, rect.left - dx, rect.top - dy, SRCCOPY );
442 443
}

444
static void CDECL nulldrv_SetCapture( HWND hwnd, UINT flags )
445 446 447
{
}

448
static void CDECL nulldrv_SetFocus( HWND hwnd )
449 450 451
{
}

452
static void CDECL nulldrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
453 454 455
{
}

456
static void CDECL nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
457 458 459
{
}

460
static void CDECL nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
461 462 463
{
}

464
static void CDECL nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
465 466 467
{
}

468
static void CDECL nulldrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
469 470 471
{
}

472
static void CDECL nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
473 474 475
{
}

476
static UINT CDECL nulldrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
477 478 479 480
{
    return swp;
}

481
static LRESULT CDECL nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
482
{
483
    return -1;
484 485
}

486 487 488 489 490 491
static BOOL CDECL nulldrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
                                               const RECT *window_rect )
{
    return TRUE;
}

492
static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
493 494 495 496
{
    return 0;
}

497 498
static void CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
                                             const RECT *window_rect, const RECT *client_rect,
499
                                             RECT *visible_rect, struct window_surface **surface )
500 501 502
{
}

503 504
static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
                                            const RECT *window_rect, const RECT *client_rect,
505 506
                                            const RECT *visible_rect, const RECT *valid_rects,
                                            struct window_surface *surface )
507 508 509
{
}

510 511 512 513 514
static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
{
    return FALSE;
}

515
static USER_DRIVER null_driver =
516 517 518 519 520 521 522
{
    /* keyboard functions */
    nulldrv_ActivateKeyboardLayout,
    nulldrv_Beep,
    nulldrv_GetAsyncKeyState,
    nulldrv_GetKeyNameText,
    nulldrv_GetKeyboardLayout,
523
    nulldrv_GetKeyboardLayoutList,
524 525 526
    nulldrv_GetKeyboardLayoutName,
    nulldrv_LoadKeyboardLayout,
    nulldrv_MapVirtualKeyEx,
527
    nulldrv_RegisterHotKey,
528 529
    nulldrv_ToUnicodeEx,
    nulldrv_UnloadKeyboardLayout,
530
    nulldrv_UnregisterHotKey,
531
    nulldrv_VkKeyScanEx,
532 533
    /* cursor/icon functions */
    nulldrv_DestroyCursorIcon,
534 535 536
    nulldrv_SetCursor,
    nulldrv_GetCursorPos,
    nulldrv_SetCursorPos,
537
    nulldrv_ClipCursor,
538 539 540 541 542 543 544 545 546 547 548
    /* clipboard functions */
    nulldrv_AcquireClipboard,
    nulldrv_CountClipboardFormats,
    nulldrv_EmptyClipboard,
    nulldrv_EndClipboardUpdate,
    nulldrv_EnumClipboardFormats,
    nulldrv_GetClipboardData,
    nulldrv_IsClipboardFormatAvailable,
    nulldrv_SetClipboardData,
    /* display modes */
    nulldrv_ChangeDisplaySettingsEx,
549
    nulldrv_EnumDisplayMonitors,
550
    nulldrv_EnumDisplaySettingsEx,
551
    nulldrv_GetMonitorInfo,
552 553 554 555
    /* windowing functions */
    nulldrv_CreateDesktopWindow,
    nulldrv_CreateWindow,
    nulldrv_DestroyWindow,
556
    nulldrv_GetDC,
557 558 559
    nulldrv_MsgWaitForMultipleObjectsEx,
    nulldrv_ReleaseDC,
    nulldrv_ScrollDC,
560
    nulldrv_SetCapture,
561
    nulldrv_SetFocus,
562
    nulldrv_SetLayeredWindowAttributes,
563 564 565 566 567
    nulldrv_SetParent,
    nulldrv_SetWindowRgn,
    nulldrv_SetWindowIcon,
    nulldrv_SetWindowStyle,
    nulldrv_SetWindowText,
568
    nulldrv_ShowWindow,
569
    nulldrv_SysCommand,
570
    nulldrv_UpdateLayeredWindow,
571 572
    nulldrv_WindowMessage,
    nulldrv_WindowPosChanging,
573 574 575
    nulldrv_WindowPosChanged,
    /* system parameters */
    nulldrv_SystemParametersInfo
576 577 578 579 580 581 582 583 584 585
};


/**********************************************************************
 * Lazy loading user driver
 *
 * Initial driver used before another driver is loaded.
 * Each entry point simply loads the real driver and chains to it.
 */

586
static HKL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
587 588 589 590
{
    return load_driver()->pActivateKeyboardLayout( layout, flags );
}

591
static void CDECL loaderdrv_Beep(void)
592 593 594 595
{
    load_driver()->pBeep();
}

596
static SHORT CDECL loaderdrv_GetAsyncKeyState( INT key )
597 598 599 600
{
    return load_driver()->pGetAsyncKeyState( key );
}

601
static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
602 603 604 605
{
    return load_driver()->pGetKeyNameText( lparam, buffer, size );
}

606
static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD thread_id )
607
{
608
    return load_driver()->pGetKeyboardLayout( thread_id );
609 610
}

611 612 613 614 615
static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
    return load_driver()->pGetKeyboardLayoutList( size, layouts );
}

616
static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
617 618 619 620
{
    return load_driver()->pGetKeyboardLayoutName( name );
}

621
static HKL CDECL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
622 623 624 625
{
    return load_driver()->pLoadKeyboardLayout( name, flags );
}

626
static UINT CDECL loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
627 628 629 630
{
    return load_driver()->pMapVirtualKeyEx( code, type, layout );
}

631 632 633 634 635
static BOOL CDECL loaderdrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    return load_driver()->pRegisterHotKey( hwnd, modifiers, vk );
}

636
static INT CDECL loaderdrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
637 638 639 640 641
                                  int size, UINT flags, HKL layout )
{
    return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
}

642
static BOOL CDECL loaderdrv_UnloadKeyboardLayout( HKL layout )
643 644 645 646
{
    return load_driver()->pUnloadKeyboardLayout( layout );
}

647 648 649 650 651
static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
}

652
static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
653 654 655 656
{
    return load_driver()->pVkKeyScanEx( ch, layout );
}

657
static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
658
{
659
    load_driver()->pSetCursor( cursor );
660 661
}

662
static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
663 664 665 666
{
    return load_driver()->pGetCursorPos( pt );
}

667
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
668 669 670 671
{
    return load_driver()->pSetCursorPos( x, y );
}

672
static BOOL CDECL loaderdrv_ClipCursor( LPCRECT clip )
673 674 675 676
{
    return load_driver()->pClipCursor( clip );
}

677
static INT CDECL loaderdrv_AcquireClipboard( HWND hwnd )
678
{
679
    return load_driver()->pAcquireClipboard( hwnd );
680 681
}

682
static BOOL CDECL loaderdrv_CountClipboardFormats(void)
683 684 685 686
{
    return load_driver()->pCountClipboardFormats();
}

687
static void CDECL loaderdrv_EmptyClipboard( BOOL keepunowned )
688 689 690 691
{
    load_driver()->pEmptyClipboard( keepunowned );
}

692
static void CDECL loaderdrv_EndClipboardUpdate(void)
693 694 695 696
{
    load_driver()->pEndClipboardUpdate();
}

697
static UINT CDECL loaderdrv_EnumClipboardFormats( UINT format )
698 699 700 701
{
    return load_driver()->pEnumClipboardFormats( format );
}

702
static HANDLE CDECL loaderdrv_GetClipboardData( UINT format )
703
{
704
    return load_driver()->pGetClipboardData( format );
705 706
}

707
static BOOL CDECL loaderdrv_IsClipboardFormatAvailable( UINT format )
708 709 710 711
{
    return load_driver()->pIsClipboardFormatAvailable( format );
}

712
static BOOL CDECL loaderdrv_SetClipboardData( UINT format, HANDLE handle, BOOL owner )
713
{
714
    return load_driver()->pSetClipboardData( format, handle, owner );
715 716
}

717 718
static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
                                                     DWORD flags, LPVOID lparam )
719 720 721 722
{
    return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
}

723
static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
724 725 726 727
{
    return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
}

728
static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
729 730 731 732
{
    return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
}

733
static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
734 735 736 737
{
    return load_driver()->pGetMonitorInfo( handle, info );
}

738
static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
739 740 741 742
{
    return load_driver()->pCreateDesktopWindow( hwnd );
}

743
static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd )
744
{
745
    return load_driver()->pCreateWindow( hwnd );
746 747
}

748 749
static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
                                   const RECT *top_rect, DWORD flags )
750
{
751
    load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
752 753
}

754
static void CDECL loaderdrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
755 756 757 758
{
    load_driver()->pSetLayeredWindowAttributes( hwnd, key, alpha, flags );
}

759
static void CDECL loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
760
{
761
    load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
762 763
}

764 765 766 767 768 769
static BOOL CDECL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
                                                 const RECT *window_rect )
{
    return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
}

770
static USER_DRIVER lazy_load_driver =
771 772 773 774 775 776 777
{
    /* keyboard functions */
    loaderdrv_ActivateKeyboardLayout,
    loaderdrv_Beep,
    loaderdrv_GetAsyncKeyState,
    loaderdrv_GetKeyNameText,
    loaderdrv_GetKeyboardLayout,
778
    loaderdrv_GetKeyboardLayoutList,
779 780 781
    loaderdrv_GetKeyboardLayoutName,
    loaderdrv_LoadKeyboardLayout,
    loaderdrv_MapVirtualKeyEx,
782
    loaderdrv_RegisterHotKey,
783 784
    loaderdrv_ToUnicodeEx,
    loaderdrv_UnloadKeyboardLayout,
785
    loaderdrv_UnregisterHotKey,
786
    loaderdrv_VkKeyScanEx,
787
    /* cursor/icon functions */
788
    nulldrv_DestroyCursorIcon,
789 790 791
    loaderdrv_SetCursor,
    loaderdrv_GetCursorPos,
    loaderdrv_SetCursorPos,
792
    loaderdrv_ClipCursor,
793 794 795 796 797 798 799 800 801 802 803
    /* clipboard functions */
    loaderdrv_AcquireClipboard,
    loaderdrv_CountClipboardFormats,
    loaderdrv_EmptyClipboard,
    loaderdrv_EndClipboardUpdate,
    loaderdrv_EnumClipboardFormats,
    loaderdrv_GetClipboardData,
    loaderdrv_IsClipboardFormatAvailable,
    loaderdrv_SetClipboardData,
    /* display modes */
    loaderdrv_ChangeDisplaySettingsEx,
804
    loaderdrv_EnumDisplayMonitors,
805
    loaderdrv_EnumDisplaySettingsEx,
806
    loaderdrv_GetMonitorInfo,
807 808 809
    /* windowing functions */
    loaderdrv_CreateDesktopWindow,
    loaderdrv_CreateWindow,
810
    nulldrv_DestroyWindow,
811
    loaderdrv_GetDC,
812 813 814 815 816
    nulldrv_MsgWaitForMultipleObjectsEx,
    nulldrv_ReleaseDC,
    nulldrv_ScrollDC,
    nulldrv_SetCapture,
    nulldrv_SetFocus,
817
    loaderdrv_SetLayeredWindowAttributes,
818
    nulldrv_SetParent,
819
    loaderdrv_SetWindowRgn,
820 821 822 823 824
    nulldrv_SetWindowIcon,
    nulldrv_SetWindowStyle,
    nulldrv_SetWindowText,
    nulldrv_ShowWindow,
    nulldrv_SysCommand,
825
    loaderdrv_UpdateLayeredWindow,
826 827 828
    nulldrv_WindowMessage,
    nulldrv_WindowPosChanging,
    nulldrv_WindowPosChanged,
829
    /* system parameters */
830
    nulldrv_SystemParametersInfo
831
};