Skip to content

Commit 5f8889d

Browse files
committed
[win32k]
- 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
1 parent 4f04249 commit 5f8889d

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

reactos/include/ndk/psfuncs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ PsGetProcessInheritedFromUniqueProcessId(
185185
IN PEPROCESS Process
186186
);
187187

188+
NTKERNELAPI
189+
NTSTATUS
190+
NTAPI
191+
PsGetProcessExitStatus(
192+
PEPROCESS Process
193+
);
194+
188195
//
189196
// Quota Functions
190197
//

reactos/include/reactos/undocuser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
//
7878
// Definitions used by WM_LOGONNOTIFY
7979
//
80+
#define LN_SHELL_EXITED 0x2
8081
#define LN_START_TASK_MANAGER 0x4
8182
#define LN_LOCK_WORKSTATION 0x5
8283
#define LN_UNLOCK_WORKSTATION 0x6

reactos/include/reactos/win32k/ntuser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ typedef struct _DESKTOPINFO
6565
HWND hProgmanWindow;
6666
HWND hShellWindow;
6767

68+
PPROCESSINFO ppiShellProcess;
69+
6870
union
6971
{
7072
UINT Dummy;

reactos/subsystems/win32/win32k/main/dllmain.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ Win32kProcessCallback(struct _EPROCESS *Process,
128128
DPRINT("Destroying W32 process PID:%d at IRQ level: %lu\n", Process->UniqueProcessId, KeGetCurrentIrql());
129129
Win32Process->W32PF_flags |= W32PF_TERMINATED;
130130

131+
/* Notify logon application to restart shell if needed */
132+
if(Win32Process->rpdeskStartup->pDeskInfo)
133+
{
134+
if(Win32Process->rpdeskStartup->pDeskInfo->ppiShellProcess == Win32Process)
135+
{
136+
DWORD ExitCode;
137+
ExitCode = PsGetProcessExitStatus(Win32Process->peProcess);
138+
139+
DPRINT1("Shell process is exiting (%d)\n", ExitCode);
140+
141+
UserPostMessage(hwndSAS,
142+
WM_LOGONNOTIFY,
143+
LN_SHELL_EXITED,
144+
ExitCode);
145+
}
146+
}
147+
131148
if (Win32Process->InputIdleEvent)
132149
{
133150
EngFreeMem((PVOID)Win32Process->InputIdleEvent);
@@ -243,6 +260,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
243260
}
244261
Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread);
245262
Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout();
263+
Win32Thread->pEThread = Thread;
246264

247265
/* HAAAAAAAACK! This should go to Win32kProcessCallback */
248266
if(Win32Thread->ppi->hdeskStartup == NULL)
@@ -322,7 +340,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread,
322340
// System thread running! Now SendMessage should be okay.
323341
Win32Thread->pcti = &Win32Thread->cti;
324342
}
325-
Win32Thread->pEThread = Thread;
343+
GetW32ThreadInfo();
326344
}
327345
else
328346
{

reactos/subsystems/win32/win32k/ntuser/window.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,7 @@ PWND FASTCALL IntGetWindowObject(HWND hWnd)
101101
/* temp hack */
102102
PWND FASTCALL UserGetWindowObject(HWND hWnd)
103103
{
104-
PTHREADINFO ti;
105-
PWND Window;
106-
107-
if (PsGetCurrentProcess() != PsInitialSystemProcess)
108-
{
109-
ti = GetW32ThreadInfo();
110-
if (ti == NULL)
111-
{
112-
EngSetLastError(ERROR_ACCESS_DENIED);
113-
return NULL;
114-
}
115-
}
104+
PWND Window;
116105

117106
if (!hWnd)
118107
{
@@ -3308,7 +3297,11 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
33083297
WinStaObject->ShellListView = hwndListView;
33093298

33103299
ti = GetW32ThreadInfo();
3311-
if (ti->pDeskInfo) ti->pDeskInfo->hShellWindow = hwndShell;
3300+
if (ti->pDeskInfo)
3301+
{
3302+
ti->pDeskInfo->hShellWindow = hwndShell;
3303+
ti->pDeskInfo->ppiShellProcess = ti->ppi;
3304+
}
33123305

33133306
UserDerefObjectCo(WndShell);
33143307

0 commit comments

Comments
 (0)