From 604e593d4d58004e44cef0c18abcf0d5703ed080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 12 Jul 2006 11:30:17 +0000 Subject: [PATCH] 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 --- reactos/base/setup/setup/setup.c | 31 +++++++++ reactos/boot/bootdata/livecd.inf | 5 +- reactos/dll/win32/syssetup/install.c | 91 +++++++++++++++++++++++++ reactos/dll/win32/syssetup/syssetup.def | 1 + 4 files changed, 124 insertions(+), 4 deletions(-) diff --git a/reactos/base/setup/setup/setup.c b/reactos/base/setup/setup/setup.c index cf788916990..87fce5d202a 100644 --- a/reactos/base/setup/setup/setup.c +++ b/reactos/base/setup/setup/setup.c @@ -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 */ diff --git a/reactos/boot/bootdata/livecd.inf b/reactos/boot/bootdata/livecd.inf index 767582a9aae..63eadfc5d90 100644 --- a/reactos/boot/bootdata/livecd.inf +++ b/reactos/boot/bootdata/livecd.inf @@ -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 diff --git a/reactos/dll/win32/syssetup/install.c b/reactos/dll/win32/syssetup/install.c index 42c0ea3c895..991a9c1ae82 100644 --- a/reactos/dll/win32/syssetup/install.c +++ b/reactos/dll/win32/syssetup/install.c @@ -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) { diff --git a/reactos/dll/win32/syssetup/syssetup.def b/reactos/dll/win32/syssetup/syssetup.def index 6de54b74e9d..7bb773198ec 100644 --- a/reactos/dll/win32/syssetup/syssetup.def +++ b/reactos/dll/win32/syssetup/syssetup.def @@ -4,6 +4,7 @@ EXPORTS ;DevInstallW ;GenerateScsiHwIdList InitializeSetupActionLog@4 +InstallLiveCD@4 InstallReactOS@4 KeyboardClassInstaller@12 LogItem@8