Author: ekohl
Date: Sat Mar  2 20:30:36 2013
New Revision: 58406

URL: http://svn.reactos.org/svn/reactos?rev=58406&view=rev
Log:
[WINLOGON]
Formatting. No code changes.

Modified:
    trunk/reactos/base/system/winlogon/screensaver.c
    trunk/reactos/base/system/winlogon/setup.c
    trunk/reactos/base/system/winlogon/winlogon.c
    trunk/reactos/base/system/winlogon/winlogon.h

Modified: trunk/reactos/base/system/winlogon/screensaver.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/screensaver.c?rev=58406&r1=58405&r2=58406&view=diff
==============================================================================
--- trunk/reactos/base/system/winlogon/screensaver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/screensaver.c [iso-8859-1] Sat Mar  2 
20:30:36 2013
@@ -15,348 +15,362 @@
 /* FUNCTIONS ****************************************************************/
 
 #ifndef USE_GETLASTINPUTINFO
-static LRESULT CALLBACK
-KeyboardActivityProc(
-       IN INT nCode,
-       IN WPARAM wParam,
-       IN LPARAM lParam)
-{
-       InterlockedExchange((LONG*)&WLSession->LastActivity, 
((PKBDLLHOOKSTRUCT)lParam)->time);
-       return CallNextHookEx(NULL, nCode, wParam, lParam);
-}
-
-static LRESULT CALLBACK
-MouseActivityProc(
-       IN INT nCode,
-       IN WPARAM wParam,
-       IN LPARAM lParam)
-{
-       InterlockedExchange((LONG*)&WLSession->LastActivity, 
((PMSLLHOOKSTRUCT)lParam)->time);
-       return CallNextHookEx(NULL, nCode, wParam, lParam);
-}
-#endif
-
-static VOID
-LoadScreenSaverParameters(
-       OUT LPDWORD Timeout)
-{
-       BOOL Enabled;
-
-       if (!SystemParametersInfoW(SPI_GETSCREENSAVETIMEOUT, 0, Timeout, 0))
-       {
-               WARN("WL: Unable to get screen saver timeout (error %lu). 
Disabling it\n", GetLastError());
-               *Timeout = INFINITE;
-       }
-       else if (!SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &Enabled, 
0))
-       {
-               WARN("WL: Unable to check if screen saver is enabled (error 
%lu). Disabling it\n", GetLastError());
-               *Timeout = INFINITE;
-       }
-       else if (!Enabled)
-       {
-               TRACE("WL: Screen saver is disabled\n");
-               *Timeout = INFINITE;
-       }
-       else
-       {
-               TRACE("WL: Screen saver timeout: %lu seconds\n", *Timeout);
-               *Timeout *= 1000;
-       }
-}
-
-static DWORD WINAPI
-ScreenSaverThreadMain(
-       IN LPVOID lpParameter)
-{
-       PWLSESSION Session = (PWLSESSION)lpParameter;
-       HANDLE HandleArray[3];
+static
+LRESULT
+CALLBACK
+KeyboardActivityProc(IN INT nCode,
+                     IN WPARAM wParam,
+                     IN LPARAM lParam)
+{
+    InterlockedExchange((LONG*)&WLSession->LastActivity, 
((PKBDLLHOOKSTRUCT)lParam)->time);
+    return CallNextHookEx(NULL, nCode, wParam, lParam);
+}
+
+
+static
+LRESULT
+CALLBACK
+MouseActivityProc(IN INT nCode,
+                  IN WPARAM wParam,
+                  IN LPARAM lParam)
+{
+    InterlockedExchange((LONG*)&WLSession->LastActivity, 
((PMSLLHOOKSTRUCT)lParam)->time);
+    return CallNextHookEx(NULL, nCode, wParam, lParam);
+}
+#endif
+
+
+static
+VOID
+LoadScreenSaverParameters(OUT LPDWORD Timeout)
+{
+    BOOL Enabled;
+
+    if (!SystemParametersInfoW(SPI_GETSCREENSAVETIMEOUT, 0, Timeout, 0))
+    {
+        WARN("WL: Unable to get screen saver timeout (error %lu). Disabling 
it\n", GetLastError());
+        *Timeout = INFINITE;
+    }
+    else if (!SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &Enabled, 0))
+    {
+        WARN("WL: Unable to check if screen saver is enabled (error %lu). 
Disabling it\n", GetLastError());
+        *Timeout = INFINITE;
+    }
+    else if (!Enabled)
+    {
+        TRACE("WL: Screen saver is disabled\n");
+        *Timeout = INFINITE;
+    }
+    else
+    {
+        TRACE("WL: Screen saver timeout: %lu seconds\n", *Timeout);
+        *Timeout *= 1000;
+    }
+}
+
+
+static
+DWORD
+WINAPI
+ScreenSaverThreadMain(IN LPVOID lpParameter)
+{
+    PWLSESSION Session = (PWLSESSION)lpParameter;
+    HANDLE HandleArray[3];
 #ifdef USE_GETLASTINPUTINFO
-       LASTINPUTINFO lastInputInfo;
+    LASTINPUTINFO lastInputInfo;
 #else
-       DWORD LastActivity;
-#endif
-       DWORD TimeToWait;
-       DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */
-       DWORD ret;
-
-       if (!ImpersonateLoggedOnUser(Session->UserToken))
-       {
-               ERR("ImpersonateLoggedOnUser() failed with error %lu\n", 
GetLastError());
-               return 0;
-       }
-
-       Session->hUserActivity = CreateEventW(NULL, FALSE, FALSE, NULL);
-       if (!Session->hUserActivity)
-       {
-               ERR("WL: Unable to create event (error %lu)\n", GetLastError());
-               goto cleanup;
-       }
-
-       Session->hEndOfScreenSaver = CreateEventW(NULL, FALSE, FALSE, NULL);
-       if (!Session->hEndOfScreenSaver)
-       {
-               ERR("WL: Unable to create event (error %lu)\n", GetLastError());
-               goto cleanup;
-       }
-
-       HandleArray[0] = Session->hEndOfScreenSaverThread;
-       HandleArray[1] = Session->hScreenSaverParametersChanged;
-       HandleArray[2] = Session->hEndOfScreenSaver;
-
-       LoadScreenSaverParameters(&Timeout);
-
-#ifndef USE_GETLASTINPUTINFO
-       InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());
+    DWORD LastActivity;
+#endif
+    DWORD TimeToWait;
+    DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */
+    DWORD ret;
+
+    if (!ImpersonateLoggedOnUser(Session->UserToken))
+    {
+        ERR("ImpersonateLoggedOnUser() failed with error %lu\n", 
GetLastError());
+        return 0;
+    }
+
+    Session->hUserActivity = CreateEventW(NULL, FALSE, FALSE, NULL);
+    if (!Session->hUserActivity)
+    {
+        ERR("WL: Unable to create event (error %lu)\n", GetLastError());
+        goto cleanup;
+    }
+
+    Session->hEndOfScreenSaver = CreateEventW(NULL, FALSE, FALSE, NULL);
+    if (!Session->hEndOfScreenSaver)
+    {
+        ERR("WL: Unable to create event (error %lu)\n", GetLastError());
+        goto cleanup;
+    }
+
+    HandleArray[0] = Session->hEndOfScreenSaverThread;
+    HandleArray[1] = Session->hScreenSaverParametersChanged;
+    HandleArray[2] = Session->hEndOfScreenSaver;
+
+    LoadScreenSaverParameters(&Timeout);
+
+#ifndef USE_GETLASTINPUTINFO
+    InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());
 #else
-       lastInputInfo.cbSize = sizeof(LASTINPUTINFO);
-#endif
-       for (;;)
-       {
-               /* See the time of last activity and calculate a timeout */
-#ifndef USE_GETLASTINPUTINFO
-               LastActivity = 
InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);
-               TimeToWait = Timeout - (GetTickCount() - LastActivity);
+    lastInputInfo.cbSize = sizeof(LASTINPUTINFO);
+#endif
+    for (;;)
+    {
+        /* See the time of last activity and calculate a timeout */
+#ifndef USE_GETLASTINPUTINFO
+        LastActivity = 
InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);
+        TimeToWait = Timeout - (GetTickCount() - LastActivity);
 #else
-               if (GetLastInputInfo(&lastInputInfo))
-                       TimeToWait = Timeout - (GetTickCount() - 
lastInputInfo.dwTime);
-               else
-               {
-                       WARN("GetLastInputInfo() failed with error %lu\n", 
GetLastError());
-                       TimeToWait = 10; /* Try again in 10 ms */
-               }
-#endif
-               if (TimeToWait > Timeout)
-               {
-                       /* GetTickCount() got back to 0 */
-                       TimeToWait = Timeout;
-               }
-
-               /* Wait for the timeout, or the end of this thread */
-               ret = WaitForMultipleObjects(2, HandleArray, FALSE, TimeToWait);
-               if (ret == WAIT_OBJECT_0)
-                       break;
-               else if (ret == WAIT_OBJECT_0 + 1)
-                       LoadScreenSaverParameters(&Timeout);
-
-               /* Check if we didn't had recent activity */
-#ifndef USE_GETLASTINPUTINFO
-               LastActivity = 
InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);
-               if (LastActivity + Timeout > GetTickCount())
-                       continue;
+        if (GetLastInputInfo(&lastInputInfo))
+            TimeToWait = Timeout - (GetTickCount() - lastInputInfo.dwTime);
+        else
+        {
+            WARN("GetLastInputInfo() failed with error %lu\n", GetLastError());
+            TimeToWait = 10; /* Try again in 10 ms */
+        }
+#endif
+
+        if (TimeToWait > Timeout)
+        {
+            /* GetTickCount() got back to 0 */
+            TimeToWait = Timeout;
+        }
+
+        /* Wait for the timeout, or the end of this thread */
+        ret = WaitForMultipleObjects(2, HandleArray, FALSE, TimeToWait);
+        if (ret == WAIT_OBJECT_0)
+            break;
+        else if (ret == WAIT_OBJECT_0 + 1)
+            LoadScreenSaverParameters(&Timeout);
+
+        /* Check if we didn't had recent activity */
+#ifndef USE_GETLASTINPUTINFO
+        LastActivity = 
InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);
+        if (LastActivity + Timeout > GetTickCount())
+            continue;
 #else
