Author: gadamopoulos
Date: Sun Feb 24 21:30:30 2013
New Revision: 58367
URL:
http://svn.reactos.org/svn/reactos?rev=58367&view=rev
Log:
[msgina]
- 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
Modified:
trunk/reactos/dll/win32/msgina/gui.c
Modified: trunk/reactos/dll/win32/msgina/gui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/gui.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/msgina/gui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msgina/gui.c [iso-8859-1] Sun Feb 24 21:30:30 2013
@@ -59,23 +59,35 @@
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;