Removed W->A from DEFWND_ImmIsUIMessageW.
[wine] / windows / user.c
1 /*
2  * Misc. USER functions
3  *
4  * Copyright 1993 Robert J. Amstadt
5  *           1996 Alex Korobka
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdarg.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "wine/winbase16.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "wine/winuser16.h"
31 #include "winreg.h"
32 #include "winternl.h"
33 #include "tlhelp32.h"
34 #include "user.h"
35 #include "win.h"
36 #include "controls.h"
37 #include "cursoricon.h"
38 #include "message.h"
39 #include "local.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(user);
43
44 static SYSLEVEL USER_SysLevel;
45 static CRITICAL_SECTION_DEBUG critsect_debug =
46 {
47     0, 0, &USER_SysLevel.crst,
48     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
49       0, 0, { 0, (DWORD)(__FILE__ ": USER_SysLevel") }
50 };
51 static SYSLEVEL USER_SysLevel = { { &critsect_debug, -1, 0, 0, 0, 0 }, 2 };
52
53 /* USER signal proc flags and codes */
54 /* See UserSignalProc for comments */
55 #define USIG_FLAGS_WIN32          0x0001
56 #define USIG_FLAGS_GUI            0x0002
57 #define USIG_FLAGS_FEEDBACK       0x0004
58 #define USIG_FLAGS_FAULT          0x0008
59
60 #define USIG_DLL_UNLOAD_WIN16     0x0001
61 #define USIG_DLL_UNLOAD_WIN32     0x0002
62 #define USIG_FAULT_DIALOG_PUSH    0x0003
63 #define USIG_FAULT_DIALOG_POP     0x0004
64 #define USIG_DLL_UNLOAD_ORPHANS   0x0005
65 #define USIG_THREAD_INIT          0x0010
66 #define USIG_THREAD_EXIT          0x0020
67 #define USIG_PROCESS_CREATE       0x0100
68 #define USIG_PROCESS_INIT         0x0200
69 #define USIG_PROCESS_EXIT         0x0300
70 #define USIG_PROCESS_DESTROY      0x0400
71 #define USIG_PROCESS_RUNNING      0x0500
72 #define USIG_PROCESS_LOADED       0x0600
73
74
75 /***********************************************************************
76  *              GetFreeSystemResources (USER.284)
77  */
78 WORD WINAPI GetFreeSystemResources16( WORD resType )
79 {
80     HINSTANCE16 gdi_inst;
81     WORD gdi_heap;
82     int userPercent, gdiPercent;
83
84     if ((gdi_inst = LoadLibrary16( "GDI" )) < 32) return 0;
85     gdi_heap = gdi_inst | 7;
86
87     switch(resType)
88     {
89     case GFSR_USERRESOURCES:
90         userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
91                                LOCAL_HeapSize( USER_HeapSel );
92         gdiPercent  = 100;
93         break;
94
95     case GFSR_GDIRESOURCES:
96         gdiPercent  = (int)LOCAL_CountFree( gdi_inst ) * 100 /
97                                LOCAL_HeapSize( gdi_inst );
98         userPercent = 100;
99         break;
100
101     case GFSR_SYSTEMRESOURCES:
102         userPercent = (int)LOCAL_CountFree( USER_HeapSel ) * 100 /
103                                LOCAL_HeapSize( USER_HeapSel );
104         gdiPercent  = (int)LOCAL_CountFree( gdi_inst ) * 100 /
105                                LOCAL_HeapSize( gdi_inst );
106         break;
107
108     default:
109         userPercent = gdiPercent = 0;
110         break;
111     }
112     FreeLibrary16( gdi_inst );
113     TRACE("<- userPercent %d, gdiPercent %d\n", userPercent, gdiPercent);
114     return (WORD)min( userPercent, gdiPercent );
115 }
116
117
118 /**********************************************************************
119  *              InitApp (USER.5)
120  */
121 INT16 WINAPI InitApp16( HINSTANCE16 hInstance )
122 {
123     /* Create task message queue */
124     if ( !InitThreadInput16( 0, 0 ) ) return 0;
125
126     return 1;
127 }
128
129
130 /***********************************************************************
131  *           USER_Lock
132  */
133 void USER_Lock(void)
134 {
135     _EnterSysLevel( &USER_SysLevel );
136 }
137
138
139 /***********************************************************************
140  *           USER_Unlock
141  */
142 void USER_Unlock(void)
143 {
144     _LeaveSysLevel( &USER_SysLevel );
145 }
146
147
148 /***********************************************************************
149  *           USER_CheckNotLock
150  *
151  * Make sure that we don't hold the user lock.
152  */
153 void USER_CheckNotLock(void)
154 {
155     _CheckNotSysLevel( &USER_SysLevel );
156 }
157
158
159 /***********************************************************************
160  *           WIN_SuspendWndsLock
161  *
162  * Suspend the lock on WND structures.
163  * Returns the number of locks suspended
164  * FIXME: should be removed
165  */
166 int WIN_SuspendWndsLock( void )
167 {
168     int isuspendedLocks = _ConfirmSysLevel( &USER_SysLevel );
169     int count = isuspendedLocks;
170
171     while ( count-- > 0 )
172         _LeaveSysLevel( &USER_SysLevel );
173
174     return isuspendedLocks;
175 }
176
177 /***********************************************************************
178  *           WIN_RestoreWndsLock
179  *
180  * Restore the suspended locks on WND structures
181  * FIXME: should be removed
182  */
183 void WIN_RestoreWndsLock( int ipreviousLocks )
184 {
185     while ( ipreviousLocks-- > 0 )
186         _EnterSysLevel( &USER_SysLevel );
187 }
188
189 /***********************************************************************
190  *              FinalUserInit (USER.400)
191  */
192 void WINAPI FinalUserInit16( void )
193 {
194     /* FIXME: Should chain to FinalGdiInit now. */
195 }
196
197 /***********************************************************************
198  *              SignalProc32 (USER.391)
199  *              UserSignalProc (USER32.@)
200  *
201  * The exact meaning of the USER signals is undocumented, but this
202  * should cover the basic idea:
203  *
204  * USIG_DLL_UNLOAD_WIN16
205  *     This is sent when a 16-bit module is unloaded.
206  *
207  * USIG_DLL_UNLOAD_WIN32
208  *     This is sent when a 32-bit module is unloaded.
209  *
210  * USIG_DLL_UNLOAD_ORPHANS
211  *     This is sent after the last Win3.1 module is unloaded,
212  *     to allow removal of orphaned menus.
213  *
214  * USIG_FAULT_DIALOG_PUSH
215  * USIG_FAULT_DIALOG_POP
216  *     These are called to allow USER to prepare for displaying a
217  *     fault dialog, even though the fault might have happened while
218  *     inside a USER critical section.
219  *
220  * USIG_THREAD_INIT
221  *     This is called from the context of a new thread, as soon as it
222  *     has started to run.
223  *
224  * USIG_THREAD_EXIT
225  *     This is called, still in its context, just before a thread is
226  *     about to terminate.
227  *
228  * USIG_PROCESS_CREATE
229  *     This is called, in the parent process context, after a new process
230  *     has been created.
231  *
232  * USIG_PROCESS_INIT
233  *     This is called in the new process context, just after the main thread
234  *     has started execution (after the main thread's USIG_THREAD_INIT has
235  *     been sent).
236  *
237  * USIG_PROCESS_LOADED
238  *     This is called after the executable file has been loaded into the
239  *     new process context.
240  *
241  * USIG_PROCESS_RUNNING
242  *     This is called immediately before the main entry point is called.
243  *
244  * USIG_PROCESS_EXIT
245  *     This is called in the context of a process that is about to
246  *     terminate (but before the last thread's USIG_THREAD_EXIT has
247  *     been sent).
248  *
249  * USIG_PROCESS_DESTROY
250  *     This is called after a process has terminated.
251  *
252  *
253  * The meaning of the dwFlags bits is as follows:
254  *
255  * USIG_FLAGS_WIN32
256  *     Current process is 32-bit.
257  *
258  * USIG_FLAGS_GUI
259  *     Current process is a (Win32) GUI process.
260  *
261  * USIG_FLAGS_FEEDBACK
262  *     Current process needs 'feedback' (determined from the STARTUPINFO
263  *     flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
264  *
265  * USIG_FLAGS_FAULT
266  *     The signal is being sent due to a fault.
267  */
268 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
269                             DWORD dwFlags, HMODULE16 hModule )
270 {
271     FIXME("(%04x, %08lx, %04lx, %04x)\n",
272           uCode, dwThreadOrProcessID, dwFlags, hModule );
273     /* FIXME: Should chain to GdiSignalProc now. */
274     return 0;
275 }
276
277 /***********************************************************************
278  *              ExitWindows (USER.7)
279  */
280 BOOL16 WINAPI ExitWindows16( DWORD dwReturnCode, UINT16 wReserved )
281 {
282     return ExitWindowsEx( EWX_LOGOFF, 0xffffffff );
283 }
284
285
286 /***********************************************************************
287  *              ExitWindowsExec (USER.246)
288  */
289 BOOL16 WINAPI ExitWindowsExec16( LPCSTR lpszExe, LPCSTR lpszParams )
290 {
291     TRACE("Should run the following in DOS-mode: \"%s %s\"\n",
292           lpszExe, lpszParams);
293     return ExitWindowsEx( EWX_LOGOFF, 0xffffffff );
294 }
295
296
297 /***********************************************************************
298  *           USER_GetProcessHandleList(Internal)
299  */
300 static HANDLE *USER_GetProcessHandleList(void)
301 {
302     DWORD count, i, n;
303     HANDLE *list;
304     PROCESSENTRY32 pe;
305     HANDLE hSnapshot;
306     BOOL r;
307
308     hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
309     if (!hSnapshot)
310     {
311         ERR("cannot create snapshot\n");
312         return FALSE;
313     }
314
315     /* count the number of processes plus one */
316     for (count=0; ;count++)
317     {
318         pe.dwSize = sizeof pe;
319         if (count)
320             r = Process32Next( hSnapshot, &pe );
321         else
322             r = Process32First( hSnapshot, &pe );
323         if (!r)
324             break;
325     }
326
327     /* allocate memory make a list of the process handles */
328     list = HeapAlloc( GetProcessHeap(), 0, (count+1)*sizeof(HANDLE) );
329     n=0;
330     for (i=0; i<count; i++)
331     {
332         pe.dwSize = sizeof pe;
333         if (i)
334             r = Process32Next( hSnapshot, &pe );
335         else
336             r = Process32First( hSnapshot, &pe );
337         if (!r)
338             break;
339
340         /* don't kill outselves */
341         if (GetCurrentProcessId() == pe.th32ProcessID )
342             continue;
343
344         /* open the process so we don't can track it */
345         list[n] = OpenProcess( PROCESS_QUERY_INFORMATION|
346                                   PROCESS_TERMINATE,
347                                   FALSE, pe.th32ProcessID );
348
349         /* check it didn't terminate already */
350         if( list[n] )
351             n++;
352     }
353     list[n]=0;
354     CloseHandle( hSnapshot );
355
356     if (!r)
357         ERR("Error enumerating processes\n");
358
359     TRACE("return %lu processes\n", n);
360
361     return list;
362 }
363
364 /***********************************************************************
365  *              USER_KillProcesses (Internal)
366  */
367 static DWORD USER_KillProcesses(void)
368 {
369     DWORD n, r, i;
370     HANDLE *handles;
371     const DWORD dwShutdownTimeout = 10000;
372
373     TRACE("terminating other processes\n");
374
375     /* kill it and add it to our list of object to wait on */
376     handles = USER_GetProcessHandleList();
377     for (n=0; handles && handles[n]; n++)
378         TerminateProcess( handles[n], 0 );
379
380     /* wait for processes to exit */
381     for (i=0; i<n; i+=MAXIMUM_WAIT_OBJECTS)
382     {
383         int n_objs = ((n-i)>MAXIMUM_WAIT_OBJECTS) ? MAXIMUM_WAIT_OBJECTS : (n-i);
384         r = WaitForMultipleObjects( n_objs, &handles[i], TRUE, dwShutdownTimeout );
385         if (r==WAIT_TIMEOUT)
386             ERR("wait failed!\n");
387     }
388     
389     /* close the handles */
390     for (i=0; i<n; i++)
391         CloseHandle( handles[i] );
392
393     HeapFree( GetProcessHeap(), 0, handles );
394
395     return n;
396 }
397  
398 /***********************************************************************
399  *              USER_DoShutdown (Internal)
400  */
401 static void USER_DoShutdown(void)
402 {
403     DWORD i, n;
404     const DWORD nRetries = 10;
405
406     for (i=0; i<nRetries; i++)
407     {
408         n = USER_KillProcesses();
409         TRACE("Killed %ld processes, attempt %ld\n", n, i);
410         if(!n)
411             break;
412     }
413 }
414  
415 /***********************************************************************
416  *              USER_StartRebootProcess (Internal)
417  */
418 static BOOL USER_StartRebootProcess(void)
419 {
420     WCHAR winebootW[] = { 'w','i','n','e','b','o','o','t',0 };
421     PROCESS_INFORMATION pi;
422     STARTUPINFOW si;
423     BOOL r;
424
425     memset( &si, 0, sizeof si );
426     si.cb = sizeof si;
427
428     r = CreateProcessW( NULL, winebootW, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
429     if (r)
430     {
431         CloseHandle( pi.hProcess );
432         CloseHandle( pi.hThread );
433     }
434     else
435         MESSAGE("wine: Failed to start wineboot\n");
436
437     return r;
438 }
439
440 /***********************************************************************
441  *              ExitWindowsEx (USER32.@)
442  */
443 BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reserved )
444 {
445     int i;
446     BOOL result;
447     HWND *list, *phwnd;
448
449     /* We have to build a list of all windows first, as in EnumWindows */
450
451     if (!(list = WIN_ListChildren( GetDesktopWindow() ))) return FALSE;
452
453     /* Send a WM_QUERYENDSESSION message to every window */
454
455     for (i = 0; list[i]; i++)
456     {
457         /* Make sure that the window still exists */
458         if (!IsWindow( list[i] )) continue;
459         if (!SendMessageW( list[i], WM_QUERYENDSESSION, 0, 0 )) break;
460     }
461     result = !list[i];
462
463     /* Now notify all windows that got a WM_QUERYENDSESSION of the result */
464
465     for (phwnd = list; i > 0; i--, phwnd++)
466     {
467         if (!IsWindow( *phwnd )) continue;
468         SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
469     }
470     HeapFree( GetProcessHeap(), 0, list );
471
472     /* USER_DoShutdown will kill all processes except the current process */
473     USER_DoShutdown();
474
475     if (flags & EWX_REBOOT)
476         USER_StartRebootProcess();
477
478     if (result) ExitKernel16();
479     return TRUE;
480 }
481
482 /***********************************************************************
483  *              ChangeDisplaySettingsA (USER32.@)
484  */
485 LONG WINAPI ChangeDisplaySettingsA( LPDEVMODEA devmode, DWORD flags )
486 {
487   return ChangeDisplaySettingsExA(NULL,devmode,NULL,flags,NULL);
488 }
489
490 /***********************************************************************
491  *              ChangeDisplaySettingsW (USER32.@)
492  */
493 LONG WINAPI ChangeDisplaySettingsW( LPDEVMODEW devmode, DWORD flags )
494 {
495   return ChangeDisplaySettingsExW(NULL,devmode,NULL,flags,NULL);
496 }
497
498 /***********************************************************************
499  *              ChangeDisplaySettings (USER.620)
500  */
501 LONG WINAPI ChangeDisplaySettings16( LPDEVMODEA devmode, DWORD flags )
502 {
503         return ChangeDisplaySettingsA(devmode, flags);
504 }
505
506 /***********************************************************************
507  *              ChangeDisplaySettingsExA (USER32.@)
508  */
509 LONG WINAPI ChangeDisplaySettingsExA(
510         LPCSTR devname, LPDEVMODEA devmode, HWND hwnd, DWORD flags,
511         LPVOID lparam
512 ) {
513     DEVMODEW devmodeW;
514     LONG ret;
515     UNICODE_STRING nameW;
516
517     if (devname) RtlCreateUnicodeStringFromAsciiz(&nameW, devname);
518     else nameW.Buffer = NULL;
519
520     if (devmode)
521     {
522         devmodeW.dmBitsPerPel       = devmode->dmBitsPerPel;
523         devmodeW.dmPelsHeight       = devmode->dmPelsHeight;
524         devmodeW.dmPelsWidth        = devmode->dmPelsWidth;
525         devmodeW.dmDisplayFlags     = devmode->dmDisplayFlags;
526         devmodeW.dmDisplayFrequency = devmode->dmDisplayFrequency;
527         devmodeW.dmFields           = devmode->dmFields;
528         ret = ChangeDisplaySettingsExW(nameW.Buffer, &devmodeW, hwnd, flags, lparam);
529     }
530     else
531     {
532         ret = ChangeDisplaySettingsExW(nameW.Buffer, NULL, hwnd, flags, lparam);
533     }
534
535     if (devname) RtlFreeUnicodeString(&nameW);
536     return ret;
537 }
538
539 /***********************************************************************
540  *              ChangeDisplaySettingsExW (USER32.@)
541  */
542 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
543                                       DWORD flags, LPVOID lparam )
544 {
545     /* Pass the request on to the driver */
546     if (!USER_Driver.pChangeDisplaySettingsExW) return DISP_CHANGE_FAILED;
547     return USER_Driver.pChangeDisplaySettingsExW( devname, devmode, hwnd, flags, lparam );
548 }
549
550 /***********************************************************************
551  *              EnumDisplaySettingsW (USER32.@)
552  *
553  * RETURNS
554  *      TRUE if nth setting exists found (described in the LPDEVMODEW struct)
555  *      FALSE if we do not have the nth setting
556  */
557 BOOL WINAPI EnumDisplaySettingsW(
558         LPCWSTR name,           /* [in] huh? */
559         DWORD n,                /* [in] nth entry in display settings list*/
560         LPDEVMODEW devmode      /* [out] devmode for that setting */
561 ) {
562     return EnumDisplaySettingsExW(name, n, devmode, 0);
563 }
564
565 /***********************************************************************
566  *              EnumDisplaySettingsA (USER32.@)
567  */
568 BOOL WINAPI EnumDisplaySettingsA(LPCSTR name,DWORD n,LPDEVMODEA devmode)
569 {
570     return EnumDisplaySettingsExA(name, n, devmode, 0);
571 }
572
573 /***********************************************************************
574  *              EnumDisplaySettings (USER.621)
575  */
576 BOOL16 WINAPI EnumDisplaySettings16(
577         LPCSTR name,            /* [in] huh? */
578         DWORD n,                /* [in] nth entry in display settings list*/
579         LPDEVMODEA devmode      /* [out] devmode for that setting */
580 ) {
581         return (BOOL16)EnumDisplaySettingsA(name, n, devmode);
582 }
583
584 /***********************************************************************
585  *              EnumDisplaySettingsExA (USER32.@)
586  */
587 BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum,
588                                    LPDEVMODEA lpDevMode, DWORD dwFlags)
589 {
590     DEVMODEW devmodeW;
591     BOOL ret;
592     UNICODE_STRING nameW;
593
594     if (lpszDeviceName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszDeviceName);
595     else nameW.Buffer = NULL;
596
597     ret = EnumDisplaySettingsExW(nameW.Buffer,iModeNum,&devmodeW,dwFlags);
598     if (ret)
599     {
600         lpDevMode->dmBitsPerPel       = devmodeW.dmBitsPerPel;
601         lpDevMode->dmPelsHeight       = devmodeW.dmPelsHeight;
602         lpDevMode->dmPelsWidth        = devmodeW.dmPelsWidth;
603         lpDevMode->dmDisplayFlags     = devmodeW.dmDisplayFlags;
604         lpDevMode->dmDisplayFrequency = devmodeW.dmDisplayFrequency;
605         lpDevMode->dmFields           = devmodeW.dmFields;
606     }
607     if (lpszDeviceName) RtlFreeUnicodeString(&nameW);
608     return ret;
609 }
610
611 /***********************************************************************
612  *              EnumDisplaySettingsExW (USER32.@)
613  */
614 BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
615                                    LPDEVMODEW lpDevMode, DWORD dwFlags)
616 {
617     /* Pass the request on to the driver */
618     if (!USER_Driver.pEnumDisplaySettingsExW) return FALSE;
619     return USER_Driver.pEnumDisplaySettingsExW(lpszDeviceName, iModeNum, lpDevMode, dwFlags);
620 }
621
622 /***********************************************************************
623  *              EnumDisplayDevicesA (USER32.@)
624  */
625 BOOL WINAPI EnumDisplayDevicesA(
626         LPVOID unused,DWORD i,LPDISPLAY_DEVICEA lpDisplayDevice,DWORD dwFlags
627 ) {
628         if (i)
629                 return FALSE;
630         FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
631         strcpy(lpDisplayDevice->DeviceName,"X11");
632         strcpy(lpDisplayDevice->DeviceString,"X 11 Windowing System");
633         lpDisplayDevice->StateFlags =
634                         DISPLAY_DEVICE_ATTACHED_TO_DESKTOP      |
635                         DISPLAY_DEVICE_PRIMARY_DEVICE           |
636                         DISPLAY_DEVICE_VGA_COMPATIBLE;
637         return TRUE;
638 }
639
640 /***********************************************************************
641  *              EnumDisplayDevicesW (USER32.@)
642  */
643 BOOL WINAPI EnumDisplayDevicesW(
644         LPVOID unused,DWORD i,LPDISPLAY_DEVICEW lpDisplayDevice,DWORD dwFlags
645 ) {
646         if (i)
647                 return FALSE;
648         FIXME("(%p,%ld,%p,0x%08lx), stub!\n",unused,i,lpDisplayDevice,dwFlags);
649         MultiByteToWideChar( CP_ACP, 0, "X11", -1, lpDisplayDevice->DeviceName,
650                              sizeof(lpDisplayDevice->DeviceName)/sizeof(WCHAR) );
651         MultiByteToWideChar( CP_ACP, 0, "X11 Windowing System", -1, lpDisplayDevice->DeviceString,
652                              sizeof(lpDisplayDevice->DeviceString)/sizeof(WCHAR) );
653         lpDisplayDevice->StateFlags =
654                         DISPLAY_DEVICE_ATTACHED_TO_DESKTOP      |
655                         DISPLAY_DEVICE_PRIMARY_DEVICE           |
656                         DISPLAY_DEVICE_VGA_COMPATIBLE;
657         return TRUE;
658 }
659
660 /***********************************************************************
661  *              SetEventHook (USER.321)
662  *
663  *      Used by Turbo Debugger for Windows
664  */
665 FARPROC16 WINAPI SetEventHook16(FARPROC16 lpfnEventHook)
666 {
667         FIXME("(lpfnEventHook=%08x): stub\n", (UINT)lpfnEventHook);
668         return NULL;
669 }
670
671 /***********************************************************************
672  *              UserSeeUserDo (USER.216)
673  */
674 DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wParam3)
675 {
676     switch (wReqType)
677     {
678     case USUD_LOCALALLOC:
679         return LOCAL_Alloc(USER_HeapSel, wParam1, wParam3);
680     case USUD_LOCALFREE:
681         return LOCAL_Free(USER_HeapSel, wParam1);
682     case USUD_LOCALCOMPACT:
683         return LOCAL_Compact(USER_HeapSel, wParam3, 0);
684     case USUD_LOCALHEAP:
685         return USER_HeapSel;
686     case USUD_FIRSTCLASS:
687         FIXME("return a pointer to the first window class.\n");
688         return (DWORD)-1;
689     default:
690         WARN("wReqType %04x (unknown)\n", wReqType);
691         return (DWORD)-1;
692     }
693 }
694
695 /***********************************************************************
696  *              GetSystemDebugState (USER.231)
697  */
698 WORD WINAPI GetSystemDebugState16(void)
699 {
700     return 0;  /* FIXME */
701 }
702
703 /***********************************************************************
704  *              RegisterLogonProcess (USER32.@)
705  */
706 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x) {
707         FIXME("(%p,%d),stub!\n",hprocess,x);
708         return 1;
709 }
710
711 /***********************************************************************
712  *              CreateWindowStationW (USER32.@)
713  */
714 HWINSTA WINAPI CreateWindowStationW(
715         LPWSTR winstation,DWORD res1,DWORD desiredaccess,
716         LPSECURITY_ATTRIBUTES lpsa
717 ) {
718         FIXME("(%s,0x%08lx,0x%08lx,%p),stub!\n",debugstr_w(winstation),
719                 res1,desiredaccess,lpsa
720         );
721         return (HWINSTA)0xdeadcafe;
722 }
723
724 /***********************************************************************
725  *              SetProcessWindowStation (USER32.@)
726  */
727 BOOL WINAPI SetProcessWindowStation(HWINSTA hWinSta) {
728         FIXME("(%p),stub!\n",hWinSta);
729         return TRUE;
730 }
731
732 /***********************************************************************
733  *              SetUserObjectSecurity (USER32.@)
734  */
735 BOOL WINAPI SetUserObjectSecurity(
736         HANDLE hObj,
737         PSECURITY_INFORMATION pSIRequested,
738         PSECURITY_DESCRIPTOR pSID
739 ) {
740         FIXME("(%p,%p,%p),stub!\n",hObj,pSIRequested,pSID);
741         return TRUE;
742 }
743
744 /***********************************************************************
745  *              CreateDesktopA (USER32.@)
746  */
747 HDESK WINAPI CreateDesktopA(
748         LPSTR lpszDesktop,LPSTR lpszDevice,LPDEVMODEA pDevmode,
749         DWORD dwFlags,DWORD dwDesiredAccess,LPSECURITY_ATTRIBUTES lpsa
750 ) {
751         FIXME("(%s,%s,%p,0x%08lx,0x%08lx,%p),stub!\n",
752                 lpszDesktop,lpszDevice,pDevmode,
753                 dwFlags,dwDesiredAccess,lpsa
754         );
755         return (HDESK)0xcafedead;
756 }
757
758 /***********************************************************************
759  *              CreateDesktopW (USER32.@)
760  */
761 HDESK WINAPI CreateDesktopW(
762         LPWSTR lpszDesktop,LPWSTR lpszDevice,LPDEVMODEW pDevmode,
763         DWORD dwFlags,DWORD dwDesiredAccess,LPSECURITY_ATTRIBUTES lpsa
764 ) {
765         FIXME("(%s,%s,%p,0x%08lx,0x%08lx,%p),stub!\n",
766                 debugstr_w(lpszDesktop),debugstr_w(lpszDevice),pDevmode,
767                 dwFlags,dwDesiredAccess,lpsa
768         );
769         return (HDESK)0xcafedead;
770 }
771
772 /***********************************************************************
773  *              EnumDesktopWindows (USER32.@)
774  */
775 BOOL WINAPI EnumDesktopWindows( HDESK hDesktop, WNDENUMPROC lpfn, LPARAM lParam ) {
776   FIXME("(%p, %p, 0x%08lx), stub!\n", hDesktop, lpfn, lParam );
777   return TRUE;
778 }
779
780
781 /***********************************************************************
782  *              CloseWindowStation (USER32.@)
783  */
784 BOOL WINAPI CloseWindowStation(HWINSTA hWinSta)
785 {
786     FIXME("(%p)\n", hWinSta);
787     return TRUE;
788 }
789
790 /***********************************************************************
791  *              CloseDesktop (USER32.@)
792  */
793 BOOL WINAPI CloseDesktop(HDESK hDesk)
794 {
795     FIXME("(%p)\n", hDesk);
796     return TRUE;
797 }
798
799 /***********************************************************************
800  *              SetWindowStationUser (USER32.@)
801  */
802 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2) {
803         FIXME("(0x%08lx,0x%08lx),stub!\n",x1,x2);
804         return 1;
805 }
806
807 /***********************************************************************
808  *              SetLogonNotifyWindow (USER32.@)
809  */
810 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd) {
811         FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
812         return 1;
813 }
814
815 /***********************************************************************
816  *              LoadLocalFonts (USER32.@)
817  */
818 VOID WINAPI LoadLocalFonts(VOID) {
819         /* are loaded. */
820         return;
821 }
822 /***********************************************************************
823  *              GetUserObjectInformationA (USER32.@)
824  */
825 BOOL WINAPI GetUserObjectInformationA( HANDLE hObj, INT nIndex, LPVOID pvInfo, DWORD nLength, LPDWORD lpnLen )
826 {       FIXME("(%p %i %p %ld %p),stub!\n", hObj, nIndex, pvInfo, nLength, lpnLen );
827         return TRUE;
828 }
829 /***********************************************************************
830  *              GetUserObjectInformationW (USER32.@)
831  */
832 BOOL WINAPI GetUserObjectInformationW( HANDLE hObj, INT nIndex, LPVOID pvInfo, DWORD nLength, LPDWORD lpnLen )
833 {       FIXME("(%p %i %p %ld %p),stub!\n", hObj, nIndex, pvInfo, nLength, lpnLen );
834         return TRUE;
835 }
836 /***********************************************************************
837  *              GetUserObjectSecurity (USER32.@)
838  */
839 BOOL WINAPI GetUserObjectSecurity(HANDLE hObj, PSECURITY_INFORMATION pSIRequested,
840         PSECURITY_DESCRIPTOR pSID, DWORD nLength, LPDWORD lpnLengthNeeded)
841 {       FIXME("(%p %p %p len=%ld %p),stub!\n",  hObj, pSIRequested, pSID, nLength, lpnLengthNeeded);
842         return TRUE;
843 }
844
845 /***********************************************************************
846  *              SetSystemCursor (USER32.@)
847  */
848 BOOL WINAPI SetSystemCursor(HCURSOR hcur, DWORD id)
849 {       FIXME("(%p,%08lx),stub!\n",  hcur, id);
850         return TRUE;
851 }
852
853 /***********************************************************************
854  *              RegisterSystemThread (USER32.@)
855  */
856 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
857 {
858         FIXME("(%08lx, %08lx)\n", flags, reserved);
859 }
860
861 /***********************************************************************
862  *              RegisterDeviceNotificationA (USER32.@)
863  *
864  * See RegisterDeviceNotificationW.
865  */
866 HDEVNOTIFY WINAPI RegisterDeviceNotificationA(HANDLE hnd, LPVOID notifyfilter, DWORD flags)
867 {
868     FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hnd,notifyfilter,flags );
869     return 0;
870 }
871
872 /***********************************************************************
873  *              RegisterDeviceNotificationW (USER32.@)
874  *
875  * Registers a window with the system so that it will receive
876  * notifications about a device.
877  *
878  * PARAMS
879  *     hRecepient           [I] Window or service status handle that
880  *                              will receive notifications.
881  *     pNotificationFilter  [I] DEV_BROADCAST_HDR followed by some
882  *                              type-specific data.
883  *     dwFlags              [I] See notes
884  *
885  * RETURNS
886  *
887  * A handle to the device notification.
888  *
889  * NOTES
890  *
891  * The dwFlags parameter can be one of two values:
892  *| DEVICE_NOTIFY_WINDOW_HANDLE  - hRecepient is a window handle
893  *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecepient is a service status handle
894  */
895 HDEVNOTIFY WINAPI RegisterDeviceNotificationW(HANDLE hRecepient, LPVOID pNotificationFilter, DWORD dwFlags)
896 {
897     FIXME("(hwnd=%p, filter=%p,flags=0x%08lx), STUB!\n", hRecepient,pNotificationFilter,dwFlags );
898     return 0;
899 }