diff --git a/reactos/include/ndk/psfuncs.h b/reactos/include/ndk/psfuncs.h index 19c6678ccfa..a32fc3b036c 100644 --- a/reactos/include/ndk/psfuncs.h +++ b/reactos/include/ndk/psfuncs.h @@ -185,6 +185,13 @@ PsGetProcessInheritedFromUniqueProcessId( IN PEPROCESS Process ); +NTKERNELAPI +NTSTATUS +NTAPI +PsGetProcessExitStatus( + PEPROCESS Process +); + // // Quota Functions // diff --git a/reactos/include/reactos/undocuser.h b/reactos/include/reactos/undocuser.h index 06312d7d34e..0fe8a816c1a 100644 --- a/reactos/include/reactos/undocuser.h +++ b/reactos/include/reactos/undocuser.h @@ -77,6 +77,7 @@ // // 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 diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 71ea1772fc6..432390a5fc7 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -65,6 +65,8 @@ typedef struct _DESKTOPINFO HWND hProgmanWindow; HWND hShellWindow; + PPROCESSINFO ppiShellProcess; + union { UINT Dummy; diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index 21b18029222..caa5ee314ed 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -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; + /* 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); @@ -243,6 +260,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, } Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread); Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout(); + Win32Thread->pEThread = Thread; /* 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; } - Win32Thread->pEThread = Thread; + GetW32ThreadInfo(); } else { diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 8bb6b56277f..11ea4669a56 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -101,18 +101,7 @@ PWND FASTCALL IntGetWindowObject(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) { @@ -3308,7 +3297,11 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) 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);