2000-03-19 12:08:09 +00:00
|
|
|
/*
|
|
|
|
* USER initialization code
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* Copyright 2000 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
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-03-19 12:08:09 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2005-05-06 19:38:50 +00:00
|
|
|
#include <stdio.h>
|
2001-01-22 02:17:29 +00:00
|
|
|
#include <string.h>
|
2000-03-19 12:08:09 +00:00
|
|
|
#include "windef.h"
|
2000-12-19 04:53:20 +00:00
|
|
|
#include "winbase.h"
|
2000-03-19 12:08:09 +00:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2000-08-03 00:04:24 +00:00
|
|
|
#include "winreg.h"
|
2005-05-25 18:42:37 +00:00
|
|
|
#include "tlhelp32.h"
|
2000-03-19 12:08:09 +00:00
|
|
|
|
2000-12-10 23:01:33 +00:00
|
|
|
#include "controls.h"
|
2004-12-08 18:06:14 +00:00
|
|
|
#include "user_private.h"
|
2000-03-19 12:08:09 +00:00
|
|
|
#include "win.h"
|
2006-03-27 10:57:17 +00:00
|
|
|
#include "wine/unicode.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2000-08-03 00:04:24 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(graphics);
|
2000-08-10 01:16:19 +00:00
|
|
|
|
2006-03-27 10:57:17 +00:00
|
|
|
#define DESKTOP_ALL_ACCESS 0x01ff
|
|
|
|
|
2001-03-23 19:13:23 +00:00
|
|
|
WORD USER_HeapSel = 0; /* USER heap selector */
|
2004-02-12 00:35:01 +00:00
|
|
|
HMODULE user32_module = 0;
|
2001-03-23 19:13:23 +00:00
|
|
|
|
2005-04-27 11:09:55 +00:00
|
|
|
static SYSLEVEL USER_SysLevel;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &USER_SysLevel.crst,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
2005-09-09 10:19:44 +00:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": USER_SysLevel") }
|
2005-04-27 11:09:55 +00:00
|
|
|
};
|
|
|
|
static SYSLEVEL USER_SysLevel = { { &critsect_debug, -1, 0, 0, 0, 0 }, 2 };
|
|
|
|
|
2004-12-08 14:12:09 +00:00
|
|
|
static HPALETTE (WINAPI *pfnGDISelectPalette)( HDC hdc, HPALETTE hpal, WORD bkgnd );
|
|
|
|
static UINT (WINAPI *pfnGDIRealizePalette)( HDC hdc );
|
|
|
|
static HPALETTE hPrimaryPalette;
|
2002-10-18 04:05:49 +00:00
|
|
|
|
2001-10-16 21:58:58 +00:00
|
|
|
static DWORD exiting_thread_id;
|
2000-08-10 01:16:19 +00:00
|
|
|
|
2001-10-16 21:58:58 +00:00
|
|
|
extern void WDML_NotifyThreadDetach(void);
|
2001-07-24 20:49:41 +00:00
|
|
|
|
2000-03-19 12:08:09 +00:00
|
|
|
|
2005-04-27 11:09:55 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* USER_Lock
|
|
|
|
*/
|
|
|
|
void USER_Lock(void)
|
|
|
|
{
|
|
|
|
_EnterSysLevel( &USER_SysLevel );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_Unlock
|
|
|
|
*/
|
|
|
|
void USER_Unlock(void)
|
|
|
|
{
|
|
|
|
_LeaveSysLevel( &USER_SysLevel );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_CheckNotLock
|
|
|
|
*
|
|
|
|
* Make sure that we don't hold the user lock.
|
|
|
|
*/
|
|
|
|
void USER_CheckNotLock(void)
|
|
|
|
{
|
|
|
|
_CheckNotSysLevel( &USER_SysLevel );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-08 14:12:09 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* UserSelectPalette (Not a Windows API)
|
|
|
|
*/
|
|
|
|
static HPALETTE WINAPI UserSelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackground )
|
|
|
|
{
|
|
|
|
WORD wBkgPalette = 1;
|
|
|
|
|
|
|
|
if (!bForceBackground && (hPal != GetStockObject(DEFAULT_PALETTE)))
|
|
|
|
{
|
|
|
|
HWND hwnd = WindowFromDC( hDC );
|
|
|
|
if (hwnd)
|
|
|
|
{
|
|
|
|
HWND hForeground = GetForegroundWindow();
|
|
|
|
/* set primary palette if it's related to current active */
|
|
|
|
if (hForeground == hwnd || IsChild(hForeground,hwnd))
|
|
|
|
{
|
|
|
|
wBkgPalette = 0;
|
|
|
|
hPrimaryPalette = hPal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pfnGDISelectPalette( hDC, hPal, wBkgPalette);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UserRealizePalette (USER32.@)
|
|
|
|
*/
|
|
|
|
UINT WINAPI UserRealizePalette( HDC hDC )
|
|
|
|
{
|
|
|
|
UINT realized = pfnGDIRealizePalette( hDC );
|
|
|
|
|
|
|
|
/* do not send anything if no colors were changed */
|
|
|
|
if (realized && GetCurrentObject( hDC, OBJ_PAL ) == hPrimaryPalette)
|
|
|
|
{
|
|
|
|
/* send palette change notification */
|
|
|
|
HWND hWnd = WindowFromDC( hDC );
|
|
|
|
if (hWnd) SendMessageTimeoutW( HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0,
|
|
|
|
SMTO_ABORTIFHUNG, 2000, NULL );
|
|
|
|
}
|
|
|
|
return realized;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-16 20:57:39 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* palette_init
|
|
|
|
*
|
|
|
|
* Patch the function pointers in GDI for SelectPalette and RealizePalette
|
|
|
|
*/
|
|
|
|
static void palette_init(void)
|
|
|
|
{
|
|
|
|
void **ptr;
|
|
|
|
HMODULE module = GetModuleHandleA( "gdi32" );
|
|
|
|
if (!module)
|
|
|
|
{
|
|
|
|
ERR( "cannot get GDI32 handle\n" );
|
|
|
|
return;
|
|
|
|
}
|
2002-10-18 04:05:49 +00:00
|
|
|
if ((ptr = (void**)GetProcAddress( module, "pfnSelectPalette" )))
|
2004-12-08 14:12:09 +00:00
|
|
|
pfnGDISelectPalette = InterlockedExchangePointer( ptr, UserSelectPalette );
|
2000-09-16 20:57:39 +00:00
|
|
|
else ERR( "cannot find pfnSelectPalette in GDI32\n" );
|
2002-10-18 04:05:49 +00:00
|
|
|
if ((ptr = (void**)GetProcAddress( module, "pfnRealizePalette" )))
|
|
|
|
pfnGDIRealizePalette = InterlockedExchangePointer( ptr, UserRealizePalette );
|
2000-09-16 20:57:39 +00:00
|
|
|
else ERR( "cannot find pfnRealizePalette in GDI32\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-27 10:57:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* winstation_init
|
|
|
|
*
|
|
|
|
* Connect to the process window station and desktop.
|
|
|
|
*/
|
|
|
|
static void winstation_init(void)
|
|
|
|
{
|
|
|
|
static const WCHAR WinSta0[] = {'W','i','n','S','t','a','0',0};
|
|
|
|
static const WCHAR Default[] = {'D','e','f','a','u','l','t',0};
|
|
|
|
|
|
|
|
STARTUPINFOW info;
|
|
|
|
WCHAR *winstation = NULL, *desktop = NULL, *buffer = NULL;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
GetStartupInfoW( &info );
|
|
|
|
if (info.lpDesktop && *info.lpDesktop)
|
|
|
|
{
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, (strlenW(info.lpDesktop) + 1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( buffer, info.lpDesktop );
|
|
|
|
if ((desktop = strchrW( buffer, '\\' )))
|
|
|
|
{
|
|
|
|
*desktop++ = 0;
|
|
|
|
winstation = buffer;
|
|
|
|
}
|
|
|
|
else desktop = buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set winstation if explicitly specified, or if we don't have one yet */
|
|
|
|
if (buffer || !GetProcessWindowStation())
|
|
|
|
{
|
|
|
|
handle = CreateWindowStationW( winstation ? winstation : WinSta0, 0, WINSTA_ALL_ACCESS, NULL );
|
|
|
|
if (handle) SetProcessWindowStation( handle );
|
|
|
|
}
|
|
|
|
if (buffer || !GetThreadDesktop( GetCurrentThreadId() ))
|
|
|
|
{
|
|
|
|
handle = CreateDesktopW( desktop ? desktop : Default, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
|
|
|
|
if (handle) SetThreadDesktop( handle );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-19 12:08:09 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* USER initialisation routine
|
|
|
|
*/
|
2004-02-12 00:35:01 +00:00
|
|
|
static BOOL process_attach(void)
|
2000-03-19 12:08:09 +00:00
|
|
|
{
|
2000-05-07 18:41:15 +00:00
|
|
|
HINSTANCE16 instance;
|
2000-03-19 12:08:09 +00:00
|
|
|
|
|
|
|
/* Create USER heap */
|
2002-10-02 02:36:20 +00:00
|
|
|
if ((instance = LoadLibrary16( "USER.EXE" )) >= 32) USER_HeapSel = instance | 7;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 65536 );
|
|
|
|
LocalInit16( USER_HeapSel, 32, 65534 );
|
|
|
|
}
|
2000-03-19 12:08:09 +00:00
|
|
|
|
2004-04-21 22:30:08 +00:00
|
|
|
/* some Win9x dlls expect keyboard to be loaded */
|
|
|
|
if (GetVersion() & 0x80000000) LoadLibrary16( "keyboard.drv" );
|
|
|
|
|
2006-03-27 10:57:17 +00:00
|
|
|
winstation_init();
|
|
|
|
|
2002-05-20 18:01:44 +00:00
|
|
|
/* Initialize system colors and metrics */
|
2004-12-09 13:48:56 +00:00
|
|
|
SYSPARAMS_Init();
|
2000-03-19 12:08:09 +00:00
|
|
|
|
2000-09-16 20:57:39 +00:00
|
|
|
/* Setup palette function pointers */
|
|
|
|
palette_init();
|
|
|
|
|
2000-03-19 12:08:09 +00:00
|
|
|
/* Initialize built-in window classes */
|
2004-02-12 00:35:01 +00:00
|
|
|
CLASS_RegisterBuiltinClasses();
|
2000-03-19 12:08:09 +00:00
|
|
|
|
|
|
|
/* Initialize message spying */
|
|
|
|
if (!SPY_Init()) return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-05-16 19:52:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-10-16 21:58:58 +00:00
|
|
|
* USER_IsExitingThread
|
|
|
|
*/
|
|
|
|
BOOL USER_IsExitingThread( DWORD tid )
|
|
|
|
{
|
|
|
|
return (tid == exiting_thread_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* thread_detach
|
2001-05-16 19:52:29 +00:00
|
|
|
*/
|
|
|
|
static void thread_detach(void)
|
|
|
|
{
|
2001-10-16 21:58:58 +00:00
|
|
|
exiting_thread_id = GetCurrentThreadId();
|
|
|
|
|
2001-08-09 22:07:22 +00:00
|
|
|
WDML_NotifyThreadDetach();
|
|
|
|
|
2005-09-17 14:28:44 +00:00
|
|
|
WIN_DestroyThreadWindows( get_user_thread_info()->desktop );
|
2005-04-27 08:18:20 +00:00
|
|
|
CloseHandle( get_user_thread_info()->server_queue );
|
2001-05-16 19:52:29 +00:00
|
|
|
|
2001-10-16 21:58:58 +00:00
|
|
|
exiting_thread_id = 0;
|
2001-05-16 19:52:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-10-08 20:42:14 +00:00
|
|
|
* UserClientDllInitialize (USER32.@)
|
|
|
|
*
|
2003-10-10 04:30:54 +00:00
|
|
|
* USER dll initialisation routine (exported as UserClientDllInitialize for compatibility).
|
2001-05-16 19:52:29 +00:00
|
|
|
*/
|
2003-10-10 04:30:54 +00:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
2001-05-16 19:52:29 +00:00
|
|
|
{
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2004-02-12 00:35:01 +00:00
|
|
|
user32_module = inst;
|
|
|
|
ret = process_attach();
|
2001-05-16 19:52:29 +00:00
|
|
|
break;
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
thread_detach();
|
|
|
|
break;
|
2005-08-10 09:56:23 +00:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
USER_unload_driver();
|
|
|
|
break;
|
2001-05-16 19:52:29 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2005-05-25 18:42:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_GetProcessHandleList(Internal)
|
|
|
|
*/
|
|
|
|
static HANDLE *USER_GetProcessHandleList(void)
|
|
|
|
{
|
|
|
|
DWORD count, i, n;
|
|
|
|
HANDLE *list;
|
|
|
|
PROCESSENTRY32 pe;
|
|
|
|
HANDLE hSnapshot;
|
|
|
|
BOOL r;
|
|
|
|
|
|
|
|
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
|
|
|
|
if (!hSnapshot)
|
|
|
|
{
|
|
|
|
ERR("cannot create snapshot\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* count the number of processes plus one */
|
|
|
|
for (count=0; ;count++)
|
|
|
|
{
|
|
|
|
pe.dwSize = sizeof pe;
|
|
|
|
if (count)
|
|
|
|
r = Process32Next( hSnapshot, &pe );
|
|
|
|
else
|
|
|
|
r = Process32First( hSnapshot, &pe );
|
|
|
|
if (!r)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate memory make a list of the process handles */
|
|
|
|
list = HeapAlloc( GetProcessHeap(), 0, (count+1)*sizeof(HANDLE) );
|
|
|
|
n=0;
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
pe.dwSize = sizeof pe;
|
|
|
|
if (i)
|
|
|
|
r = Process32Next( hSnapshot, &pe );
|
|
|
|
else
|
|
|
|
r = Process32First( hSnapshot, &pe );
|
|
|
|
if (!r)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* don't kill ourselves */
|
|
|
|
if (GetCurrentProcessId() == pe.th32ProcessID )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* open the process so we don't can track it */
|
|
|
|
list[n] = OpenProcess( PROCESS_QUERY_INFORMATION|
|
|
|
|
PROCESS_TERMINATE,
|
|
|
|
FALSE, pe.th32ProcessID );
|
|
|
|
|
|
|
|
/* check it didn't terminate already */
|
|
|
|
if( list[n] )
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
list[n]=0;
|
|
|
|
CloseHandle( hSnapshot );
|
|
|
|
|
|
|
|
if (!r)
|
|
|
|
ERR("Error enumerating processes\n");
|
|
|
|
|
|
|
|
TRACE("return %lu processes\n", n);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_KillProcesses (Internal)
|
|
|
|
*/
|
|
|
|
static DWORD USER_KillProcesses(void)
|
|
|
|
{
|
|
|
|
DWORD n, r, i;
|
|
|
|
HANDLE *handles;
|
|
|
|
const DWORD dwShutdownTimeout = 10000;
|
|
|
|
|
|
|
|
TRACE("terminating other processes\n");
|
|
|
|
|
|
|
|
/* kill it and add it to our list of object to wait on */
|
|
|
|
handles = USER_GetProcessHandleList();
|
|
|
|
for (n=0; handles && handles[n]; n++)
|
|
|
|
TerminateProcess( handles[n], 0 );
|
|
|
|
|
|
|
|
/* wait for processes to exit */
|
|
|
|
for (i=0; i<n; i+=MAXIMUM_WAIT_OBJECTS)
|
|
|
|
{
|
|
|
|
int n_objs = ((n-i)>MAXIMUM_WAIT_OBJECTS) ? MAXIMUM_WAIT_OBJECTS : (n-i);
|
|
|
|
r = WaitForMultipleObjects( n_objs, &handles[i], TRUE, dwShutdownTimeout );
|
|
|
|
if (r==WAIT_TIMEOUT)
|
|
|
|
ERR("wait failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* close the handles */
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
CloseHandle( handles[i] );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, handles );
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_DoShutdown (Internal)
|
|
|
|
*/
|
|
|
|
static void USER_DoShutdown(void)
|
|
|
|
{
|
|
|
|
DWORD i, n;
|
|
|
|
const DWORD nRetries = 10;
|
|
|
|
|
|
|
|
for (i=0; i<nRetries; i++)
|
|
|
|
{
|
|
|
|
n = USER_KillProcesses();
|
|
|
|
TRACE("Killed %ld processes, attempt %ld\n", n, i);
|
|
|
|
if(!n)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExitWindowsEx (USER32.@)
|
|
|
|
*/
|
2005-09-09 10:35:47 +00:00
|
|
|
BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason )
|
2005-05-25 18:42:37 +00:00
|
|
|
{
|
2005-09-09 10:35:47 +00:00
|
|
|
TRACE("(%x,%lx)\n", flags, reason);
|
2005-05-25 18:42:37 +00:00
|
|
|
|
2005-09-09 10:35:47 +00:00
|
|
|
if ((flags & EWX_FORCE) == 0)
|
2005-05-25 18:42:37 +00:00
|
|
|
{
|
2005-09-09 10:35:47 +00:00
|
|
|
HWND *list;
|
2005-05-25 18:42:37 +00:00
|
|
|
|
2005-09-09 10:35:47 +00:00
|
|
|
/* We have to build a list of all windows first, as in EnumWindows */
|
|
|
|
list = WIN_ListChildren( GetDesktopWindow() );
|
|
|
|
if (list)
|
2005-05-25 18:42:37 +00:00
|
|
|
{
|
2005-09-09 10:35:47 +00:00
|
|
|
HWND *phwnd;
|
|
|
|
UINT send_flags;
|
2006-02-24 11:58:16 +00:00
|
|
|
DWORD_PTR result=1;
|
|
|
|
|
|
|
|
/* Send a WM_QUERYENDSESSION / WM_ENDSESSION message pair to
|
|
|
|
* each window. Note: it might be better to send all the
|
|
|
|
* WM_QUERYENDSESSION messages, aggregate the results and then
|
|
|
|
* send all the WM_ENDSESSION messages with the results but
|
|
|
|
* that's not what Windows does.
|
|
|
|
*/
|
2005-09-09 10:35:47 +00:00
|
|
|
send_flags=(flags & EWX_FORCEIFHUNG) ? SMTO_ABORTIFHUNG : SMTO_NORMAL;
|
|
|
|
for (phwnd = list; *phwnd; phwnd++)
|
|
|
|
{
|
|
|
|
/* Make sure that the window still exists */
|
|
|
|
if (!IsWindow( *phwnd )) continue;
|
2006-02-24 11:58:16 +00:00
|
|
|
if (SendMessageTimeoutW( *phwnd, WM_QUERYENDSESSION, 0, 0, send_flags, 0, &result))
|
|
|
|
{
|
|
|
|
DWORD_PTR dummy;
|
|
|
|
SendMessageTimeoutW( *phwnd, WM_ENDSESSION, result, 0, send_flags, 0, &dummy );
|
|
|
|
if (!result) break;
|
|
|
|
}
|
2005-09-09 10:35:47 +00:00
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
2005-05-25 18:42:37 +00:00
|
|
|
|
2005-09-09 10:35:47 +00:00
|
|
|
if (!result)
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-05-25 18:42:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* USER_DoShutdown will kill all processes except the current process */
|
|
|
|
USER_DoShutdown();
|
|
|
|
|
|
|
|
if (flags & EWX_REBOOT)
|
|
|
|
{
|
|
|
|
WCHAR winebootW[] = { 'w','i','n','e','b','o','o','t',0 };
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
|
|
|
|
memset( &si, 0, sizeof si );
|
|
|
|
si.cb = sizeof si;
|
|
|
|
if (CreateProcessW( NULL, winebootW, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
|
|
|
{
|
|
|
|
CloseHandle( pi.hProcess );
|
|
|
|
CloseHandle( pi.hThread );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MESSAGE("wine: Failed to start wineboot\n");
|
|
|
|
}
|
|
|
|
|
2005-09-09 10:35:47 +00:00
|
|
|
ExitProcess(0);
|
2005-05-25 18:42:37 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|