#include "precomp.h"
+#include <rpcproxy.h>
+
#define NDEBUG
#include <debug.h>
/* GLOBALS ******************************************************************/
-PSID DomainSid = NULL;
-PSID AdminSid = NULL;
-
HINF hSysSetupInf = INVALID_HANDLE_VALUE;
+ADMIN_INFO AdminInfo;
/* FUNCTIONS ****************************************************************/
static BOOL
CreateShortcut(
- int csidl,
LPCTSTR pszFolder,
- UINT nIdName,
+ LPCTSTR pszName,
LPCTSTR pszCommand,
- UINT nIdTitle,
- BOOL bCheckExistence,
+ LPCTSTR pszDescription,
INT iIconNr)
{
TCHAR szPath[MAX_PATH];
TCHAR szExeName[MAX_PATH];
- TCHAR szTitle[256];
- TCHAR szName[256];
- LPTSTR Ptr = szPath;
+ LPTSTR Ptr;
TCHAR szWorkingDirBuf[MAX_PATH];
LPTSTR pszWorkingDir = NULL;
LPTSTR lpFilePart;
_tcscpy(szPath, pszCommand);
}
- if (bCheckExistence)
- {
- if ((_taccess(szPath, 0 )) == -1)
- /* Expected error, don't return FALSE */
- return TRUE;
- }
+ if ((_taccess(szPath, 0 )) == -1)
+ /* Expected error, don't return FALSE */
+ return TRUE;
dwLen = GetFullPathName(szPath,
sizeof(szWorkingDirBuf) / sizeof(szWorkingDirBuf[0]),
pszWorkingDir = szWorkingDirBuf;
}
+ _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;
- if (!SHGetSpecialFolderPath(0, szPath, csidl, TRUE))
+ if (!SetupFindFirstLine(hinf, pszSection, NULL, &Context))
return FALSE;
- if (pszFolder)
+ do
{
- Ptr = PathAddBackslash(Ptr);
- _tcscpy(Ptr, pszFolder);
- }
+ if (SetupGetFieldCount(&Context) < 4)
+ continue;
- Ptr = PathAddBackslash(Ptr);
+ if (!SetupGetStringFieldW(&Context, 1, szCommand, MAX_PATH, NULL))
+ continue;
- if (!LoadString(hDllInstance, nIdName, szName, sizeof(szName)/sizeof(szName[0])))
- return FALSE;
- _tcscpy(Ptr, szName);
+ if (!SetupGetStringFieldW(&Context, 2, szName, MAX_PATH, NULL))
+ continue;
- if (!LoadString(hDllInstance, nIdTitle, szTitle, sizeof(szTitle)/sizeof(szTitle[0])))
- return FALSE;
+ if (!SetupGetStringFieldW(&Context, 3, szDescription, MAX_PATH, NULL))
+ continue;
- // FIXME: we should pass 'command' straight in here, but shell32 doesn't expand it
- return SUCCEEDED(CreateShellLink(szPath, szExeName, _T(""), pszWorkingDir, szExeName, iIconNr, szTitle));
+ if (!SetupGetIntField(&Context, 4, &iIconNr))
+ continue;
+
+ _tcscat(szName, L".lnk");
+
+ CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr);
+
+ }while (SetupFindNextLine(&Context, &Context));
+
+ return TRUE;
}
-static BOOL
-CreateShortcutFolder(int csidl, UINT nID, LPTSTR pszName, int cchNameLen)
+static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection)
{
- TCHAR szPath[MAX_PATH];
- LPTSTR p;
+ INFCONTEXT Context;
+ WCHAR szPath[MAX_PATH];
+ WCHAR szFolder[MAX_PATH];
+ WCHAR szFolderSection[MAX_PATH];
+ INT csidl;
+ LPWSTR p;
- if (!SHGetSpecialFolderPath(0, szPath, csidl, TRUE))
- return FALSE;
+ CoInitialize(NULL);
- if (!LoadString(hDllInstance, nID, pszName, cchNameLen))
+ if (!SetupFindFirstLine(hinf, szSection, NULL, &Context))
return FALSE;
- p = PathAddBackslash(szPath);
- _tcscpy(p, pszName);
+ do
+ {
+ if (SetupGetFieldCount(&Context) < 2)
+ continue;
- return CreateDirectory(szPath, NULL) || GetLastError()==ERROR_ALREADY_EXISTS;
-}
+ if (!SetupGetStringFieldW(&Context, 0, szFolderSection, MAX_PATH, NULL))
+ continue;
-static BOOL
-CreateRandomSid(
- OUT PSID *Sid)
-{
- SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
- LARGE_INTEGER SystemTime;
- PULONG Seed;
- NTSTATUS Status;
-
- NtQuerySystemTime(&SystemTime);
- Seed = &SystemTime.u.LowPart;
-
- Status = RtlAllocateAndInitializeSid(
- &SystemAuthority,
- 4,
- SECURITY_NT_NON_UNIQUE,
- RtlUniform(Seed),
- RtlUniform(Seed),
- RtlUniform(Seed),
- SECURITY_NULL_RID,
- SECURITY_NULL_RID,
- SECURITY_NULL_RID,
- SECURITY_NULL_RID,
- Sid);
- return NT_SUCCESS(Status);
-}
+ if (!SetupGetIntField(&Context, 1, &csidl))
+ continue;
-static VOID
-AppendRidToSid(
- OUT PSID *Dst,
- IN PSID Src,
- IN ULONG NewRid)
-{
- ULONG Rid[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- UCHAR RidCount;
- ULONG i;
+ if (!SetupGetStringFieldW(&Context, 2, szFolder, MAX_PATH, NULL))
+ continue;
- RidCount = *RtlSubAuthorityCountSid (Src);
+ if (!SHGetSpecialFolderPathW(0, szPath, csidl, TRUE))
+ continue;
- for (i = 0; i < RidCount; i++)
- Rid[i] = *RtlSubAuthoritySid (Src, i);
+ p = PathAddBackslash(szPath);
+ _tcscpy(p, szFolder);
- if (RidCount < 8)
- {
- Rid[RidCount] = NewRid;
- RidCount++;
- }
+ if (!CreateDirectory(szPath, NULL))
+ {
+ if (GetLastError() != ERROR_ALREADY_EXISTS)
+ {
+ continue;
+ }
+ }
+
+ CreateShortcutsFromSection(hinf, szFolderSection, szPath);
+
+ }while (SetupFindNextLine(&Context, &Context));
+
+ CoUninitialize();
- RtlAllocateAndInitializeSid(
- RtlIdentifierAuthoritySid(Src),
- RidCount,
- Rid[0],
- Rid[1],
- Rid[2],
- Rid[3],
- Rid[4],
- Rid[5],
- Rid[6],
- Rid[7],
- Dst);
+ return TRUE;
}
static VOID
return TRUE;
}
+
+
+
+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;
+}
+
static BOOL
EnableUserModePnpManager(VOID)
{
bRet = TRUE;
cleanup:
- if (hSCManager != NULL)
- CloseServiceHandle(hSCManager);
if (hService != NULL)
CloseServiceHandle(hService);
+ if (hSCManager != NULL)
+ CloseServiceHandle(hSCManager);
return bRet;
}
if (rc != ERROR_SUCCESS)
goto cleanup;
- /* Check for CMDCONS in SystemStartOptions */
+ /* Check for CONSOLE switch in SystemStartOptions */
pwszCurrentOption = pwszSystemStartOptions;
while (pwszCurrentOption)
{
{
DPRINT1("SetupInstallFromInfSectionW failed!\n");
}
+
+ RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries");
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetupCloseInfFile(hSysSetupInf);
/* Run the shell */
- StartupInfo.cb = sizeof(STARTUPINFOW);
- StartupInfo.lpReserved = NULL;
- StartupInfo.lpDesktop = NULL;
- StartupInfo.lpTitle = NULL;
- StartupInfo.dwFlags = 0;
- StartupInfo.cbReserved2 = 0;
- StartupInfo.lpReserved2 = 0;
+ ZeroMemory(&StartupInfo, sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(StartupInfo);
bRes = CreateProcessW(
L"userinit.exe",
NULL,
}
-static BOOL
-CreateShortcuts(VOID)
-{
- TCHAR szFolder[256];
-
- CoInitialize(NULL);
-
- /* Create desktop shortcuts */
- CreateShortcut(CSIDL_DESKTOP, NULL, IDS_SHORT_CMD, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD, TRUE, 0);
-
- /* Create program startmenu shortcuts */
- CreateShortcut(CSIDL_PROGRAMS, NULL, IDS_SHORT_EXPLORER, _T("%SystemRoot%\\explorer.exe"), IDS_CMT_EXPLORER, TRUE, 1);
- CreateShortcut(CSIDL_PROGRAMS, NULL, IDS_SHORT_DOWNLOADER, _T("%SystemRoot%\\system32\\rapps.exe"), IDS_CMT_DOWNLOADER, TRUE, 0);
-
- /* Create administrative tools startmenu shortcuts */
- CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_SERVICE, _T("%SystemRoot%\\system32\\servman.exe"), IDS_CMT_SERVMAN, TRUE, 0);
- CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_DEVICE, _T("%SystemRoot%\\system32\\devmgmt.exe"), IDS_CMT_DEVMGMT, TRUE, 0);
- CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_EVENTVIEW, _T("%SystemRoot%\\system32\\eventvwr.exe"), IDS_CMT_EVENTVIEW, TRUE, 0);
- CreateShortcut(CSIDL_COMMON_ADMINTOOLS, NULL, IDS_SHORT_MSCONFIG, _T("%SystemRoot%\\system32\\msconfig.exe"), IDS_CMT_MSCONFIG, TRUE, 0);
-
- /* Create and fill Accessories subfolder */
- if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_ACCESSORIES, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
- {
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CALC, _T("%SystemRoot%\\system32\\calc.exe"), IDS_CMT_CALC, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CMD, _T("%SystemRoot%\\system32\\cmd.exe"), IDS_CMT_CMD, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_NOTEPAD, _T("%SystemRoot%\\system32\\notepad.exe"), IDS_CMT_NOTEPAD, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_RDESKTOP, _T("%SystemRoot%\\system32\\mstsc.exe"), IDS_CMT_RDESKTOP, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNAP, _T("%SystemRoot%\\system32\\screenshot.exe"), IDS_CMT_SCREENSHOT, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_WORDPAD, _T("%SystemRoot%\\system32\\wordpad.exe"), IDS_CMT_WORDPAD, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_PAINT, _T("%SystemRoot%\\system32\\mspaint.exe"), IDS_CMT_PAINT, TRUE, 0);
- }
-
- /* Create System Tools subfolder and fill if the exe is available */
- if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_TOOLS, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
- {
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_CHARMAP, _T("%SystemRoot%\\system32\\charmap.exe"), IDS_CMT_CHARMAP, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_KBSWITCH, _T("%SystemRoot%\\system32\\kbswitch.exe"), IDS_CMT_KBSWITCH, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_REGEDIT, _T("%SystemRoot%\\regedit.exe"), IDS_CMT_REGEDIT, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_DXDIAG, _T("%SystemRoot%\\system32\\dxdiag.exe"), IDS_CMT_DXDIAG, TRUE, 0);
- }
-
- /* Create Accessibility subfolder and fill if the exe is available */
- if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_ACCESSIBILITY, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
- {
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_MAGNIFY, _T("%SystemRoot%\\system32\\magnify.exe"), IDS_CMT_MAGNIFY, TRUE, 0);
- }
-
- /* Create Entertainment subfolder and fill if the exe is available */
- if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_SYS_ENTERTAINMENT, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
- {
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_MPLAY32, _T("%SystemRoot%\\system32\\mplay32.exe"), IDS_CMT_MPLAY32, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNDVOL32, _T("%SystemRoot%\\system32\\sndvol32.exe"), IDS_CMT_SNDVOL32, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SNDREC32, _T("%SystemRoot%\\system32\\sndrec32.exe"), IDS_CMT_SNDREC32, TRUE, 0);
- }
-
- /* Create Games subfolder and fill if the exe is available */
- if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_GAMES, szFolder, sizeof(szFolder)/sizeof(szFolder[0])))
- {
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SOLITAIRE, _T("%SystemRoot%\\system32\\sol.exe"), IDS_CMT_SOLITAIRE, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_WINEMINE, _T("%SystemRoot%\\system32\\winmine.exe"), IDS_CMT_WINEMINE, TRUE, 0);
- CreateShortcut(CSIDL_PROGRAMS, szFolder, IDS_SHORT_SPIDER, _T("%SystemRoot%\\system32\\spider.exe"), IDS_CMT_SPIDER, TRUE, 0);
- }
-
- CoUninitialize();
-
- return TRUE;
-}
-
static BOOL
SetSetupType(DWORD dwSetupType)
{
InstallReactOS(HINSTANCE hInstance)
{
TCHAR szBuffer[MAX_PATH];
- DWORD LastError;
HANDLE token;
TOKEN_PRIVILEGES privs;
HKEY hKey;
+ HINF hShortcutsInf;
InitializeSetupActionLog(FALSE);
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
return 0;
}
- /* Initialize the Security Account Manager (SAM) */
- if (!SamInitializeSAM())
- {
- FatalError("SamInitializeSAM() failed!");
- return 0;
- }
-
- /* Create the semi-random Domain-SID */
- if (!CreateRandomSid(&DomainSid))
- {
- FatalError("Domain-SID creation failed!");
- return 0;
- }
-
- /* Set the Domain SID (aka Computer SID) */
- if (SetAccountDomain(NULL, DomainSid) != STATUS_SUCCESS)
- {
- FatalError("SetAccountDomain() failed!");
- RtlFreeSid(DomainSid);
- return 0;
- }
-
- /* Append the Admin-RID */
- AppendRidToSid(&AdminSid, DomainSid, DOMAIN_USER_RID_ADMIN);
-
CreateTempDir(L"TEMP");
CreateTempDir(L"TMP");
InstallSecurity();
- /* Create the Administrator account */
- if (!SamCreateUser(L"Administrator", L"", AdminSid))
+ SetAutoAdminLogon();
+
+ hShortcutsInf = SetupOpenInfFileW(L"shortcuts.inf",
+ NULL,
+ INF_STYLE_WIN4,
+ NULL);
+ if (hShortcutsInf == INVALID_HANDLE_VALUE)
{
- /* 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();
- if (LastError != ERROR_USER_EXISTS)
- {
- FatalError("SamCreateUser() failed!");
- RtlFreeSid(AdminSid);
- RtlFreeSid(DomainSid);
- return 0;
- }
+ FatalError("Failed to open shortcuts.inf");
+ return 0;
}
- RtlFreeSid(AdminSid);
- RtlFreeSid(DomainSid);
-
- if (!CreateShortcuts())
+ if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders"))
{
FatalError("CreateShortcuts() failed");
return 0;
}
+ SetupCloseInfFile(hShortcutsInf);
+
/* ROS HACK, as long as NtUnloadKey is not implemented */
{
NTSTATUS Status = NtUnloadKey(NULL);
HANDLE hToken;
BOOL ret;
- ret = LogonUserW(L"Administrator", L"", L"", LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &hToken);
+ ret = LogonUserW(AdminInfo.Name,
+ AdminInfo.Domain,
+ AdminInfo.Password,
+ LOGON32_LOGON_INTERACTIVE,
+ LOGON32_PROVIDER_DEFAULT,
+ &hToken);
if (!ret)
{
FatalError("LogonUserW() failed!");
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
TerminateSetupActionLog();
+ 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);
+
/* Get shutdown privilege */
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
{