diff --git a/reactos/subsys/system/winlogon/makefile b/reactos/subsys/system/winlogon/makefile index 92ee92c619f..18a5051edc4 100644 --- a/reactos/subsys/system/winlogon/makefile +++ b/reactos/subsys/system/winlogon/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.5 2001/08/21 20:13:05 chorns Exp $ +# $Id: makefile,v 1.6 2003/03/25 19:26:32 ekohl Exp $ PATH_TO_TOP = ../../.. @@ -12,7 +12,7 @@ TARGET_INSTALLDIR = system32 TARGET_SDKLIBS = ntdll.a kernel32.a user32.a -TARGET_OBJECTS = $(TARGET_NAME).o +TARGET_OBJECTS = $(TARGET_NAME).o setup.o include $(PATH_TO_TOP)/rules.mak diff --git a/reactos/subsys/system/winlogon/setup.c b/reactos/subsys/system/winlogon/setup.c new file mode 100644 index 00000000000..6a32bfbb861 --- /dev/null +++ b/reactos/subsys/system/winlogon/setup.c @@ -0,0 +1,195 @@ +/* + * ReactOS kernel + * Copyright (C) 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: setup.c,v 1.1 2003/03/25 19:26:33 ekohl Exp $ + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS winlogon + * FILE: subsys/system/winlogon/setup.h + * PURPOSE: Setup support functions + * PROGRAMMER: Eric Kohl + */ + +/* INCLUDES *****************************************************************/ + +#include +#include +#include +#include + +#include "setup.h" + +#define NDEBUG +#include + + +/* FUNCTIONS ****************************************************************/ + +DWORD +GetSetupType(VOID) +{ + DWORD dwError; + HANDLE hKey; + DWORD dwType; + DWORD dwSize; + DWORD dwSetupType; + + dwError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), + 0, + KEY_QUERY_VALUE, + &hKey); + if (dwError != ERROR_SUCCESS) + { + return 0; + } + + dwSize = sizeof(DWORD); + dwError = RegQueryValueEx (hKey, + "SetupType", //TEXT("SetupType"), + NULL, + &dwType, + (LPBYTE)&dwSetupType, + &dwSize); + RegCloseKey (hKey); + if (dwError != ERROR_SUCCESS || dwType != REG_DWORD) + { + return 0; + } + + return dwSetupType; +} + + +BOOL +SetSetupType (DWORD dwSetupType) +{ + DWORD dwError; + HANDLE hKey; + + dwError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SYSTEM\\Setup", //TEXT("SYSTEM\\Setup"), + 0, + KEY_QUERY_VALUE, + &hKey); + if (dwError != ERROR_SUCCESS) + { + return FALSE; + } + + dwError = RegSetValueEx (hKey, + "SetupType", //TEXT("SetupType"), + 0, + REG_DWORD, + (LPBYTE)&dwSetupType, + sizeof(DWORD)); + RegCloseKey (hKey); + if (dwError != ERROR_SUCCESS) + { + return FALSE; + } + + return TRUE; +} + + +BOOL +RunSetup (VOID) +{ + PROCESS_INFORMATION ProcessInformation; + STARTUPINFO StartupInfo; + CHAR CommandLine[MAX_PATH]; + BOOLEAN Result; + DWORD dwError; + HANDLE hKey; + DWORD dwType; + DWORD dwSize; + DWORD dwExitCode; + + DPRINT ("RunSetup() called\n"); + + dwError = RegOpenKeyEx (HKEY_LOCAL_MACHINE, + "SYSTEM\\Setup", + 0, + KEY_QUERY_VALUE, + &hKey); + if (dwError != ERROR_SUCCESS) + { + return FALSE; + } + + dwSize = MAX_PATH; + dwError = RegQueryValueEx (hKey, + "CmdLine", + NULL, + &dwType, + (LPBYTE)CommandLine, + &dwSize); + RegCloseKey (hKey); + if (dwError != ERROR_SUCCESS || dwType != REG_SZ) + { + return FALSE; + } + + DPRINT ("Winlogon: Should run '%s' now.\n", CommandLine); + + StartupInfo.cb = sizeof(StartupInfo); + StartupInfo.lpReserved = NULL; + StartupInfo.lpDesktop = NULL; + StartupInfo.lpTitle = NULL; + StartupInfo.dwFlags = 0; + StartupInfo.cbReserved2 = 0; + StartupInfo.lpReserved2 = 0; + + DPRINT ("Winlogon: Creating new setup process\n"); + + Result = CreateProcess (NULL, + CommandLine, + NULL, + NULL, + FALSE, + DETACHED_PROCESS, + NULL, + NULL, + &StartupInfo, + &ProcessInformation); + if (!Result) + { + DPRINT ("Winlogon: Failed to run setup process\n"); + return FALSE; + } + + /* Wait for process termination */ + WaitForSingleObject (ProcessInformation.hProcess, INFINITE); + + GetExitCodeProcess (ProcessInformation.hProcess, &dwExitCode); + + CloseHandle (ProcessInformation.hThread); + CloseHandle (ProcessInformation.hProcess); + + if (dwExitCode == 0) + { + SetSetupType (0); + } + + DPRINT ("Winlogon: RunSetup() done.\n"); + + return TRUE; +} + + +/* EOF */ diff --git a/reactos/subsys/system/winlogon/setup.h b/reactos/subsys/system/winlogon/setup.h new file mode 100644 index 00000000000..fcdd2fd57d8 --- /dev/null +++ b/reactos/subsys/system/winlogon/setup.h @@ -0,0 +1,36 @@ +/* + * ReactOS kernel + * Copyright (C) 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: setup.h,v 1.1 2003/03/25 19:26:33 ekohl Exp $ + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS winlogon + * FILE: subsys/system/winlogon/setup.h + * PURPOSE: Setup support functions + * PROGRAMMER: Eric Kohl + */ + +#ifndef __SETUP_H__ +#define __SETUP_H__ + +DWORD GetSetupType (VOID); +BOOL SetSetupType (DWORD dwSetupType); +BOOL RunSetup (VOID); + +#endif /* __SETUP_H__ */ + +/* EOF */ diff --git a/reactos/subsys/system/winlogon/winlogon.c b/reactos/subsys/system/winlogon/winlogon.c index 3fa25888657..645a07581d4 100644 --- a/reactos/subsys/system/winlogon/winlogon.c +++ b/reactos/subsys/system/winlogon/winlogon.c @@ -1,4 +1,4 @@ -/* $Id: winlogon.c,v 1.17 2003/03/20 20:56:52 gvg Exp $ +/* $Id: winlogon.c,v 1.18 2003/03/25 19:26:33 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -15,9 +15,10 @@ #include #include #include - #include +#include "setup.h" + #define NDEBUG #include @@ -384,12 +385,27 @@ WinMain(HINSTANCE hInstance, AllocConsole(); SetConsoleTitle( "Winlogon" ); + + /* Check for pending setup */ + if (GetSetupType () != 0) + { + DPRINT ("Winlogon: CheckForSetup() in setup mode\n"); + + /* Run setup and reboot when done */ + RunSetup (); + +// NtShutdownSystem (ShutdownReboot); + NtShutdownSystem (ShutdownNoReboot); + ExitProcess (0); + return 0; + } + /* start system processes (services.exe & lsass.exe) */ if (StartProcess("StartServices")) { if (!StartServices()) { - DbgPrint("WL: Failed to Start Services (0x%X)\n", GetLastError()); + DbgPrint("WL: Failed to start Services (0x%X)\n", GetLastError()); } } #if 0 @@ -397,7 +413,7 @@ WinMain(HINSTANCE hInstance, { if (!StartLsass()) { - DbgPrint("WL: Failed to Start Security System (0x%X)\n", GetLastError()); + DbgPrint("WL: Failed to start LSASS (0x%X)\n", GetLastError()); } } #endif @@ -408,7 +424,7 @@ WinMain(HINSTANCE hInstance, Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode); if (!NT_SUCCESS(Status)) { - DbgPrint("WL: Failed to connect to lsass\n"); + DbgPrint("WL: Failed to connect to LSASS\n"); return(1); } #endif