LiveCD change: don't directly name the shell executable in SYSTEM\Setup key, but run setup.exe, which then loads syssetup.dll, which then runs the selected shell.

This is the first step to do custom operations when running the livecd.

svn path=/trunk/; revision=23016
This commit is contained in:
Hervé Poussineau 2006-07-12 11:30:17 +00:00
parent 7a738ccc46
commit 604e593d4d
4 changed files with 124 additions and 4 deletions

View file

@ -85,6 +85,33 @@ RunNewSetup (HINSTANCE hInstance)
FreeLibrary (hDll);
}
static VOID
RunLiveCD (HINSTANCE hInstance)
{
HMODULE hDll;
PINSTALL_REACTOS InstallLiveCD;
hDll = LoadLibrary (TEXT("syssetup"));
if (hDll == NULL)
{
DPRINT("Failed to load 'syssetup'!\n");
return;
}
DPRINT("Loaded 'syssetup'!\n");
InstallLiveCD = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallLiveCD");
if (InstallLiveCD == NULL)
{
DPRINT("Failed to get address for 'InstallReactOS()'!\n");
FreeLibrary (hDll);
return;
}
InstallLiveCD (hInstance);
FreeLibrary (hDll);
}
int STDCALL
WinMain (HINSTANCE hInstance,
@ -107,6 +134,10 @@ WinMain (HINSTANCE hInstance,
{
RunNewSetup (hInstance);
}
else if (!lstrcmpi (p, TEXT("-mini")))
{
RunLiveCD (hInstance);
}
#if 0
/* Add new setup types here */

View file

@ -17,10 +17,7 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Cdrom","Start",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Services\Ntfs","Start",0x00010001,0x00000004
; Shell
HKLM,"SYSTEM\Setup","CmdLine",0x00020000,"%SystemRoot%\explorer.exe"
; Serial mouse driver
HKLM,"SYSTEM\CurrentControlSet\Services\Sermouse","Start",0x00010001,0x00000001
HKLM,"SYSTEM\Setup","CmdLine",0x00020000,"setup -mini"
; User Profile List
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList",,0x00000012

View file

@ -368,6 +368,97 @@ cleanup:
}
DWORD STDCALL
InstallLiveCD (HINSTANCE hInstance)
{
LONG rc;
HKEY hKey = NULL;
DWORD dwType;
DWORD requiredSize;
LPTSTR Shell = NULL;
TCHAR CommandLine[MAX_PATH];
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
BOOL res;
/* Load the default shell */
rc = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon"), /* FIXME: should be REGSTR_PATH_WINLOGON */
0,
KEY_QUERY_VALUE,
&hKey);
if (rc != ERROR_SUCCESS)
goto cleanup;
rc = RegQueryValueEx(
hKey,
TEXT("Shell"),
NULL,
&dwType,
NULL,
&requiredSize);
if (rc != ERROR_SUCCESS)
goto cleanup;
else if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
goto cleanup;
else if (requiredSize > (MAX_PATH - 1) * sizeof(TCHAR))
goto cleanup;
Shell = HeapAlloc(GetProcessHeap(), 0, requiredSize + sizeof(TCHAR));
if (!Shell)
goto cleanup;
Shell[requiredSize / sizeof(WCHAR)] = '\0';
rc = RegQueryValueEx(
hKey,
TEXT("Shell"),
NULL,
NULL,
(LPBYTE)Shell,
&requiredSize);
if (rc != ERROR_SUCCESS)
goto cleanup;
if (dwType == REG_EXPAND_SZ)
ExpandEnvironmentStrings(Shell, CommandLine, MAX_PATH);
else if (dwType == REG_SZ)
_tcscpy(CommandLine, Shell);
/* Run the shell */
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
StartupInfo.lpTitle = NULL;
StartupInfo.dwFlags = 0;
StartupInfo.cbReserved2 = 0;
StartupInfo.lpReserved2 = 0;
res = CreateProcess(
CommandLine,
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
if (!res)
goto cleanup;
/* Wait for process termination */
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
cleanup:
if (hKey != NULL)
RegCloseKey(hKey);
HeapFree(GetProcessHeap(), 0, Shell);
MessageBoxA(
NULL,
"You can shutdown your computer, or press ENTER to reboot",
"ReactOS LiveCD",
MB_OK);
return 0;
}
DWORD STDCALL
InstallReactOS (HINSTANCE hInstance)
{

View file

@ -4,6 +4,7 @@ EXPORTS
;DevInstallW
;GenerateScsiHwIdList
InitializeSetupActionLog@4
InstallLiveCD@4
InstallReactOS@4
KeyboardClassInstaller@12
LogItem@8