-               if (!GetLastInputInfo(&lastInputInfo))
-               {
-                       WARN("GetLastInputInfo() failed with error %lu\n", 
GetLastError());
-                       continue;
-               }
-               if (lastInputInfo.dwTime + Timeout > GetTickCount())
-                       continue;
-#endif
-
-               /* Run screen saver */
-               PostMessageW(Session->SASWindow, WLX_WM_SAS, 
WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0);
-
-               /* Wait for the end of this thread or of the screen saver */
-               ret = WaitForMultipleObjects(3, HandleArray, FALSE, INFINITE);
-               if (ret == WAIT_OBJECT_0)
-                       break;
-               else if (ret == WAIT_OBJECT_0 + 1)
-                       LoadScreenSaverParameters(&Timeout);
-               else if (ret == WAIT_OBJECT_0 + 2)
-                       SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, FALSE, 
NULL, 0);
-       }
+        if (!GetLastInputInfo(&lastInputInfo))
+        {
+            WARN("GetLastInputInfo() failed with error %lu\n", GetLastError());
+            continue;
+        }
+
+        if (lastInputInfo.dwTime + Timeout > GetTickCount())
+            continue;
+#endif
+
+        /* Run screen saver */
+        PostMessageW(Session->SASWindow, WLX_WM_SAS, 
WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0);
+
+        /* Wait for the end of this thread or of the screen saver */
+        ret = WaitForMultipleObjects(3, HandleArray, FALSE, INFINITE);
+        if (ret == WAIT_OBJECT_0)
+            break;
+        else if (ret == WAIT_OBJECT_0 + 1)
+            LoadScreenSaverParameters(&Timeout);
+        else if (ret == WAIT_OBJECT_0 + 2)
+            SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, FALSE, NULL, 0);
+    }
 
 cleanup:
-       RevertToSelf();
-       if (Session->hUserActivity)
-               CloseHandle(Session->hUserActivity);
-       if (Session->hEndOfScreenSaver)
-               CloseHandle(Session->hEndOfScreenSaver);
-#ifndef USE_GETLASTINPUTINFO
-       if (Session->KeyboardHook)
-               UnhookWindowsHookEx(Session->KeyboardHook);
-       if (Session->MouseHook)
-               UnhookWindowsHookEx(Session->MouseHook);
-#endif
-       CloseHandle(Session->hEndOfScreenSaverThread);
-       CloseHandle(Session->hScreenSaverParametersChanged);
-       return 0;
-}
+    RevertToSelf();
+    if (Session->hUserActivity)
+        CloseHandle(Session->hUserActivity);
+
+    if (Session->hEndOfScreenSaver)
+        CloseHandle(Session->hEndOfScreenSaver);
+
+#ifndef USE_GETLASTINPUTINFO
+    if (Session->KeyboardHook)
+        UnhookWindowsHookEx(Session->KeyboardHook);
+
+    if (Session->MouseHook)
+        UnhookWindowsHookEx(Session->MouseHook);
+#endif
+
+    CloseHandle(Session->hEndOfScreenSaverThread);
+    CloseHandle(Session->hScreenSaverParametersChanged);
+    return 0;
+}
+
 
 BOOL
-InitializeScreenSaver(
-       IN OUT PWLSESSION Session)
-{
-       HANDLE ScreenSaverThread;
-
-#ifndef USE_GETLASTINPUTINFO
-       /* Register hooks to detect keyboard and mouse activity */
-       Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, 
KeyboardActivityProc, hAppInstance, 0);
-       if (!Session->KeyboardHook)
-       {
-               ERR("WL: Unable to register keyboard hook\n");
-               return FALSE;
-       }
-       Session->MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseActivityProc, 
hAppInstance, 0);
-       if (!Session->MouseHook)
-       {
-               ERR("WL: Unable to register mouse hook\n");
-               return FALSE;
-       }
-#endif
-
-       Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, 
FALSE, NULL);
-       if (!Session->hScreenSaverParametersChanged)
-       {
-               WARN("WL: Unable to create screen saver event (error %lu)\n", 
GetLastError());
-               return TRUE;
-       }
-       Session->hEndOfScreenSaverThread = CreateEventW(NULL, FALSE, FALSE, 
NULL);
-       if (!Session->hEndOfScreenSaverThread)
-       {
-               WARN("WL: Unable to create screen saver event (error %lu)\n", 
GetLastError());
-               CloseHandle(Session->hScreenSaverParametersChanged);
-               return TRUE;
-       }
-
-       ScreenSaverThread = CreateThread(
-               NULL,
-               0,
-               ScreenSaverThreadMain,
-               Session,
-               0,
-               NULL);
-       if (ScreenSaverThread)
-               CloseHandle(ScreenSaverThread);
-       else
-               ERR("WL: Unable to start screen saver thread\n");
-
-       return TRUE;
-}
+InitializeScreenSaver(IN OUT PWLSESSION Session)
+{
+    HANDLE ScreenSaverThread;
+
+#ifndef USE_GETLASTINPUTINFO
+    /* Register hooks to detect keyboard and mouse activity */
+    Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, 
KeyboardActivityProc, hAppInstance, 0);
+    if (!Session->KeyboardHook)
+    {
+        ERR("WL: Unable to register keyboard hook\n");
+        return FALSE;
+    }
+
+    Session->MouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseActivityProc, 
hAppInstance, 0);
+    if (!Session->MouseHook)
+    {
+        ERR("WL: Unable to register mouse hook\n");
+        return FALSE;
+    }
+#endif
+
+    Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, FALSE, 
NULL);
+    if (!Session->hScreenSaverParametersChanged)
+    {
+        WARN("WL: Unable to create screen saver event (error %lu)\n", 
GetLastError());
+        return TRUE;
+    }
+
+    Session->hEndOfScreenSaverThread = CreateEventW(NULL, FALSE, FALSE, NULL);
+    if (!Session->hEndOfScreenSaverThread)
+    {
+        WARN("WL: Unable to create screen saver event (error %lu)\n", 
GetLastError());
+        CloseHandle(Session->hScreenSaverParametersChanged);
+        return TRUE;
+    }
+
+    ScreenSaverThread = CreateThread(NULL,
+                                     0,
+                                     ScreenSaverThreadMain,
+                                     Session,
+                                     0,
+                                     NULL);
+    if (ScreenSaverThread)
+        CloseHandle(ScreenSaverThread);
+    else
+        ERR("WL: Unable to start screen saver thread\n");
+
+    return TRUE;
+}
+
 
 VOID
