2000-03-19 13:08:09 +01:00
|
|
|
/*
|
|
|
|
* USER initialization code
|
2002-03-10 00:29:33 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-03-19 13:08:09 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2005-05-06 21:38:50 +02:00
|
|
|
#include <stdio.h>
|
2001-01-22 03:17:29 +01:00
|
|
|
#include <string.h>
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
#include "winbase.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
2000-12-11 00:01:33 +01:00
|
|
|
#include "controls.h"
|
2004-12-08 19:06:14 +01:00
|
|
|
#include "user_private.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "win.h"
|
2006-03-27 12:57:17 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-08-03 02:04:24 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(graphics);
|
2000-08-10 03:16:19 +02:00
|
|
|
|
2006-03-27 12:57:17 +02:00
|
|
|
#define DESKTOP_ALL_ACCESS 0x01ff
|
|
|
|
|
2004-02-12 01:35:01 +01:00
|
|
|
HMODULE user32_module = 0;
|
2001-03-23 20:13:23 +01:00
|
|
|
|
2009-12-24 17:42:19 +01:00
|
|
|
static CRITICAL_SECTION user_section;
|
2005-04-27 13:09:55 +02:00
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
2009-12-24 17:42:19 +01:00
|
|
|
0, 0, &user_section,
|
2005-04-27 13:09:55 +02:00
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
2009-12-24 17:42:19 +01:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": user_section") }
|
2005-04-27 13:09:55 +02:00
|
|
|
};
|
2009-12-24 17:42:19 +01:00
|
|
|
static CRITICAL_SECTION user_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
2005-04-27 13:09:55 +02:00
|
|
|
|
2004-12-08 15:12:09 +01:00
|
|
|
static HPALETTE (WINAPI *pfnGDISelectPalette)( HDC hdc, HPALETTE hpal, WORD bkgnd );
|
|
|
|
static UINT (WINAPI *pfnGDIRealizePalette)( HDC hdc );
|
|
|
|
static HPALETTE hPrimaryPalette;
|
2002-10-18 06:05:49 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
static DWORD exiting_thread_id;
|
2000-08-10 03:16:19 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
extern void WDML_NotifyThreadDetach(void);
|
2001-07-24 22:49:41 +02:00
|
|
|
|
2000-03-19 13:08:09 +01:00
|
|
|
|
2005-04-27 13:09:55 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* USER_Lock
|
|
|
|
*/
|
|
|
|
void USER_Lock(void)
|
|
|
|
{
|
2009-12-24 17:42:19 +01:00
|
|
|
EnterCriticalSection( &user_section );
|
2005-04-27 13:09:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_Unlock
|
|
|
|
*/
|
|
|
|
void USER_Unlock(void)
|
|
|
|
{
|
2009-12-24 17:42:19 +01:00
|
|
|
LeaveCriticalSection( &user_section );
|
2005-04-27 13:09:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* USER_CheckNotLock
|
|
|
|
*
|
|
|
|
* Make sure that we don't hold the user lock.
|
|
|
|
*/
|
|
|
|
void USER_CheckNotLock(void)
|
|
|
|
{
|
2015-10-10 05:40:36 +02:00
|
|
|
if (RtlIsCriticalSectionLockedByThread(&user_section))
|
2009-12-24 17:42:19 +01:00
|
|
|
{
|
|
|
|
ERR( "BUG: holding USER lock\n" );
|
|
|
|
DebugBreak();
|
|
|
|
}
|
2005-04-27 13:09:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-08 15:12:09 +01: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 22:57:39 +02: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 06:05:49 +02:00
|
|
|
if ((ptr = (void**)GetProcAddress( module, "pfnSelectPalette" )))
|
2004-12-08 15:12:09 +01:00
|
|
|
pfnGDISelectPalette = InterlockedExchangePointer( ptr, UserSelectPalette );
|
2000-09-16 22:57:39 +02:00
|
|
|
else ERR( "cannot find pfnSelectPalette in GDI32\n" );
|
2002-10-18 06:05:49 +02:00
|
|
|
if ((ptr = (void**)GetProcAddress( module, "pfnRealizePalette" )))
|
|
|
|
pfnGDIRealizePalette = InterlockedExchangePointer( ptr, UserRealizePalette );
|
2000-09-16 22:57:39 +02:00
|
|
|
else ERR( "cannot find pfnRealizePalette in GDI32\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-24 17:22:04 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_default_desktop
|
|
|
|
*
|
|
|
|
* Get the name of the desktop to use for this app if not specified explicitly.
|
|
|
|
*/
|
|
|
|
static const WCHAR *get_default_desktop(void)
|
|
|
|
{
|
|
|
|
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0};
|
|
|
|
static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
|
|
|
|
static const WCHAR explorerW[] = {'\\','E','x','p','l','o','r','e','r',0};
|
|
|
|
static const WCHAR app_defaultsW[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'W','i','n','e','\\',
|
|
|
|
'A','p','p','D','e','f','a','u','l','t','s',0};
|
2018-08-08 22:20:04 +02:00
|
|
|
static WCHAR buffer[MAX_PATH + ARRAY_SIZE(explorerW)];
|
2008-04-24 17:22:04 +02:00
|
|
|
WCHAR *p, *appname = buffer;
|
|
|
|
const WCHAR *ret = defaultW;
|
|
|
|
DWORD len;
|
|
|
|
HKEY tmpkey, appkey;
|
|
|
|
|
|
|
|
len = (GetModuleFileNameW( 0, buffer, MAX_PATH ));
|
|
|
|
if (!len || len >= MAX_PATH) return ret;
|
|
|
|
if ((p = strrchrW( appname, '/' ))) appname = p + 1;
|
|
|
|
if ((p = strrchrW( appname, '\\' ))) appname = p + 1;
|
|
|
|
p = appname + strlenW(appname);
|
|
|
|
strcpyW( p, explorerW );
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Explorer */
|
|
|
|
if (!RegOpenKeyW( HKEY_CURRENT_USER, app_defaultsW, &tmpkey ))
|
|
|
|
{
|
|
|
|
if (RegOpenKeyW( tmpkey, appname, &appkey )) appkey = 0;
|
|
|
|
RegCloseKey( tmpkey );
|
|
|
|
if (appkey)
|
|
|
|
{
|
|
|
|
len = sizeof(buffer);
|
|
|
|
if (!RegQueryValueExW( appkey, desktopW, 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
|
|
|
|
RegCloseKey( appkey );
|
|
|
|
if (ret && strcmpiW( ret, defaultW )) return ret;
|
|
|
|
ret = defaultW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( buffer, app_defaultsW, 13 * sizeof(WCHAR) ); /* copy only software\\wine */
|
|
|
|
strcpyW( buffer + 13, explorerW );
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Explorer */
|
|
|
|
if (!RegOpenKeyW( HKEY_CURRENT_USER, buffer, &appkey ))
|
|
|
|
{
|
|
|
|
len = sizeof(buffer);
|
|
|
|
if (!RegQueryValueExW( appkey, desktopW, 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
|
|
|
|
RegCloseKey( appkey );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-30 16:45:22 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* dpiaware_init
|
|
|
|
*
|
|
|
|
* Initialize the DPI awareness style.
|
|
|
|
*/
|
|
|
|
static void dpiaware_init(void)
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
2018-04-02 11:19:17 +02:00
|
|
|
DWORD option;
|
2018-03-30 16:45:22 +02:00
|
|
|
static const WCHAR dpiAwareW[] = {'d','p','i','A','w','a','r','e',0};
|
|
|
|
static const WCHAR dpiAwarenessW[] = {'d','p','i','A','w','a','r','e','n','e','s','s',0};
|
|
|
|
static const WCHAR namespace2005W[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','0','5','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
|
|
|
|
static const WCHAR namespace2016W[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','1','6','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
|
|
|
|
|
2018-04-02 11:19:17 +02:00
|
|
|
if (!LdrQueryImageFileExecutionOptions( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName,
|
|
|
|
dpiAwarenessW, REG_DWORD, &option, sizeof(option), NULL ))
|
|
|
|
{
|
|
|
|
TRACE( "got option %x\n", option );
|
|
|
|
if (option <= 2)
|
|
|
|
{
|
|
|
|
SetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~(ULONG_PTR)option );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 16:45:22 +02:00
|
|
|
if (QueryActCtxSettingsW( 0, NULL, namespace2016W, dpiAwarenessW, buffer, ARRAY_SIZE(buffer), NULL ))
|
|
|
|
{
|
|
|
|
static const WCHAR unawareW[] = {'u','n','a','w','a','r','e',0};
|
|
|
|
static const WCHAR systemW[] = {'s','y','s','t','e','m',0};
|
|
|
|
static const WCHAR permonW[] = {'p','e','r','m','o','n','i','t','o','r',0};
|
|
|
|
static const WCHAR permonv2W[] = {'p','e','r','m','o','n','i','t','o','r','v','2',0};
|
|
|
|
static const WCHAR spacesW[] = {' ','\t','\r','\n',0};
|
|
|
|
static const WCHAR * const types[] = { unawareW, systemW, permonW, permonv2W };
|
|
|
|
WCHAR *p, *start = buffer, *end;
|
|
|
|
ULONG_PTR i;
|
|
|
|
|
|
|
|
TRACE( "got dpiAwareness=%s\n", debugstr_w(buffer) );
|
|
|
|
for (start = buffer; *start; start = end)
|
|
|
|
{
|
|
|
|
start += strspnW( start, spacesW );
|
|
|
|
if (!(end = strchrW( start, ',' ))) end = start + strlenW(start);
|
|
|
|
else *end++ = 0;
|
|
|
|
if ((p = strpbrkW( start, spacesW ))) *p = 0;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(types); i++)
|
|
|
|
{
|
|
|
|
if (strcmpiW( start, types[i] )) continue;
|
|
|
|
SetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (QueryActCtxSettingsW( 0, NULL, namespace2005W, dpiAwareW, buffer, ARRAY_SIZE(buffer), NULL ))
|
|
|
|
{
|
|
|
|
static const WCHAR trueW[] = {'t','r','u','e',0};
|
|
|
|
static const WCHAR truepmW[] = {'t','r','u','e','/','p','m',0};
|
|
|
|
static const WCHAR permonW[] = {'p','e','r',' ','m','o','n','i','t','o','r',0};
|
|
|
|
|
|
|
|
TRACE( "got dpiAware=%s\n", debugstr_w(buffer) );
|
|
|
|
if (!strcmpiW( buffer, trueW ))
|
|
|
|
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
|
|
|
|
else if (!strcmpiW( buffer, truepmW ) || !strcmpiW( buffer, permonW ))
|
|
|
|
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
|
|
|
|
else
|
|
|
|
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-27 12:57:17 +02: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};
|
|
|
|
|
|
|
|
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 );
|
2007-12-18 19:47:31 +01:00
|
|
|
if (handle)
|
|
|
|
{
|
|
|
|
SetProcessWindowStation( handle );
|
|
|
|
/* only WinSta0 is visible */
|
|
|
|
if (!winstation || !strcmpiW( winstation, WinSta0 ))
|
|
|
|
{
|
|
|
|
USEROBJECTFLAGS flags;
|
|
|
|
flags.fInherit = FALSE;
|
|
|
|
flags.fReserved = FALSE;
|
|
|
|
flags.dwFlags = WSF_VISIBLE;
|
|
|
|
SetUserObjectInformationW( handle, UOI_FLAGS, &flags, sizeof(flags) );
|
|
|
|
}
|
|
|
|
}
|
2006-03-27 12:57:17 +02:00
|
|
|
}
|
|
|
|
if (buffer || !GetThreadDesktop( GetCurrentThreadId() ))
|
|
|
|
{
|
2008-04-24 17:22:04 +02:00
|
|
|
handle = CreateDesktopW( desktop ? desktop : get_default_desktop(),
|
|
|
|
NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
|
2006-03-27 12:57:17 +02:00
|
|
|
if (handle) SetThreadDesktop( handle );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
2013-10-24 17:40:37 +02:00
|
|
|
|
|
|
|
register_desktop_class();
|
2006-03-27 12:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-19 13:08:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* USER initialisation routine
|
|
|
|
*/
|
2004-02-12 01:35:01 +01:00
|
|
|
static BOOL process_attach(void)
|
2000-03-19 13:08:09 +01:00
|
|
|
{
|
2018-03-30 16:45:22 +02:00
|
|
|
dpiaware_init();
|
2006-03-27 12:57:17 +02:00
|
|
|
winstation_init();
|
|
|
|
|
2002-05-20 20:01:44 +02:00
|
|
|
/* Initialize system colors and metrics */
|
2004-12-09 14:48:56 +01:00
|
|
|
SYSPARAMS_Init();
|
2000-03-19 13:08:09 +01:00
|
|
|
|
2000-09-16 22:57:39 +02:00
|
|
|
/* Setup palette function pointers */
|
|
|
|
palette_init();
|
|
|
|
|
2000-03-19 13:08:09 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2001-10-16 23:58:58 +02:00
|
|
|
* USER_IsExitingThread
|
|
|
|
*/
|
|
|
|
BOOL USER_IsExitingThread( DWORD tid )
|
|
|
|
{
|
|
|
|
return (tid == exiting_thread_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* thread_detach
|
2001-05-16 21:52:29 +02:00
|
|
|
*/
|
|
|
|
static void thread_detach(void)
|
|
|
|
{
|
2008-06-25 14:26:06 +02:00
|
|
|
struct user_thread_info *thread_info = get_user_thread_info();
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
exiting_thread_id = GetCurrentThreadId();
|
|
|
|
|
2001-08-10 00:07:22 +02:00
|
|
|
WDML_NotifyThreadDetach();
|
2016-08-25 14:33:45 +02:00
|
|
|
USER_Driver->pThreadDetach();
|
2001-08-10 00:07:22 +02:00
|
|
|
|
2018-04-27 16:23:39 +02:00
|
|
|
destroy_thread_windows();
|
2008-06-25 14:26:06 +02:00
|
|
|
CloseHandle( thread_info->server_queue );
|
|
|
|
HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data );
|
2011-12-15 14:30:41 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, thread_info->key_state );
|
2012-09-11 00:27:04 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, thread_info->rawinput );
|
2001-05-16 21:52:29 +02:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
exiting_thread_id = 0;
|
2001-05-16 21:52:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-10-08 22:42:14 +02:00
|
|
|
* UserClientDllInitialize (USER32.@)
|
|
|
|
*
|
2003-10-10 06:30:54 +02:00
|
|
|
* USER dll initialisation routine (exported as UserClientDllInitialize for compatibility).
|
2001-05-16 21:52:29 +02:00
|
|
|
*/
|
2003-10-10 06:30:54 +02:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
|
2001-05-16 21:52:29 +02:00
|
|
|
{
|
2014-11-10 13:46:18 +01:00
|
|
|
static const WCHAR imm32_dllW[] = {'i','m','m','3','2','.','d','l','l',0};
|
|
|
|
static HMODULE imm32_module;
|
2001-05-16 21:52:29 +02:00
|
|
|
BOOL ret = TRUE;
|
2014-11-10 13:46:18 +01:00
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2004-02-12 01:35:01 +01:00
|
|
|
user32_module = inst;
|
|
|
|
ret = process_attach();
|
2014-11-10 13:46:18 +01:00
|
|
|
if(ret)
|
|
|
|
imm32_module = LoadLibraryW(imm32_dllW);
|
2001-05-16 21:52:29 +02:00
|
|
|
break;
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
thread_detach();
|
|
|
|
break;
|
2005-08-10 11:56:23 +02:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
USER_unload_driver();
|
2014-11-10 13:46:18 +01:00
|
|
|
FreeLibrary(imm32_module);
|
2011-11-17 09:54:45 +01:00
|
|
|
DeleteCriticalSection(&user_section);
|
2005-08-10 11:56:23 +02:00
|
|
|
break;
|
2001-05-16 21:52:29 +02:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2005-05-25 20:42:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExitWindowsEx (USER32.@)
|
|
|
|
*/
|
2005-09-09 12:35:47 +02:00
|
|
|
BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason )
|
2005-05-25 20:42:37 +02:00
|
|
|
{
|
2006-08-18 20:54:26 +02:00
|
|
|
static const WCHAR winebootW[] = { '\\','w','i','n','e','b','o','o','t','.','e','x','e',0 };
|
2006-08-17 20:54:21 +02:00
|
|
|
static const WCHAR killW[] = { ' ','-','-','k','i','l','l',0 };
|
|
|
|
static const WCHAR end_sessionW[] = { ' ','-','-','e','n','d','-','s','e','s','s','i','o','n',0 };
|
|
|
|
static const WCHAR forceW[] = { ' ','-','-','f','o','r','c','e',0 };
|
|
|
|
static const WCHAR shutdownW[] = { ' ','-','-','s','h','u','t','d','o','w','n',0 };
|
2006-08-04 18:28:04 +02:00
|
|
|
|
2009-10-27 11:22:38 +01:00
|
|
|
WCHAR app[MAX_PATH];
|
2006-08-17 20:54:21 +02:00
|
|
|
WCHAR cmdline[MAX_PATH + 64];
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFOW si;
|
2010-03-29 15:48:25 +02:00
|
|
|
void *redir;
|
2005-05-25 20:42:37 +02:00
|
|
|
|
2018-08-08 22:20:04 +02:00
|
|
|
GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( winebootW ));
|
2009-10-27 11:22:38 +01:00
|
|
|
strcatW( app, winebootW );
|
|
|
|
strcpyW( cmdline, app );
|
2005-05-25 20:42:37 +02:00
|
|
|
|
2006-08-17 20:54:21 +02:00
|
|
|
if (flags & EWX_FORCE) lstrcatW( cmdline, killW );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lstrcatW( cmdline, end_sessionW );
|
|
|
|
if (flags & EWX_FORCEIFHUNG) lstrcatW( cmdline, forceW );
|
2005-05-25 20:42:37 +02:00
|
|
|
}
|
2006-08-17 20:54:21 +02:00
|
|
|
if (!(flags & EWX_REBOOT)) lstrcatW( cmdline, shutdownW );
|
2005-05-25 20:42:37 +02:00
|
|
|
|
2006-08-17 20:54:21 +02:00
|
|
|
memset( &si, 0, sizeof si );
|
|
|
|
si.cb = sizeof si;
|
2010-03-29 15:48:25 +02:00
|
|
|
Wow64DisableWow64FsRedirection( &redir );
|
2009-10-27 11:22:38 +01:00
|
|
|
if (!CreateProcessW( app, cmdline, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi ))
|
2005-05-25 20:42:37 +02:00
|
|
|
{
|
2010-03-29 15:48:25 +02:00
|
|
|
Wow64RevertWow64FsRedirection( redir );
|
2006-08-17 20:54:21 +02:00
|
|
|
ERR( "Failed to run %s\n", debugstr_w(cmdline) );
|
|
|
|
return FALSE;
|
2005-05-25 20:42:37 +02:00
|
|
|
}
|
2010-03-29 15:48:25 +02:00
|
|
|
Wow64RevertWow64FsRedirection( redir );
|
2006-08-17 20:54:21 +02:00
|
|
|
CloseHandle( pi.hProcess );
|
|
|
|
CloseHandle( pi.hThread );
|
2005-05-25 20:42:37 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2008-01-01 23:35:41 +01:00
|
|
|
|
2008-09-17 17:12:20 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* LockWorkStation (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI LockWorkStation(void)
|
|
|
|
{
|
|
|
|
TRACE(": stub\n");
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-01 23:35:41 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RegisterServicesProcess (USER32.@)
|
|
|
|
*/
|
|
|
|
int WINAPI RegisterServicesProcess(DWORD ServicesProcessId)
|
|
|
|
{
|
|
|
|
FIXME("(0x%x): stub\n", ServicesProcessId);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-06-26 20:35:28 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ShutdownBlockReasonCreate (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ShutdownBlockReasonCreate(HWND hwnd, LPCWSTR reason)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %s): stub\n", hwnd, debugstr_w(reason));
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ShutdownBlockReasonDestroy (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ShutdownBlockReasonDestroy(HWND hwnd)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", hwnd);
|
|
|
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
|
|
|
return FALSE;
|
|
|
|
}
|