[win32k]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 1 May 2011 09:20:15 +0000 (09:20 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 1 May 2011 09:20:15 +0000 (09:20 +0000)
- Do not try to initialize thread info in UserGetWindowObject. Do it in thread callout. Removing this hack is needed in order to use UserPostMessage in ProcessCallout when a process is terminating
- Notify winlogon that the shell is exiting in order to restart the shell

svn path=/trunk/; revision=51519

reactos/include/ndk/psfuncs.h
reactos/include/reactos/undocuser.h
reactos/include/reactos/win32k/ntuser.h
reactos/subsystems/win32/win32k/main/dllmain.c
reactos/subsystems/win32/win32k/ntuser/window.c

index 19c6678..a32fc3b 100644 (file)
@@ -185,6 +185,13 @@ PsGetProcessInheritedFromUniqueProcessId(
     IN PEPROCESS Process
 );
 
     IN PEPROCESS Process
 );
 
+NTKERNELAPI
+NTSTATUS
+NTAPI
+PsGetProcessExitStatus(
+    PEPROCESS Process
+);
+
 //
 // Quota Functions
 //
 //
 // Quota Functions
 //
index 06312d7..0fe8a81 100644 (file)
@@ -77,6 +77,7 @@
 //
 // Definitions used by WM_LOGONNOTIFY
 //
 //
 // Definitions used by WM_LOGONNOTIFY
 //
+#define LN_SHELL_EXITED       0x2
 #define LN_START_TASK_MANAGER 0x4
 #define LN_LOCK_WORKSTATION   0x5
 #define LN_UNLOCK_WORKSTATION 0x6
 #define LN_START_TASK_MANAGER 0x4
 #define LN_LOCK_WORKSTATION   0x5
 #define LN_UNLOCK_WORKSTATION 0x6
index 71ea177..432390a 100644 (file)
@@ -65,6 +65,8 @@ typedef struct _DESKTOPINFO
     HWND hProgmanWindow;
     HWND hShellWindow;
 
     HWND hProgmanWindow;
     HWND hShellWindow;
 
+    PPROCESSINFO ppiShellProcess;
+
     union
     {
         UINT Dummy;
     union
     {
         UINT Dummy;
index 21b1802..caa5ee3 100644 (file)
@@ -128,6 +128,23 @@ Win32kProcessCallback(struct _EPROCESS *Process,
         DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
         Win32Process->W32PF_flags |= W32PF_TERMINATED;
 
         DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
         Win32Process->W32PF_flags |= W32PF_TERMINATED;
 
+        /* Notify logon application to restart shell if needed */
+        if(Win32Process->rpdeskStartup->pDeskInfo)
+        {
+            if(Win32Process->rpdeskStartup->pDeskInfo->ppiShellProcess == Win32Process)
+            {
+                DWORD ExitCode;
+                ExitCode = PsGetProcessExitStatus(Win32Process->peProcess);
+
+                DPRINT1("Shell process is exiting (%d)\n", ExitCode);
+
+                UserPostMessage(hwndSAS, 
+                                WM_LOGONNOTIFY, 
+                                LN_SHELL_EXITED, 
+                                ExitCode);
+            }
+        }
+
         if (Win32Process->InputIdleEvent)
         {
            EngFreeMem((PVOID)Win32Process->InputIdleEvent);
         if (Win32Process->InputIdleEvent)
         {
            EngFreeMem((PVOID)Win32Process->InputIdleEvent);
@@ -243,6 +260,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
         }
         Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
         Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
         }
         Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
         Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
+        Win32Thread->pEThread = Thread;
 
         /* HAAAAAAAACK! This should go to Win32kProcessCallback */
         if(Win32Thread->ppi->hdeskStartup == NULL)
 
         /* HAAAAAAAACK! This should go to Win32kProcessCallback */
         if(Win32Thread->ppi->hdeskStartup == NULL)
@@ -322,7 +340,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
            // System thread running! Now SendMessage should be okay.
            Win32Thread->pcti = &Win32Thread->cti;
         }
            // System thread running! Now SendMessage should be okay.
            Win32Thread->pcti = &Win32Thread->cti;
         }
-        Win32Thread->pEThread = Thread;
+        GetW32ThreadInfo();
     }
     else
     {
     }
     else
     {
index 8bb6b56..11ea466 100644 (file)
@@ -101,18 +101,7 @@ PWND FASTCALL IntGetWindowObject(HWND hWnd)
 /* temp hack */
 PWND FASTCALL UserGetWindowObject(HWND hWnd)
 {
 /* temp hack */
 PWND FASTCALL UserGetWindowObject(HWND hWnd)
 {
-   PTHREADINFO ti;
-   PWND Window;
-
-   if (PsGetCurrentProcess() != PsInitialSystemProcess)
-   {
-       ti = GetW32ThreadInfo();
-       if (ti == NULL)
-       {
-          EngSetLastError(ERROR_ACCESS_DENIED);
-          return NULL;
-       }
-   }
+    PWND Window;
 
    if (!hWnd)
    {
 
    if (!hWnd)
    {
@@ -3308,7 +3297,11 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
    WinStaObject->ShellListView = hwndListView;
 
    ti = GetW32ThreadInfo();
    WinStaObject->ShellListView = hwndListView;
 
    ti = GetW32ThreadInfo();
-   if (ti->pDeskInfo) ti->pDeskInfo->hShellWindow = hwndShell;
+   if (ti->pDeskInfo) 
+   {
+       ti->pDeskInfo->hShellWindow = hwndShell;
+       ti->pDeskInfo->ppiShellProcess = ti->ppi;
+   }
 
    UserDerefObjectCo(WndShell);
 
 
    UserDerefObjectCo(WndShell);