-StartScreenSaver(
-       IN PWLSESSION Session)
-{
-       HKEY hKey = NULL, hCurrentUser = NULL;
-       WCHAR szApplicationName[MAX_PATH];
-       WCHAR szCommandLine[MAX_PATH + 3];
-       DWORD bufferSize = sizeof(szApplicationName) - sizeof(WCHAR);
-       DWORD dwType;
-       STARTUPINFOW StartupInfo;
-       PROCESS_INFORMATION ProcessInformation;
-       HANDLE HandleArray[2];
-       LONG rc;
-       DWORD Status;
-       BOOL ret = FALSE;
-
-       if (!ImpersonateLoggedOnUser(Session->UserToken))
-       {
-               ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", 
GetLastError());
-               goto cleanup;
-       }
-
-       rc = RegOpenCurrentUser(
-               KEY_READ,
-               &hCurrentUser);
-       if (rc != ERROR_SUCCESS)
-       {
-               ERR("WL: RegOpenCurrentUser Error!\n");
-               goto cleanup;
-       }
-
-       rc = RegOpenKeyExW(
-               hCurrentUser,
-               L"Control Panel\\Desktop",
-               0,
-               KEY_QUERY_VALUE,
-               &hKey);
-       if (rc != ERROR_SUCCESS)
-       {
-               ERR("WL: RegOpenKeyEx Error!\n");
-               goto cleanup;
-       }
-
-       rc = RegQueryValueExW(
-               hKey,
-               L"SCRNSAVE.EXE",
-               0,
-               &dwType,
-               (LPBYTE)szApplicationName,
-               &bufferSize);
-       if (rc != ERROR_SUCCESS || dwType != REG_SZ)
-       {
-               ERR("WL: RegQueryValueEx Error!\n");
-               goto cleanup;
-       }
-
-       if (bufferSize == 0)
-       {
-               ERR("WL: Buffer size is NULL!\n");
-               goto cleanup;
-       }
-
-       szApplicationName[bufferSize / sizeof(WCHAR)] = 0; /* Terminate the 
string */
-
-       if (wcslen(szApplicationName) == 0)
-       {
-               ERR("WL: Application Name length is zero!\n");
-               goto cleanup;
-       }
-
-       wsprintfW(szCommandLine, L"%s /s", szApplicationName);
-       TRACE("WL: Executing %S\n", szCommandLine);
-
-       ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
-       ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
-       StartupInfo.cb = sizeof(STARTUPINFOW);
-       StartupInfo.dwFlags = STARTF_SCRNSAVER;
-       /* FIXME: run the screen saver on the screen saver desktop */
-       ret = CreateProcessW(
-               szApplicationName,
-               szCommandLine,
-               NULL,
-               NULL,
-               FALSE,
-               0,
-               NULL,
-               NULL,
-               &StartupInfo,
-               &ProcessInformation);
-       if (!ret)
-       {
-               ERR("WL: Unable to start %S, error %lu\n", szApplicationName, 
GetLastError());
-               goto cleanup;
-       }
-       CloseHandle(ProcessInformation.hThread);
-
-       SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0);
-
-       /* Wait the end of the process or some other activity */
-       ResetEvent(Session->hUserActivity);
-       HandleArray[0] = ProcessInformation.hProcess;
-       HandleArray[1] = Session->hUserActivity;
-       Status = WaitForMultipleObjects(2, HandleArray, FALSE, INFINITE);
-       if (Status == WAIT_OBJECT_0 + 1)
-       {
-               /* Kill the screen saver */
-               TerminateProcess(ProcessInformation.hProcess, 0);
-       }
-       SetEvent(Session->hEndOfScreenSaver);
-
-       CloseHandle(ProcessInformation.hProcess);
+StartScreenSaver(IN PWLSESSION Session)
+{
+    HKEY hKey = NULL, hCurrentUser = NULL;
+    WCHAR szApplicationName[MAX_PATH];
+    WCHAR szCommandLine[MAX_PATH + 3];
+    DWORD bufferSize = sizeof(szApplicationName) - sizeof(WCHAR);
+    DWORD dwType;
+    STARTUPINFOW StartupInfo;
+    PROCESS_INFORMATION ProcessInformation;
+    HANDLE HandleArray[2];
+    LONG rc;
+    DWORD Status;
+    BOOL ret = FALSE;
+
+    if (!ImpersonateLoggedOnUser(Session->UserToken))
+    {
+        ERR("WL: ImpersonateLoggedOnUser() failed with error %lu\n", 
GetLastError());
+        goto cleanup;
+    }
+
+    rc = RegOpenCurrentUser(KEY_READ,
+                            &hCurrentUser);
+    if (rc != ERROR_SUCCESS)
+    {
+        ERR("WL: RegOpenCurrentUser Error!\n");
+        goto cleanup;
+    }
+
+    rc = RegOpenKeyExW(hCurrentUser,
+                       L"Control Panel\\Desktop",
+                       0,
+                       KEY_QUERY_VALUE,
+                       &hKey);
+    if (rc != ERROR_SUCCESS)
+    {
+        ERR("WL: RegOpenKeyEx Error!\n");
+        goto cleanup;
+    }
+
+    rc = RegQueryValueExW(hKey,
+                          L"SCRNSAVE.EXE",
+                          0,
+                          &dwType,
+                          (LPBYTE)szApplicationName,
+                          &bufferSize);
+    if (rc != ERROR_SUCCESS || dwType != REG_SZ)
+    {
+        ERR("WL: RegQueryValueEx Error!\n");
+        goto cleanup;
+    }
+
+    if (bufferSize == 0)
+    {
+        ERR("WL: Buffer size is NULL!\n");
+        goto cleanup;
+    }
+
+    szApplicationName[bufferSize / sizeof(WCHAR)] = 0; /* Terminate the string 
*/
+
+    if (wcslen(szApplicationName) == 0)
+    {
+        ERR("WL: Application Name length is zero!\n");
+        goto cleanup;
+    }
+
+    wsprintfW(szCommandLine, L"%s /s", szApplicationName);
+    TRACE("WL: Executing %S\n", szCommandLine);
+
+    ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
+    ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
+    StartupInfo.cb = sizeof(STARTUPINFOW);
+    StartupInfo.dwFlags = STARTF_SCRNSAVER;
+
+    /* FIXME: run the screen saver on the screen saver desktop */
+    ret = CreateProcessW(szApplicationName,
+                         szCommandLine,
+                         NULL,
+                         NULL,
+                         FALSE,
+                         0,
+                         NULL,
+                         NULL,
+                         &StartupInfo,
+                         &ProcessInformation);
+    if (!ret)
+    {
+        ERR("WL: Unable to start %S, error %lu\n", szApplicationName, 
GetLastError());
+        goto cleanup;
+    }
+
+    CloseHandle(ProcessInformation.hThread);
+
+    SystemParametersInfoW(SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0);
+
+    /* Wait the end of the process or some other activity */
+    ResetEvent(Session->hUserActivity);
+    HandleArray[0] = ProcessInformation.hProcess;
+    HandleArray[1] = Session->hUserActivity;
+    Status = WaitForMultipleObjects(2, HandleArray, FALSE, INFINITE);
+    if (Status == WAIT_OBJECT_0 + 1)
+    {
+        /* Kill the screen saver */
+        TerminateProcess(ProcessInformation.hProcess, 0);
+    }
+
+    SetEvent(Session->hEndOfScreenSaver);
+
+    CloseHandle(ProcessInformation.hProcess);
 
 cleanup:
-       RevertToSelf();
-       if (hKey)
-               RegCloseKey(hKey);
-       if (hCurrentUser)
-               RegCloseKey(hCurrentUser);
-       if (!ret)
-       {
-               PostMessageW(Session->SASWindow, WLX_WM_SAS, 
WLX_SAS_TYPE_SCRNSVR_ACTIVITY, 0);
-#ifndef USE_GETLASTINPUTINFO
-               InterlockedExchange((LONG*)&Session->LastActivity, 
GetTickCount());
-#endif
-       }
-}
+    RevertToSelf();
+    if (hKey)
+        RegCloseKey(hKey);
+
+    if (hCurrentUser)
+        RegCloseKey(hCurrentUser);
+
+    if (!ret)
+    {
+        PostMessageW(Session->SASWindow, WLX_WM_SAS, 
WLX_SAS_TYPE_SCRNSVR_ACTIVITY, 0);
+#ifndef USE_GETLASTINPUTINFO
+        InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());
+#endif
+    }
+}

