#include "precomp.h"
+#include <rpcproxy.h>
+
#define NDEBUG
#include <debug.h>
/* GLOBALS ******************************************************************/
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));
+}
+
- if (!SHGetSpecialFolderPath(0, szPath, csidl, TRUE))
+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 (!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;
+
+ if (!SetupGetStringFieldW(&Context, 0, szFolderSection, MAX_PATH, NULL))
+ continue;
- return CreateDirectory(szPath, NULL) || GetLastError()==ERROR_ALREADY_EXISTS;
-}
+ if (!SetupGetIntField(&Context, 1, &csidl))
+ continue;
+
+ 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;
+}
static VOID
CreateTempDir(
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)
{
{
DPRINT1("SetupInstallFromInfSectionW failed!\n");
}
+
+ RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries");
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
-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)
{
return TRUE;
}
-
-static
-BOOL
-SetPrivilege(IN LPTSTR lpPrivilegeName,
- IN DWORD dwAttribute)
-{
- TOKEN_PRIVILEGES privs;
- HANDLE hToken = NULL;
- BOOL bResult = TRUE;
-
- if (!OpenProcessToken(GetCurrentProcess(),
- TOKEN_ADJUST_PRIVILEGES,
- &hToken))
- {
- FatalError("OpenProcessToken() failed!");
- return FALSE;
- }
-
- if (!LookupPrivilegeValue(NULL,
- lpPrivilegeName,
- &privs.Privileges[0].Luid))
- {
- FatalError("LookupPrivilegeValue() failed!");
- bResult = FALSE;
- goto done;
- }
-
- privs.PrivilegeCount = 1;
- privs.Privileges[0].Attributes = dwAttribute;
- if (AdjustTokenPrivileges(hToken,
- FALSE,
- &privs,
- 0,
- (PTOKEN_PRIVILEGES)NULL,
- NULL) == 0)
- {
- FatalError("AdjustTokenPrivileges() failed!");
- bResult = FALSE;
- }
-
-done:
- if (hToken != NULL)
- CloseHandle(hToken);
-
- return bResult;
-}
-
-
DWORD WINAPI
InstallReactOS(HINSTANCE hInstance)
{
TCHAR szBuffer[MAX_PATH];
+ HANDLE token;
+ TOKEN_PRIVILEGES privs;
HKEY hKey;
+ HINF hShortcutsInf;
InitializeSetupActionLog(FALSE);
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");
InstallSecurity();
- if (!CreateShortcuts())
+ SetAutoAdminLogon();
+
+ 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"))
{
FatalError("CreateShortcuts() failed");
return 0;
}
- SetPrivilege(SE_RESTORE_NAME, SE_PRIVILEGE_ENABLED);
+ SetupCloseInfFile(hShortcutsInf);
/* ROS HACK, as long as NtUnloadKey is not implemented */
{
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!");
}
/* END OF ROS HACK */
- SetPrivilege(SE_RESTORE_NAME, 0);
-
SetupCloseInfFile(hSysSetupInf);
SetSetupType(0);
LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
TerminateSetupActionLog();
- SetPrivilege(SE_SHUTDOWN_NAME, SE_PRIVILEGE_ENABLED);
+ 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))
+ {
+ FatalError("OpenProcessToken() failed!");
+ 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;
+ }
ExitWindowsEx(EWX_REBOOT, 0);
return 0;