2003-01-04 03:52:05 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Andreas Mohr
|
|
|
|
* Copyright (C) 2002 Shachar Shemesh
|
|
|
|
*
|
|
|
|
* 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
|
2003-01-04 03:52:05 +01:00
|
|
|
*/
|
2003-01-14 20:33:12 +01:00
|
|
|
/* Wine "bootup" handler application
|
|
|
|
*
|
|
|
|
* This app handles the various "hooks" windows allows for applications to perform
|
2007-10-11 18:31:26 +02:00
|
|
|
* as part of the bootstrap process. These are roughly divided into three types.
|
2003-01-14 20:33:12 +01:00
|
|
|
* Knowledge base articles that explain this are 137367, 179365, 232487 and 232509.
|
2003-01-15 01:52:36 +01:00
|
|
|
* Also, 119941 has some info on grpconv.exe
|
2003-01-14 20:33:12 +01:00
|
|
|
* The operations performed are (by order of execution):
|
|
|
|
*
|
|
|
|
* Preboot (prior to fully loading the Windows kernel):
|
|
|
|
* - wininit.exe (rename operations left in wininit.ini - Win 9x only)
|
|
|
|
* - PendingRenameOperations (rename operations left in the registry - Win NT+ only)
|
|
|
|
*
|
|
|
|
* Startup (before the user logs in)
|
2007-12-20 15:53:03 +01:00
|
|
|
* - Services (NT)
|
2003-01-15 01:52:36 +01:00
|
|
|
* - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce (9x, asynch)
|
|
|
|
* - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices (9x, asynch)
|
2003-01-14 20:33:12 +01:00
|
|
|
*
|
|
|
|
* After log in
|
2003-01-15 01:52:36 +01:00
|
|
|
* - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce (all, synch)
|
|
|
|
* - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run (all, asynch)
|
|
|
|
* - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (all, asynch)
|
2007-02-12 04:09:45 +01:00
|
|
|
* - Startup folders (all, ?asynch?)
|
2003-01-15 01:52:36 +01:00
|
|
|
* - HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce (all, asynch)
|
2007-02-12 04:09:45 +01:00
|
|
|
*
|
2003-01-14 20:33:12 +01:00
|
|
|
* Somewhere in there is processing the RunOnceEx entries (also no imp)
|
|
|
|
*
|
|
|
|
* Bugs:
|
|
|
|
* - If a pending rename registry does not start with \??\ the entry is
|
|
|
|
* processed anyways. I'm not sure that is the Windows behaviour.
|
2003-01-11 22:02:50 +01:00
|
|
|
* - Need to check what is the windows behaviour when trying to delete files
|
|
|
|
* and directories that are read-only
|
|
|
|
* - In the pending rename registry processing - there are no traces of the files
|
|
|
|
* processed (requires translations from Unicode to Ansi).
|
|
|
|
*/
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2008-04-07 11:03:22 +02:00
|
|
|
#define COBJMACROS
|
2006-01-16 20:41:09 +01:00
|
|
|
|
2008-04-17 21:07:10 +02:00
|
|
|
#include <errno.h>
|
2008-04-21 15:39:55 +02:00
|
|
|
#include <fcntl.h>
|
2003-01-04 03:52:05 +01:00
|
|
|
#include <stdio.h>
|
2008-04-17 21:07:10 +02:00
|
|
|
#include <stdlib.h>
|
2020-05-05 02:52:46 +02:00
|
|
|
#include <intrin.h>
|
2019-07-04 15:40:46 +02:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2020-05-29 12:26:57 +02:00
|
|
|
|
|
|
|
#include <ntstatus.h>
|
|
|
|
#define WIN32_NO_STATUS
|
2003-01-11 22:02:50 +01:00
|
|
|
#include <windows.h>
|
2020-09-28 16:20:04 +02:00
|
|
|
#include <ws2tcpip.h>
|
2009-09-24 14:22:57 +02:00
|
|
|
#include <winternl.h>
|
2020-05-29 12:26:57 +02:00
|
|
|
#include <ddk/wdm.h>
|
2019-11-20 12:25:13 +01:00
|
|
|
#include <sddl.h>
|
2008-04-01 13:48:46 +02:00
|
|
|
#include <wine/svcctl.h>
|
2019-05-14 12:30:46 +02:00
|
|
|
#include <wine/asm.h>
|
2003-01-11 22:02:50 +01:00
|
|
|
#include <wine/debug.h>
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2007-02-12 04:09:45 +01:00
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shobjidl.h>
|
|
|
|
#include <shlwapi.h>
|
|
|
|
#include <shellapi.h>
|
2019-11-07 06:54:59 +01:00
|
|
|
#include <setupapi.h>
|
|
|
|
#include <newdev.h>
|
2010-03-30 16:49:53 +02:00
|
|
|
#include "resource.h"
|
2007-02-12 04:09:45 +01:00
|
|
|
|
2003-01-04 03:52:05 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wineboot);
|
|
|
|
|
2006-08-17 20:54:15 +02:00
|
|
|
extern BOOL shutdown_close_windows( BOOL force );
|
2010-05-18 20:36:36 +02:00
|
|
|
extern BOOL shutdown_all_desktops( BOOL force );
|
2006-08-17 20:54:15 +02:00
|
|
|
extern void kill_processes( BOOL kill_desktop );
|
|
|
|
|
2007-12-20 16:16:17 +01:00
|
|
|
static WCHAR windowsdir[MAX_PATH];
|
2019-04-16 11:27:38 +02:00
|
|
|
static const BOOL is_64bit = sizeof(void *) > sizeof(int);
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
/* retrieve the path to the wine.inf file */
|
|
|
|
static WCHAR *get_wine_inf_path(void)
|
2008-04-17 21:07:10 +02:00
|
|
|
{
|
2019-07-04 15:40:46 +02:00
|
|
|
WCHAR *dir, *name = NULL;
|
2008-04-17 21:07:10 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if ((dir = _wgetenv( L"WINEBUILDDIR" )))
|
2008-04-17 21:07:10 +02:00
|
|
|
{
|
2019-07-04 15:40:46 +02:00
|
|
|
if (!(name = HeapAlloc( GetProcessHeap(), 0,
|
2020-05-21 13:36:06 +02:00
|
|
|
sizeof(L"\\loader\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) )))
|
2008-04-17 21:07:10 +02:00
|
|
|
return NULL;
|
2019-07-04 15:40:46 +02:00
|
|
|
lstrcpyW( name, dir );
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( name, L"\\loader" );
|
2008-04-17 21:07:10 +02:00
|
|
|
}
|
2020-05-21 13:36:06 +02:00
|
|
|
else if ((dir = _wgetenv( L"WINEDATADIR" )))
|
2008-04-17 21:07:10 +02:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!(name = HeapAlloc( GetProcessHeap(), 0, sizeof(L"\\wine.inf") + lstrlenW(dir) * sizeof(WCHAR) )))
|
2008-04-17 21:07:10 +02:00
|
|
|
return NULL;
|
2019-07-04 15:40:46 +02:00
|
|
|
lstrcpyW( name, dir );
|
2008-04-17 21:07:10 +02:00
|
|
|
}
|
2019-07-04 15:40:46 +02:00
|
|
|
else return NULL;
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( name, L"\\wine.inf" );
|
2019-07-04 15:40:46 +02:00
|
|
|
name[1] = '\\'; /* change \??\ to \\?\ */
|
2008-04-17 21:07:10 +02:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2008-04-21 15:39:55 +02:00
|
|
|
/* update the timestamp if different from the reference time */
|
2019-07-04 15:40:46 +02:00
|
|
|
static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp )
|
2008-04-21 15:39:55 +02:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
int fd, count;
|
|
|
|
char buffer[100];
|
2020-05-21 13:36:06 +02:00
|
|
|
WCHAR *file = HeapAlloc( GetProcessHeap(), 0, lstrlenW(config_dir) * sizeof(WCHAR) + sizeof(L"\\.update-timestamp") );
|
2008-04-21 15:39:55 +02:00
|
|
|
|
|
|
|
if (!file) return FALSE;
|
2019-07-04 15:40:46 +02:00
|
|
|
lstrcpyW( file, config_dir );
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( file, L"\\.update-timestamp" );
|
2008-04-21 15:39:55 +02:00
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
if ((fd = _wopen( file, O_RDWR )) != -1)
|
2008-04-21 15:39:55 +02:00
|
|
|
{
|
|
|
|
if ((count = read( fd, buffer, sizeof(buffer) - 1 )) >= 0)
|
|
|
|
{
|
|
|
|
buffer[count] = 0;
|
|
|
|
if (!strncmp( buffer, "disable", sizeof("disable")-1 )) goto done;
|
2008-09-17 14:58:52 +02:00
|
|
|
if (timestamp == strtoul( buffer, NULL, 10 )) goto done;
|
2008-04-21 15:39:55 +02:00
|
|
|
}
|
|
|
|
lseek( fd, 0, SEEK_SET );
|
2019-07-04 15:40:46 +02:00
|
|
|
chsize( fd, 0 );
|
2008-04-21 15:39:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (errno != ENOENT) goto done;
|
2019-07-04 15:40:46 +02:00
|
|
|
if ((fd = _wopen( file, O_WRONLY | O_CREAT | O_TRUNC, 0666 )) == -1) goto done;
|
2008-04-21 15:39:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
count = sprintf( buffer, "%lu\n", timestamp );
|
|
|
|
if (write( fd, buffer, count ) != count)
|
|
|
|
{
|
2019-07-04 15:40:46 +02:00
|
|
|
WINE_WARN( "failed to update timestamp in %s\n", debugstr_w(file) );
|
|
|
|
chsize( fd, 0 );
|
2008-04-21 15:39:55 +02:00
|
|
|
}
|
|
|
|
else ret = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (fd != -1) close( fd );
|
|
|
|
HeapFree( GetProcessHeap(), 0, file );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
/* print the config directory in a more Unix-ish way */
|
2019-11-28 08:51:17 +01:00
|
|
|
static const WCHAR *prettyprint_configdir(void)
|
2019-07-04 15:40:46 +02:00
|
|
|
{
|
2019-11-28 08:51:17 +01:00
|
|
|
static WCHAR buffer[MAX_PATH];
|
2020-05-21 13:36:06 +02:00
|
|
|
WCHAR *p, *path = _wgetenv( L"WINECONFIGDIR" );
|
2019-07-04 15:40:46 +02:00
|
|
|
|
2019-11-28 08:51:17 +01:00
|
|
|
lstrcpynW( buffer, path, ARRAY_SIZE(buffer) );
|
2020-05-21 13:36:06 +02:00
|
|
|
if (lstrlenW( path ) >= ARRAY_SIZE(buffer) )
|
2019-11-28 08:51:17 +01:00
|
|
|
lstrcpyW( buffer + ARRAY_SIZE(buffer) - 4, L"..." );
|
2019-07-04 15:40:46 +02:00
|
|
|
|
2019-11-28 08:51:17 +01:00
|
|
|
if (!wcsncmp( buffer, L"\\??\\unix\\", 9 ))
|
2019-07-04 15:40:46 +02:00
|
|
|
{
|
|
|
|
for (p = buffer + 9; *p; p++) if (*p == '\\') *p = '/';
|
|
|
|
return buffer + 9;
|
|
|
|
}
|
2019-11-28 08:51:17 +01:00
|
|
|
else if (!wcsncmp( buffer, L"\\??\\Z:\\", 7 ))
|
2019-07-04 15:40:46 +02:00
|
|
|
{
|
|
|
|
for (p = buffer + 6; *p; p++) if (*p == '\\') *p = '/';
|
|
|
|
return buffer + 6;
|
|
|
|
}
|
|
|
|
else return buffer + 4;
|
|
|
|
}
|
|
|
|
|
2010-01-28 13:08:59 +01:00
|
|
|
/* wrapper for RegSetValueExW */
|
|
|
|
static DWORD set_reg_value( HKEY hkey, const WCHAR *name, const WCHAR *value )
|
|
|
|
{
|
2019-07-04 15:40:46 +02:00
|
|
|
return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, (lstrlenW(value) + 1) * sizeof(WCHAR) );
|
2010-01-28 13:08:59 +01:00
|
|
|
}
|
|
|
|
|
2020-02-20 21:50:44 +01:00
|
|
|
static DWORD set_reg_value_dword( HKEY hkey, const WCHAR *name, DWORD value )
|
|
|
|
{
|
|
|
|
return RegSetValueExW( hkey, name, 0, REG_DWORD, (const BYTE *)&value, sizeof(value) );
|
|
|
|
}
|
|
|
|
|
2020-08-19 23:22:59 +02:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
|
|
|
|
static void initialize_xstate_features(struct _KUSER_SHARED_DATA *data)
|
|
|
|
{
|
|
|
|
XSTATE_CONFIGURATION *xstate = &data->XState;
|
|
|
|
unsigned int i;
|
|
|
|
int regs[4];
|
|
|
|
|
|
|
|
if (!data->ProcessorFeatures[PF_AVX_INSTRUCTIONS_AVAILABLE])
|
|
|
|
return;
|
|
|
|
|
|
|
|
__cpuidex(regs, 0, 0);
|
|
|
|
|
|
|
|
TRACE("Max cpuid level %#x.\n", regs[0]);
|
|
|
|
if (regs[0] < 0xd)
|
|
|
|
return;
|
|
|
|
|
|
|
|
__cpuidex(regs, 1, 0);
|
|
|
|
TRACE("CPU features %#x, %#x, %#x, %#x.\n", regs[0], regs[1], regs[2], regs[3]);
|
|
|
|
if (!(regs[2] & (0x1 << 27))) /* xsave OS enabled */
|
|
|
|
return;
|
|
|
|
|
|
|
|
__cpuidex(regs, 0xd, 0);
|
|
|
|
TRACE("XSAVE details %#x, %#x, %#x, %#x.\n", regs[0], regs[1], regs[2], regs[3]);
|
|
|
|
if (!(regs[0] & XSTATE_AVX))
|
|
|
|
return;
|
|
|
|
|
|
|
|
xstate->EnabledFeatures = (1 << XSTATE_LEGACY_FLOATING_POINT) | (1 << XSTATE_LEGACY_SSE) | (1 << XSTATE_AVX);
|
|
|
|
xstate->EnabledVolatileFeatures = xstate->EnabledFeatures;
|
|
|
|
xstate->Size = sizeof(XSAVE_FORMAT) + sizeof(XSTATE);
|
|
|
|
xstate->AllFeatureSize = regs[1];
|
|
|
|
xstate->AllFeatures[0] = offsetof(XSAVE_FORMAT, XmmRegisters);
|
|
|
|
xstate->AllFeatures[1] = sizeof(M128A) * 16;
|
|
|
|
xstate->AllFeatures[2] = sizeof(YMMCONTEXT);
|
|
|
|
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
|
|
xstate->Features[i].Size = xstate->AllFeatures[i];
|
|
|
|
|
|
|
|
xstate->Features[1].Offset = xstate->Features[0].Size;
|
|
|
|
xstate->Features[2].Offset = sizeof(XSAVE_FORMAT) + offsetof(XSTATE, YmmContext);
|
|
|
|
|
|
|
|
__cpuidex(regs, 0xd, 1);
|
|
|
|
xstate->OptimizedSave = regs[0] & 1;
|
|
|
|
xstate->CompactionEnabled = !!(regs[0] & 2);
|
|
|
|
|
|
|
|
__cpuidex(regs, 0xd, 2);
|
|
|
|
TRACE("XSAVE feature 2 %#x, %#x, %#x, %#x.\n", regs[0], regs[1], regs[2], regs[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void initialize_xstate_features(struct _KUSER_SHARED_DATA *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-05-29 12:26:57 +02:00
|
|
|
static void create_user_shared_data(void)
|
|
|
|
{
|
|
|
|
struct _KUSER_SHARED_DATA *data;
|
|
|
|
RTL_OSVERSIONINFOEXW version;
|
|
|
|
SYSTEM_CPU_INFORMATION sci;
|
|
|
|
SYSTEM_BASIC_INFORMATION sbi;
|
|
|
|
BOOLEAN *features;
|
|
|
|
OBJECT_ATTRIBUTES attr = {sizeof(attr)};
|
|
|
|
UNICODE_STRING name;
|
|
|
|
NTSTATUS status;
|
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
RtlInitUnicodeString( &name, L"\\KernelObjects\\__wine_user_shared_data" );
|
|
|
|
InitializeObjectAttributes( &attr, &name, OBJ_OPENIF, NULL, NULL );
|
|
|
|
if ((status = NtOpenSection( &handle, SECTION_ALL_ACCESS, &attr )))
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
ERR( "cannot open __wine_user_shared_data: %lx\n", status );
|
2020-05-29 12:26:57 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
data = MapViewOfFile( handle, FILE_MAP_WRITE, 0, 0, sizeof(*data) );
|
|
|
|
CloseHandle( handle );
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
ERR( "cannot map __wine_user_shared_data\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
version.dwOSVersionInfoSize = sizeof(version);
|
|
|
|
RtlGetVersion( &version );
|
|
|
|
NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), NULL );
|
|
|
|
NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL );
|
|
|
|
|
|
|
|
data->TickCountMultiplier = 1 << 24;
|
|
|
|
data->LargePageMinimum = 2 * 1024 * 1024;
|
|
|
|
data->NtBuildNumber = version.dwBuildNumber;
|
|
|
|
data->NtProductType = version.wProductType;
|
|
|
|
data->ProductTypeIsValid = TRUE;
|
2021-04-30 15:56:32 +02:00
|
|
|
data->NativeProcessorArchitecture = sci.ProcessorArchitecture;
|
2020-05-29 12:26:57 +02:00
|
|
|
data->NtMajorVersion = version.dwMajorVersion;
|
|
|
|
data->NtMinorVersion = version.dwMinorVersion;
|
|
|
|
data->SuiteMask = version.wSuiteMask;
|
|
|
|
data->NumberOfPhysicalPages = sbi.MmNumberOfPhysicalPages;
|
2021-01-29 05:08:20 +01:00
|
|
|
data->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
|
2020-05-29 12:26:57 +02:00
|
|
|
wcscpy( data->NtSystemRoot, L"C:\\windows" );
|
|
|
|
|
|
|
|
features = data->ProcessorFeatures;
|
2021-04-30 15:56:32 +02:00
|
|
|
switch (sci.ProcessorArchitecture)
|
2020-05-29 12:26:57 +02:00
|
|
|
{
|
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
2021-04-30 15:56:32 +02:00
|
|
|
features[PF_COMPARE_EXCHANGE_DOUBLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_CX8);
|
|
|
|
features[PF_MMX_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_MMX);
|
|
|
|
features[PF_XMMI_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSE);
|
|
|
|
features[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_3DNOW);
|
|
|
|
features[PF_RDTSC_INSTRUCTION_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_TSC);
|
|
|
|
features[PF_PAE_ENABLED] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_PAE);
|
|
|
|
features[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSE2);
|
|
|
|
features[PF_SSE3_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSE3);
|
|
|
|
features[PF_SSSE3_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSSE3);
|
|
|
|
features[PF_XSAVE_ENABLED] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_XSAVE);
|
|
|
|
features[PF_COMPARE_EXCHANGE128] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_CX128);
|
|
|
|
features[PF_SSE_DAZ_MODE_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_DAZ);
|
|
|
|
features[PF_NX_ENABLED] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_NX);
|
|
|
|
features[PF_SECOND_LEVEL_ADDRESS_TRANSLATION] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_2NDLEV);
|
|
|
|
features[PF_VIRT_FIRMWARE_ENABLED] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_VIRT);
|
|
|
|
features[PF_RDWRFSGSBASE_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_RDFS);
|
2020-05-29 12:26:57 +02:00
|
|
|
features[PF_FASTFAIL_AVAILABLE] = TRUE;
|
2021-04-30 15:56:32 +02:00
|
|
|
features[PF_SSE4_1_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSE41);
|
|
|
|
features[PF_SSE4_2_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_SSE42);
|
|
|
|
features[PF_AVX_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_AVX);
|
|
|
|
features[PF_AVX2_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_AVX2);
|
2020-05-29 12:26:57 +02:00
|
|
|
break;
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM:
|
2021-04-30 15:56:32 +02:00
|
|
|
features[PF_ARM_VFP_32_REGISTERS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_ARM_VFP_32);
|
|
|
|
features[PF_ARM_NEON_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_ARM_NEON);
|
|
|
|
features[PF_ARM_V8_INSTRUCTIONS_AVAILABLE] = (sci.ProcessorLevel >= 8);
|
2020-05-29 12:26:57 +02:00
|
|
|
break;
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM64:
|
|
|
|
features[PF_ARM_V8_INSTRUCTIONS_AVAILABLE] = TRUE;
|
2021-04-30 15:56:32 +02:00
|
|
|
features[PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_ARM_V8_CRC32);
|
|
|
|
features[PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE] = !!(sci.ProcessorFeatureBits & CPU_FEATURE_ARM_V8_CRYPTO);
|
2020-05-29 12:26:57 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
data->ActiveProcessorCount = NtCurrentTeb()->Peb->NumberOfProcessors;
|
|
|
|
data->ActiveGroupCount = 1;
|
|
|
|
|
2020-08-19 23:22:59 +02:00
|
|
|
initialize_xstate_features( data );
|
|
|
|
|
2020-05-29 12:26:57 +02:00
|
|
|
UnmapViewOfFile( data );
|
|
|
|
}
|
|
|
|
|
2019-08-13 20:24:48 +02:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
|
2020-05-05 02:52:46 +02:00
|
|
|
static void regs_to_str( int *regs, unsigned int len, WCHAR *buffer )
|
2019-01-28 15:37:26 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
unsigned char *p = (unsigned char *)regs;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) { buffer[i] = *p++; }
|
|
|
|
buffer[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int get_model( unsigned int reg0, unsigned int *stepping, unsigned int *family )
|
|
|
|
{
|
|
|
|
unsigned int model, family_id = (reg0 & (0x0f << 8)) >> 8;
|
|
|
|
|
|
|
|
model = (reg0 & (0x0f << 4)) >> 4;
|
|
|
|
if (family_id == 6 || family_id == 15) model |= (reg0 & (0x0f << 16)) >> 12;
|
|
|
|
|
|
|
|
*family = family_id;
|
|
|
|
if (family_id == 15) *family += (reg0 & (0xff << 20)) >> 20;
|
|
|
|
|
|
|
|
*stepping = reg0 & 0x0f;
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
static void get_identifier( WCHAR *buf, size_t size, const WCHAR *arch )
|
2019-01-28 15:37:26 +01:00
|
|
|
{
|
2020-05-05 02:52:46 +02:00
|
|
|
unsigned int family, model, stepping;
|
|
|
|
int regs[4] = {0, 0, 0, 0};
|
2019-01-28 15:37:26 +01:00
|
|
|
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 1 );
|
2019-01-28 15:37:26 +01:00
|
|
|
model = get_model( regs[0], &stepping, &family );
|
2020-05-21 13:36:06 +02:00
|
|
|
swprintf( buf, size, L"%s Family %u Model %u Stepping %u", arch, family, model, stepping );
|
2019-01-28 15:37:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void get_vendorid( WCHAR *buf )
|
|
|
|
{
|
2020-05-05 02:52:46 +02:00
|
|
|
int tmp, regs[4] = {0, 0, 0, 0};
|
2019-01-28 15:37:26 +01:00
|
|
|
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 0 );
|
2019-01-28 15:37:26 +01:00
|
|
|
tmp = regs[2]; /* swap edx and ecx */
|
|
|
|
regs[2] = regs[3];
|
|
|
|
regs[3] = tmp;
|
|
|
|
|
|
|
|
regs_to_str( regs + 1, 12, buf );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_namestring( WCHAR *buf )
|
|
|
|
{
|
2020-05-05 02:52:46 +02:00
|
|
|
int regs[4] = {0, 0, 0, 0};
|
2019-01-28 15:37:26 +01:00
|
|
|
int i;
|
|
|
|
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 0x80000000 );
|
2019-01-28 15:37:26 +01:00
|
|
|
if (regs[0] >= 0x80000004)
|
|
|
|
{
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 0x80000002 );
|
2019-01-28 15:37:26 +01:00
|
|
|
regs_to_str( regs, 16, buf );
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 0x80000003 );
|
2019-01-28 15:37:26 +01:00
|
|
|
regs_to_str( regs, 16, buf + 16 );
|
2020-05-05 02:52:46 +02:00
|
|
|
__cpuid( regs, 0x80000004 );
|
2019-01-28 15:37:26 +01:00
|
|
|
regs_to_str( regs, 16, buf + 32 );
|
|
|
|
}
|
2019-07-04 15:40:46 +02:00
|
|
|
for (i = lstrlenW(buf) - 1; i >= 0 && buf[i] == ' '; i--) buf[i] = 0;
|
2019-01-28 15:37:26 +01:00
|
|
|
}
|
|
|
|
|
2019-08-13 20:24:48 +02:00
|
|
|
#else /* __i386__ || __x86_64__ */
|
|
|
|
|
|
|
|
static void get_identifier( WCHAR *buf, size_t size, const WCHAR *arch ) { }
|
|
|
|
static void get_vendorid( WCHAR *buf ) { }
|
|
|
|
static void get_namestring( WCHAR *buf ) { }
|
|
|
|
|
|
|
|
#endif /* __i386__ || __x86_64__ */
|
|
|
|
|
2020-02-20 21:50:44 +01:00
|
|
|
#include "pshpack1.h"
|
|
|
|
struct smbios_prologue
|
|
|
|
{
|
|
|
|
BYTE calling_method;
|
|
|
|
BYTE major_version;
|
|
|
|
BYTE minor_version;
|
|
|
|
BYTE revision;
|
|
|
|
DWORD length;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum smbios_type
|
|
|
|
{
|
|
|
|
SMBIOS_TYPE_BIOS,
|
|
|
|
SMBIOS_TYPE_SYSTEM,
|
|
|
|
SMBIOS_TYPE_BASEBOARD,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct smbios_header
|
|
|
|
{
|
|
|
|
BYTE type;
|
|
|
|
BYTE length;
|
|
|
|
WORD handle;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct smbios_baseboard
|
|
|
|
{
|
|
|
|
struct smbios_header hdr;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE product;
|
|
|
|
BYTE version;
|
|
|
|
BYTE serial;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct smbios_bios
|
|
|
|
{
|
|
|
|
struct smbios_header hdr;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE version;
|
|
|
|
WORD start;
|
|
|
|
BYTE date;
|
|
|
|
BYTE size;
|
|
|
|
UINT64 characteristics;
|
|
|
|
BYTE characteristics_ext[2];
|
|
|
|
BYTE system_bios_major_release;
|
|
|
|
BYTE system_bios_minor_release;
|
|
|
|
BYTE ec_firmware_major_release;
|
|
|
|
BYTE ec_firmware_minor_release;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct smbios_system
|
|
|
|
{
|
|
|
|
struct smbios_header hdr;
|
|
|
|
BYTE vendor;
|
|
|
|
BYTE product;
|
|
|
|
BYTE version;
|
|
|
|
BYTE serial;
|
|
|
|
BYTE uuid[16];
|
|
|
|
BYTE wake_up_type;
|
|
|
|
BYTE sku;
|
|
|
|
BYTE family;
|
|
|
|
};
|
|
|
|
#include "poppack.h"
|
|
|
|
|
|
|
|
#define RSMB (('R' << 24) | ('S' << 16) | ('M' << 8) | 'B')
|
|
|
|
|
|
|
|
static const struct smbios_header *find_smbios_entry( enum smbios_type type, const char *buf, UINT len )
|
|
|
|
{
|
|
|
|
const char *ptr, *start;
|
|
|
|
const struct smbios_prologue *prologue;
|
|
|
|
const struct smbios_header *hdr;
|
|
|
|
|
|
|
|
if (len < sizeof(struct smbios_prologue)) return NULL;
|
|
|
|
prologue = (const struct smbios_prologue *)buf;
|
|
|
|
if (prologue->length > len - sizeof(*prologue) || prologue->length < sizeof(*hdr)) return NULL;
|
|
|
|
|
|
|
|
start = (const char *)(prologue + 1);
|
|
|
|
hdr = (const struct smbios_header *)start;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ((const char *)hdr - start >= prologue->length - sizeof(*hdr)) return NULL;
|
|
|
|
|
|
|
|
if (!hdr->length)
|
|
|
|
{
|
|
|
|
WARN( "invalid entry\n" );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr->type == type)
|
|
|
|
{
|
|
|
|
if ((const char *)hdr - start + hdr->length > prologue->length) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else /* skip other entries and their strings */
|
|
|
|
{
|
|
|
|
for (ptr = (const char *)hdr + hdr->length; ptr - buf < len && *ptr; ptr++)
|
|
|
|
{
|
|
|
|
for (; ptr - buf < len; ptr++) if (!*ptr) break;
|
|
|
|
}
|
|
|
|
if (ptr == (const char *)hdr + hdr->length) ptr++;
|
|
|
|
hdr = (const struct smbios_header *)(ptr + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hdr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WCHAR *heap_strdupAW( const char *src )
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
WCHAR *dst;
|
|
|
|
if (!src) return NULL;
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
|
|
|
if ((dst = HeapAlloc( GetProcessHeap(), 0, len * sizeof(*dst) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *get_smbios_string( BYTE id, const char *buf, UINT offset, UINT buflen )
|
|
|
|
{
|
|
|
|
const char *ptr = buf + offset;
|
|
|
|
UINT i = 0;
|
|
|
|
|
|
|
|
if (!id || offset >= buflen) return NULL;
|
|
|
|
for (ptr = buf + offset; ptr - buf < buflen && *ptr; ptr++)
|
|
|
|
{
|
|
|
|
if (++i == id) return heap_strdupAW( ptr );
|
|
|
|
for (; ptr - buf < buflen; ptr++) if (!*ptr) break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_value_from_smbios_string( HKEY key, const WCHAR *value, BYTE id, const char *buf, UINT offset, UINT buflen )
|
|
|
|
{
|
|
|
|
WCHAR *str;
|
|
|
|
str = get_smbios_string( id, buf, offset, buflen );
|
|
|
|
set_reg_value( key, value, str ? str : L"" );
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_bios_baseboard_values( HKEY bios_key, const char *buf, UINT len )
|
|
|
|
{
|
|
|
|
const struct smbios_header *hdr;
|
|
|
|
const struct smbios_baseboard *baseboard;
|
|
|
|
UINT offset;
|
|
|
|
|
|
|
|
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BASEBOARD, buf, len ))) return;
|
|
|
|
baseboard = (const struct smbios_baseboard *)hdr;
|
|
|
|
offset = (const char *)baseboard - buf + baseboard->hdr.length;
|
|
|
|
|
|
|
|
set_value_from_smbios_string( bios_key, L"BaseBoardManufacturer", baseboard->vendor, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"BaseBoardProduct", baseboard->product, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"BaseBoardVersion", baseboard->version, buf, offset, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_bios_bios_values( HKEY bios_key, const char *buf, UINT len )
|
|
|
|
{
|
|
|
|
const struct smbios_header *hdr;
|
|
|
|
const struct smbios_bios *bios;
|
|
|
|
UINT offset;
|
|
|
|
|
|
|
|
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_BIOS, buf, len ))) return;
|
|
|
|
bios = (const struct smbios_bios *)hdr;
|
|
|
|
offset = (const char *)bios - buf + bios->hdr.length;
|
|
|
|
|
|
|
|
set_value_from_smbios_string( bios_key, L"BIOSVendor", bios->vendor, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"BIOSVersion", bios->version, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"BIOSReleaseDate", bios->date, buf, offset, len );
|
|
|
|
|
|
|
|
if (bios->hdr.length >= 0x18)
|
|
|
|
{
|
|
|
|
set_reg_value_dword( bios_key, L"BiosMajorRelease", bios->system_bios_major_release );
|
|
|
|
set_reg_value_dword( bios_key, L"BiosMinorRelease", bios->system_bios_minor_release );
|
|
|
|
set_reg_value_dword( bios_key, L"ECFirmwareMajorVersion", bios->ec_firmware_major_release );
|
|
|
|
set_reg_value_dword( bios_key, L"ECFirmwareMinorVersion", bios->ec_firmware_minor_release );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_reg_value_dword( bios_key, L"BiosMajorRelease", 0xFF );
|
|
|
|
set_reg_value_dword( bios_key, L"BiosMinorRelease", 0xFF );
|
|
|
|
set_reg_value_dword( bios_key, L"ECFirmwareMajorVersion", 0xFF );
|
|
|
|
set_reg_value_dword( bios_key, L"ECFirmwareMinorVersion", 0xFF );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_bios_system_values( HKEY bios_key, const char *buf, UINT len )
|
|
|
|
{
|
|
|
|
const struct smbios_header *hdr;
|
|
|
|
const struct smbios_system *system;
|
|
|
|
UINT offset;
|
|
|
|
|
|
|
|
if (!(hdr = find_smbios_entry( SMBIOS_TYPE_SYSTEM, buf, len ))) return;
|
|
|
|
system = (const struct smbios_system *)hdr;
|
|
|
|
offset = (const char *)system - buf + system->hdr.length;
|
|
|
|
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemManufacturer", system->vendor, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemProductName", system->product, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemVersion", system->version, buf, offset, len );
|
|
|
|
|
|
|
|
if (system->hdr.length >= 0x1B)
|
|
|
|
{
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemSKU", system->sku, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemFamily", system->family, buf, offset, len );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemSKU", 0, buf, offset, len );
|
|
|
|
set_value_from_smbios_string( bios_key, L"SystemFamily", 0, buf, offset, len );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void create_bios_key( HKEY system_key )
|
|
|
|
{
|
|
|
|
HKEY bios_key;
|
|
|
|
UINT len;
|
|
|
|
char *buf;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW( system_key, L"BIOS", 0, NULL, REG_OPTION_VOLATILE,
|
|
|
|
KEY_ALL_ACCESS, NULL, &bios_key, NULL ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 );
|
|
|
|
if (!(buf = HeapAlloc( GetProcessHeap(), 0, len ))) goto done;
|
|
|
|
len = GetSystemFirmwareTable( RSMB, 0, buf, len );
|
|
|
|
|
|
|
|
create_bios_baseboard_values( bios_key, buf, len );
|
|
|
|
create_bios_bios_values( bios_key, buf, len );
|
|
|
|
create_bios_system_values( bios_key, buf, len );
|
|
|
|
|
|
|
|
done:
|
|
|
|
HeapFree( GetProcessHeap(), 0, buf );
|
|
|
|
RegCloseKey( bios_key );
|
|
|
|
}
|
|
|
|
|
2009-09-24 14:22:57 +02:00
|
|
|
/* create the volatile hardware registry keys */
|
|
|
|
static void create_hardware_registry_keys(void)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
HKEY hkey, system_key, cpu_key, fpu_key;
|
|
|
|
SYSTEM_CPU_INFORMATION sci;
|
2012-09-12 21:15:50 +02:00
|
|
|
PROCESSOR_POWER_INFORMATION* power_info;
|
|
|
|
ULONG sizeof_power_info = sizeof(PROCESSOR_POWER_INFORMATION) * NtCurrentTeb()->Peb->NumberOfProcessors;
|
2019-01-28 15:37:26 +01:00
|
|
|
WCHAR id[60], namestr[49], vendorid[13];
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2019-01-28 15:37:26 +01:00
|
|
|
get_namestring( namestr );
|
|
|
|
get_vendorid( vendorid );
|
2009-09-24 14:22:57 +02:00
|
|
|
NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL );
|
2012-09-12 21:15:50 +02:00
|
|
|
|
|
|
|
power_info = HeapAlloc( GetProcessHeap(), 0, sizeof_power_info );
|
|
|
|
if (power_info == NULL)
|
|
|
|
return;
|
|
|
|
if (NtPowerInformation( ProcessorInformation, NULL, 0, power_info, sizeof_power_info ))
|
|
|
|
memset( power_info, 0, sizeof_power_info );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
switch (sci.ProcessorArchitecture)
|
2013-11-10 22:44:52 +01:00
|
|
|
{
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM:
|
2015-05-21 16:12:44 +02:00
|
|
|
case PROCESSOR_ARCHITECTURE_ARM64:
|
2020-05-21 13:36:06 +02:00
|
|
|
swprintf( id, ARRAY_SIZE(id), L"ARM Family %u Model %u Revision %u",
|
2021-04-30 15:56:32 +02:00
|
|
|
sci.ProcessorLevel, HIBYTE(sci.ProcessorRevision), LOBYTE(sci.ProcessorRevision) );
|
2013-11-10 22:44:52 +01:00
|
|
|
break;
|
2019-01-28 15:37:26 +01:00
|
|
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
2020-05-21 13:36:06 +02:00
|
|
|
get_identifier( id, ARRAY_SIZE(id), !wcscmp(vendorid, L"AuthenticAMD") ? L"AMD64" : L"Intel64" );
|
2019-01-28 15:37:26 +01:00
|
|
|
break;
|
|
|
|
|
2013-11-10 22:44:52 +01:00
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
2019-01-28 15:37:26 +01:00
|
|
|
default:
|
2020-05-21 13:36:06 +02:00
|
|
|
get_identifier( id, ARRAY_SIZE(id), L"x86" );
|
2013-11-10 22:44:52 +01:00
|
|
|
break;
|
|
|
|
}
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System", 0, NULL,
|
|
|
|
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &system_key, NULL ))
|
2012-09-12 21:15:50 +02:00
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, power_info );
|
2009-09-24 14:22:57 +02:00
|
|
|
return;
|
2012-09-12 21:15:50 +02:00
|
|
|
}
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
switch (sci.ProcessorArchitecture)
|
2013-11-10 22:44:52 +01:00
|
|
|
{
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM:
|
2015-05-21 16:12:44 +02:00
|
|
|
case PROCESSOR_ARCHITECTURE_ARM64:
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( system_key, L"Identifier", L"ARM processor family" );
|
2013-11-10 22:44:52 +01:00
|
|
|
break;
|
2019-01-28 15:37:26 +01:00
|
|
|
|
2013-11-10 22:44:52 +01:00
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
2019-01-28 15:37:26 +01:00
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
|
|
|
default:
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( system_key, L"Identifier", L"AT compatible" );
|
2013-11-10 22:44:52 +01:00
|
|
|
break;
|
|
|
|
}
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
if (sci.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM ||
|
|
|
|
sci.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64 ||
|
2020-05-21 13:36:06 +02:00
|
|
|
RegCreateKeyExW( system_key, L"FloatingPointProcessor", 0, NULL, REG_OPTION_VOLATILE,
|
2009-09-24 14:22:57 +02:00
|
|
|
KEY_ALL_ACCESS, NULL, &fpu_key, NULL ))
|
|
|
|
fpu_key = 0;
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegCreateKeyExW( system_key, L"CentralProcessor", 0, NULL, REG_OPTION_VOLATILE,
|
2009-09-24 14:22:57 +02:00
|
|
|
KEY_ALL_ACCESS, NULL, &cpu_key, NULL ))
|
|
|
|
cpu_key = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < NtCurrentTeb()->Peb->NumberOfProcessors; i++)
|
|
|
|
{
|
|
|
|
WCHAR numW[10];
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
swprintf( numW, ARRAY_SIZE(numW), L"%u", i );
|
2009-09-24 14:22:57 +02:00
|
|
|
if (!RegCreateKeyExW( cpu_key, numW, 0, NULL, REG_OPTION_VOLATILE,
|
|
|
|
KEY_ALL_ACCESS, NULL, &hkey, NULL ))
|
|
|
|
{
|
2021-04-30 15:56:32 +02:00
|
|
|
RegSetValueExW( hkey, L"FeatureSet", 0, REG_DWORD, (BYTE *)&sci.ProcessorFeatureBits, sizeof(DWORD) );
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"Identifier", id );
|
2019-01-28 15:37:26 +01:00
|
|
|
/* TODO: report ARM properly */
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"ProcessorNameString", namestr );
|
|
|
|
set_reg_value( hkey, L"VendorIdentifier", vendorid );
|
|
|
|
RegSetValueExW( hkey, L"~MHz", 0, REG_DWORD, (BYTE *)&power_info[i].MaxMhz, sizeof(DWORD) );
|
2009-09-24 14:22:57 +02:00
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
2021-04-30 15:56:32 +02:00
|
|
|
if (sci.ProcessorArchitecture != PROCESSOR_ARCHITECTURE_ARM &&
|
|
|
|
sci.ProcessorArchitecture != PROCESSOR_ARCHITECTURE_ARM64 &&
|
2013-11-10 22:44:52 +01:00
|
|
|
!RegCreateKeyExW( fpu_key, numW, 0, NULL, REG_OPTION_VOLATILE,
|
2009-09-24 14:22:57 +02:00
|
|
|
KEY_ALL_ACCESS, NULL, &hkey, NULL ))
|
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"Identifier", id );
|
2009-09-24 14:22:57 +02:00
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
}
|
2020-02-20 21:50:44 +01:00
|
|
|
|
|
|
|
create_bios_key( system_key );
|
|
|
|
|
2009-09-24 14:22:57 +02:00
|
|
|
RegCloseKey( fpu_key );
|
|
|
|
RegCloseKey( cpu_key );
|
|
|
|
RegCloseKey( system_key );
|
2012-09-12 21:15:50 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, power_info );
|
2009-09-24 14:22:57 +02:00
|
|
|
}
|
|
|
|
|
2010-03-01 14:01:28 +01:00
|
|
|
|
|
|
|
/* create the DynData registry keys */
|
|
|
|
static void create_dynamic_registry_keys(void)
|
|
|
|
{
|
|
|
|
HKEY key;
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegCreateKeyExW( HKEY_DYN_DATA, L"PerfStats\\StatData", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL ))
|
2010-03-01 14:01:28 +01:00
|
|
|
RegCloseKey( key );
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegCreateKeyExW( HKEY_DYN_DATA, L"Config Manager\\Enum", 0, NULL, 0, KEY_WRITE, NULL, &key, NULL ))
|
2010-03-01 14:01:28 +01:00
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
|
2009-09-24 14:22:57 +02:00
|
|
|
/* create the platform-specific environment registry keys */
|
|
|
|
static void create_environment_registry_keys( void )
|
|
|
|
{
|
|
|
|
HKEY env_key;
|
|
|
|
SYSTEM_CPU_INFORMATION sci;
|
2019-01-28 15:37:26 +01:00
|
|
|
WCHAR buffer[60], vendorid[13];
|
2019-02-09 05:06:29 +01:00
|
|
|
const WCHAR *arch, *parch;
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegCreateKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager\\Environment", &env_key )) return;
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2019-01-28 15:37:26 +01:00
|
|
|
get_vendorid( vendorid );
|
2015-10-04 21:18:32 +02:00
|
|
|
NtQuerySystemInformation( SystemCpuInformation, &sci, sizeof(sci), NULL );
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"%u", NtCurrentTeb()->Peb->NumberOfProcessors );
|
|
|
|
set_reg_value( env_key, L"NUMBER_OF_PROCESSORS", buffer );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
switch (sci.ProcessorArchitecture)
|
2010-08-15 18:54:47 +02:00
|
|
|
{
|
2019-01-28 15:37:26 +01:00
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
2020-05-21 13:36:06 +02:00
|
|
|
arch = L"AMD64";
|
|
|
|
parch = !wcscmp(vendorid, L"AuthenticAMD") ? L"AMD64" : L"Intel64";
|
2019-01-28 15:37:26 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
2010-12-14 22:48:11 +01:00
|
|
|
default:
|
2020-05-21 13:36:06 +02:00
|
|
|
arch = parch = L"x86";
|
2019-01-28 15:37:26 +01:00
|
|
|
break;
|
2010-08-15 18:54:47 +02:00
|
|
|
}
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( env_key, L"PROCESSOR_ARCHITECTURE", arch );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
switch (sci.ProcessorArchitecture)
|
2013-11-10 22:40:36 +01:00
|
|
|
{
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM:
|
2015-05-21 16:12:25 +02:00
|
|
|
case PROCESSOR_ARCHITECTURE_ARM64:
|
2020-05-21 13:36:06 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"ARM Family %u Model %u Revision %u",
|
2021-04-30 15:56:32 +02:00
|
|
|
sci.ProcessorLevel, HIBYTE(sci.ProcessorRevision), LOBYTE(sci.ProcessorRevision) );
|
2013-11-10 22:40:36 +01:00
|
|
|
break;
|
2019-01-28 15:37:26 +01:00
|
|
|
|
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
2013-11-10 22:40:36 +01:00
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
2019-01-28 15:37:26 +01:00
|
|
|
default:
|
2019-07-04 15:40:46 +02:00
|
|
|
get_identifier( buffer, ARRAY_SIZE(buffer), parch );
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( buffer, L", " );
|
2019-07-04 15:40:46 +02:00
|
|
|
lstrcatW( buffer, vendorid );
|
2013-11-10 22:40:36 +01:00
|
|
|
break;
|
|
|
|
}
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( env_key, L"PROCESSOR_IDENTIFIER", buffer );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"%u", sci.ProcessorLevel );
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( env_key, L"PROCESSOR_LEVEL", buffer );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
2021-04-30 15:56:32 +02:00
|
|
|
swprintf( buffer, ARRAY_SIZE(buffer), L"%04x", sci.ProcessorRevision );
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( env_key, L"PROCESSOR_REVISION", buffer );
|
2009-09-24 14:22:57 +02:00
|
|
|
|
|
|
|
RegCloseKey( env_key );
|
|
|
|
}
|
|
|
|
|
2020-09-28 16:20:04 +02:00
|
|
|
/* create the ComputerName registry keys */
|
|
|
|
static void create_computer_name_keys(void)
|
|
|
|
{
|
|
|
|
struct addrinfo hints = {0}, *res;
|
2020-11-10 12:22:19 +01:00
|
|
|
char *dot, buffer[256], *name = buffer;
|
2020-09-28 16:20:04 +02:00
|
|
|
HKEY key, subkey;
|
|
|
|
|
|
|
|
if (gethostname( buffer, sizeof(buffer) )) return;
|
|
|
|
hints.ai_flags = AI_CANONNAME;
|
2020-11-10 12:22:19 +01:00
|
|
|
if (!getaddrinfo( buffer, NULL, &hints, &res )) name = res->ai_canonname;
|
|
|
|
dot = strchr( name, '.' );
|
2020-09-28 16:20:04 +02:00
|
|
|
if (dot) *dot++ = 0;
|
2020-11-10 12:22:19 +01:00
|
|
|
else dot = name + strlen(name);
|
2020-09-28 16:20:04 +02:00
|
|
|
SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot );
|
2020-11-10 12:22:19 +01:00
|
|
|
SetComputerNameExA( ComputerNamePhysicalDnsHostname, name );
|
|
|
|
if (name != buffer) freeaddrinfo( res );
|
2020-09-28 16:20:04 +02:00
|
|
|
|
|
|
|
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!RegOpenKeyW( key, L"ComputerName", &subkey ))
|
|
|
|
{
|
|
|
|
DWORD type, size = sizeof(buffer);
|
|
|
|
|
|
|
|
if (RegQueryValueExW( subkey, L"ComputerName", NULL, &type, (BYTE *)buffer, &size )) size = 0;
|
|
|
|
RegCloseKey( subkey );
|
|
|
|
if (size && !RegCreateKeyExW( key, L"ActiveComputerName", 0, NULL, REG_OPTION_VOLATILE,
|
|
|
|
KEY_ALL_ACCESS, NULL, &subkey, NULL ))
|
|
|
|
{
|
|
|
|
RegSetValueExW( subkey, L"ComputerName", 0, type, (const BYTE *)buffer, size );
|
|
|
|
RegCloseKey( subkey );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
|
2009-12-25 11:33:33 +01:00
|
|
|
static void create_volatile_environment_registry_key(void)
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
2010-01-28 13:08:59 +01:00
|
|
|
WCHAR computername[MAX_COMPUTERNAME_LENGTH + 1 + 2];
|
2010-01-28 13:01:00 +01:00
|
|
|
DWORD size;
|
2009-12-25 11:33:33 +01:00
|
|
|
HKEY hkey;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegCreateKeyExW( HKEY_CURRENT_USER, L"Volatile Environment", 0, NULL, REG_OPTION_VOLATILE,
|
2009-12-25 11:33:33 +01:00
|
|
|
KEY_ALL_ACCESS, NULL, &hkey, NULL ))
|
|
|
|
return;
|
|
|
|
|
2018-09-17 17:32:10 +02:00
|
|
|
hr = SHGetFolderPathW( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path );
|
2020-05-21 13:36:06 +02:00
|
|
|
if (SUCCEEDED(hr)) set_reg_value( hkey, L"APPDATA", path );
|
2009-12-25 11:33:33 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"CLIENTNAME", L"Console" );
|
2009-12-25 11:33:33 +01:00
|
|
|
|
|
|
|
/* Write the profile path's drive letter and directory components into
|
|
|
|
* HOMEDRIVE and HOMEPATH respectively. */
|
2018-09-17 17:32:10 +02:00
|
|
|
hr = SHGetFolderPathW( NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path );
|
2009-12-25 11:33:33 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"USERPROFILE", path );
|
|
|
|
set_reg_value( hkey, L"HOMEPATH", path + 2 );
|
2009-12-25 11:33:33 +01:00
|
|
|
path[2] = '\0';
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"HOMEDRIVE", path );
|
2009-12-25 11:33:33 +01:00
|
|
|
}
|
|
|
|
|
2018-07-24 22:13:44 +02:00
|
|
|
size = ARRAY_SIZE(path);
|
2020-05-21 13:36:06 +02:00
|
|
|
if (GetUserNameW( path, &size )) set_reg_value( hkey, L"USERNAME", path );
|
2010-01-28 13:01:00 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"HOMESHARE", L"" );
|
2009-12-25 11:33:33 +01:00
|
|
|
|
2018-09-17 17:32:10 +02:00
|
|
|
hr = SHGetFolderPathW( NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, path );
|
2009-12-25 11:33:33 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"LOCALAPPDATA", path );
|
2009-12-25 11:33:33 +01:00
|
|
|
|
2018-07-24 22:13:44 +02:00
|
|
|
size = ARRAY_SIZE(computername) - 2;
|
2009-12-25 11:33:33 +01:00
|
|
|
if (GetComputerNameW(&computername[2], &size))
|
2010-01-28 13:08:59 +01:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"USERDOMAIN", &computername[2] );
|
2010-01-28 13:08:59 +01:00
|
|
|
computername[0] = computername[1] = '\\';
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"LOGONSERVER", computername );
|
2010-01-28 13:08:59 +01:00
|
|
|
}
|
2009-12-25 11:33:33 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value( hkey, L"SESSIONNAME", L"Console" );
|
2009-12-25 11:33:33 +01:00
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
2003-01-04 03:52:05 +01:00
|
|
|
/* Performs the rename operations dictated in %SystemRoot%\Wininit.ini.
|
|
|
|
* Returns FALSE if there was an error, or otherwise if all is ok.
|
|
|
|
*/
|
2005-06-16 17:52:44 +02:00
|
|
|
static BOOL wininit(void)
|
2003-01-04 03:52:05 +01:00
|
|
|
{
|
2007-12-20 15:53:53 +01:00
|
|
|
WCHAR initial_buffer[1024];
|
|
|
|
WCHAR *str, *buffer = initial_buffer;
|
2018-07-24 22:13:44 +02:00
|
|
|
DWORD size = ARRAY_SIZE(initial_buffer);
|
2007-12-20 15:53:53 +01:00
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
for (;;)
|
2003-01-04 03:52:05 +01:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!(res = GetPrivateProfileSectionW( L"rename", buffer, size, L"wininit.ini" ))) return TRUE;
|
2007-12-20 15:53:53 +01:00
|
|
|
if (res < size - 2) break;
|
|
|
|
if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
size *= 2;
|
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE;
|
|
|
|
}
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
for (str = buffer; *str; str += lstrlenW(str) + 1)
|
2007-12-20 15:53:53 +01:00
|
|
|
{
|
|
|
|
WCHAR *value;
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2007-12-20 15:53:53 +01:00
|
|
|
if (*str == ';') continue; /* comment */
|
2019-07-04 15:40:46 +02:00
|
|
|
if (!(value = wcschr( str, '=' ))) continue;
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2007-12-20 15:53:53 +01:00
|
|
|
/* split the line into key and value */
|
|
|
|
*value++ = 0;
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!lstrcmpiW( L"NUL", str ))
|
2007-12-20 15:53:53 +01:00
|
|
|
{
|
|
|
|
WINE_TRACE("Deleting file %s\n", wine_dbgstr_w(value) );
|
|
|
|
if( !DeleteFileW( value ) )
|
|
|
|
WINE_WARN("Error deleting file %s\n", wine_dbgstr_w(value) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINE_TRACE("Renaming file %s to %s\n", wine_dbgstr_w(value), wine_dbgstr_w(str) );
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2007-12-20 15:53:53 +01:00
|
|
|
if( !MoveFileExW(value, str, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) )
|
|
|
|
WINE_WARN("Error renaming %s to %s\n", wine_dbgstr_w(value), wine_dbgstr_w(str) );
|
|
|
|
}
|
|
|
|
str = value;
|
2003-01-04 03:52:05 +01:00
|
|
|
}
|
|
|
|
|
2007-12-20 15:53:53 +01:00
|
|
|
if (buffer != initial_buffer) HeapFree( GetProcessHeap(), 0, buffer );
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if( !MoveFileExW( L"wininit.ini", L"wininit.bak", MOVEFILE_REPLACE_EXISTING) )
|
2003-01-04 03:52:05 +01:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Couldn't rename wininit.ini, error %ld\n", GetLastError() );
|
2003-01-04 03:52:05 +01:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
static void pendingRename(void)
|
2003-01-11 22:02:50 +01:00
|
|
|
{
|
2003-01-11 23:50:15 +01:00
|
|
|
WCHAR *buffer=NULL;
|
2003-01-11 22:02:50 +01:00
|
|
|
const WCHAR *src=NULL, *dst=NULL;
|
|
|
|
DWORD dataLength=0;
|
2020-05-21 13:36:06 +02:00
|
|
|
HKEY hSession;
|
2003-01-11 22:02:50 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Session Manager",
|
|
|
|
0, KEY_ALL_ACCESS, &hSession ))
|
|
|
|
return;
|
2003-01-11 22:02:50 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL, NULL, &dataLength ))
|
2003-01-11 22:02:50 +01:00
|
|
|
goto end;
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, dataLength ))) goto end;
|
2003-01-11 22:02:50 +01:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (RegQueryValueExW( hSession, L"PendingFileRenameOperations", NULL, NULL,
|
|
|
|
(LPBYTE)buffer, &dataLength ))
|
2003-01-11 22:02:50 +01:00
|
|
|
goto end;
|
|
|
|
|
|
|
|
/* Make sure that the data is long enough and ends with two NULLs. This
|
|
|
|
* simplifies the code later on.
|
|
|
|
*/
|
|
|
|
if( dataLength<2*sizeof(buffer[0]) ||
|
|
|
|
buffer[dataLength/sizeof(buffer[0])-1]!='\0' ||
|
|
|
|
buffer[dataLength/sizeof(buffer[0])-2]!='\0' )
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
for( src=buffer; (src-buffer)*sizeof(src[0])<dataLength && *src!='\0';
|
|
|
|
src=dst+lstrlenW(dst)+1 )
|
|
|
|
{
|
|
|
|
DWORD dwFlags=0;
|
|
|
|
|
|
|
|
dst=src+lstrlenW(src)+1;
|
|
|
|
|
|
|
|
/* We need to skip the \??\ header */
|
|
|
|
if( src[0]=='\\' && src[1]=='?' && src[2]=='?' && src[3]=='\\' )
|
|
|
|
src+=4;
|
|
|
|
|
|
|
|
if( dst[0]=='!' )
|
|
|
|
{
|
|
|
|
dwFlags|=MOVEFILE_REPLACE_EXISTING;
|
|
|
|
dst++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( dst[0]=='\\' && dst[1]=='?' && dst[2]=='?' && dst[3]=='\\' )
|
|
|
|
dst+=4;
|
|
|
|
|
|
|
|
if( *dst!='\0' )
|
|
|
|
{
|
|
|
|
/* Rename the file */
|
|
|
|
MoveFileExW( src, dst, dwFlags );
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
/* Delete the file or directory */
|
2013-06-11 13:50:05 +02:00
|
|
|
if (!RemoveDirectoryW( src ) && GetLastError() == ERROR_DIRECTORY) DeleteFileW( src );
|
2003-01-11 22:02:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
RegDeleteValueW(hSession, L"PendingFileRenameOperations");
|
|
|
|
|
2003-01-11 22:02:50 +01:00
|
|
|
end:
|
2006-05-10 00:33:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2020-05-21 13:36:06 +02:00
|
|
|
RegCloseKey( hSession );
|
2003-01-11 22:02:50 +01:00
|
|
|
}
|
|
|
|
|
2003-01-15 01:52:36 +01:00
|
|
|
#define INVALID_RUNCMD_RETURN -1
|
|
|
|
/*
|
|
|
|
* This function runs the specified command in the specified dir.
|
|
|
|
* [in,out] cmdline - the command line to run. The function may change the passed buffer.
|
|
|
|
* [in] dir - the dir to run the command in. If it is NULL, then the current dir is used.
|
|
|
|
* [in] wait - whether to wait for the run program to finish before returning.
|
|
|
|
* [in] minimized - Whether to ask the program to run minimized.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* If running the process failed, returns INVALID_RUNCMD_RETURN. Use GetLastError to get the error code.
|
|
|
|
* If wait is FALSE - returns 0 if successful.
|
|
|
|
* If wait is TRUE - returns the program's return value.
|
|
|
|
*/
|
|
|
|
static DWORD runCmd(LPWSTR cmdline, LPCWSTR dir, BOOL wait, BOOL minimized)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
DWORD exit_code=0;
|
|
|
|
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
si.cb=sizeof(si);
|
|
|
|
if( minimized )
|
|
|
|
{
|
|
|
|
si.dwFlags=STARTF_USESHOWWINDOW;
|
|
|
|
si.wShowWindow=SW_MINIMIZE;
|
|
|
|
}
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
|
|
|
|
if( !CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, dir, &si, &info) )
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_WARN("Failed to run command %s (%ld)\n", wine_dbgstr_w(cmdline), GetLastError() );
|
2003-01-15 01:52:36 +01:00
|
|
|
return INVALID_RUNCMD_RETURN;
|
|
|
|
}
|
|
|
|
|
2003-02-12 02:14:08 +01:00
|
|
|
WINE_TRACE("Successfully ran command %s - Created process handle %p\n",
|
|
|
|
wine_dbgstr_w(cmdline), info.hProcess );
|
2003-01-15 01:52:36 +01:00
|
|
|
|
|
|
|
if(wait)
|
|
|
|
{ /* wait for the process to exit */
|
|
|
|
WaitForSingleObject(info.hProcess, INFINITE);
|
|
|
|
GetExitCodeProcess(info.hProcess, &exit_code);
|
|
|
|
}
|
|
|
|
|
2008-02-25 10:00:25 +01:00
|
|
|
CloseHandle( info.hThread );
|
2003-01-15 01:52:36 +01:00
|
|
|
CloseHandle( info.hProcess );
|
|
|
|
|
|
|
|
return exit_code;
|
|
|
|
}
|
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
static void process_run_key( HKEY key, const WCHAR *keyname, BOOL delete, BOOL synchronous )
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2019-04-16 11:27:38 +02:00
|
|
|
HKEY runkey;
|
|
|
|
LONG res;
|
|
|
|
DWORD disp, i, max_cmdline = 0, max_value = 0;
|
|
|
|
WCHAR *cmdline = NULL, *value = NULL;
|
2003-01-15 01:52:36 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if (RegCreateKeyExW( key, keyname, 0, NULL, 0, delete ? KEY_ALL_ACCESS : KEY_READ, NULL, &runkey, &disp ))
|
|
|
|
return;
|
2003-01-15 01:52:36 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if (disp == REG_CREATED_NEW_KEY)
|
|
|
|
goto end;
|
2008-01-07 12:25:56 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if (RegQueryInfoKeyW( runkey, NULL, NULL, NULL, NULL, NULL, NULL, &i, &max_value, &max_cmdline, NULL, NULL ))
|
2003-01-15 01:52:36 +01:00
|
|
|
goto end;
|
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if (!i)
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2019-04-16 11:27:38 +02:00
|
|
|
WINE_TRACE( "No commands to execute.\n" );
|
2003-01-15 01:52:36 +01:00
|
|
|
goto end;
|
|
|
|
}
|
2019-04-16 11:27:38 +02:00
|
|
|
if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, max_cmdline )))
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2019-04-16 11:27:38 +02:00
|
|
|
WINE_ERR( "Couldn't allocate memory for the commands to be executed.\n" );
|
2003-01-15 01:52:36 +01:00
|
|
|
goto end;
|
|
|
|
}
|
2019-04-16 11:27:38 +02:00
|
|
|
if (!(value = HeapAlloc( GetProcessHeap(), 0, ++max_value * sizeof(*value) )))
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2019-04-16 11:27:38 +02:00
|
|
|
WINE_ERR( "Couldn't allocate memory for the value names.\n" );
|
2003-01-15 01:52:36 +01:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
while (i)
|
|
|
|
{
|
|
|
|
DWORD len = max_value, len_data = max_cmdline, type;
|
2003-01-15 01:52:36 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if ((res = RegEnumValueW( runkey, --i, value, &len, 0, &type, (BYTE *)cmdline, &len_data )))
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR( "Couldn't read value %lu (%ld).\n", i, res );
|
2003-01-15 01:52:36 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-16 11:27:38 +02:00
|
|
|
if (delete && (res = RegDeleteValueW( runkey, value )))
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR( "Couldn't delete value %lu (%ld). Running command anyways.\n", i, res );
|
2003-01-15 01:52:36 +01:00
|
|
|
}
|
2019-04-16 11:27:38 +02:00
|
|
|
if (type != REG_SZ)
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR( "Incorrect type of value %lu (%lu).\n", i, type );
|
2003-01-15 01:52:36 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-04-16 11:27:38 +02:00
|
|
|
if (runCmd( cmdline, NULL, synchronous, FALSE ) == INVALID_RUNCMD_RETURN)
|
2003-01-15 01:52:36 +01:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR( "Error running cmd %s (%lu).\n", wine_dbgstr_w(cmdline), GetLastError() );
|
2003-01-15 01:52:36 +01:00
|
|
|
}
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_TRACE( "Done processing cmd %lu.\n", i );
|
2003-01-15 01:52:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2019-04-16 11:27:38 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, value );
|
|
|
|
HeapFree( GetProcessHeap(), 0, cmdline );
|
|
|
|
RegCloseKey( runkey );
|
|
|
|
WINE_TRACE( "Done.\n" );
|
|
|
|
}
|
2003-01-15 01:52:36 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
/*
|
|
|
|
* Process a "Run" type registry key.
|
|
|
|
* hkRoot is the HKEY from which "Software\Microsoft\Windows\CurrentVersion" is
|
|
|
|
* opened.
|
|
|
|
* szKeyName is the key holding the actual entries.
|
|
|
|
* bDelete tells whether we should delete each value right before executing it.
|
|
|
|
* bSynchronous tells whether we should wait for the prog to complete before
|
|
|
|
* going on to the next prog.
|
|
|
|
*/
|
|
|
|
static void ProcessRunKeys( HKEY root, const WCHAR *keyname, BOOL delete, BOOL synchronous )
|
|
|
|
{
|
|
|
|
HKEY key;
|
2003-01-15 01:52:36 +01:00
|
|
|
|
2019-04-16 11:27:38 +02:00
|
|
|
if (root == HKEY_LOCAL_MACHINE)
|
|
|
|
{
|
|
|
|
WINE_TRACE( "Processing %s entries under HKLM.\n", wine_dbgstr_w(keyname) );
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegCreateKeyExW( root, L"Software\\Microsoft\\Windows\\CurrentVersion",
|
|
|
|
0, NULL, 0, KEY_READ, NULL, &key, NULL ))
|
2019-04-16 11:27:38 +02:00
|
|
|
{
|
|
|
|
process_run_key( key, keyname, delete, synchronous );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
2020-05-21 13:36:06 +02:00
|
|
|
if (is_64bit && !RegCreateKeyExW( root, L"Software\\Microsoft\\Windows\\CurrentVersion",
|
|
|
|
0, NULL, 0, KEY_READ|KEY_WOW64_32KEY, NULL, &key, NULL ))
|
2019-04-16 11:27:38 +02:00
|
|
|
{
|
|
|
|
process_run_key( key, keyname, delete, synchronous );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINE_TRACE( "Processing %s entries under HKCU.\n", wine_dbgstr_w(keyname) );
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegCreateKeyExW( root, L"Software\\Microsoft\\Windows\\CurrentVersion",
|
|
|
|
0, NULL, 0, KEY_READ, NULL, &key, NULL ))
|
2019-04-16 11:27:38 +02:00
|
|
|
{
|
|
|
|
process_run_key( key, keyname, delete, synchronous );
|
|
|
|
RegCloseKey( key );
|
|
|
|
}
|
|
|
|
}
|
2003-01-15 01:52:36 +01:00
|
|
|
}
|
|
|
|
|
2006-07-15 06:54:57 +02:00
|
|
|
/*
|
|
|
|
* WFP is Windows File Protection, in NT5 and Windows 2000 it maintains a cache
|
|
|
|
* of known good dlls and scans through and replaces corrupted DLLs with these
|
|
|
|
* known good versions. The only programs that should install into this dll
|
|
|
|
* cache are Windows Updates and IE (which is treated like a Windows Update)
|
|
|
|
*
|
2007-12-20 16:16:17 +01:00
|
|
|
* Implementing this allows installing ie in win2k mode to actually install the
|
2006-07-15 06:54:57 +02:00
|
|
|
* system dlls that we expect and need
|
|
|
|
*/
|
|
|
|
static int ProcessWindowsFileProtection(void)
|
|
|
|
{
|
2007-12-20 16:16:17 +01:00
|
|
|
WIN32_FIND_DATAW finddata;
|
2006-07-15 06:54:57 +02:00
|
|
|
HANDLE find_handle;
|
|
|
|
BOOL find_rc;
|
|
|
|
DWORD rc;
|
|
|
|
HKEY hkey;
|
2007-12-20 16:16:17 +01:00
|
|
|
LPWSTR dllcache = NULL;
|
2006-07-15 06:54:57 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", &hkey ))
|
2006-07-15 06:54:57 +02:00
|
|
|
{
|
|
|
|
DWORD sz = 0;
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, NULL, &sz))
|
2006-07-15 06:54:57 +02:00
|
|
|
{
|
2007-12-20 16:16:17 +01:00
|
|
|
sz += sizeof(WCHAR);
|
2020-05-21 13:36:06 +02:00
|
|
|
dllcache = HeapAlloc(GetProcessHeap(),0,sz + sizeof(L"\\*"));
|
|
|
|
RegQueryValueExW( hkey, L"SFCDllCacheDir", 0, NULL, (LPBYTE)dllcache, &sz);
|
|
|
|
lstrcatW( dllcache, L"\\*" );
|
2006-07-15 06:54:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2007-12-20 16:16:17 +01:00
|
|
|
if (!dllcache)
|
|
|
|
{
|
|
|
|
DWORD sz = GetSystemDirectoryW( NULL, 0 );
|
2020-05-21 13:36:06 +02:00
|
|
|
dllcache = HeapAlloc( GetProcessHeap(), 0, sz * sizeof(WCHAR) + sizeof(L"\\dllcache\\*"));
|
2007-12-20 16:16:17 +01:00
|
|
|
GetSystemDirectoryW( dllcache, sz );
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( dllcache, L"\\dllcache\\*" );
|
2007-12-20 16:16:17 +01:00
|
|
|
}
|
2006-07-15 06:54:57 +02:00
|
|
|
|
2007-12-20 16:16:17 +01:00
|
|
|
find_handle = FindFirstFileW(dllcache,&finddata);
|
2019-07-04 15:40:46 +02:00
|
|
|
dllcache[ lstrlenW(dllcache) - 2] = 0; /* strip off wildcard */
|
2006-07-15 06:54:57 +02:00
|
|
|
find_rc = find_handle != INVALID_HANDLE_VALUE;
|
|
|
|
while (find_rc)
|
|
|
|
{
|
2007-12-20 16:16:17 +01:00
|
|
|
WCHAR targetpath[MAX_PATH];
|
|
|
|
WCHAR currentpath[MAX_PATH];
|
2006-07-15 06:54:57 +02:00
|
|
|
UINT sz;
|
|
|
|
UINT sz2;
|
2007-12-20 16:16:17 +01:00
|
|
|
WCHAR tempfile[MAX_PATH];
|
2006-07-15 06:54:57 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (wcscmp(finddata.cFileName,L".") == 0 || wcscmp(finddata.cFileName,L"..") == 0)
|
2006-07-15 06:54:57 +02:00
|
|
|
{
|
2007-12-20 16:16:17 +01:00
|
|
|
find_rc = FindNextFileW(find_handle,&finddata);
|
2006-07-15 06:54:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = MAX_PATH;
|
|
|
|
sz2 = MAX_PATH;
|
2007-12-20 16:16:17 +01:00
|
|
|
VerFindFileW(VFFF_ISSHAREDFILE, finddata.cFileName, windowsdir,
|
|
|
|
windowsdir, currentpath, &sz, targetpath, &sz2);
|
2006-07-15 06:54:57 +02:00
|
|
|
sz = MAX_PATH;
|
2007-12-20 16:16:17 +01:00
|
|
|
rc = VerInstallFileW(0, finddata.cFileName, finddata.cFileName,
|
|
|
|
dllcache, targetpath, currentpath, tempfile, &sz);
|
2006-07-15 06:54:57 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_WARN("WFP: %s error 0x%lx\n",wine_dbgstr_w(finddata.cFileName),rc);
|
2007-12-20 16:16:17 +01:00
|
|
|
DeleteFileW(tempfile);
|
2006-07-15 06:54:57 +02:00
|
|
|
}
|
2008-02-19 12:19:42 +01:00
|
|
|
|
|
|
|
/* now delete the source file so that we don't try to install it over and over again */
|
|
|
|
lstrcpynW( targetpath, dllcache, MAX_PATH - 1 );
|
2019-07-04 15:40:46 +02:00
|
|
|
sz = lstrlenW( targetpath );
|
2008-02-19 12:19:42 +01:00
|
|
|
targetpath[sz++] = '\\';
|
|
|
|
lstrcpynW( targetpath + sz, finddata.cFileName, MAX_PATH - sz );
|
|
|
|
if (!DeleteFileW( targetpath ))
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_WARN( "failed to delete %s: error %lu\n", wine_dbgstr_w(targetpath), GetLastError() );
|
2008-02-19 12:19:42 +01:00
|
|
|
|
2007-12-20 16:16:17 +01:00
|
|
|
find_rc = FindNextFileW(find_handle,&finddata);
|
2006-07-15 06:54:57 +02:00
|
|
|
}
|
|
|
|
FindClose(find_handle);
|
2007-12-20 16:16:17 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,dllcache);
|
2006-07-15 06:54:57 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-01 13:48:46 +02:00
|
|
|
static BOOL start_services_process(void)
|
|
|
|
{
|
|
|
|
static const WCHAR svcctl_started_event[] = SVCCTL_STARTED_EVENT;
|
|
|
|
PROCESS_INFORMATION pi;
|
2020-05-21 13:36:06 +02:00
|
|
|
STARTUPINFOW si = { sizeof(si) };
|
2008-04-01 13:48:46 +02:00
|
|
|
HANDLE wait_handles[2];
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!CreateProcessW(L"C:\\windows\\system32\\services.exe", NULL,
|
|
|
|
NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &si, &pi))
|
2008-04-01 13:48:46 +02:00
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Couldn't start services.exe: error %lu\n", GetLastError());
|
2008-04-01 13:48:46 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
|
|
|
|
wait_handles[0] = CreateEventW(NULL, TRUE, FALSE, svcctl_started_event);
|
|
|
|
wait_handles[1] = pi.hProcess;
|
|
|
|
|
|
|
|
/* wait for the event to become available or the process to exit */
|
|
|
|
if ((WaitForMultipleObjects(2, wait_handles, FALSE, INFINITE)) == WAIT_OBJECT_0 + 1)
|
|
|
|
{
|
|
|
|
DWORD exit_code;
|
|
|
|
GetExitCodeProcess(pi.hProcess, &exit_code);
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Unexpected termination of services.exe - exit code %ld\n", exit_code);
|
2008-04-01 13:48:46 +02:00
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
CloseHandle(wait_handles[0]);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
CloseHandle(wait_handles[0]);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-30 16:49:53 +02:00
|
|
|
static INT_PTR CALLBACK wait_dlgproc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2019-07-04 15:40:46 +02:00
|
|
|
DWORD len;
|
2010-03-30 16:49:53 +02:00
|
|
|
WCHAR *buffer, text[1024];
|
|
|
|
const WCHAR *name = (WCHAR *)lp;
|
|
|
|
HICON icon = LoadImageW( 0, (LPCWSTR)IDI_WINLOGO, IMAGE_ICON, 48, 48, LR_SHARED );
|
|
|
|
SendDlgItemMessageW( hwnd, IDC_WAITICON, STM_SETICON, (WPARAM)icon, 0 );
|
|
|
|
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_GETTEXT, 1024, (LPARAM)text );
|
2019-07-04 15:40:46 +02:00
|
|
|
len = lstrlenW(text) + lstrlenW(name) + 1;
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
swprintf( buffer, len, text, name );
|
2010-03-30 16:49:53 +02:00
|
|
|
SendDlgItemMessageW( hwnd, IDC_WAITTEXT, WM_SETTEXT, 0, (LPARAM)buffer );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HWND show_wait_window(void)
|
|
|
|
{
|
2019-11-28 08:51:17 +01:00
|
|
|
HWND hwnd = CreateDialogParamW( GetModuleHandleW(0), MAKEINTRESOURCEW(IDD_WAITDLG), 0,
|
|
|
|
wait_dlgproc, (LPARAM)prettyprint_configdir() );
|
2010-03-30 16:49:53 +02:00
|
|
|
ShowWindow( hwnd, SW_SHOWNORMAL );
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2021-09-17 12:45:46 +02:00
|
|
|
static HANDLE start_rundll32( const WCHAR *inf_path, const WCHAR *install, WORD machine )
|
2010-03-30 16:38:58 +02:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
WCHAR app[MAX_PATH + ARRAY_SIZE(L"\\rundll32.exe" )];
|
2010-03-30 16:38:58 +02:00
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
WCHAR *buffer;
|
2019-07-04 15:40:46 +02:00
|
|
|
DWORD len;
|
2010-03-30 16:38:58 +02:00
|
|
|
|
|
|
|
memset( &si, 0, sizeof(si) );
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
2021-04-28 10:03:36 +02:00
|
|
|
if (!GetSystemWow64Directory2W( app, MAX_PATH, machine )) return 0;
|
2020-05-21 13:36:06 +02:00
|
|
|
lstrcatW( app, L"\\rundll32.exe" );
|
2021-04-28 10:03:36 +02:00
|
|
|
TRACE( "machine %x starting %s\n", machine, debugstr_w(app) );
|
2010-03-30 16:38:58 +02:00
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
len = lstrlenW(app) + ARRAY_SIZE(L" setupapi,InstallHinfSection DefaultInstall 128 ") + lstrlenW(inf_path);
|
2010-03-30 16:38:58 +02:00
|
|
|
|
2019-07-04 15:40:46 +02:00
|
|
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0;
|
2021-09-17 12:45:46 +02:00
|
|
|
swprintf( buffer, len, L"%s setupapi,InstallHinfSection %s 128 %s", app, install, inf_path );
|
2010-03-30 16:38:58 +02:00
|
|
|
|
|
|
|
if (CreateProcessW( app, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
|
|
|
CloseHandle( pi.hThread );
|
|
|
|
else
|
|
|
|
pi.hProcess = 0;
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
return pi.hProcess;
|
|
|
|
}
|
|
|
|
|
2019-11-07 06:54:59 +01:00
|
|
|
static void install_root_pnp_devices(void)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *hardware_id;
|
|
|
|
const char *infpath;
|
|
|
|
}
|
|
|
|
root_devices[] =
|
|
|
|
{
|
|
|
|
{"root\\wine\\winebus", "root\\winebus\0", "C:\\windows\\inf\\winebus.inf"},
|
2020-04-17 02:58:19 +02:00
|
|
|
{"root\\wine\\wineusb", "root\\wineusb\0", "C:\\windows\\inf\\wineusb.inf"},
|
2019-11-07 06:54:59 +01:00
|
|
|
};
|
|
|
|
SP_DEVINFO_DATA device = {sizeof(device)};
|
|
|
|
unsigned int i;
|
|
|
|
HDEVINFO set;
|
|
|
|
|
|
|
|
if ((set = SetupDiCreateDeviceInfoList( NULL, NULL )) == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Failed to create device info list, error %#lx.\n", GetLastError());
|
2019-11-07 06:54:59 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(root_devices); ++i)
|
|
|
|
{
|
|
|
|
if (!SetupDiCreateDeviceInfoA( set, root_devices[i].name, &GUID_NULL, NULL, NULL, 0, &device))
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_DEVINST_ALREADY_EXISTS)
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Failed to create device %s, error %#lx.\n", debugstr_a(root_devices[i].name), GetLastError());
|
2019-11-07 06:54:59 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetupDiSetDeviceRegistryPropertyA(set, &device, SPDRP_HARDWAREID,
|
|
|
|
(const BYTE *)root_devices[i].hardware_id, (strlen(root_devices[i].hardware_id) + 2) * sizeof(WCHAR)))
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Failed to set hardware id for %s, error %#lx.\n", debugstr_a(root_devices[i].name), GetLastError());
|
2019-11-07 06:54:59 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE, set, &device))
|
|
|
|
{
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Failed to register device %s, error %#lx.\n", debugstr_a(root_devices[i].name), GetLastError());
|
2019-11-07 06:54:59 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UpdateDriverForPlugAndPlayDevicesA(NULL, root_devices[i].hardware_id, root_devices[i].infpath, 0, NULL))
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Failed to install drivers for %s, error %#lx.\n", debugstr_a(root_devices[i].name), GetLastError());
|
2019-11-07 06:54:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SetupDiDestroyDeviceInfoList(set);
|
|
|
|
}
|
|
|
|
|
2019-11-20 12:25:13 +01:00
|
|
|
static void update_user_profile(void)
|
|
|
|
{
|
|
|
|
char token_buf[sizeof(TOKEN_USER) + sizeof(SID) + sizeof(DWORD) * SID_MAX_SUB_AUTHORITIES];
|
|
|
|
HANDLE token;
|
|
|
|
WCHAR profile[MAX_PATH], *sid;
|
|
|
|
DWORD size;
|
|
|
|
HKEY hkey, profile_hkey;
|
|
|
|
|
|
|
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token))
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = sizeof(token_buf);
|
|
|
|
GetTokenInformation(token, TokenUser, token_buf, size, &size);
|
|
|
|
CloseHandle(token);
|
|
|
|
|
|
|
|
ConvertSidToStringSidW(((TOKEN_USER *)token_buf)->User.Sid, &sid);
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
|
|
|
|
0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL))
|
2019-11-20 12:25:13 +01:00
|
|
|
{
|
|
|
|
if (!RegCreateKeyExW(hkey, sid, 0, NULL, 0,
|
|
|
|
KEY_ALL_ACCESS, NULL, &profile_hkey, NULL))
|
|
|
|
{
|
2019-11-21 09:24:35 +01:00
|
|
|
DWORD flags = 0;
|
2019-11-20 12:25:13 +01:00
|
|
|
if (SHGetSpecialFolderPathW(NULL, profile, CSIDL_PROFILE, TRUE))
|
2020-05-21 13:36:06 +02:00
|
|
|
set_reg_value(profile_hkey, L"ProfileImagePath", profile);
|
2019-11-21 09:24:35 +01:00
|
|
|
RegSetValueExW( profile_hkey, L"Flags", 0, REG_DWORD, (const BYTE *)&flags, sizeof(flags) );
|
2019-11-20 12:25:13 +01:00
|
|
|
RegCloseKey(profile_hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalFree(sid);
|
|
|
|
}
|
|
|
|
|
2008-04-17 21:07:10 +02:00
|
|
|
/* execute rundll32 on the wine.inf file if necessary */
|
2013-10-22 22:21:51 +02:00
|
|
|
static void update_wineprefix( BOOL force )
|
2008-04-17 21:07:10 +02:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
const WCHAR *config_dir = _wgetenv( L"WINECONFIGDIR" );
|
2019-07-04 15:40:46 +02:00
|
|
|
WCHAR *inf_path = get_wine_inf_path();
|
2009-05-25 11:48:23 +02:00
|
|
|
int fd;
|
2008-04-17 21:07:10 +02:00
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (!inf_path)
|
|
|
|
{
|
2019-11-28 08:51:17 +01:00
|
|
|
WINE_MESSAGE( "wine: failed to update %s, wine.inf not found\n", debugstr_w( config_dir ));
|
2008-04-17 21:07:10 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-07-04 15:40:46 +02:00
|
|
|
if ((fd = _wopen( inf_path, O_RDONLY )) == -1)
|
2008-04-21 15:39:55 +02:00
|
|
|
{
|
2009-05-25 11:48:23 +02:00
|
|
|
WINE_MESSAGE( "wine: failed to update %s with %s: %s\n",
|
2019-11-28 08:51:17 +01:00
|
|
|
debugstr_w(config_dir), debugstr_w(inf_path), strerror(errno) );
|
2008-04-21 15:39:55 +02:00
|
|
|
goto done;
|
|
|
|
}
|
2009-05-25 11:48:23 +02:00
|
|
|
fstat( fd, &st );
|
|
|
|
close( fd );
|
2008-04-21 15:39:55 +02:00
|
|
|
|
2008-09-17 14:58:52 +02:00
|
|
|
if (update_timestamp( config_dir, st.st_mtime ) || force)
|
2008-04-17 21:07:10 +02:00
|
|
|
{
|
2021-04-28 10:03:36 +02:00
|
|
|
ULONG machines[8];
|
|
|
|
HANDLE process = 0;
|
2010-03-30 16:49:53 +02:00
|
|
|
DWORD count = 0;
|
2008-04-17 21:07:10 +02:00
|
|
|
|
2021-04-28 10:03:36 +02:00
|
|
|
if (NtQuerySystemInformationEx( SystemSupportedProcessorArchitectures, &process, sizeof(process),
|
|
|
|
machines, sizeof(machines), NULL )) machines[0] = 0;
|
|
|
|
|
2021-09-17 12:45:46 +02:00
|
|
|
if ((process = start_rundll32( inf_path, L"PreInstall", IMAGE_FILE_MACHINE_TARGET_HOST )))
|
2010-03-30 16:43:52 +02:00
|
|
|
{
|
2010-03-30 16:49:53 +02:00
|
|
|
HWND hwnd = show_wait_window();
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
DWORD res = MsgWaitForMultipleObjects( 1, &process, FALSE, INFINITE, QS_ALLINPUT );
|
|
|
|
if (res == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
CloseHandle( process );
|
2021-04-28 10:03:36 +02:00
|
|
|
if (!machines[count]) break;
|
2021-09-17 12:45:46 +02:00
|
|
|
if (HIWORD(machines[count]) & 4 /* native machine */)
|
|
|
|
process = start_rundll32( inf_path, L"DefaultInstall", IMAGE_FILE_MACHINE_TARGET_HOST );
|
|
|
|
else
|
|
|
|
process = start_rundll32( inf_path, L"Wow64Install", LOWORD(machines[count]) );
|
|
|
|
count++;
|
|
|
|
if (!process) break;
|
2010-03-30 16:49:53 +02:00
|
|
|
}
|
|
|
|
else while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
|
|
|
|
}
|
|
|
|
DestroyWindow( hwnd );
|
2010-03-30 16:38:58 +02:00
|
|
|
}
|
2019-11-07 06:54:59 +01:00
|
|
|
install_root_pnp_devices();
|
2019-11-20 12:25:13 +01:00
|
|
|
update_user_profile();
|
2019-11-07 06:54:59 +01:00
|
|
|
|
2019-11-28 08:51:17 +01:00
|
|
|
WINE_MESSAGE( "wine: configuration in %s has been updated.\n", debugstr_w(prettyprint_configdir()) );
|
2008-04-17 21:07:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
HeapFree( GetProcessHeap(), 0, inf_path );
|
|
|
|
}
|
|
|
|
|
2007-02-12 04:09:45 +01:00
|
|
|
/* Process items in the StartUp group of the user's Programs under the Start Menu. Some installers put
|
|
|
|
* shell links here to restart themselves after boot. */
|
|
|
|
static BOOL ProcessStartupItems(void)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
HRESULT hr;
|
|
|
|
IShellFolder *psfDesktop = NULL, *psfStartup = NULL;
|
|
|
|
LPITEMIDLIST pidlStartup = NULL, pidlItem;
|
|
|
|
ULONG NumPIDLs;
|
|
|
|
IEnumIDList *iEnumList = NULL;
|
|
|
|
STRRET strret;
|
|
|
|
WCHAR wszCommand[MAX_PATH];
|
|
|
|
|
|
|
|
WINE_TRACE("Processing items in the StartUp folder.\n");
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WINE_ERR("Couldn't get desktop folder.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = SHGetSpecialFolderLocation(NULL, CSIDL_STARTUP, &pidlStartup);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WINE_TRACE("Couldn't get StartUp folder location.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlStartup, NULL, &IID_IShellFolder, (LPVOID*)&psfStartup);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WINE_TRACE("Couldn't bind IShellFolder to StartUp folder.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IShellFolder_EnumObjects(psfStartup, NULL, SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WINE_TRACE("Unable to enumerate StartUp objects.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (IEnumIDList_Next(iEnumList, 1, &pidlItem, &NumPIDLs) == S_OK &&
|
|
|
|
(NumPIDLs) == 1)
|
|
|
|
{
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(psfStartup, pidlItem, SHGDN_FORPARSING, &strret);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WINE_TRACE("Unable to get display name of enumeration item.\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = StrRetToBufW(&strret, pidlItem, wszCommand, MAX_PATH);
|
|
|
|
if (FAILED(hr))
|
|
|
|
WINE_TRACE("Unable to parse display name.\n");
|
|
|
|
else
|
2008-04-09 14:23:06 +02:00
|
|
|
{
|
|
|
|
HINSTANCE hinst;
|
|
|
|
|
|
|
|
hinst = ShellExecuteW(NULL, NULL, wszCommand, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
if (PtrToUlong(hinst) <= 32)
|
|
|
|
WINE_WARN("Error %p executing command %s.\n", hinst, wine_dbgstr_w(wszCommand));
|
|
|
|
}
|
2007-02-12 04:09:45 +01:00
|
|
|
}
|
|
|
|
|
2020-01-27 09:33:51 +01:00
|
|
|
ILFree(pidlItem);
|
2007-02-12 04:09:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return success */
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (iEnumList) IEnumIDList_Release(iEnumList);
|
|
|
|
if (psfStartup) IShellFolder_Release(psfStartup);
|
2020-01-27 09:33:51 +01:00
|
|
|
if (pidlStartup) ILFree(pidlStartup);
|
2007-02-12 04:09:45 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-07-03 20:58:43 +02:00
|
|
|
static void usage( int status )
|
2006-08-17 20:54:15 +02:00
|
|
|
{
|
|
|
|
WINE_MESSAGE( "Usage: wineboot [options]\n" );
|
|
|
|
WINE_MESSAGE( "Options;\n" );
|
|
|
|
WINE_MESSAGE( " -h,--help Display this help message\n" );
|
|
|
|
WINE_MESSAGE( " -e,--end-session End the current session cleanly\n" );
|
|
|
|
WINE_MESSAGE( " -f,--force Force exit for processes that don't exit cleanly\n" );
|
2008-01-16 19:23:09 +01:00
|
|
|
WINE_MESSAGE( " -i,--init Perform initialization for first Wine instance\n" );
|
2006-08-17 20:54:15 +02:00
|
|
|
WINE_MESSAGE( " -k,--kill Kill running processes without any cleanup\n" );
|
|
|
|
WINE_MESSAGE( " -r,--restart Restart only, don't do normal startup operations\n" );
|
|
|
|
WINE_MESSAGE( " -s,--shutdown Shutdown only, don't reboot\n" );
|
2008-04-17 21:07:10 +02:00
|
|
|
WINE_MESSAGE( " -u,--update Update the wineprefix directory\n" );
|
2019-07-03 20:58:43 +02:00
|
|
|
exit( status );
|
2006-08-17 20:54:15 +02:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:24:19 +02:00
|
|
|
int __cdecl main( int argc, char *argv[] )
|
2003-01-04 03:52:05 +01:00
|
|
|
{
|
2003-01-07 20:44:00 +01:00
|
|
|
/* First, set the current directory to SystemRoot */
|
2019-07-03 20:58:43 +02:00
|
|
|
int i, j;
|
2013-10-22 22:21:51 +02:00
|
|
|
BOOL end_session, force, init, kill, restart, shutdown, update;
|
2008-01-04 12:51:04 +01:00
|
|
|
HANDLE event;
|
2019-11-05 11:05:07 +01:00
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING nameW;
|
2010-12-15 22:29:25 +01:00
|
|
|
BOOL is_wow64;
|
2003-01-07 20:44:00 +01:00
|
|
|
|
2013-10-22 22:21:51 +02:00
|
|
|
end_session = force = init = kill = restart = shutdown = update = FALSE;
|
2007-12-20 16:16:17 +01:00
|
|
|
GetWindowsDirectoryW( windowsdir, MAX_PATH );
|
|
|
|
if( !SetCurrentDirectoryW( windowsdir ) )
|
2022-02-07 08:40:25 +01:00
|
|
|
WINE_ERR("Cannot set the dir to %s (%ld)\n", wine_dbgstr_w(windowsdir), GetLastError() );
|
2003-01-07 20:44:00 +01:00
|
|
|
|
2010-12-15 22:29:25 +01:00
|
|
|
if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
void *redir;
|
|
|
|
DWORD exit_code;
|
|
|
|
|
|
|
|
memset( &si, 0, sizeof(si) );
|
|
|
|
si.cb = sizeof(si);
|
2021-04-16 11:11:22 +02:00
|
|
|
GetSystemDirectoryW( filename, MAX_PATH );
|
|
|
|
wcscat( filename, L"\\wineboot.exe" );
|
2010-12-15 22:29:25 +01:00
|
|
|
|
|
|
|
Wow64DisableWow64FsRedirection( &redir );
|
|
|
|
if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
|
|
|
{
|
|
|
|
WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) );
|
|
|
|
WaitForSingleObject( pi.hProcess, INFINITE );
|
|
|
|
GetExitCodeProcess( pi.hProcess, &exit_code );
|
|
|
|
ExitProcess( exit_code );
|
|
|
|
}
|
2022-02-07 08:40:25 +01:00
|
|
|
else WINE_ERR( "failed to restart 64-bit %s, err %ld\n", wine_dbgstr_w(filename), GetLastError() );
|
2010-12-15 22:29:25 +01:00
|
|
|
Wow64RevertWow64FsRedirection( redir );
|
|
|
|
}
|
|
|
|
|
2019-07-03 20:58:43 +02:00
|
|
|
for (i = 1; i < argc; i++)
|
2003-03-12 21:15:15 +01:00
|
|
|
{
|
2019-07-03 20:58:43 +02:00
|
|
|
if (argv[i][0] != '-') continue;
|
|
|
|
if (argv[i][1] == '-')
|
2003-03-12 21:15:15 +01:00
|
|
|
{
|
2019-07-03 20:58:43 +02:00
|
|
|
if (!strcmp( argv[i], "--help" )) usage( 0 );
|
|
|
|
else if (!strcmp( argv[i], "--end-session" )) end_session = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--force" )) force = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--init" )) init = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--kill" )) kill = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--restart" )) restart = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--shutdown" )) shutdown = TRUE;
|
|
|
|
else if (!strcmp( argv[i], "--update" )) update = TRUE;
|
|
|
|
else usage( 1 );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (j = 1; argv[i][j]; j++)
|
|
|
|
{
|
|
|
|
switch (argv[i][j])
|
|
|
|
{
|
|
|
|
case 'e': end_session = TRUE; break;
|
|
|
|
case 'f': force = TRUE; break;
|
|
|
|
case 'i': init = TRUE; break;
|
|
|
|
case 'k': kill = TRUE; break;
|
|
|
|
case 'r': restart = TRUE; break;
|
|
|
|
case 's': shutdown = TRUE; break;
|
|
|
|
case 'u': update = TRUE; break;
|
|
|
|
case 'h': usage(0); break;
|
|
|
|
default: usage(1); break;
|
|
|
|
}
|
2003-03-12 21:15:15 +01:00
|
|
|
}
|
2006-08-17 20:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (end_session)
|
|
|
|
{
|
2010-05-18 20:36:36 +02:00
|
|
|
if (kill)
|
|
|
|
{
|
|
|
|
if (!shutdown_all_desktops( force )) return 1;
|
|
|
|
}
|
|
|
|
else if (!shutdown_close_windows( force )) return 1;
|
2006-08-17 20:54:15 +02:00
|
|
|
}
|
|
|
|
|
2008-01-16 19:23:09 +01:00
|
|
|
if (kill) kill_processes( shutdown );
|
2006-08-17 20:54:15 +02:00
|
|
|
|
|
|
|
if (shutdown) return 0;
|
|
|
|
|
2019-11-05 11:05:07 +01:00
|
|
|
/* create event to be inherited by services.exe */
|
|
|
|
InitializeObjectAttributes( &attr, &nameW, OBJ_OPENIF | OBJ_INHERIT, 0, NULL );
|
2020-05-21 13:36:06 +02:00
|
|
|
RtlInitUnicodeString( &nameW, L"\\KernelObjects\\__wineboot_event" );
|
2019-11-05 11:05:07 +01:00
|
|
|
NtCreateEvent( &event, EVENT_ALL_ACCESS, &attr, NotificationEvent, 0 );
|
2008-04-02 12:19:25 +02:00
|
|
|
|
2008-01-04 12:51:04 +01:00
|
|
|
ResetEvent( event ); /* in case this is a restart */
|
|
|
|
|
2020-05-29 12:26:57 +02:00
|
|
|
create_user_shared_data();
|
2009-09-24 14:22:57 +02:00
|
|
|
create_hardware_registry_keys();
|
2010-03-01 14:01:28 +01:00
|
|
|
create_dynamic_registry_keys();
|
2009-09-24 14:22:57 +02:00
|
|
|
create_environment_registry_keys();
|
2020-09-28 16:20:04 +02:00
|
|
|
create_computer_name_keys();
|
2007-12-20 15:08:39 +01:00
|
|
|
wininit();
|
|
|
|
pendingRename();
|
2003-01-04 03:52:05 +01:00
|
|
|
|
2007-12-20 15:08:39 +01:00
|
|
|
ProcessWindowsFileProtection();
|
2020-05-21 13:36:06 +02:00
|
|
|
ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunServicesOnce", TRUE, FALSE );
|
2008-04-17 21:07:10 +02:00
|
|
|
|
2008-01-16 19:23:09 +01:00
|
|
|
if (init || (kill && !restart))
|
2007-12-20 15:53:03 +01:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunServices", FALSE, FALSE );
|
2008-04-11 12:00:11 +02:00
|
|
|
start_services_process();
|
2007-12-20 15:53:03 +01:00
|
|
|
}
|
2008-04-21 15:39:55 +02:00
|
|
|
if (init || update) update_wineprefix( update );
|
2008-04-17 21:07:10 +02:00
|
|
|
|
2009-12-25 11:33:33 +01:00
|
|
|
create_volatile_environment_registry_key();
|
|
|
|
|
2020-05-21 13:36:06 +02:00
|
|
|
ProcessRunKeys( HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE );
|
2008-01-16 19:23:09 +01:00
|
|
|
|
|
|
|
if (!init && !restart)
|
2007-12-20 15:08:39 +01:00
|
|
|
{
|
2020-05-21 13:36:06 +02:00
|
|
|
ProcessRunKeys( HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE );
|
|
|
|
ProcessRunKeys( HKEY_CURRENT_USER, L"Run", FALSE, FALSE );
|
2007-12-20 15:08:39 +01:00
|
|
|
ProcessStartupItems();
|
|
|
|
}
|
2003-01-14 20:33:12 +01:00
|
|
|
|
2007-12-20 15:08:39 +01:00
|
|
|
WINE_TRACE("Operation done\n");
|
2008-01-04 12:51:04 +01:00
|
|
|
|
|
|
|
SetEvent( event );
|
2007-12-20 15:08:39 +01:00
|
|
|
return 0;
|
2003-01-04 03:52:05 +01:00
|
|
|
}
|