Modified: trunk/reactos/base/system/winlogon/setup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/setup.c?rev=58406&r1=58405&r2=58406&view=diff
==============================================================================
--- trunk/reactos/base/system/winlogon/setup.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/setup.c [iso-8859-1] Sat Mar  2 20:30:36 
2013
@@ -17,142 +17,147 @@
 DWORD
 GetSetupType(VOID)
 {
-       DWORD dwError;
-       HKEY hKey;
-       DWORD dwType;
-       DWORD dwSize;
-       DWORD dwSetupType;
+    DWORD dwError;
+    HKEY hKey;
+    DWORD dwType;
+    DWORD dwSize;
+    DWORD dwSetupType;
 
-       TRACE("GetSetupType()\n");
+    TRACE("GetSetupType()\n");
 
-       /* Open key */
-       dwError = RegOpenKeyExW(
-               HKEY_LOCAL_MACHINE,
-               L"SYSTEM\\Setup",
-               0,
-               KEY_QUERY_VALUE,
-               &hKey);
-       if (dwError != ERROR_SUCCESS)
-               return 0;
+    /* Open key */
+    dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                            L"SYSTEM\\Setup",
+                            0,
+                            KEY_QUERY_VALUE,
+                            &hKey);
+    if (dwError != ERROR_SUCCESS)
+        return 0;
 
-       /* Read key */
-       dwSize = sizeof(DWORD);
-       dwError = RegQueryValueExW(
-               hKey,
-               L"SetupType",
-               NULL,
-               &dwType,
-               (LPBYTE)&dwSetupType,
-               &dwSize);
+    /* Read key */
+    dwSize = sizeof(DWORD);
+    dwError = RegQueryValueExW(hKey,
+                               L"SetupType",
+                               NULL,
+                               &dwType,
+                               (LPBYTE)&dwSetupType,
+                               &dwSize);
 
-       /* Close key, and check if returned values are correct */
-       RegCloseKey(hKey);
-       if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != 
sizeof(DWORD))
-               return 0;
+    /* Close key, and check if returned values are correct */
+    RegCloseKey(hKey);
+    if (dwError != ERROR_SUCCESS || dwType != REG_DWORD || dwSize != 
sizeof(DWORD))
+        return 0;
 
-       TRACE("GetSetupType() returns %lu\n", dwSetupType);
-       return dwSetupType;
+    TRACE("GetSetupType() returns %lu\n", dwSetupType);
+    return dwSetupType;
 }
 
-static DWORD WINAPI
-RunSetupThreadProc(
-       IN LPVOID lpParameter)
+
+static
+DWORD
+WINAPI
+RunSetupThreadProc(IN LPVOID lpParameter)
 {
-       PROCESS_INFORMATION ProcessInformation;
-       STARTUPINFOW StartupInfo;
-       WCHAR Shell[MAX_PATH];
-       WCHAR CommandLine[MAX_PATH];
-       BOOL Result;
-       DWORD dwError;
-       HKEY hKey;
-       DWORD dwType;
-       DWORD dwSize;
-       DWORD dwExitCode;
+    PROCESS_INFORMATION ProcessInformation;
+    STARTUPINFOW StartupInfo;
+    WCHAR Shell[MAX_PATH];
+    WCHAR CommandLine[MAX_PATH];
+    BOOL Result;
+    DWORD dwError;
+    HKEY hKey;
+    DWORD dwType;
+    DWORD dwSize;
+    DWORD dwExitCode;
 
-       TRACE("RunSetup() called\n");
+    TRACE("RunSetup() called\n");
 
-       /* Open key */
-       dwError = RegOpenKeyExW(
-               HKEY_LOCAL_MACHINE,
-               L"SYSTEM\\Setup",
-               0,
-               KEY_QUERY_VALUE,
-               &hKey);
-       if (dwError != ERROR_SUCCESS)
-               return FALSE;
+    /* Open key */
+    dwError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                            L"SYSTEM\\Setup",
+                            0,
+                            KEY_QUERY_VALUE,
+                            &hKey);
+    if (dwError != ERROR_SUCCESS)
+        return FALSE;
 
-       /* Read key */
-       dwSize = (sizeof(Shell) / sizeof(Shell[0])) - 1;
-       dwError = RegQueryValueExW(
-               hKey,
-               L"CmdLine",
-               NULL,
-               &dwType,
-               (LPBYTE)Shell,
-               &dwSize);
-       RegCloseKey(hKey);
-       if (dwError != ERROR_SUCCESS)
-               return FALSE;
+    /* Read key */
+    dwSize = (sizeof(Shell) / sizeof(Shell[0])) - 1;
+    dwError = RegQueryValueExW(hKey,
+                               L"CmdLine",
+                               NULL,
+                               &dwType,
+                               (LPBYTE)Shell,
+                               &dwSize);
+    RegCloseKey(hKey);
+    if (dwError != ERROR_SUCCESS)
+        return FALSE;
 
-       /* Finish string */
-       Shell[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
+    /* Finish string */
+    Shell[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
 
-       /* Expand string (if applicable) */
-       if (dwType == REG_EXPAND_SZ)
-               ExpandEnvironmentStringsW(Shell, CommandLine, MAX_PATH);
-       else if (dwType == REG_SZ)
-               wcscpy(CommandLine, Shell);
-       else
-               return FALSE;
+    /* Expand string (if applicable) */
+    if (dwType == REG_EXPAND_SZ)
+        ExpandEnvironmentStringsW(Shell, CommandLine, MAX_PATH);
+    else if (dwType == REG_SZ)
+        wcscpy(CommandLine, Shell);
+    else
+        return FALSE;
 
-       TRACE("Should run '%s' now\n", debugstr_w(CommandLine));
+    TRACE("Should run '%s' now\n", debugstr_w(CommandLine));
 
-       /* Start process */
-       StartupInfo.cb = sizeof(StartupInfo);
-       StartupInfo.lpReserved = NULL;
-       StartupInfo.lpDesktop = NULL;
-       StartupInfo.lpTitle = NULL;
-       StartupInfo.dwFlags = 0;
-       StartupInfo.cbReserved2 = 0;
-       StartupInfo.lpReserved2 = 0;
-       Result = CreateProcessW(
-               NULL,
-               CommandLine,
-               NULL,
-               NULL,
-               FALSE,
-               DETACHED_PROCESS,
-               NULL,
-               NULL,
-               &StartupInfo,
-               &ProcessInformation);
-       if (!Result)
-       {
-               TRACE("Failed to run setup process\n");
-               return FALSE;
-       }
+    /* Start process */
+    StartupInfo.cb = sizeof(StartupInfo);
+    StartupInfo.lpReserved = NULL;
+    StartupInfo.lpDesktop = NULL;
+    StartupInfo.lpTitle = NULL;
+    StartupInfo.dwFlags = 0;
+    StartupInfo.cbReserved2 = 0;
+    StartupInfo.lpReserved2 = 0;
 
-       /* Wait for process termination */
-       WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
+    Result = CreateProcessW(NULL,
+                            CommandLine,
+                            NULL,
+                            NULL,
+                            FALSE,
+                            DETACHED_PROCESS,
+                            NULL,
+                            NULL,
+                            &StartupInfo,
+                            &ProcessInformation);
+    if (!Result)
+    {
+        TRACE("Failed to run setup process\n");
+        return FALSE;
+    }
 
-       GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);
+    /* Wait for process termination */
+    WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
 
-       /* Close handles */
-       CloseHandle(ProcessInformation.hThread);
-       CloseHandle(ProcessInformation.hProcess);
+    GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);
 
