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"
|
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
|
|
|
|
2019-03-27 16:50:21 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
/* work around a Mingw build issue where _wassert causes a duplicate reference to MessageBoxW */
|
|
|
|
void __cdecl _wassert( const WCHAR *msg, const WCHAR *file, unsigned line) { abort(); }
|
|
|
|
#endif
|
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)
|
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
static WCHAR buffer[MAX_PATH + ARRAY_SIZE(L"\\Explorer")];
|
2008-04-24 17:22:04 +02:00
|
|
|
WCHAR *p, *appname = buffer;
|
2020-06-24 12:37:20 +02:00
|
|
|
const WCHAR *ret = NULL;
|
2008-04-24 17:22:04 +02:00
|
|
|
DWORD len;
|
|
|
|
HKEY tmpkey, appkey;
|
|
|
|
|
|
|
|
len = (GetModuleFileNameW( 0, buffer, MAX_PATH ));
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!len || len >= MAX_PATH) return L"Default";
|
2020-09-21 13:53:21 +02:00
|
|
|
if ((p = wcsrchr( appname, '/' ))) appname = p + 1;
|
|
|
|
if ((p = wcsrchr( appname, '\\' ))) appname = p + 1;
|
|
|
|
p = appname + lstrlenW(appname);
|
2020-09-21 16:31:11 +02:00
|
|
|
lstrcpyW( p, L"\\Explorer" );
|
2008-04-24 17:22:04 +02:00
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Explorer */
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!RegOpenKeyW( HKEY_CURRENT_USER, L"Software\\Wine\\AppDefaults", &tmpkey ))
|
2008-04-24 17:22:04 +02:00
|
|
|
{
|
|
|
|
if (RegOpenKeyW( tmpkey, appname, &appkey )) appkey = 0;
|
|
|
|
RegCloseKey( tmpkey );
|
|
|
|
if (appkey)
|
|
|
|
{
|
|
|
|
len = sizeof(buffer);
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!RegQueryValueExW( appkey, L"Desktop", 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
|
2008-04-24 17:22:04 +02:00
|
|
|
RegCloseKey( appkey );
|
2020-06-24 12:37:21 +02:00
|
|
|
if (ret && *ret) return ret;
|
|
|
|
ret = NULL;
|
2008-04-24 17:22:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Explorer */
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!RegOpenKeyW( HKEY_CURRENT_USER, L"Software\\Wine\\Explorer", &appkey ))
|
2008-04-24 17:22:04 +02:00
|
|
|
{
|
|
|
|
len = sizeof(buffer);
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!RegQueryValueExW( appkey, L"Desktop", 0, NULL, (LPBYTE)buffer, &len )) ret = buffer;
|
2008-04-24 17:22:04 +02:00
|
|
|
RegCloseKey( appkey );
|
2020-06-24 12:37:21 +02:00
|
|
|
if (ret && *ret) return ret;
|
2008-04-24 17:22:04 +02:00
|
|
|
}
|
2020-09-21 16:31:11 +02:00
|
|
|
return L"Default";
|
2008-04-24 17:22:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-04-02 11:19:17 +02:00
|
|
|
if (!LdrQueryImageFileExecutionOptions( &NtCurrentTeb()->Peb->ProcessParameters->ImagePathName,
|
2020-09-21 16:31:11 +02:00
|
|
|
L"dpiAwareness", REG_DWORD, &option, sizeof(option), NULL ))
|
2018-04-02 11:19:17 +02:00
|
|
|
{
|
|
|
|
TRACE( "got option %x\n", option );
|
|
|
|
if (option <= 2)
|
|
|
|
{
|
|
|
|
SetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~(ULONG_PTR)option );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 16:31:11 +02:00
|
|
|
if (QueryActCtxSettingsW( 0, NULL, L"http://schemas.microsoft.com/SMI/2016/WindowsSettings",
|
|
|
|
L"dpiAwareness", buffer, ARRAY_SIZE(buffer), NULL ))
|
2018-03-30 16:45:22 +02:00
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
static const WCHAR * const types[] = { L"unaware", L"system", L"permonitor", L"permonitorv2" };
|
2019-09-16 07:39:59 +02:00
|
|
|
WCHAR *p, *start, *end;
|
2018-03-30 16:45:22 +02:00
|
|
|
ULONG_PTR i;
|
|
|
|
|
|
|
|
TRACE( "got dpiAwareness=%s\n", debugstr_w(buffer) );
|
|
|
|
for (start = buffer; *start; start = end)
|
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
start += wcsspn( start, L" \t\r\n" );
|
2020-09-21 13:53:21 +02:00
|
|
|
if (!(end = wcschr( start, ',' ))) end = start + lstrlenW(start);
|
2018-03-30 16:45:22 +02:00
|
|
|
else *end++ = 0;
|
2020-09-21 16:31:11 +02:00
|
|
|
if ((p = wcspbrk( start, L" \t\r\n" ))) *p = 0;
|
2018-03-30 16:45:22 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(types); i++)
|
|
|
|
{
|
2020-09-21 13:53:21 +02:00
|
|
|
if (wcsicmp( start, types[i] )) continue;
|
2018-03-30 16:45:22 +02:00
|
|
|
SetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-21 16:31:11 +02:00
|
|
|
else if (QueryActCtxSettingsW( 0, NULL, L"http://schemas.microsoft.com/SMI/2005/WindowsSettings",
|
|
|
|
L"dpiAware", buffer, ARRAY_SIZE(buffer), NULL ))
|
2018-03-30 16:45:22 +02:00
|
|
|
{
|
|
|
|
TRACE( "got dpiAware=%s\n", debugstr_w(buffer) );
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!wcsicmp( buffer, L"true" ))
|
2018-03-30 16:45:22 +02:00
|
|
|
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
|
2020-09-21 16:31:11 +02:00
|
|
|
else if (!wcsicmp( buffer, L"true/pm" ) || !wcsicmp( buffer, L"per monitor" ))
|
2018-03-30 16:45:22 +02:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
STARTUPINFOW info;
|
|
|
|
WCHAR *winstation = NULL, *desktop = NULL, *buffer = NULL;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
GetStartupInfoW( &info );
|
|
|
|
if (info.lpDesktop && *info.lpDesktop)
|
|
|
|
{
|
2020-09-21 13:53:21 +02:00
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(info.lpDesktop) + 1) * sizeof(WCHAR) );
|
|
|
|
lstrcpyW( buffer, info.lpDesktop );
|
|
|
|
if ((desktop = wcschr( buffer, '\\' )))
|
2006-03-27 12:57:17 +02:00
|
|
|
{
|
|
|
|
*desktop++ = 0;
|
|
|
|
winstation = buffer;
|
|
|
|
}
|
|
|
|
else desktop = buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set winstation if explicitly specified, or if we don't have one yet */
|
|
|
|
if (buffer || !GetProcessWindowStation())
|
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
handle = CreateWindowStationW( winstation ? winstation : L"WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
|
2007-12-18 19:47:31 +01:00
|
|
|
if (handle)
|
|
|
|
{
|
|
|
|
SetProcessWindowStation( handle );
|
|
|
|
/* only WinSta0 is visible */
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!winstation || !wcsicmp( winstation, L"WinSta0" ))
|
2007-12-18 19:47:31 +01:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2021-05-06 12:03:14 +02:00
|
|
|
keyboard_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 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)
|
2020-09-21 16:31:11 +02:00
|
|
|
imm32_module = LoadLibraryW(L"imm32.dll");
|
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
|
|
|
{
|
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
|
|
|
|
2020-09-21 16:31:11 +02:00
|
|
|
GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( L"\\wineboot.exe" ));
|
|
|
|
lstrcatW( app, L"\\wineboot.exe" );
|
2020-09-21 13:53:21 +02:00
|
|
|
lstrcpyW( cmdline, app );
|
2005-05-25 20:42:37 +02:00
|
|
|
|
2020-09-21 16:31:11 +02:00
|
|
|
if (flags & EWX_FORCE) lstrcatW( cmdline, L" --kill" );
|
2006-08-17 20:54:21 +02:00
|
|
|
else
|
|
|
|
{
|
2020-09-21 16:31:11 +02:00
|
|
|
lstrcatW( cmdline, L" --end-session" );
|
|
|
|
if (flags & EWX_FORCEIFHUNG) lstrcatW( cmdline, L" --force" );
|
2005-05-25 20:42:37 +02:00
|
|
|
}
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!(flags & EWX_REBOOT)) lstrcatW( cmdline, L" --shutdown" );
|
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;
|
|
|
|
}
|