branch update for HEAD-2003050101
[reactos.git] / subsys / system / winlogon / winlogon.c
index 2b3da97..3ab16dc 100644 (file)
 #include <windows.h>
 #include <stdio.h>
 #include <lsass/ntsecapi.h>
-
 #include <wchar.h>
 
-#define DBG
+#include "setup.h"
+
+#define NDEBUG
 #include <debug.h>
 
 /* GLOBALS ******************************************************************/
@@ -243,7 +244,7 @@ static PCHAR GetShell(PCHAR CommandLine)
    if (! GotCommandLine)
      {
        GetSystemDirectory(CommandLine, MAX_PATH - 10);
-       strcat(CommandLine, "\\shell.exe");
+       strcat(CommandLine, "\\cmd.exe");
      }
 
    return CommandLine;
@@ -381,15 +382,30 @@ WinMain(HINSTANCE hInstance,
      {
        DbgPrint("WL: Cannot switch to Winlogon desktop (0x%X)\n", GetLastError());
      }
-   
+
    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
@@ -420,50 +436,49 @@ WinMain(HINSTANCE hInstance,
     */
    
    /* Main loop */
-   for (;;)
-     {
 #if 0
-       /* Display login prompt */
-       WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
-                    LoginPrompt,
-                    strlen(LoginPrompt),  // wcslen(LoginPrompt),
-                    &Result,
-                    NULL);
-       i = 0;
-       do
-         {
-           ReadConsole(GetStdHandle(STD_INPUT_HANDLE),
-                       &LoginName[i],
-                       1,
-                       &Result,
-                       NULL);
-           i++;
-         } while (LoginName[i - 1] != '\n');
-       LoginName[i - 1] = 0;
+   /* Display login prompt */
+   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
+                LoginPrompt,
+                strlen(LoginPrompt),  // wcslen(LoginPrompt),
+                &Result,
+                NULL);
+   i = 0;
+   do
+     {
+       ReadConsole(GetStdHandle(STD_INPUT_HANDLE),
+                   &LoginName[i],
+                   1,
+                   &Result,
+                   NULL);
+       i++;
+     } while (LoginName[i - 1] != '\n');
+   LoginName[i - 1] = 0;
        
-        /* Display password prompt */
-       WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
-                    PasswordPrompt,
-                    strlen(PasswordPrompt),  // wcslen(PasswordPrompt),
-                    &Result,
-                    NULL);
-       i = 0;
-       do
-         {
-           ReadConsole(GetStdHandle(STD_INPUT_HANDLE),
-                       &Password[i],
-                       1,
-                       &Result,
-                       NULL);
-           i++;
-         } while (Password[i - 1] != '\n');
-       Password[i - 1] =0;
+   /* Display password prompt */
+   WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),
+                PasswordPrompt,
+                strlen(PasswordPrompt),  // wcslen(PasswordPrompt),
+                &Result,
+                NULL);
+   i = 0;
+   do
+     {
+       ReadConsole(GetStdHandle(STD_INPUT_HANDLE),
+                   &Password[i],
+                   1,
+                   &Result,
+                   NULL);
+       i++;
+     } while (Password[i - 1] != '\n');
+   Password[i - 1] =0;
 #endif
-       if (! DoLoginUser(LoginName, Password))
-         {
-           break;
-         }
+
+   if (! DoLoginUser(LoginName, Password))
+     {
      }
+
+   NtShutdownSystem(ShutdownNoReboot);
    
    ExitProcess(0);