-       TRACE ("RunSetup() done\n");
+    /* Close handles */
+    CloseHandle(ProcessInformation.hThread);
+    CloseHandle(ProcessInformation.hProcess);
 
-       return TRUE;
+    TRACE ("RunSetup() done\n");
+
+    return TRUE;
 }
+
 
 BOOL
 RunSetup(VOID)
 {
-       HANDLE hThread;
+    HANDLE hThread;
 
-       hThread = CreateThread(NULL, 0, RunSetupThreadProc, NULL, 0, NULL);
-       return hThread != NULL;
+    hThread = CreateThread(NULL,
+                           0,
+                           RunSetupThreadProc,
+                           NULL,
+                           0,
+                           NULL);
+
+    return hThread != NULL;
 }
 
 /* EOF */

Modified: trunk/reactos/base/system/winlogon/winlogon.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlogon.c?rev=58406&r1=58405&r2=58406&view=diff
==============================================================================
--- trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/winlogon.c [iso-8859-1] Sat Mar  2 
20:30:36 2013
@@ -21,96 +21,97 @@
 
 /* FUNCTIONS *****************************************************************/
 
-static BOOL
+static
+BOOL
 StartServicesManager(VOID)
 {
-       STARTUPINFOW StartupInfo;
-       PROCESS_INFORMATION ProcessInformation;
-       LPCWSTR ServiceString = L"services.exe";
-       BOOL res;
-
-       /* Start the service control manager (services.exe) */
-       ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
-       StartupInfo.cb = sizeof(StartupInfo);
-       StartupInfo.lpReserved = NULL;
-       StartupInfo.lpDesktop = NULL;
-       StartupInfo.lpTitle = NULL;
-       StartupInfo.dwFlags = 0;
-       StartupInfo.cbReserved2 = 0;
-       StartupInfo.lpReserved2 = 0;
-
-       TRACE("WL: Creating new process - %S\n", ServiceString);
-
-       res = CreateProcessW(
-               ServiceString,
-               NULL,
-               NULL,
-               NULL,
-               FALSE,
-               DETACHED_PROCESS,
-               NULL,
-               NULL,
-               &StartupInfo,
-               &ProcessInformation);
-       if (!res)
-       {
-               ERR("WL: Failed to execute services (error %lu)\n", 
GetLastError());
-               return FALSE;
-       }
-
-       TRACE("WL: Created new process - %S\n", ServiceString);
-
-       CloseHandle(ProcessInformation.hThread);
-       CloseHandle(ProcessInformation.hProcess);
-
-       TRACE("WL: StartServicesManager() done.\n");
-
-       return TRUE;
-}
-
-
-static BOOL
+    STARTUPINFOW StartupInfo;
+    PROCESS_INFORMATION ProcessInformation;
+    LPCWSTR ServiceString = L"services.exe";
+    BOOL res;
+
+    /* Start the service control manager (services.exe) */
+    ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
+    StartupInfo.cb = sizeof(StartupInfo);
+    StartupInfo.lpReserved = NULL;
+    StartupInfo.lpDesktop = NULL;
+    StartupInfo.lpTitle = NULL;
+    StartupInfo.dwFlags = 0;
+    StartupInfo.cbReserved2 = 0;
+    StartupInfo.lpReserved2 = 0;
+
+    TRACE("WL: Creating new process - %S\n", ServiceString);
+
+    res = CreateProcessW(ServiceString,
+                         NULL,
+                         NULL,
+                         NULL,
+                         FALSE,
+                         DETACHED_PROCESS,
+                         NULL,
+                         NULL,
+                         &StartupInfo,
+                         &ProcessInformation);
+    if (!res)
+    {
+        ERR("WL: Failed to execute services (error %lu)\n", GetLastError());
+        return FALSE;
+    }
+
+    TRACE("WL: Created new process - %S\n", ServiceString);
+
+    CloseHandle(ProcessInformation.hThread);
+    CloseHandle(ProcessInformation.hProcess);
+
+    TRACE("WL: StartServicesManager() done.\n");
+
+    return TRUE;
+}
+
+
+static
+BOOL
 StartLsass(VOID)
 {
-       STARTUPINFOW StartupInfo;
-       PROCESS_INFORMATION ProcessInformation;
-       LPCWSTR ServiceString = L"lsass.exe";
-       BOOL res;
-
-       /* Start the local security authority subsystem (lsass.exe) */
-       ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
-       StartupInfo.cb = sizeof(StartupInfo);
-       StartupInfo.lpReserved = NULL;
-       StartupInfo.lpDesktop = NULL;
-       StartupInfo.lpTitle = NULL;
-       StartupInfo.dwFlags = 0;
-       StartupInfo.cbReserved2 = 0;
-       StartupInfo.lpReserved2 = 0;
-
-       TRACE("WL: Creating new process - %S\n", ServiceString);
-
-       res = CreateProcessW(
-               ServiceString,
-               NULL,
-               NULL,
-               NULL,
-               FALSE,
-               DETACHED_PROCESS,
-               NULL,
-               NULL,
-               &StartupInfo,
-               &ProcessInformation);
-
-       TRACE("WL: Created new process - %S\n", ServiceString);
-
-       CloseHandle(ProcessInformation.hThread);
-       CloseHandle(ProcessInformation.hProcess);
-
-       return res;
-}
-
-
-static VOID
+    STARTUPINFOW StartupInfo;
+    PROCESS_INFORMATION ProcessInformation;
+    LPCWSTR ServiceString = L"lsass.exe";
+    BOOL res;
+
+    /* Start the local security authority subsystem (lsass.exe) */
+    ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
+    StartupInfo.cb = sizeof(StartupInfo);
+    StartupInfo.lpReserved = NULL;
+    StartupInfo.lpDesktop = NULL;
+    StartupInfo.lpTitle = NULL;
+    StartupInfo.dwFlags = 0;
+    StartupInfo.cbReserved2 = 0;
+    StartupInfo.lpReserved2 = 0;
+
+    TRACE("WL: Creating new process - %S\n", ServiceString);
+
+    res = CreateProcessW(ServiceString,
+                         NULL,
+                         NULL,
+                         NULL,
+                         FALSE,
+                         DETACHED_PROCESS,
+                         NULL,
+                         NULL,
+                         &StartupInfo,
+                         &ProcessInformation);
+
+    TRACE("WL: Created new process - %S\n", ServiceString);
+
+    CloseHandle(ProcessInformation.hThread);
+    CloseHandle(ProcessInformation.hProcess);
+
+    return res;
+}
+
+
+static
+VOID
 WaitForLsass(VOID)
 {
     HANDLE hEvent;
@@ -146,18 +147,19 @@
 }
 
 
-static BOOL
-InitKeyboardLayouts()
+static
+BOOL
+InitKeyboardLayouts(VOID)
 {
     WCHAR wszKeyName[12], wszKLID[10];
-       DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
+    DWORD dwSize = sizeof(wszKLID), dwType, i = 1;
     HKEY hKey;
     UINT Flags;
     BOOL bRet = FALSE;
 
     /* Open registry key with preloaded layouts */
-       if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, 
KEY_READ, &hKey) == ERROR_SUCCESS)
-       {
+    if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, 
KEY_READ, &hKey) == ERROR_SUCCESS)
+    {
         while(TRUE)
         {
             /* Read values with integer names only */
@@ -195,9 +197,9 @@
 
         /* Close the key now */
         RegCloseKey(hKey);
-       }
-       else
-           WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
+    }
+    else
+        WARN("RegOpenKeyExW(Keyboard Layout\\Preload) failed!\n");
 
     if (!bRet)
     {
@@ -211,234 +213,242 @@
 
 
 BOOL
-DisplayStatusMessage(
-       IN PWLSESSION Session,
-       IN HDESK hDesktop,
-       IN UINT ResourceId)
-{
-       WCHAR StatusMsg[MAX_PATH];
-
-       if (Session->Gina.Version < WLX_VERSION_1_3)
-               return TRUE;
-
-       if (Session->SuppressStatus)
-               return TRUE;
-
-       if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
-               return FALSE;
-
-       return 
Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, 
hDesktop, 0, NULL, StatusMsg);
-}
+DisplayStatusMessage(IN PWLSESSION Session,
+                     IN HDESK hDesktop,
+                     IN UINT ResourceId)
+{
+    WCHAR StatusMsg[MAX_PATH];
+
+    if (Session->Gina.Version < WLX_VERSION_1_3)
+        return TRUE;
+
+    if (Session->SuppressStatus)
+        return TRUE;
+
+    if (LoadStringW(hAppInstance, ResourceId, StatusMsg, MAX_PATH) == 0)
+        return FALSE;
+
+    return 
Session->Gina.Functions.WlxDisplayStatusMessage(Session->Gina.Context, 
hDesktop, 0, NULL, StatusMsg);
+}
+
 
 BOOL
