2003-05-02 18:12:38 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-05-02 18:12:38 +00:00
|
|
|
*/
|
2006-08-06 20:33:34 +00:00
|
|
|
/*
|
2003-05-02 18:12:38 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* PURPOSE: System setup
|
2010-02-19 20:03:11 +00:00
|
|
|
* FILE: dll/win32/syssetup/install.c
|
2004-08-28 11:08:50 +00:00
|
|
|
* PROGRAMER: Eric Kohl
|
2003-05-02 18:12:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2011-07-28 15:57:04 +00:00
|
|
|
#include "precomp.h"
|
2004-03-21 14:37:19 +00:00
|
|
|
|
2014-01-25 19:51:44 +00:00
|
|
|
#include <tchar.h>
|
|
|
|
#include <wincon.h>
|
|
|
|
#include <winsvc.h>
|
|
|
|
#include <userenv.h>
|
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shlwapi.h>
|
2013-05-17 21:40:46 +00:00
|
|
|
#include <rpcproxy.h>
|
2014-01-25 19:51:44 +00:00
|
|
|
#include <ndk/cmfuncs.h>
|
2013-05-17 21:40:46 +00:00
|
|
|
|
2007-10-31 13:17:42 +00:00
|
|
|
#define NDEBUG
|
2007-04-29 21:29:41 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
2006-10-02 18:46:39 +00:00
|
|
|
DWORD WINAPI
|
|
|
|
CMP_WaitNoPendingInstallEvents(DWORD dwTimeout);
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
|
2014-01-18 14:26:07 +00:00
|
|
|
ADMIN_INFO AdminInfo;
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2003-05-02 18:12:38 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
static VOID
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError(char *pszFmt,...)
|
2004-01-16 21:33:23 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
char szBuffer[512];
|
2007-07-11 08:52:55 +00:00
|
|
|
va_list ap;
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
va_start(ap, pszFmt);
|
|
|
|
vsprintf(szBuffer, pszFmt, ap);
|
2007-07-11 08:52:55 +00:00
|
|
|
va_end(ap);
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
LogItem(SYSSETUP_SEVERITY_FATAL_ERROR, L"Failed");
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
strcat(szBuffer, "\nRebooting now!");
|
2007-07-11 08:52:55 +00:00
|
|
|
MessageBoxA(NULL,
|
2011-11-19 00:24:58 +00:00
|
|
|
szBuffer,
|
2007-07-11 08:52:55 +00:00
|
|
|
"ReactOS Setup",
|
|
|
|
MB_OK);
|
2004-01-16 21:33:23 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
static HRESULT
|
|
|
|
CreateShellLink(
|
|
|
|
LPCTSTR pszLinkPath,
|
|
|
|
LPCTSTR pszCmd,
|
|
|
|
LPCTSTR pszArg,
|
|
|
|
LPCTSTR pszDir,
|
|
|
|
LPCTSTR pszIconPath,
|
|
|
|
int iIconNr,
|
|
|
|
LPCTSTR pszComment)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
IShellLink *psl;
|
|
|
|
IPersistFile *ppf;
|
2005-01-03 18:44:36 +00:00
|
|
|
#ifndef _UNICODE
|
2011-11-19 00:24:58 +00:00
|
|
|
WCHAR wszBuf[MAX_PATH];
|
2005-01-03 18:44:36 +00:00
|
|
|
#endif /* _UNICODE */
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl);
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
if (SUCCEEDED(hr))
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = psl->lpVtbl->SetPath(psl, pszCmd);
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (pszArg)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = psl->lpVtbl->SetArguments(psl, pszArg);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (pszDir)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = psl->lpVtbl->SetWorkingDirectory(psl, pszDir);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (pszIconPath)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = psl->lpVtbl->SetIconLocation(psl, pszIconPath, iIconNr);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (pszComment)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = psl->lpVtbl->SetDescription(psl, pszComment);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
if (SUCCEEDED(hr))
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2005-01-03 18:44:36 +00:00
|
|
|
#ifdef _UNICODE
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = ppf->lpVtbl->Save(ppf, pszLinkPath, TRUE);
|
2005-01-03 18:44:36 +00:00
|
|
|
#else /* _UNICODE */
|
2011-11-19 00:24:58 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pszLinkPath, -1, wszBuf, MAX_PATH);
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
hr = ppf->lpVtbl->Save(ppf, wszBuf, TRUE);
|
2005-01-03 18:44:36 +00:00
|
|
|
#endif /* _UNICODE */
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
ppf->lpVtbl->Release(ppf);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
psl->lpVtbl->Release(psl);
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
return hr;
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
static BOOL
|
2011-11-19 00:24:58 +00:00
|
|
|
CreateShortcut(
|
|
|
|
LPCTSTR pszFolder,
|
2013-05-29 20:33:11 +00:00
|
|
|
LPCTSTR pszName,
|
2011-11-19 00:24:58 +00:00
|
|
|
LPCTSTR pszCommand,
|
2013-05-29 20:33:11 +00:00
|
|
|
LPCTSTR pszDescription,
|
2011-11-19 00:24:58 +00:00
|
|
|
INT iIconNr)
|
2005-10-17 11:03:30 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
TCHAR szPath[MAX_PATH];
|
|
|
|
TCHAR szExeName[MAX_PATH];
|
2013-05-29 20:33:11 +00:00
|
|
|
LPTSTR Ptr;
|
2011-11-19 00:24:58 +00:00
|
|
|
TCHAR szWorkingDirBuf[MAX_PATH];
|
|
|
|
LPTSTR pszWorkingDir = NULL;
|
2007-07-11 18:49:01 +00:00
|
|
|
LPTSTR lpFilePart;
|
|
|
|
DWORD dwLen;
|
2007-07-11 09:55:53 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (ExpandEnvironmentStrings(pszCommand,
|
|
|
|
szPath,
|
|
|
|
sizeof(szPath) / sizeof(szPath[0])) == 0)
|
2005-10-17 11:03:30 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
_tcscpy(szPath, pszCommand);
|
2005-10-17 11:03:30 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if ((_taccess(szPath, 0 )) == -1)
|
|
|
|
/* Expected error, don't return FALSE */
|
|
|
|
return TRUE;
|
2007-07-11 19:43:57 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
dwLen = GetFullPathName(szPath,
|
|
|
|
sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]),
|
|
|
|
szWorkingDirBuf,
|
2007-07-11 18:49:01 +00:00
|
|
|
&lpFilePart);
|
2011-11-19 00:24:58 +00:00
|
|
|
if (dwLen != 0 && dwLen <= sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]))
|
2007-07-11 18:49:01 +00:00
|
|
|
{
|
2011-09-20 14:21:21 +00:00
|
|
|
/* Since those should only be called with (.exe) files,
|
|
|
|
lpFilePart has not to be NULL */
|
|
|
|
ASSERT(lpFilePart != NULL);
|
|
|
|
|
2007-07-12 15:50:19 +00:00
|
|
|
/* Save the file name */
|
2011-11-19 00:24:58 +00:00
|
|
|
_tcscpy(szExeName, lpFilePart);
|
2007-07-11 18:49:01 +00:00
|
|
|
|
2011-09-20 14:21:21 +00:00
|
|
|
/* We're only interested in the path. Cut the file name off.
|
|
|
|
Also remove the trailing backslash unless the working directory
|
|
|
|
is only going to be a drive, ie. C:\ */
|
|
|
|
*(lpFilePart--) = _T('\0');
|
2011-11-19 00:24:58 +00:00
|
|
|
if (!(lpFilePart - szWorkingDirBuf == 2 && szWorkingDirBuf[1] == _T(':') &&
|
|
|
|
szWorkingDirBuf[2] == _T('\\')))
|
2007-07-11 18:49:01 +00:00
|
|
|
{
|
2011-09-20 14:21:21 +00:00
|
|
|
*lpFilePart = _T('\0');
|
2007-07-11 18:49:01 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
pszWorkingDir = szWorkingDirBuf;
|
2007-07-11 18:49:01 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
_tcscpy(szPath, pszFolder);
|
|
|
|
|
|
|
|
Ptr = PathAddBackslash(szPath);
|
|
|
|
|
|
|
|
_tcscpy(Ptr, pszName);
|
|
|
|
|
|
|
|
// FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
|
|
|
|
return SUCCEEDED(CreateShellLink(szPath, szExeName, _T(""), pszWorkingDir, szExeName, iIconNr, pszDescription));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder)
|
|
|
|
{
|
|
|
|
INFCONTEXT Context;
|
|
|
|
WCHAR szCommand[MAX_PATH];
|
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
WCHAR szDescription[MAX_PATH];
|
|
|
|
INT iIconNr;
|
2007-07-11 19:34:45 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context))
|
2007-07-11 19:34:45 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
do
|
2007-07-11 19:34:45 +00:00
|
|
|
{
|
2013-05-29 20:33:11 +00:00
|
|
|
if (SetupGetFieldCount(&Context) < 4)
|
|
|
|
continue;
|
2007-07-11 19:34:45 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL))
|
|
|
|
continue;
|
2007-07-11 19:34:45 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetStringFieldW(&Context, 2, szName, MAX_PATH, NULL))
|
|
|
|
continue;
|
2007-07-11 19:34:45 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetStringFieldW(&Context, 3, szDescription, MAX_PATH, NULL))
|
|
|
|
continue;
|
2007-07-11 19:34:45 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetIntField(&Context, 4, &iIconNr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
_tcscat(szName, L".lnk");
|
|
|
|
|
|
|
|
CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr);
|
|
|
|
|
|
|
|
}while (SetupFindNextLine(&Context, &Context));
|
|
|
|
|
|
|
|
return TRUE;
|
2005-10-17 11:03:30 +00:00
|
|
|
}
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2013-05-29 20:33:11 +00:00
|
|
|
INFCONTEXT Context;
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
WCHAR szFolder[MAX_PATH];
|
|
|
|
WCHAR szFolderSection[MAX_PATH];
|
|
|
|
INT csidl;
|
|
|
|
LPWSTR p;
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
CoInitialize(NULL);
|
2005-10-17 11:03:30 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupFindFirstLine(hinf, szSection, NULL, &Context))
|
2007-07-11 08:52:55 +00:00
|
|
|
return FALSE;
|
2005-10-17 11:03:30 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (SetupGetFieldCount(&Context) < 2)
|
|
|
|
continue;
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetStringFieldW(&Context, 0, szFolderSection, MAX_PATH, NULL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!SetupGetIntField(&Context, 1, &csidl))
|
|
|
|
continue;
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
if (!SetupGetStringFieldW(&Context, 2, szFolder, MAX_PATH, NULL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!SHGetSpecialFolderPathW(0, szPath, csidl, TRUE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p = PathAddBackslash(szPath);
|
|
|
|
_tcscpy(p, szFolder);
|
|
|
|
|
|
|
|
if (!CreateDirectory(szPath, NULL))
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateShortcutsFromSection(hinf, szFolderSection, szPath);
|
|
|
|
|
|
|
|
}while (SetupFindNextLine(&Context, &Context));
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-01-16 21:33:23 +00:00
|
|
|
|
2004-06-24 09:17:33 +00:00
|
|
|
static VOID
|
2007-07-11 08:52:55 +00:00
|
|
|
CreateTempDir(
|
|
|
|
IN LPCWSTR VarName)
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2008-12-11 11:24:32 +00:00
|
|
|
WCHAR szTempDir[MAX_PATH];
|
|
|
|
WCHAR szBuffer[MAX_PATH];
|
2007-07-11 08:52:55 +00:00
|
|
|
DWORD dwLength;
|
|
|
|
HKEY hKey;
|
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment",
|
2007-07-11 08:52:55 +00:00
|
|
|
0,
|
2007-07-11 09:55:53 +00:00
|
|
|
KEY_QUERY_VALUE,
|
2011-11-19 00:24:58 +00:00
|
|
|
&hKey) != ERROR_SUCCESS)
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error: %lu\n", GetLastError());
|
2007-07-11 08:52:55 +00:00
|
|
|
return;
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
/* Get temp dir */
|
2008-12-11 11:24:32 +00:00
|
|
|
dwLength = MAX_PATH * sizeof(WCHAR);
|
|
|
|
if (RegQueryValueExW(hKey,
|
2007-07-11 08:52:55 +00:00
|
|
|
VarName,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(LPBYTE)szBuffer,
|
2011-11-19 00:24:58 +00:00
|
|
|
&dwLength) != ERROR_SUCCESS)
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error: %lu\n", GetLastError());
|
|
|
|
goto cleanup;
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
/* Expand it */
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!ExpandEnvironmentStringsW(szBuffer,
|
2007-07-11 08:52:55 +00:00
|
|
|
szTempDir,
|
|
|
|
MAX_PATH))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error: %lu\n", GetLastError());
|
|
|
|
goto cleanup;
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
/* Create profiles directory */
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!CreateDirectoryW(szTempDir, NULL))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2007-07-11 08:52:55 +00:00
|
|
|
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error: %lu\n", GetLastError());
|
|
|
|
goto cleanup;
|
2007-07-11 08:52:55 +00:00
|
|
|
}
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
cleanup:
|
2007-07-11 08:52:55 +00:00
|
|
|
RegCloseKey(hKey);
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
static BOOL
|
2007-10-26 16:19:52 +00:00
|
|
|
InstallSysSetupInfDevices(VOID)
|
2004-08-03 13:43:00 +00:00
|
|
|
{
|
2007-07-11 08:52:55 +00:00
|
|
|
INFCONTEXT InfContext;
|
2011-11-19 00:24:58 +00:00
|
|
|
WCHAR szLineBuffer[256];
|
|
|
|
DWORD dwLineLength;
|
2007-07-11 08:52:55 +00:00
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupFindFirstLineW(hSysSetupInf,
|
|
|
|
L"DeviceInfsToInstall",
|
2007-07-11 08:52:55 +00:00
|
|
|
NULL,
|
|
|
|
&InfContext))
|
2004-08-28 11:08:50 +00:00
|
|
|
{
|
2007-07-11 08:52:55 +00:00
|
|
|
return FALSE;
|
2004-08-28 11:08:50 +00:00
|
|
|
}
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
do
|
2004-08-28 11:08:50 +00:00
|
|
|
{
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-07-11 08:52:55 +00:00
|
|
|
0,
|
2011-11-19 00:24:58 +00:00
|
|
|
szLineBuffer,
|
|
|
|
sizeof(szLineBuffer)/sizeof(szLineBuffer[0]),
|
|
|
|
&dwLineLength))
|
2007-07-11 08:52:55 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
if (!SetupDiInstallClassW(NULL, szLineBuffer, DI_QUIETINSTALL, NULL))
|
2007-07-11 08:52:55 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-08-28 11:08:50 +00:00
|
|
|
}
|
2007-07-11 08:52:55 +00:00
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
return TRUE;
|
2004-07-19 01:33:48 +00:00
|
|
|
}
|
2011-11-19 00:24:58 +00:00
|
|
|
|
|
|
|
static BOOL
|
2007-10-26 16:19:52 +00:00
|
|
|
InstallSysSetupInfComponents(VOID)
|
|
|
|
{
|
|
|
|
INFCONTEXT InfContext;
|
2011-11-19 00:24:58 +00:00
|
|
|
WCHAR szNameBuffer[256];
|
|
|
|
WCHAR szSectionBuffer[256];
|
2008-06-25 14:21:27 +00:00
|
|
|
HINF hComponentInf = INVALID_HANDLE_VALUE;
|
2004-07-19 01:33:48 +00:00
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupFindFirstLineW(hSysSetupInf,
|
|
|
|
L"Infs.Always",
|
2007-10-26 16:19:52 +00:00
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
|
|
|
DPRINT("No Inf.Always section found\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-26 16:19:52 +00:00
|
|
|
1, // Get the component name
|
2011-11-19 00:24:58 +00:00
|
|
|
szNameBuffer,
|
|
|
|
sizeof(szNameBuffer)/sizeof(szNameBuffer[0]),
|
2007-10-26 16:19:52 +00:00
|
|
|
NULL))
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error while trying to get component name \n");
|
2007-10-26 16:19:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupGetStringFieldW(&InfContext,
|
2007-10-26 16:19:52 +00:00
|
|
|
2, // Get the component install section
|
2011-11-19 00:24:58 +00:00
|
|
|
szSectionBuffer,
|
|
|
|
sizeof(szSectionBuffer)/sizeof(szSectionBuffer[0]),
|
2007-10-26 16:19:52 +00:00
|
|
|
NULL))
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error while trying to get component install section \n");
|
2007-10-26 16:19:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
DPRINT("Trying to execute install section '%S' from '%S' \n", szSectionBuffer, szNameBuffer);
|
2007-10-26 16:19:52 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
hComponentInf = SetupOpenInfFileW(szNameBuffer,
|
2008-06-25 14:21:27 +00:00
|
|
|
NULL,
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (hComponentInf == INVALID_HANDLE_VALUE)
|
2007-10-26 16:19:52 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("SetupOpenInfFileW() failed to open '%S' (Error: %lu)\n", szNameBuffer, GetLastError());
|
2007-10-26 16:19:52 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-06-25 14:21:27 +00:00
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!SetupInstallFromInfSectionW(NULL,
|
2008-06-25 14:21:27 +00:00
|
|
|
hComponentInf,
|
2011-11-19 00:24:58 +00:00
|
|
|
szSectionBuffer,
|
2008-06-25 14:21:27 +00:00
|
|
|
SPINST_ALL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
SP_COPY_NEWER,
|
|
|
|
SetupDefaultQueueCallbackW,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL))
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("Error while trying to install : %S (Error: %lu)\n", szNameBuffer, GetLastError());
|
2008-06-25 14:21:27 +00:00
|
|
|
SetupCloseInfFile(hComponentInf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetupCloseInfFile(hComponentInf);
|
2007-10-26 16:19:52 +00:00
|
|
|
}
|
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-07-19 01:33:48 +00:00
|
|
|
|
2013-05-17 21:40:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
RegisterTypeLibraries (HINF hinf, LPCWSTR szSection)
|
|
|
|
{
|
|
|
|
INFCONTEXT InfContext;
|
|
|
|
BOOL res;
|
|
|
|
WCHAR szName[MAX_PATH];
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
INT csidl;
|
|
|
|
LPWSTR p;
|
|
|
|
HMODULE hmod;
|
|
|
|
HRESULT hret;
|
|
|
|
|
|
|
|
/* Begin iterating the entries in the inf section */
|
|
|
|
res = SetupFindFirstLine(hinf, szSection, NULL, &InfContext);
|
|
|
|
if (!res) return FALSE;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* Get the name of the current type library */
|
|
|
|
if (!SetupGetStringFieldW(&InfContext, 1, szName, MAX_PATH, NULL))
|
|
|
|
{
|
|
|
|
FatalError("SetupGetStringFieldW failed\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!SetupGetIntField(&InfContext, 2, &csidl))
|
|
|
|
csidl = CSIDL_SYSTEM;
|
|
|
|
|
|
|
|
hret = SHGetFolderPathW(NULL, csidl, NULL, 0, szPath);
|
|
|
|
if (FAILED(hret))
|
|
|
|
{
|
|
|
|
FatalError("SHGetSpecialFolderPathW failed hret=0x%d\n", hret);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = PathAddBackslash(szPath);
|
|
|
|
_tcscpy(p, szName);
|
|
|
|
|
|
|
|
hmod = LoadLibraryW(szName);
|
|
|
|
if (hmod == NULL)
|
|
|
|
{
|
|
|
|
FatalError("LoadLibraryW failed\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
__wine_register_resources(hmod);
|
|
|
|
|
|
|
|
}while (SetupFindNextLine(&InfContext, &InfContext));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-17 12:49:37 +00:00
|
|
|
static BOOL
|
|
|
|
EnableUserModePnpManager(VOID)
|
|
|
|
{
|
2007-07-11 08:52:55 +00:00
|
|
|
SC_HANDLE hSCManager = NULL;
|
|
|
|
SC_HANDLE hService = NULL;
|
2011-11-19 00:24:58 +00:00
|
|
|
BOOL bRet = FALSE;
|
2005-11-17 12:49:37 +00:00
|
|
|
|
2011-02-05 16:00:11 +00:00
|
|
|
hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
|
2007-07-11 08:52:55 +00:00
|
|
|
if (hSCManager == NULL)
|
2011-02-05 16:00:11 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Unable to open the service control manager.\n");
|
2011-03-13 21:55:49 +00:00
|
|
|
DPRINT1("Last Error %d\n", GetLastError());
|
2007-07-11 08:52:55 +00:00
|
|
|
goto cleanup;
|
2011-02-05 16:00:11 +00:00
|
|
|
}
|
2005-11-17 12:49:37 +00:00
|
|
|
|
2010-02-19 20:03:11 +00:00
|
|
|
hService = OpenServiceW(hSCManager,
|
|
|
|
L"PlugPlay",
|
2010-02-20 23:10:53 +00:00
|
|
|
SERVICE_CHANGE_CONFIG | SERVICE_START);
|
2007-07-11 08:52:55 +00:00
|
|
|
if (hService == NULL)
|
2011-02-05 16:00:11 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Unable to open PlugPlay service\n");
|
2007-07-11 08:52:55 +00:00
|
|
|
goto cleanup;
|
2011-02-05 16:00:11 +00:00
|
|
|
}
|
2005-11-17 12:49:37 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
bRet = ChangeServiceConfigW(hService,
|
2010-02-19 20:03:11 +00:00
|
|
|
SERVICE_NO_CHANGE,
|
|
|
|
SERVICE_AUTO_START,
|
|
|
|
SERVICE_NO_CHANGE,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL);
|
2011-11-19 00:24:58 +00:00
|
|
|
if (!bRet)
|
2011-02-05 16:00:11 +00:00
|
|
|
{
|
|
|
|
DPRINT1("Unable to change the service configuration\n");
|
2007-07-11 08:52:55 +00:00
|
|
|
goto cleanup;
|
2011-02-05 16:00:11 +00:00
|
|
|
}
|
2005-11-17 12:49:37 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
bRet = StartServiceW(hService, 0, NULL);
|
|
|
|
if (!bRet && (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING))
|
2011-02-05 16:00:11 +00:00
|
|
|
{
|
2011-02-27 19:09:45 +00:00
|
|
|
DPRINT1("Unable to start service\n");
|
2007-07-11 08:52:55 +00:00
|
|
|
goto cleanup;
|
2011-02-05 16:00:11 +00:00
|
|
|
}
|
2005-11-17 12:49:37 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
bRet = TRUE;
|
2005-11-17 12:49:37 +00:00
|
|
|
|
|
|
|
cleanup:
|
2007-07-11 08:52:55 +00:00
|
|
|
if (hService != NULL)
|
|
|
|
CloseServiceHandle(hService);
|
2013-03-13 20:40:43 +00:00
|
|
|
if (hSCManager != NULL)
|
|
|
|
CloseServiceHandle(hSCManager);
|
2011-11-19 00:24:58 +00:00
|
|
|
return bRet;
|
2005-11-17 12:49:37 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 01:06:20 +00:00
|
|
|
static INT_PTR CALLBACK
|
2007-07-11 11:51:42 +00:00
|
|
|
StatusMessageWindowProc(
|
|
|
|
IN HWND hwndDlg,
|
|
|
|
IN UINT uMsg,
|
|
|
|
IN WPARAM wParam,
|
|
|
|
IN LPARAM lParam)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2008-12-11 11:24:32 +00:00
|
|
|
WCHAR szMsg[256];
|
2007-07-11 11:51:42 +00:00
|
|
|
|
2008-12-11 11:24:32 +00:00
|
|
|
if (!LoadStringW(hDllInstance, IDS_STATUS_INSTALL_DEV, szMsg, sizeof(szMsg)/sizeof(szMsg[0])))
|
2007-07-11 11:51:42 +00:00
|
|
|
return FALSE;
|
2008-12-11 11:24:32 +00:00
|
|
|
SetDlgItemTextW(hwndDlg, IDC_STATUSLABEL, szMsg);
|
2007-07-11 11:51:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
ShowStatusMessageThread(
|
|
|
|
IN LPVOID lpParameter)
|
|
|
|
{
|
|
|
|
HWND *phWnd = (HWND *)lpParameter;
|
|
|
|
HWND hWnd;
|
|
|
|
MSG Msg;
|
|
|
|
|
|
|
|
hWnd = CreateDialogParam(
|
|
|
|
hDllInstance,
|
|
|
|
MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG),
|
|
|
|
GetDesktopWindow(),
|
|
|
|
StatusMessageWindowProc,
|
|
|
|
(LPARAM)NULL);
|
|
|
|
if (!hWnd)
|
|
|
|
return 0;
|
|
|
|
*phWnd = hWnd;
|
|
|
|
|
|
|
|
ShowWindow(hWnd, SW_SHOW);
|
|
|
|
|
|
|
|
/* Message loop for the Status window */
|
|
|
|
while (GetMessage(&Msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&Msg);
|
|
|
|
DispatchMessage(&Msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-10-29 12:54:47 +00:00
|
|
|
static LONG
|
|
|
|
ReadRegSzKey(
|
|
|
|
IN HKEY hKey,
|
|
|
|
IN LPCWSTR pszKey,
|
|
|
|
OUT LPWSTR* pValue)
|
|
|
|
{
|
|
|
|
LONG rc;
|
|
|
|
DWORD dwType;
|
|
|
|
DWORD cbData = 0;
|
2011-11-19 00:24:58 +00:00
|
|
|
LPWSTR pwszValue;
|
2007-10-29 12:54:47 +00:00
|
|
|
|
|
|
|
if (!pValue)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
*pValue = NULL;
|
|
|
|
rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
if (dwType != REG_SZ)
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
2011-11-19 00:24:58 +00:00
|
|
|
pwszValue = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
|
|
|
|
if (!pwszValue)
|
2007-10-29 12:54:47 +00:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2011-11-19 00:24:58 +00:00
|
|
|
rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)pwszValue, &cbData);
|
2007-10-29 12:54:47 +00:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pwszValue);
|
2007-10-29 12:54:47 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
/* NULL-terminate the string */
|
2011-11-19 00:24:58 +00:00
|
|
|
pwszValue[cbData / sizeof(WCHAR)] = '\0';
|
2007-10-29 12:54:47 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
*pValue = pwszValue;
|
2007-10-29 12:54:47 +00:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
IsConsoleBoot(VOID)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
HKEY hControlKey = NULL;
|
|
|
|
LPWSTR pwszSystemStartOptions = NULL;
|
|
|
|
LPWSTR pwszCurrentOption, pwszNextOption; /* Pointers into SystemStartOptions */
|
|
|
|
BOOL bConsoleBoot = FALSE;
|
2007-10-29 12:54:47 +00:00
|
|
|
LONG rc;
|
|
|
|
|
|
|
|
rc = RegOpenKeyExW(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
L"SYSTEM\\CurrentControlSet\\Control",
|
|
|
|
0,
|
|
|
|
KEY_QUERY_VALUE,
|
2011-11-19 00:24:58 +00:00
|
|
|
&hControlKey);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto cleanup;
|
2007-10-29 12:54:47 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
rc = ReadRegSzKey(hControlKey, L"SystemStartOptions", &pwszSystemStartOptions);
|
2007-10-29 12:54:47 +00:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto cleanup;
|
|
|
|
|
2012-11-23 20:05:35 +00:00
|
|
|
/* Check for CONSOLE switch in SystemStartOptions */
|
2011-11-19 00:24:58 +00:00
|
|
|
pwszCurrentOption = pwszSystemStartOptions;
|
|
|
|
while (pwszCurrentOption)
|
2007-10-29 12:54:47 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
pwszNextOption = wcschr(pwszCurrentOption, L' ');
|
|
|
|
if (pwszNextOption)
|
|
|
|
*pwszNextOption = L'\0';
|
|
|
|
if (wcsicmp(pwszCurrentOption, L"CONSOLE") == 0)
|
2007-10-29 12:54:47 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
DPRINT("Found %S. Switching to console boot\n", pwszCurrentOption);
|
|
|
|
bConsoleBoot = TRUE;
|
2007-10-29 12:54:47 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2011-11-19 00:24:58 +00:00
|
|
|
pwszCurrentOption = pwszNextOption ? pwszNextOption + 1 : NULL;
|
2007-10-29 12:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
2011-11-19 00:24:58 +00:00
|
|
|
if (hControlKey != NULL)
|
|
|
|
RegCloseKey(hControlKey);
|
|
|
|
if (pwszSystemStartOptions)
|
|
|
|
HeapFree(GetProcessHeap(), 0, pwszSystemStartOptions);
|
|
|
|
return bConsoleBoot;
|
2007-10-29 12:54:47 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
static BOOL
|
|
|
|
CommonInstall(VOID)
|
2006-07-12 11:30:17 +00:00
|
|
|
{
|
2007-07-11 11:51:42 +00:00
|
|
|
HWND hWnd = NULL;
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
hSysSetupInf = SetupOpenInfFileW(
|
|
|
|
L"syssetup.inf",
|
|
|
|
NULL,
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
NULL);
|
|
|
|
if (hSysSetupInf == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
|
2007-07-11 09:55:53 +00:00
|
|
|
return FALSE;
|
2007-07-11 08:52:55 +00:00
|
|
|
}
|
2006-07-12 11:54:04 +00:00
|
|
|
|
2007-10-26 16:19:52 +00:00
|
|
|
if (!InstallSysSetupInfDevices())
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("InstallSysSetupInfDevices() failed!\n");
|
|
|
|
goto error;
|
2007-10-26 16:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!InstallSysSetupInfComponents())
|
2007-07-11 08:52:55 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("InstallSysSetupInfComponents() failed!\n");
|
|
|
|
goto error;
|
2007-07-11 08:52:55 +00:00
|
|
|
}
|
2006-07-12 11:54:04 +00:00
|
|
|
|
2007-10-29 12:54:47 +00:00
|
|
|
if (!IsConsoleBoot())
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
HANDLE hThread;
|
|
|
|
|
|
|
|
hThread = CreateThread(
|
2007-10-29 12:54:47 +00:00
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
ShowStatusMessageThread,
|
|
|
|
(LPVOID)&hWnd,
|
|
|
|
0,
|
|
|
|
NULL);
|
2011-11-19 00:24:58 +00:00
|
|
|
|
|
|
|
if (hThread)
|
|
|
|
CloseHandle(hThread);
|
2007-10-29 12:54:47 +00:00
|
|
|
}
|
2007-07-11 11:51:42 +00:00
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
if (!EnableUserModePnpManager())
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("EnableUserModePnpManager() failed!\n");
|
|
|
|
goto error;
|
2007-07-11 08:52:55 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
if (CMP_WaitNoPendingInstallEvents(INFINITE) != WAIT_OBJECT_0)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("CMP_WaitNoPendingInstallEvents() failed!\n");
|
|
|
|
goto error;
|
2007-07-11 09:55:53 +00:00
|
|
|
}
|
|
|
|
|
2007-07-11 11:51:42 +00:00
|
|
|
EndDialog(hWnd, 0);
|
2007-07-11 09:55:53 +00:00
|
|
|
return TRUE;
|
2011-11-19 00:24:58 +00:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (hWnd)
|
|
|
|
EndDialog(hWnd, 0);
|
|
|
|
SetupCloseInfFile(hSysSetupInf);
|
|
|
|
return FALSE;
|
2007-07-11 09:55:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD WINAPI
|
|
|
|
InstallLiveCD(IN HINSTANCE hInstance)
|
|
|
|
{
|
2008-12-11 11:24:32 +00:00
|
|
|
STARTUPINFOW StartupInfo;
|
2007-07-11 09:55:53 +00:00
|
|
|
PROCESS_INFORMATION ProcessInformation;
|
2011-11-19 00:24:58 +00:00
|
|
|
BOOL bRes;
|
2007-07-11 09:55:53 +00:00
|
|
|
|
|
|
|
if (!CommonInstall())
|
2011-11-19 00:24:58 +00:00
|
|
|
goto error;
|
2011-11-28 09:53:01 +00:00
|
|
|
|
|
|
|
/* Register components */
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
if (!SetupInstallFromInfSectionW(NULL,
|
|
|
|
hSysSetupInf, L"RegistrationPhase2",
|
|
|
|
SPINST_ALL,
|
|
|
|
0, NULL, 0, NULL, NULL, NULL, NULL))
|
|
|
|
{
|
|
|
|
DPRINT1("SetupInstallFromInfSectionW failed!\n");
|
|
|
|
}
|
2013-05-17 21:40:46 +00:00
|
|
|
|
|
|
|
RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries");
|
2011-11-28 09:53:01 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
DPRINT1("Catching exception\n");
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
SetupCloseInfFile(hSysSetupInf);
|
2007-07-11 08:52:55 +00:00
|
|
|
|
|
|
|
/* Run the shell */
|
2012-12-23 23:17:10 +00:00
|
|
|
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
|
|
|
StartupInfo.cb = sizeof(StartupInfo);
|
2011-11-19 00:24:58 +00:00
|
|
|
bRes = CreateProcessW(
|
2008-12-11 11:24:32 +00:00
|
|
|
L"userinit.exe",
|
2007-07-11 08:52:55 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&StartupInfo,
|
|
|
|
&ProcessInformation);
|
2011-11-19 00:24:58 +00:00
|
|
|
if (!bRes)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
CloseHandle(ProcessInformation.hThread);
|
|
|
|
CloseHandle(ProcessInformation.hProcess);
|
2007-07-11 08:52:55 +00:00
|
|
|
|
2007-08-03 09:28:01 +00:00
|
|
|
return 0;
|
2006-07-12 11:30:17 +00:00
|
|
|
|
2011-11-19 00:24:58 +00:00
|
|
|
error:
|
2008-12-11 11:24:32 +00:00
|
|
|
MessageBoxW(
|
2007-07-11 08:52:55 +00:00
|
|
|
NULL,
|
2011-11-15 08:59:50 +00:00
|
|
|
L"Failed to load LiveCD! You can shutdown your computer, or press ENTER to reboot.",
|
2008-12-11 11:24:32 +00:00
|
|
|
L"ReactOS LiveCD",
|
2007-07-11 08:52:55 +00:00
|
|
|
MB_OK);
|
|
|
|
return 0;
|
2006-07-12 11:30:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-06 14:41:05 +00:00
|
|
|
static BOOL
|
|
|
|
SetSetupType(DWORD dwSetupType)
|
|
|
|
{
|
|
|
|
DWORD dwError;
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
dwError = RegOpenKeyExW(
|
|
|
|
HKEY_LOCAL_MACHINE,
|
|
|
|
L"SYSTEM\\Setup",
|
|
|
|
0,
|
|
|
|
KEY_SET_VALUE,
|
|
|
|
&hKey);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
dwError = RegSetValueExW(
|
|
|
|
hKey,
|
|
|
|
L"SetupType",
|
|
|
|
0,
|
|
|
|
REG_DWORD,
|
|
|
|
(LPBYTE)&dwSetupType,
|
|
|
|
sizeof(DWORD));
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
if (dwError != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
DWORD WINAPI
|
|
|
|
InstallReactOS(HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
TCHAR szBuffer[MAX_PATH];
|
2013-05-17 21:44:27 +00:00
|
|
|
HANDLE token;
|
|
|
|
TOKEN_PRIVILEGES privs;
|
2010-06-15 19:31:19 +00:00
|
|
|
HKEY hKey;
|
2013-05-29 20:33:11 +00:00
|
|
|
HINF hShortcutsInf;
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
InitializeSetupActionLog(FALSE);
|
|
|
|
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
|
2007-07-11 08:52:55 +00:00
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
if (!InitializeProfiles())
|
2007-04-14 01:09:38 +00:00
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("InitializeProfiles() failed");
|
2007-07-11 09:55:53 +00:00
|
|
|
return 0;
|
2007-04-14 01:09:38 +00:00
|
|
|
}
|
2005-10-20 23:08:44 +00:00
|
|
|
|
2009-02-04 14:28:27 +00:00
|
|
|
CreateTempDir(L"TEMP");
|
|
|
|
CreateTempDir(L"TMP");
|
|
|
|
|
|
|
|
if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
|
|
|
|
{
|
2010-06-15 19:31:19 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
|
|
|
|
0,
|
|
|
|
KEY_WRITE,
|
|
|
|
&hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegSetValueExW(hKey,
|
|
|
|
L"PathName",
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(LPBYTE)szBuffer,
|
|
|
|
(wcslen(szBuffer) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegSetValueExW(hKey,
|
|
|
|
L"SystemRoot",
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(LPBYTE)szBuffer,
|
|
|
|
(wcslen(szBuffer) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2009-02-04 14:28:27 +00:00
|
|
|
PathAddBackslash(szBuffer);
|
|
|
|
_tcscat(szBuffer, _T("system"));
|
|
|
|
CreateDirectory(szBuffer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CommonInstall())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
InstallWizard();
|
|
|
|
|
2012-05-17 21:30:30 +00:00
|
|
|
InstallSecurity();
|
|
|
|
|
2014-01-18 14:26:07 +00:00
|
|
|
SetAutoAdminLogon();
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
hShortcutsInf = SetupOpenInfFileW(L"shortcuts.inf",
|
|
|
|
NULL,
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
NULL);
|
|
|
|
if (hShortcutsInf == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
FatalError("Failed to open shortcuts.inf");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders"))
|
2011-12-20 18:55:09 +00:00
|
|
|
{
|
|
|
|
FatalError("CreateShortcuts() failed");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-29 20:33:11 +00:00
|
|
|
SetupCloseInfFile(hShortcutsInf);
|
|
|
|
|
2007-08-08 13:44:03 +00:00
|
|
|
/* ROS HACK, as long as NtUnloadKey is not implemented */
|
|
|
|
{
|
2013-05-17 21:44:27 +00:00
|
|
|
NTSTATUS Status = NtUnloadKey(NULL);
|
2007-08-08 13:44:03 +00:00
|
|
|
if (Status == STATUS_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
/* Create the Administrator profile */
|
|
|
|
PROFILEINFOW ProfileInfo;
|
|
|
|
HANDLE hToken;
|
|
|
|
BOOL ret;
|
2011-11-15 08:59:50 +00:00
|
|
|
|
2014-01-18 14:26:07 +00:00
|
|
|
ret = LogonUserW(AdminInfo.Name,
|
|
|
|
AdminInfo.Domain,
|
|
|
|
AdminInfo.Password,
|
|
|
|
LOGON32_LOGON_INTERACTIVE,
|
|
|
|
LOGON32_PROVIDER_DEFAULT,
|
|
|
|
&hToken);
|
2007-08-08 13:44:03 +00:00
|
|
|
if (!ret)
|
|
|
|
{
|
2011-11-19 00:24:58 +00:00
|
|
|
FatalError("LogonUserW() failed!");
|
2007-08-08 13:44:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW));
|
|
|
|
ProfileInfo.dwSize = sizeof(PROFILEINFOW);
|
|
|
|
ProfileInfo.lpUserName = L"Administrator";
|
|
|
|
ProfileInfo.dwFlags = PI_NOUI;
|
|
|
|
LoadUserProfileW(hToken, &ProfileInfo);
|
|
|
|
CloseHandle(hToken);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DPRINT1("ROS HACK not needed anymore. Please remove it\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* END OF ROS HACK */
|
|
|
|
|
2007-07-11 08:52:55 +00:00
|
|
|
SetupCloseInfFile(hSysSetupInf);
|
2007-08-06 14:41:05 +00:00
|
|
|
SetSetupType(0);
|
2004-08-28 11:08:50 +00:00
|
|
|
|
2007-07-11 09:55:53 +00:00
|
|
|
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
|
|
|
|
TerminateSetupActionLog();
|
|
|
|
|
2014-01-18 14:26:07 +00:00
|
|
|
if (AdminInfo.Name != NULL)
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Name);
|
|
|
|
|
|
|
|
if (AdminInfo.Domain != NULL)
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Domain);
|
|
|
|
|
|
|
|
if (AdminInfo.Password != NULL)
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Password);
|
|
|
|
|
2013-05-17 21:44:27 +00:00
|
|
|
/* Get shutdown privilege */
|
|
|
|
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
|
|
|
|
{
|
2013-05-29 20:33:11 +00:00
|
|
|
FatalError("OpenProcessToken() failed!");
|
2013-05-17 21:44:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!LookupPrivilegeValue(
|
|
|
|
NULL,
|
|
|
|
SE_SHUTDOWN_NAME,
|
|
|
|
&privs.Privileges[0].Luid))
|
|
|
|
{
|
|
|
|
FatalError("LookupPrivilegeValue() failed!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
privs.PrivilegeCount = 1;
|
|
|
|
privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
|
|
|
if (AdjustTokenPrivileges(
|
|
|
|
token,
|
|
|
|
FALSE,
|
|
|
|
&privs,
|
|
|
|
0,
|
|
|
|
(PTOKEN_PRIVILEGES)NULL,
|
|
|
|
NULL) == 0)
|
|
|
|
{
|
|
|
|
FatalError("AdjustTokenPrivileges() failed!");
|
|
|
|
return 0;
|
|
|
|
}
|
2007-08-06 11:57:15 +00:00
|
|
|
|
2007-08-03 09:28:01 +00:00
|
|
|
ExitWindowsEx(EWX_REBOOT, 0);
|
2007-07-11 08:52:55 +00:00
|
|
|
return 0;
|
2003-05-02 18:12:38 +00:00
|
|
|
}
|
|
|
|
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2003-09-08 09:56:57 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
DWORD WINAPI
|
2007-07-11 09:55:53 +00:00
|
|
|
SetupChangeFontSize(
|
|
|
|
IN HANDLE hWnd,
|
|
|
|
IN LPCWSTR lpszFontSize)
|
2003-09-08 09:56:57 +00:00
|
|
|
{
|
2007-07-11 09:55:53 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
2007-07-11 08:52:55 +00:00
|
|
|
return FALSE;
|
2003-09-08 09:56:57 +00:00
|
|
|
}
|
2009-02-07 18:33:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
DWORD WINAPI
|
|
|
|
SetupChangeLocaleEx(HWND hWnd,
|
|
|
|
LCID Lcid,
|
|
|
|
LPCWSTR lpSrcRootPath,
|
|
|
|
char Unknown,
|
|
|
|
DWORD dwUnused1,
|
|
|
|
DWORD dwUnused2)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
DWORD WINAPI
|
|
|
|
SetupChangeLocale(HWND hWnd, LCID Lcid)
|
|
|
|
{
|
|
|
|
return SetupChangeLocaleEx(hWnd, Lcid, NULL, 0, 0, 0);
|
|
|
|
}
|