user.c 25 KB

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