-RemoveStatusMessage(
-       IN PWLSESSION Session)
-{
-       if (Session->Gina.Version < WLX_VERSION_1_3)
-               return TRUE;
-
-       return 
Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
-}
-
-static INT_PTR CALLBACK
-GinaLoadFailedWindowProc(
-       IN HWND hwndDlg,
-       IN UINT uMsg,
-       IN WPARAM wParam,
-       IN LPARAM lParam)
-{
-       switch (uMsg)
-       {
-               case WM_COMMAND:
-               {
-                       switch (LOWORD(wParam))
-                       {
-                               case IDOK:
-                                       EndDialog(hwndDlg, IDOK);
-                                       return TRUE;
-                       }
-                       break;
-               }
-               case WM_INITDIALOG:
-               {
-                       int len;
-                       WCHAR templateText[MAX_PATH], text[MAX_PATH];
-
-                       len = GetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, 
templateText, MAX_PATH);
-                       if (len)
-                       {
-                               wsprintfW(text, templateText, (LPWSTR)lParam);
-                               SetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, 
text);
-                       }
-                       SetFocus(GetDlgItem(hwndDlg, IDOK));
-                       return TRUE;
-               }
-               case WM_CLOSE:
-               {
-                       EndDialog(hwndDlg, IDCANCEL);
-                       return TRUE;
-               }
-       }
-
-       return FALSE;
-}
-
-int WINAPI
-WinMain(
-       IN HINSTANCE hInstance,
-       IN HINSTANCE hPrevInstance,
-       IN LPSTR lpCmdLine,
-       IN int nShowCmd)
+RemoveStatusMessage(IN PWLSESSION Session)
+{
+    if (Session->Gina.Version < WLX_VERSION_1_3)
+        return TRUE;
+
+    return 
Session->Gina.Functions.WlxRemoveStatusMessage(Session->Gina.Context);
+}
+
+
+static
+INT_PTR
+CALLBACK
+GinaLoadFailedWindowProc(IN HWND hwndDlg,
+                         IN UINT uMsg,
+                         IN WPARAM wParam,
+                         IN LPARAM lParam)
+{
+    switch (uMsg)
+    {
+        case WM_COMMAND:
+        {
+            switch (LOWORD(wParam))
+            {
+                case IDOK:
+                    EndDialog(hwndDlg, IDOK);
+                    return TRUE;
+            }
+            break;
+        }
+
+        case WM_INITDIALOG:
+        {
+            int len;
+            WCHAR templateText[MAX_PATH], text[MAX_PATH];
+
+            len = GetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, templateText, 
MAX_PATH);
+            if (len)
+            {
+                wsprintfW(text, templateText, (LPWSTR)lParam);
+                SetDlgItemTextW(hwndDlg, IDC_GINALOADFAILED, text);
+            }
+
+            SetFocus(GetDlgItem(hwndDlg, IDOK));
+            return TRUE;
+        }
+
+        case WM_CLOSE:
+        {
+            EndDialog(hwndDlg, IDCANCEL);
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+
+int
+WINAPI
+WinMain(IN HINSTANCE hInstance,
+        IN HINSTANCE hPrevInstance,
+        IN LPSTR lpCmdLine,
+        IN int nShowCmd)
 {
 #if 0
-       LSA_STRING ProcessName, PackageName;
-       HANDLE LsaHandle;
-       LSA_OPERATIONAL_MODE Mode;
-       BOOLEAN Old;
-       ULONG AuthenticationPackage;
-       NTSTATUS Status;
+    LSA_STRING ProcessName, PackageName;
+    HANDLE LsaHandle;
+    LSA_OPERATIONAL_MODE Mode;
+    BOOLEAN Old;
+    ULONG AuthenticationPackage;
+    NTSTATUS Status;
 #endif
-       ULONG HardErrorResponse;
-       MSG Msg;
-
-       UNREFERENCED_PARAMETER(hPrevInstance);
-       UNREFERENCED_PARAMETER(lpCmdLine);
-       UNREFERENCED_PARAMETER(nShowCmd);
-
-       hAppInstance = hInstance;
-
-       if (!RegisterLogonProcess(GetCurrentProcessId(), TRUE))
-       {
-               ERR("WL: Could not register logon process\n");
-               NtShutdownSystem(ShutdownNoReboot);
-               ExitProcess(0);
-       }
-
-       WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, 
sizeof(WLSESSION));
-       if (!WLSession)
-       {
-               ERR("WL: Could not allocate memory for winlogon instance\n");
-               NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
-               ExitProcess(1);
-       }
-       ZeroMemory(WLSession, sizeof(WLSESSION));
-       WLSession->DialogTimeout = 120; /* 2 minutes */
-
-       if (!CreateWindowStationAndDesktops(WLSession))
-       {
-               ERR("WL: Could not create window station and desktops\n");
-               NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
-               ExitProcess(1);
-       }
-       LockWorkstation(WLSession);
+    ULONG HardErrorResponse;
+    MSG Msg;
+
+    UNREFERENCED_PARAMETER(hPrevInstance);
+    UNREFERENCED_PARAMETER(lpCmdLine);
+    UNREFERENCED_PARAMETER(nShowCmd);
+
+    hAppInstance = hInstance;
+
+    if (!RegisterLogonProcess(GetCurrentProcessId(), TRUE))
+    {
+        ERR("WL: Could not register logon process\n");
+        NtShutdownSystem(ShutdownNoReboot);
+        ExitProcess(0);
+    }
+
+    WLSession = (PWLSESSION)HeapAlloc(GetProcessHeap(), 0, sizeof(WLSESSION));
+    if (!WLSession)
+    {
+        ERR("WL: Could not allocate memory for winlogon instance\n");
+        NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
+        ExitProcess(1);
+    }
+
+    ZeroMemory(WLSession, sizeof(WLSESSION));
+    WLSession->DialogTimeout = 120; /* 2 minutes */
+
+    if (!CreateWindowStationAndDesktops(WLSession))
+    {
+        ERR("WL: Could not create window station and desktops\n");
+        NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
+        ExitProcess(1);
+    }
+
+    LockWorkstation(WLSession);
 
     /* Load default keyboard layouts */
     if (!InitKeyboardLayouts())
     {
         ERR("WL: Could not preload keyboard layouts\n");
-               NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
-               ExitProcess(1);
-    }
-
-       if (!StartServicesManager())
-       {
-               ERR("WL: Could not start services.exe\n");
-               NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
-               ExitProcess(1);
-       }
-
-       if (!StartLsass())
-       {
-               ERR("WL: Failed to start lsass.exe service (error %lu)\n", 
GetLastError());
-               NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 
OptionOk, &HardErrorResponse);
-               ExitProcess(1);
-       }
-
-       /* Load and initialize gina */
-       if (!GinaInit(WLSession))
-       {
-               ERR("WL: Failed to initialize Gina\n");
-               DialogBoxParam(hAppInstance, 
MAKEINTRESOURCE(IDD_GINALOADFAILED), GetDesktopWindow(), 
GinaLoadFailedWindowProc, (LPARAM)L"");
-               HandleShutdown(WLSession, WLX_SAS_ACTION_SHUTDOWN_REBOOT);
-               ExitProcess(1);
-       }
-
-       DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop, 
IDS_REACTOSISSTARTINGUP);
-
-
-       /* Wait for the LSA server */
-       WaitForLsass();
+        NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
+        ExitProcess(1);
+    }
+
+    if (!StartServicesManager())
+    {
+        ERR("WL: Could not start services.exe\n");
+        NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, NULL, 
OptionOk, &HardErrorResponse);
+        ExitProcess(1);
+    }
+
+    if (!StartLsass())
+    {
+        ERR("WL: Failed to start lsass.exe service (error %lu)\n", 
GetLastError());
+        NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, OptionOk, 
&HardErrorResponse);
+        ExitProcess(1);
+    }
+
+    /* Load and initialize gina */
+    if (!GinaInit(WLSession))
+    {
+        ERR("WL: Failed to initialize Gina\n");
+        DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_GINALOADFAILED), 
GetDesktopWindow(), GinaLoadFailedWindowProc, (LPARAM)L"");
+        HandleShutdown(WLSession, WLX_SAS_ACTION_SHUTDOWN_REBOOT);
+        ExitProcess(1);
+    }
+
+    DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop, 
IDS_REACTOSISSTARTINGUP);
+
+    /* Wait for the LSA server */
+    WaitForLsass();
 
 #if 0
