*/
// if (ptiCurrent->ppi->hdeskStartup == NULL && InputWindowStation != NULL)
/* Last things to do only if we are not a SYSTEM or CSRSS thread */
- if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
+ // HACK Part #1: Temporarily disabled to have our current USERSRV running, but normally this is its duty to connect itself to the required desktop!
+ if (// !(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
/**/ptiCurrent->ppi->hdeskStartup == NULL &&/**/
InputWindowStation != NULL)
{
UNICODE_STRING DesktopPath;
PDESKTOP pdesk;
+ // HACK Part #2: We force USERSRV to connect to WinSta0 by setting the STARTF_INHERITDESKTOP flag.
+ if (ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD))
+ ProcessParams->WindowFlags |= STARTF_INHERITDESKTOP;
+
/*
* Inherit the thread desktop and process window station (if not yet inherited)
* from the process startup info structure. See documentation of CreateProcess().
IN ULONG Timeout)
{
ULONG MessageBoxResponse;
+ HDESK hDesk, hOldDesk;
DPRINT("Text = '%S', Caption = '%S', Type = 0x%lx\n",
TextStringU->Buffer, CaptionStringU->Buffer, Type);
+ // TEMPORARY HACK to fix desktop assignment for harderror message boxes.
+ hDesk = OpenInputDesktop(0, FALSE, GENERIC_WRITE);
+ if (!hDesk)
+ return ResponseNotHandled;
+
+ /* Assign the desktop to this thread */
+ hOldDesk = GetThreadDesktop(GetCurrentThreadId());
+ if (!SetThreadDesktop(hDesk))
+ {
+ CloseDesktop(hDesk);
+ return ResponseNotHandled;
+ }
+
/* Display a message box */
MessageBoxResponse = MessageBoxTimeoutW(NULL,
TextStringU->Buffer,
CaptionStringU->Buffer,
Type, 0, Timeout);
+ /* Restore the original desktop */
+ SetThreadDesktop(hOldDesk);
+ CloseDesktop(hDesk);
+
/* Return response value */
switch (MessageBoxResponse)
{