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.
|
|
|
|
*
|
|
|
|
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
2005-01-03 18:44:36 +00:00
|
|
|
/* $Id$
|
2003-05-02 18:12:38 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* PURPOSE: System setup
|
|
|
|
* FILE: lib/syssetup/install.c
|
2004-08-28 11:08:50 +00:00
|
|
|
* PROGRAMER: Eric Kohl
|
2003-05-02 18:12:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2005-10-19 17:03:38 +00:00
|
|
|
#define WIN32_NO_STATUS
|
2003-05-02 18:12:38 +00:00
|
|
|
#include <windows.h>
|
2005-06-20 19:58:43 +00:00
|
|
|
#define NTOS_MODE_USER
|
|
|
|
#include <ndk/ntndk.h>
|
|
|
|
|
2004-03-21 14:37:19 +00:00
|
|
|
#include <commctrl.h>
|
2004-01-16 21:33:23 +00:00
|
|
|
#include <stdio.h>
|
2005-10-20 22:11:33 +00:00
|
|
|
#include <io.h>
|
2004-07-19 01:33:48 +00:00
|
|
|
#include <tchar.h>
|
|
|
|
#include <stdlib.h>
|
2003-05-02 18:12:38 +00:00
|
|
|
|
2005-07-01 03:40:52 +00:00
|
|
|
#include <samlib/samlib.h>
|
2005-07-20 03:42:05 +00:00
|
|
|
#include <syssetup/syssetup.h>
|
2004-04-19 10:54:23 +00:00
|
|
|
#include <userenv.h>
|
2004-08-28 11:08:50 +00:00
|
|
|
#include <setupapi.h>
|
2003-05-02 18:12:38 +00:00
|
|
|
|
2004-12-28 14:41:46 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
#include <objidl.h>
|
|
|
|
#include <shlwapi.h>
|
|
|
|
|
2004-04-16 13:37:18 +00:00
|
|
|
#include "globals.h"
|
2004-03-21 14:37:19 +00:00
|
|
|
#include "resource.h"
|
|
|
|
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
|
|
|
PSID DomainSid = NULL;
|
|
|
|
PSID AdminSid = NULL;
|
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2003-05-02 18:12:38 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
void
|
|
|
|
DebugPrint(char* fmt,...)
|
|
|
|
{
|
2004-01-23 16:51:41 +00:00
|
|
|
char buffer[512];
|
2004-01-16 21:33:23 +00:00
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(buffer, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
2004-08-03 13:43:00 +00:00
|
|
|
strcat(buffer, "\nRebooting now!");
|
|
|
|
MessageBoxA(NULL,
|
|
|
|
buffer,
|
|
|
|
"ReactOS Setup",
|
|
|
|
MB_OK);
|
2004-01-16 21:33:23 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 10:54:23 +00:00
|
|
|
|
2005-01-03 18:44:36 +00:00
|
|
|
HRESULT CreateShellLink(LPCTSTR linkPath, LPCTSTR cmd, LPCTSTR arg, LPCTSTR dir, LPCTSTR iconPath, int icon_nr, LPCTSTR comment)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2005-01-03 18:44:36 +00:00
|
|
|
IShellLink* psl;
|
2004-12-28 14:41:46 +00:00
|
|
|
IPersistFile* ppf;
|
2005-01-03 18:44:36 +00:00
|
|
|
#ifndef _UNICODE
|
2004-12-28 14:41:46 +00:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2005-01-03 18:44:36 +00:00
|
|
|
#endif /* _UNICODE */
|
2004-12-28 14:41:46 +00:00
|
|
|
|
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = psl->lpVtbl->SetPath(psl, cmd);
|
|
|
|
|
|
|
|
if (arg)
|
|
|
|
{
|
|
|
|
hr = psl->lpVtbl->SetArguments(psl, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
hr = psl->lpVtbl->SetWorkingDirectory(psl, dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iconPath)
|
|
|
|
{
|
|
|
|
hr = psl->lpVtbl->SetIconLocation(psl, iconPath, icon_nr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (comment)
|
|
|
|
{
|
|
|
|
hr = psl->lpVtbl->SetDescription(psl, comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2005-01-03 18:44:36 +00:00
|
|
|
#ifdef _UNICODE
|
|
|
|
hr = ppf->lpVtbl->Save(ppf, linkPath, TRUE);
|
|
|
|
#else /* _UNICODE */
|
2004-12-28 14:41:46 +00:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, linkPath, -1, buffer, MAX_PATH);
|
|
|
|
|
|
|
|
hr = ppf->lpVtbl->Save(ppf, buffer, TRUE);
|
2005-01-03 18:44:36 +00:00
|
|
|
#endif /* _UNICODE */
|
2004-12-28 14:41:46 +00:00
|
|
|
|
|
|
|
ppf->lpVtbl->Release(ppf);
|
|
|
|
}
|
|
|
|
|
|
|
|
psl->lpVtbl->Release(psl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
static BOOL
|
|
|
|
CreateShortcut(int csidl, LPCTSTR folder, LPCTSTR linkName, LPCTSTR command, UINT nIdTitle)
|
|
|
|
{
|
|
|
|
TCHAR path[MAX_PATH];
|
|
|
|
TCHAR title[256];
|
|
|
|
LPTSTR p = path;
|
|
|
|
|
|
|
|
if (!SHGetSpecialFolderPath(0, path, csidl, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (folder)
|
|
|
|
{
|
|
|
|
p = PathAddBackslash(p);
|
|
|
|
_tcscpy(p, folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = PathAddBackslash(p);
|
|
|
|
_tcscpy(p, linkName);
|
|
|
|
|
|
|
|
if (!LoadString(hDllInstance, nIdTitle, title, 256))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return SUCCEEDED(CreateShellLink(path, command, _T(""), NULL, NULL, 0, title));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
CreateShortcutFolder(int csidl, UINT nID, LPTSTR name, int nameLen)
|
2004-12-28 14:41:46 +00:00
|
|
|
{
|
2005-01-03 18:44:36 +00:00
|
|
|
TCHAR path[MAX_PATH];
|
|
|
|
LPTSTR p;
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
if (!SHGetSpecialFolderPath(0, path, csidl, TRUE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!LoadString(hDllInstance, nID, name, nameLen))
|
|
|
|
return FALSE;
|
|
|
|
|
2005-01-03 18:44:36 +00:00
|
|
|
p = PathAddBackslash(path);
|
2005-10-17 11:03:30 +00:00
|
|
|
_tcscpy(p, name);
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
return CreateDirectory(path, NULL) || GetLastError()==ERROR_ALREADY_EXISTS;
|
2004-12-28 14:41:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
static VOID
|
|
|
|
CreateRandomSid (PSID *Sid)
|
|
|
|
{
|
|
|
|
SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
|
|
|
|
LARGE_INTEGER SystemTime;
|
|
|
|
PULONG Seed;
|
|
|
|
|
|
|
|
NtQuerySystemTime (&SystemTime);
|
|
|
|
Seed = &SystemTime.u.LowPart;
|
|
|
|
|
|
|
|
RtlAllocateAndInitializeSid (&SystemAuthority,
|
|
|
|
4,
|
|
|
|
SECURITY_NT_NON_UNIQUE_RID,
|
|
|
|
RtlUniform (Seed),
|
|
|
|
RtlUniform (Seed),
|
|
|
|
RtlUniform (Seed),
|
|
|
|
SECURITY_NULL_RID,
|
|
|
|
SECURITY_NULL_RID,
|
|
|
|
SECURITY_NULL_RID,
|
|
|
|
SECURITY_NULL_RID,
|
|
|
|
Sid);
|
|
|
|
}
|
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
static VOID
|
|
|
|
AppendRidToSid (PSID *Dst,
|
|
|
|
PSID Src,
|
|
|
|
ULONG NewRid)
|
|
|
|
{
|
|
|
|
ULONG Rid[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
|
|
|
UCHAR RidCount;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
RidCount = *RtlSubAuthorityCountSid (Src);
|
|
|
|
|
|
|
|
for (i = 0; i < RidCount; i++)
|
|
|
|
Rid[i] = *RtlSubAuthoritySid (Src, i);
|
|
|
|
|
|
|
|
if (RidCount < 8)
|
|
|
|
{
|
|
|
|
Rid[RidCount] = NewRid;
|
|
|
|
RidCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
RtlAllocateAndInitializeSid (RtlIdentifierAuthoritySid (Src),
|
|
|
|
RidCount,
|
|
|
|
Rid[0],
|
|
|
|
Rid[1],
|
|
|
|
Rid[2],
|
|
|
|
Rid[3],
|
|
|
|
Rid[4],
|
|
|
|
Rid[5],
|
|
|
|
Rid[6],
|
|
|
|
Rid[7],
|
|
|
|
Dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-24 09:17:33 +00:00
|
|
|
static VOID
|
|
|
|
CreateTempDir(LPCWSTR VarName)
|
|
|
|
{
|
2004-11-24 23:09:46 +00:00
|
|
|
TCHAR szTempDir[MAX_PATH];
|
|
|
|
TCHAR szBuffer[MAX_PATH];
|
2004-06-24 09:17:33 +00:00
|
|
|
DWORD dwLength;
|
|
|
|
HKEY hKey;
|
|
|
|
|
2004-11-24 23:09:46 +00:00
|
|
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
|
|
|
_T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"),
|
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&hKey))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
|
|
|
DebugPrint("Error: %lu\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get temp dir */
|
2004-11-24 23:09:46 +00:00
|
|
|
dwLength = MAX_PATH * sizeof(TCHAR);
|
|
|
|
if (RegQueryValueEx(hKey,
|
|
|
|
VarName,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(LPBYTE)szBuffer,
|
|
|
|
&dwLength))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
|
|
|
DebugPrint("Error: %lu\n", GetLastError());
|
2004-11-24 23:09:46 +00:00
|
|
|
RegCloseKey(hKey);
|
2004-06-24 09:17:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Expand it */
|
2004-11-24 23:09:46 +00:00
|
|
|
if (!ExpandEnvironmentStrings(szBuffer,
|
|
|
|
szTempDir,
|
|
|
|
MAX_PATH))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
|
|
|
DebugPrint("Error: %lu\n", GetLastError());
|
2004-11-24 23:09:46 +00:00
|
|
|
RegCloseKey(hKey);
|
2004-06-24 09:17:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create profiles directory */
|
2004-11-24 23:09:46 +00:00
|
|
|
if (!CreateDirectory(szTempDir, NULL))
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
2004-11-24 23:09:46 +00:00
|
|
|
if (GetLastError() != ERROR_ALREADY_EXISTS)
|
2004-06-24 09:17:33 +00:00
|
|
|
{
|
|
|
|
DebugPrint("Error: %lu\n", GetLastError());
|
2004-11-24 23:09:46 +00:00
|
|
|
RegCloseKey(hKey);
|
2004-06-24 09:17:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-24 23:09:46 +00:00
|
|
|
RegCloseKey(hKey);
|
2004-06-24 09:17:33 +00:00
|
|
|
}
|
|
|
|
|
2004-07-19 01:33:48 +00:00
|
|
|
|
2004-08-03 13:43:00 +00:00
|
|
|
BOOL
|
|
|
|
ProcessSysSetupInf(VOID)
|
|
|
|
{
|
2004-08-28 11:08:50 +00:00
|
|
|
INFCONTEXT InfContext;
|
|
|
|
TCHAR LineBuffer[256];
|
|
|
|
DWORD LineLength;
|
|
|
|
|
|
|
|
if (!SetupFindFirstLine(hSysSetupInf,
|
|
|
|
_T("DeviceInfsToInstall"),
|
|
|
|
NULL,
|
|
|
|
&InfContext))
|
|
|
|
{
|
2004-08-03 13:43:00 +00:00
|
|
|
return FALSE;
|
2004-08-28 11:08:50 +00:00
|
|
|
}
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
do
|
2004-08-03 13:43:00 +00:00
|
|
|
{
|
2004-08-28 11:08:50 +00:00
|
|
|
if (!SetupGetStringField(&InfContext,
|
|
|
|
0,
|
|
|
|
LineBuffer,
|
|
|
|
256,
|
|
|
|
&LineLength))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
if (!SetupDiInstallClass(NULL, LineBuffer, DI_QUIETINSTALL, NULL))
|
|
|
|
{
|
2004-08-03 13:43:00 +00:00
|
|
|
return FALSE;
|
2004-08-28 11:08:50 +00:00
|
|
|
}
|
2004-08-03 13:43:00 +00:00
|
|
|
}
|
2004-08-28 11:08:50 +00:00
|
|
|
while (SetupFindNextLine(&InfContext, &InfContext));
|
2004-08-03 13:43:00 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2004-07-19 01:33:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-02 18:12:38 +00:00
|
|
|
DWORD STDCALL
|
|
|
|
InstallReactOS (HINSTANCE hInstance)
|
|
|
|
{
|
2005-10-17 11:03:30 +00:00
|
|
|
TCHAR sAccessories[256];
|
2005-10-20 21:11:56 +00:00
|
|
|
TCHAR sGames[256];
|
2005-10-23 11:55:49 +00:00
|
|
|
TCHAR Sys[MAX_PATH];
|
2005-10-23 14:39:51 +00:00
|
|
|
TCHAR GamePath[MAX_PATH];
|
2005-10-20 23:08:44 +00:00
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
|
2004-01-09 20:05:04 +00:00
|
|
|
# if 0
|
2003-08-07 04:03:25 +00:00
|
|
|
OutputDebugStringA ("InstallReactOS() called\n");
|
2003-05-02 18:12:38 +00:00
|
|
|
|
|
|
|
if (!InitializeSetupActionLog (FALSE))
|
|
|
|
{
|
2003-08-07 04:03:25 +00:00
|
|
|
OutputDebugStringA ("InitializeSetupActionLog() failed\n");
|
2003-05-02 18:12:38 +00:00
|
|
|
}
|
|
|
|
|
2004-01-14 22:15:09 +00:00
|
|
|
LogItem (SYSSETUP_SEVERITY_INFORMATION,
|
2003-05-02 18:12:38 +00:00
|
|
|
L"ReactOS Setup starting");
|
|
|
|
|
2004-01-14 22:15:09 +00:00
|
|
|
LogItem (SYSSETUP_SEVERITY_FATAL_ERROR,
|
2003-05-02 18:12:38 +00:00
|
|
|
L"Buuuuuuaaaah!");
|
|
|
|
|
2004-01-14 22:15:09 +00:00
|
|
|
LogItem (SYSSETUP_SEVERITY_INFORMATION,
|
2003-05-02 18:12:38 +00:00
|
|
|
L"ReactOS Setup finished");
|
|
|
|
|
|
|
|
TerminateSetupActionLog ();
|
2004-01-09 20:05:04 +00:00
|
|
|
#endif
|
2004-01-16 21:33:23 +00:00
|
|
|
#if 0
|
|
|
|
UNICODE_STRING SidString;
|
|
|
|
#endif
|
2004-11-09 15:02:35 +00:00
|
|
|
ULONG LastError;
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2004-01-16 21:33:23 +00:00
|
|
|
if (!InitializeProfiles ())
|
|
|
|
{
|
2004-01-23 10:35:52 +00:00
|
|
|
DebugPrint ("InitializeProfiles() failed\n");
|
2004-01-16 21:33:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-01-09 20:05:04 +00:00
|
|
|
|
2005-10-05 16:47:19 +00:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
/* create desktop shortcuts */
|
|
|
|
CreateShortcut(CSIDL_DESKTOP, NULL, _T("Command Prompt.lnk"), _T("cmd.exe"), IDS_CMT_CMD);
|
|
|
|
|
2005-10-18 21:41:45 +00:00
|
|
|
/* create program startmenu shortcuts */
|
2005-10-17 11:03:30 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, NULL, _T("winefile.lnk"), _T("winefile.exe"), IDS_CMT_WINEFILE);
|
2005-10-05 16:47:19 +00:00
|
|
|
|
2005-10-17 11:03:30 +00:00
|
|
|
/* create and fill Accessories subfolder */
|
|
|
|
if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_ACCESSORIES, sAccessories, 256)) {
|
2005-10-23 15:06:20 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Calculator.lnk"), _T("calc.exe"), IDS_CMT_CALC);
|
2005-10-18 21:41:45 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Command Prompt.lnk"), _T("cmd.exe"), IDS_CMT_CMD);
|
2005-10-23 15:06:20 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Notepad.lnk"), _T("notepad.exe"), IDS_CMT_NOTEPAD);
|
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("ReactOS Explorer.lnk"), _T("explorer.exe"), IDS_CMT_EXPLORER);
|
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Regedit.lnk"), _T("regedit.exe"), IDS_CMT_REGEDIT);
|
2005-10-17 11:03:30 +00:00
|
|
|
}
|
2005-10-20 23:08:44 +00:00
|
|
|
|
|
|
|
|
2005-10-20 22:11:33 +00:00
|
|
|
/* create Games subfolder and fill if the exe is available */
|
|
|
|
if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_GAMES, sGames, 256)) {
|
2005-10-23 11:55:49 +00:00
|
|
|
if(GetSystemDirectory(Sys, MAX_PATH)) {
|
2005-10-23 14:39:51 +00:00
|
|
|
/* copy system dir */
|
|
|
|
_tcscpy(GamePath, Sys);
|
|
|
|
/* concatonate full file path and check for existance */
|
|
|
|
if((_taccess(_tcscat(GamePath, _T("\\sol.exe")), 0 )) != -1)
|
2005-10-20 23:08:44 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sGames, _T("Solitaire.lnk"), _T("sol.exe"), IDS_CMT_SOLITAIRE);
|
2005-10-23 14:39:51 +00:00
|
|
|
|
|
|
|
_tcscpy(GamePath, Sys);
|
|
|
|
if((_taccess(_tcscat(GamePath, _T("\\winemine.exe")), 0 )) != -1)
|
2005-10-23 15:06:20 +00:00
|
|
|
CreateShortcut(CSIDL_PROGRAMS, sGames, _T("WineMine.lnk"), _T("winemine.exe"), IDS_CMT_WINEMINE);
|
2005-10-20 23:08:44 +00:00
|
|
|
}
|
2005-10-20 22:11:33 +00:00
|
|
|
}
|
2005-10-05 16:47:19 +00:00
|
|
|
|
|
|
|
CoUninitialize();
|
2004-12-28 14:41:46 +00:00
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Create the semi-random Domain-SID */
|
2004-01-16 21:33:23 +00:00
|
|
|
CreateRandomSid (&DomainSid);
|
|
|
|
if (DomainSid == NULL)
|
2004-01-09 20:05:04 +00:00
|
|
|
{
|
2004-01-23 10:35:52 +00:00
|
|
|
DebugPrint ("Domain-SID creation failed!\n");
|
2004-01-16 21:33:23 +00:00
|
|
|
return 0;
|
2004-01-09 20:05:04 +00:00
|
|
|
}
|
2004-01-16 21:33:23 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
RtlConvertSidToUnicodeString (&SidString, DomainSid, TRUE);
|
|
|
|
DebugPrint ("Domain-SID: %wZ\n", &SidString);
|
|
|
|
RtlFreeUnicodeString (&SidString);
|
|
|
|
#endif
|
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Initialize the Security Account Manager (SAM) */
|
|
|
|
if (!SamInitializeSAM ())
|
2004-01-09 20:05:04 +00:00
|
|
|
{
|
2004-01-23 10:35:52 +00:00
|
|
|
DebugPrint ("SamInitializeSAM() failed!\n");
|
|
|
|
RtlFreeSid (DomainSid);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-01-16 21:33:23 +00:00
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Set the Domain SID (aka Computer SID) */
|
|
|
|
if (!SamSetDomainSid (DomainSid))
|
|
|
|
{
|
|
|
|
DebugPrint ("SamSetDomainSid() failed!\n");
|
2004-01-16 21:33:23 +00:00
|
|
|
RtlFreeSid (DomainSid);
|
|
|
|
return 0;
|
2004-01-09 20:05:04 +00:00
|
|
|
}
|
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Append the Admin-RID */
|
2004-08-28 11:08:50 +00:00
|
|
|
AppendRidToSid(&AdminSid, DomainSid, DOMAIN_USER_RID_ADMIN);
|
2004-01-16 21:33:23 +00:00
|
|
|
|
|
|
|
#if 0
|
2004-01-23 10:35:52 +00:00
|
|
|
RtlConvertSidToUnicodeString (&SidString, DomainSid, TRUE);
|
|
|
|
DebugPrint ("Admin-SID: %wZ\n", &SidString);
|
2004-01-16 21:33:23 +00:00
|
|
|
RtlFreeUnicodeString (&SidString);
|
|
|
|
#endif
|
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Create the Administrator account */
|
2004-08-28 11:08:50 +00:00
|
|
|
if (!SamCreateUser(L"Administrator", L"", AdminSid))
|
|
|
|
{
|
2004-11-09 15:02:35 +00:00
|
|
|
/* Check what the error was.
|
|
|
|
* If the Admin Account already exists, then it means Setup
|
|
|
|
* wasn't allowed to finish properly. Instead of rebooting
|
|
|
|
* and not completing it, let it restart instead
|
|
|
|
*/
|
|
|
|
LastError = GetLastError();
|
2004-12-28 14:41:46 +00:00
|
|
|
if (LastError != ERROR_USER_EXISTS)
|
|
|
|
{
|
2004-11-09 15:02:35 +00:00
|
|
|
DebugPrint("SamCreateUser() failed!\n");
|
|
|
|
RtlFreeSid(AdminSid);
|
|
|
|
RtlFreeSid(DomainSid);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-28 11:08:50 +00:00
|
|
|
}
|
2004-01-16 21:33:23 +00:00
|
|
|
|
2004-01-23 10:35:52 +00:00
|
|
|
/* Create the Administrator profile */
|
2004-08-28 11:08:50 +00:00
|
|
|
if (!CreateUserProfileW(AdminSid, L"Administrator"))
|
|
|
|
{
|
|
|
|
DebugPrint("CreateUserProfileW() failed!\n");
|
|
|
|
RtlFreeSid(AdminSid);
|
|
|
|
RtlFreeSid(DomainSid);
|
|
|
|
return 0;
|
|
|
|
}
|
2004-01-16 21:33:23 +00:00
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
RtlFreeSid(AdminSid);
|
|
|
|
RtlFreeSid(DomainSid);
|
2004-01-16 21:33:23 +00:00
|
|
|
|
2004-06-24 09:17:33 +00:00
|
|
|
CreateTempDir(L"TEMP");
|
|
|
|
CreateTempDir(L"TMP");
|
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
hSysSetupInf = SetupOpenInfFileW(L"syssetup.inf",
|
|
|
|
NULL,
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
NULL);
|
|
|
|
if (hSysSetupInf == INVALID_HANDLE_VALUE)
|
2004-07-19 01:33:48 +00:00
|
|
|
{
|
2004-08-28 11:08:50 +00:00
|
|
|
DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ProcessSysSetupInf())
|
|
|
|
{
|
|
|
|
DebugPrint("ProcessSysSetupInf() failed!\n");
|
|
|
|
return 0;
|
2004-07-19 01:33:48 +00:00
|
|
|
}
|
2004-08-03 13:43:00 +00:00
|
|
|
|
|
|
|
InstallWizard();
|
2003-05-02 18:12:38 +00:00
|
|
|
|
2004-08-28 11:08:50 +00:00
|
|
|
SetupCloseInfFile(hSysSetupInf);
|
|
|
|
|
2003-05-02 18:12:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-03 13:43:00 +00:00
|
|
|
|
2003-09-08 09:56:57 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
2004-08-03 13:43:00 +00:00
|
|
|
DWORD STDCALL
|
|
|
|
SetupChangeFontSize(HANDLE hWnd,
|
|
|
|
LPCWSTR lpszFontSize)
|
2003-09-08 09:56:57 +00:00
|
|
|
{
|
2004-08-03 13:43:00 +00:00
|
|
|
return FALSE;
|
2003-09-08 09:56:57 +00:00
|
|
|
}
|