-       /* Connect to NetLogon service (lsass.exe) */
-       /* Real winlogon uses "Winlogon" */
-       RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
-       Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
-       if (Status == STATUS_PORT_CONNECTION_REFUSED)
-       {
-               /* Add the 'SeTcbPrivilege' privilege and try again */
-               Status = RtlAdjustPrivilege(SE_TCB_PRIVILEGE, TRUE, TRUE, &Old);
-               if (!NT_SUCCESS(Status))
-               {
-                       ERR("RtlAdjustPrivilege() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
-                       return 1;
-               }
-               Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, 
&Mode);
-       }
-       if (!NT_SUCCESS(Status))
-       {
-               ERR("LsaRegisterLogonProcess() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
-               return 1;
-       }
-
-       RtlInitUnicodeString((PUNICODE_STRING)&PackageName, 
MICROSOFT_KERBEROS_NAME_W);
-       Status = LsaLookupAuthenticationPackage(LsaHandle, &PackageName, 
&AuthenticationPackage);
-       if (!NT_SUCCESS(Status))
-       {
-               ERR("LsaLookupAuthenticationPackage() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
-               LsaDeregisterLogonProcess(LsaHandle);
-               return 1;
-       }
+    /* Connect to NetLogon service (lsass.exe) */
+    /* Real winlogon uses "Winlogon" */
+    RtlInitUnicodeString((PUNICODE_STRING)&ProcessName, L"Winlogon");
+    Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
+    if (Status == STATUS_PORT_CONNECTION_REFUSED)
+    {
+        /* Add the 'SeTcbPrivilege' privilege and try again */
+        Status = RtlAdjustPrivilege(SE_TCB_PRIVILEGE, TRUE, TRUE, &Old);
+        if (!NT_SUCCESS(Status))
+        {
+            ERR("RtlAdjustPrivilege() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
+            return 1;
+        }
+
+        Status = LsaRegisterLogonProcess(&ProcessName, &LsaHandle, &Mode);
+    }
+
+    if (!NT_SUCCESS(Status))
+    {
+        ERR("LsaRegisterLogonProcess() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
+        return 1;
+    }
+
+    RtlInitUnicodeString((PUNICODE_STRING)&PackageName, 
MICROSOFT_KERBEROS_NAME_W);
+    Status = LsaLookupAuthenticationPackage(LsaHandle, &PackageName, 
&AuthenticationPackage);
+    if (!NT_SUCCESS(Status))
+    {
+        ERR("LsaLookupAuthenticationPackage() failed with error %lu\n", 
LsaNtStatusToWinError(Status));
+        LsaDeregisterLogonProcess(LsaHandle);
+        return 1;
+    }
 #endif
 
-       /* Create a hidden window to get SAS notifications */
-       if (!InitializeSAS(WLSession))
-       {
-               ERR("WL: Failed to initialize SAS\n");
-               ExitProcess(2);
-       }
-
-       //DisplayStatusMessage(Session, Session->WinlogonDesktop, 
IDS_PREPARENETWORKCONNECTIONS);
-       //DisplayStatusMessage(Session, Session->WinlogonDesktop, 
IDS_APPLYINGCOMPUTERSETTINGS);
-
-       /* Display logged out screen */
-       WLSession->LogonState = STATE_LOGGED_OFF;
-       RemoveStatusMessage(WLSession);
-
-       /* Check for pending setup */
-       if (GetSetupType() != 0)
-       {
-               TRACE("WL: Setup mode detected\n");
-
-               /* Run setup and reboot when done */
-               SwitchDesktop(WLSession->ApplicationDesktop);
-               RunSetup();
-       }
-       else
-               PostMessageW(WLSession->SASWindow, WLX_WM_SAS, 
WLX_SAS_TYPE_TIMEOUT, 0);
-
-       /* Tell kernel that CurrentControlSet is good (needed
-        * to support Last good known configuration boot) */
-       NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED | 1);
-
-       /* Message loop for the SAS window */
-       while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
-       {
-               TranslateMessage(&Msg);
-               DispatchMessageW(&Msg);
-       }
-
-       /* We never go there */
-
-       return 0;
-}
+    /* Create a hidden window to get SAS notifications */
+    if (!InitializeSAS(WLSession))
+    {
+        ERR("WL: Failed to initialize SAS\n");
+        ExitProcess(2);
+    }
+
+    //DisplayStatusMessage(Session, Session->WinlogonDesktop, 
IDS_PREPARENETWORKCONNECTIONS);
+    //DisplayStatusMessage(Session, Session->WinlogonDesktop, 
IDS_APPLYINGCOMPUTERSETTINGS);
+
+    /* Display logged out screen */
+    WLSession->LogonState = STATE_LOGGED_OFF;
+    RemoveStatusMessage(WLSession);
+
+    /* Check for pending setup */
+    if (GetSetupType() != 0)
+    {
+        TRACE("WL: Setup mode detected\n");
+
+        /* Run setup and reboot when done */
+        SwitchDesktop(WLSession->ApplicationDesktop);
+        RunSetup();
+    }
+    else
+        PostMessageW(WLSession->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_TIMEOUT, 
0);
+
+    /* Tell kernel that CurrentControlSet is good (needed
+     * to support Last good known configuration boot) */
+    NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED | 1);
+
+    /* Message loop for the SAS window */
+    while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
+    {
+        TranslateMessage(&Msg);
+        DispatchMessageW(&Msg);
+    }
+
+    /* We never go there */
+
+    return 0;
+}

