[ros-diffs] [hpoussin] 23016: 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.

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Wed Jul 12 13:30:18 CEST 2006


Author: hpoussin
Date: Wed Jul 12 15:30:17 2006
New Revision: 23016

URL: http://svn.reactos.org/svn/reactos?rev=23016&view=rev
Log:
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.

Modified:
    trunk/reactos/base/setup/setup/setup.c
    trunk/reactos/boot/bootdata/livecd.inf
    trunk/reactos/dll/win32/syssetup/install.c
    trunk/reactos/dll/win32/syssetup/syssetup.def

Modified: trunk/reactos/base/setup/setup/setup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/setup/setup.c?rev=23016&r1=23015&r2=23016&view=diff
==============================================================================
--- trunk/reactos/base/setup/setup/setup.c (original)
+++ trunk/reactos/base/setup/setup/setup.c Wed Jul 12 15:30:17 2006
@@ -85,6 +85,33 @@
   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 @@
     {
       RunNewSetup (hInstance);
     }
+  else if (!lstrcmpi (p, TEXT("-mini")))
+    {
+      RunLiveCD (hInstance);
+    }
 
 #if 0
   /* Add new setup types here */

Modified: trunk/reactos/boot/bootdata/livecd.inf
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/livecd.inf?rev=23016&r1=23015&r2=23016&view=diff
==============================================================================
--- trunk/reactos/boot/bootdata/livecd.inf (original)
+++ trunk/reactos/boot/bootdata/livecd.inf Wed Jul 12 15:30:17 2006
@@ -17,10 +17,7 @@
 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

Modified: trunk/reactos/dll/win32/syssetup/install.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install.c?rev=23016&r1=23015&r2=23016&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/install.c (original)
+++ trunk/reactos/dll/win32/syssetup/install.c Wed Jul 12 15:30:17 2006
@@ -369,6 +369,97 @@
 
 
 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)
 {
   TCHAR sAccessories[256];

Modified: trunk/reactos/dll/win32/syssetup/syssetup.def
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/syssetup.def?rev=23016&r1=23015&r2=23016&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/syssetup.def (original)
+++ trunk/reactos/dll/win32/syssetup/syssetup.def Wed Jul 12 15:30:17 2006
@@ -4,6 +4,7 @@
 ;DevInstallW
 ;GenerateScsiHwIdList
 InitializeSetupActionLog at 4
+InstallLiveCD at 4
 InstallReactOS at 4
 KeyboardClassInstaller at 12
 LogItem at 8




More information about the Ros-diffs mailing list