- Fix a bug in StartupWindowThread that had as a result to close the desktop handle we get from winlogon. The problem is the wrong usage of SetThreadDesktop as it closes the previous desktop, so keeping OldDesk is totally useless and when the thread exits it will close the handle to the current thread desktop which is Session->WinlogonDesktop from winlogon. To solve this issue we have to duplicate the handle we get from winlogon and let it get closed by win32k when the thread exits

svn path=/trunk/; revision=58367
This commit is contained in:
Giannis Adamopoulos 2013-02-24 21:30:30 +00:00
parent d35321f340
commit c2107a591d

View file

@ -59,23 +59,35 @@ StatusMessageWindowProc(
static DWORD WINAPI
StartupWindowThread(LPVOID lpParam)
{
HDESK OldDesk;
HDESK hDesk;
PDISPLAYSTATUSMSG msg = (PDISPLAYSTATUSMSG)lpParam;
OldDesk = GetThreadDesktop(GetCurrentThreadId());
if(!SetThreadDesktop(msg->hDesktop))
/* When SetThreadDesktop is called the system closes the desktop handle when needed
so we have to create a new handle because this handle may still be in use by winlogon */
if (!DuplicateHandle ( GetCurrentProcess(),
msg->hDesktop,
GetCurrentProcess(),
&hDesk,
0,
FALSE,
DUPLICATE_SAME_ACCESS))
{
HeapFree(GetProcessHeap(), 0, lpParam);
return FALSE;
}
if(!SetThreadDesktop(hDesk))
{
HeapFree(GetProcessHeap(), 0, lpParam);
return FALSE;
}
DialogBoxParam(
hDllInstance,
MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG),
GetDesktopWindow(),
StatusMessageWindowProc,
(LPARAM)lpParam);
SetThreadDesktop(OldDesk);
HeapFree(GetProcessHeap(), 0, lpParam);
return TRUE;