Modified: trunk/reactos/base/system/winlogon/winlogon.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/winlogon.h?rev=58406&r1=58405&r2=58406&view=diff
==============================================================================
--- trunk/reactos/base/system/winlogon/winlogon.h [iso-8859-1] (original)
+++ trunk/reactos/base/system/winlogon/winlogon.h [iso-8859-1] Sat Mar  2 
20:30:36 2013
@@ -79,44 +79,44 @@
 
 typedef struct _GINAFUNCTIONS
 {
-       /* Functions always available for a valid GINA */
-       PFWLXNEGOTIATE            WlxNegotiate; /* optional */
-       PFWLXINITIALIZE           WlxInitialize;
-
-       /* Functions available if WlxVersion >= WLX_VERSION_1_0 (MS Windows 
3.5.0) */
-       PFWLXDISPLAYSASNOTICE     WlxDisplaySASNotice;
-       PFWLXLOGGEDOUTSAS         WlxLoggedOutSAS;
-       PFWLXACTIVATEUSERSHELL    WlxActivateUserShell;
-       PFWLXLOGGEDONSAS          WlxLoggedOnSAS;
-       PFWLXDISPLAYLOCKEDNOTICE  WlxDisplayLockedNotice;
-       PFWLXWKSTALOCKEDSAS       WlxWkstaLockedSAS;
-       PFWLXISLOCKOK             WlxIsLockOk;
-       PFWLXISLOGOFFOK           WlxIsLogoffOk;
-       PFWLXLOGOFF               WlxLogoff;
-       PFWLXSHUTDOWN             WlxShutdown;
-
-       /* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 
3.5.1) */
-       PFWLXSCREENSAVERNOTIFY    WlxScreenSaverNotify; /* optional */
-       PFWLXSTARTAPPLICATION     WlxStartApplication; /* optional */
-
-       /* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 
4.0) */
-
-       /* Functions available if WlxVersion >= WLX_VERSION_1_3 (MS Windows 
2000) */
-       PFWLXNETWORKPROVIDERLOAD  WlxNetworkProviderLoad; /* not called ATM */
-       PFWLXDISPLAYSTATUSMESSAGE WlxDisplayStatusMessage;
-       PFWLXGETSTATUSMESSAGE     WlxGetStatusMessage; /* doesn't need to be 
called */
-       PFWLXREMOVESTATUSMESSAGE  WlxRemoveStatusMessage;
-
-       /* Functions available if WlxVersion >= WLX_VERSION_1_4 (MS Windows XP) 
*/
+    /* Functions always available for a valid GINA */
+    PFWLXNEGOTIATE            WlxNegotiate; /* optional */
+    PFWLXINITIALIZE           WlxInitialize;
+
+    /* Functions available if WlxVersion >= WLX_VERSION_1_0 (MS Windows 3.5.0) 
*/
+    PFWLXDISPLAYSASNOTICE     WlxDisplaySASNotice;
+    PFWLXLOGGEDOUTSAS         WlxLoggedOutSAS;
+    PFWLXACTIVATEUSERSHELL    WlxActivateUserShell;
+    PFWLXLOGGEDONSAS          WlxLoggedOnSAS;
+    PFWLXDISPLAYLOCKEDNOTICE  WlxDisplayLockedNotice;
+    PFWLXWKSTALOCKEDSAS       WlxWkstaLockedSAS;
+    PFWLXISLOCKOK             WlxIsLockOk;
+    PFWLXISLOGOFFOK           WlxIsLogoffOk;
+    PFWLXLOGOFF               WlxLogoff;
+    PFWLXSHUTDOWN             WlxShutdown;
+
+    /* Functions available if WlxVersion >= WLX_VERSION_1_1 (MS Windows 3.5.1) 
*/
+    PFWLXSCREENSAVERNOTIFY    WlxScreenSaverNotify; /* optional */
+    PFWLXSTARTAPPLICATION     WlxStartApplication; /* optional */
+
+    /* Functions available if WlxVersion >= WLX_VERSION_1_2 (MS Windows NT 
4.0) */
+
+    /* Functions available if WlxVersion >= WLX_VERSION_1_3 (MS Windows 2000) 
*/
+    PFWLXNETWORKPROVIDERLOAD  WlxNetworkProviderLoad; /* not called ATM */
+    PFWLXDISPLAYSTATUSMESSAGE WlxDisplayStatusMessage;
+    PFWLXGETSTATUSMESSAGE     WlxGetStatusMessage; /* doesn't need to be 
called */
+    PFWLXREMOVESTATUSMESSAGE  WlxRemoveStatusMessage;
+
+    /* Functions available if WlxVersion >= WLX_VERSION_1_4 (MS Windows XP) */
 } GINAFUNCTIONS, *PGINAFUNCTIONS;
 
 typedef struct _GINAINSTANCE
 {
-       HMODULE hDllInstance;
-       GINAFUNCTIONS Functions;
-       PVOID Context;
-       DWORD Version;
-       BOOL UseCtrlAltDelete;
+    HMODULE hDllInstance;
+    GINAFUNCTIONS Functions;
+    PVOID Context;
+    DWORD Version;
+    BOOL UseCtrlAltDelete;
 } GINAINSTANCE, *PGINAINSTANCE;
 
 
@@ -206,39 +206,39 @@
 
 typedef struct _WLSESSION
 {
-  GINAINSTANCE Gina;
-  DWORD SASAction;
-  BOOL SuppressStatus;
-  BOOL TaskManHotkey;
-  HWND SASWindow;
-  HWINSTA InteractiveWindowStation;
-  LPWSTR InteractiveWindowStationName;
-  HDESK ApplicationDesktop;
-  HDESK WinlogonDesktop;
-  HDESK ScreenSaverDesktop;
-  LUID LogonId;
-  HANDLE UserToken;
-  HANDLE hProfileInfo;
-  LOGON_STATE LogonState;
-  DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
-
-  /* Screen-saver informations */
+    GINAINSTANCE Gina;
+    DWORD SASAction;
+    BOOL SuppressStatus;
+    BOOL TaskManHotkey;
+    HWND SASWindow;
+    HWINSTA InteractiveWindowStation;
+    LPWSTR InteractiveWindowStationName;
+    HDESK ApplicationDesktop;
+    HDESK WinlogonDesktop;
+    HDESK ScreenSaverDesktop;
+    LUID LogonId;
+    HANDLE UserToken;
+    HANDLE hProfileInfo;
+    LOGON_STATE LogonState;
+    DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
+
+    /* Screen-saver informations */
 #ifndef USE_GETLASTINPUTINFO
-  HHOOK KeyboardHook;
-  HHOOK MouseHook;
+    HHOOK KeyboardHook;
+    HHOOK MouseHook;
 #endif
-  HANDLE hEndOfScreenSaverThread;
-  HANDLE hScreenSaverParametersChanged;
-  HANDLE hUserActivity;
-  HANDLE hEndOfScreenSaver;
+    HANDLE hEndOfScreenSaverThread;
+    HANDLE hScreenSaverParametersChanged;
+    HANDLE hUserActivity;
+    HANDLE hEndOfScreenSaver;
 #ifndef USE_GETLASTINPUTINFO
-  DWORD LastActivity;
+    DWORD LastActivity;
 #endif
 
-  /* Logon informations */
-  DWORD Options;
-  WLX_MPR_NOTIFY_INFO MprNotifyInfo;
-  WLX_PROFILE_V2_0 *Profile;
+    /* Logon informations */
+    DWORD Options;
+    WLX_MPR_NOTIFY_INFO MprNotifyInfo;
+    WLX_PROFILE_V2_0 *Profile;
 } WLSESSION, *PWLSESSION;
 
 extern HINSTANCE hAppInstance;
@@ -262,52 +262,43 @@
 
 /* sas.c */
 BOOL
-SetDefaultLanguage(
-       IN BOOL UserProfile);
-
-BOOL
-InitializeSAS(
-       IN OUT PWLSESSION Session);
+SetDefaultLanguage(IN BOOL UserProfile);
+
+BOOL
+InitializeSAS(IN OUT PWLSESSION Session);
 
 /* screensaver.c */
 BOOL
-InitializeScreenSaver(
-       IN OUT PWLSESSION Session);
+InitializeScreenSaver(IN OUT PWLSESSION Session);
 
 VOID
-StartScreenSaver(
-       IN PWLSESSION Session);
+StartScreenSaver(IN PWLSESSION Session);
 
 /* winlogon.c */
 
 BOOL
-PlaySoundRoutine(
-       IN LPCWSTR FileName,
-       IN UINT Logon,
-       IN UINT Flags);
-
-BOOL
-DisplayStatusMessage(
-       IN PWLSESSION Session,
-       IN HDESK hDesktop,
-       IN UINT ResourceId);
-
-BOOL
-RemoveStatusMessage(
-       IN PWLSESSION Session);
+PlaySoundRoutine(IN LPCWSTR FileName,
+                 IN UINT Logon,
+                 IN UINT Flags);
+
+BOOL
+DisplayStatusMessage(IN PWLSESSION Session,
+                     IN HDESK hDesktop,
+                     IN UINT ResourceId);
+
+BOOL
+RemoveStatusMessage(IN PWLSESSION Session);
 
 /* wlx.c */
 BOOL
-GinaInit(
-       IN OUT PWLSESSION Session);
-BOOL
-CreateWindowStationAndDesktops(
-       IN OUT PWLSESSION Session);
+GinaInit(IN OUT PWLSESSION Session);
+
+BOOL
+CreateWindowStationAndDesktops(IN OUT PWLSESSION Session);
 
 NTSTATUS
-HandleShutdown(
-       IN OUT PWLSESSION Session,
-       IN DWORD wlxAction);
+HandleShutdown(IN OUT PWLSESSION Session,
+               IN DWORD wlxAction);
 
 VOID WINAPI WlxUseCtrlAltDel(HANDLE hWlx);
 VOID WINAPI WlxSetContextPointer(HANDLE hWlx, PVOID pWlxContext);


Reply via email to