+
+ /* HAAAAAAAACK! This should go to Win32kProcessCallback */
+ if(Win32Thread->ppi->hdeskStartup == NULL)
+ {
+ /*
+ * inherit the thread desktop and process window station (if not yet inherited) from the process startup
+ * info structure. See documentation of CreateProcess()
+ */
+ DesktopPath = (ProcessParams ? ((ProcessParams->DesktopInfo.Length > 0) ? &ProcessParams->DesktopInfo : NULL) : NULL);
+ Status = IntParseDesktopPath(Process,
+ DesktopPath,
+ &hWinSta,
+ &hDesk);
+ if(NT_SUCCESS(Status))
+ {
+ if(hWinSta != NULL)
+ {
+ if(!UserSetProcessWindowStation(hWinSta))
+ {
+ DPRINT1("Failed to set process window station\n");
+ }
+ }
+
+ if (hDesk != NULL)
+ {
+ /* Validate the new desktop. */
+ Status = IntValidateDesktopHandle(hDesk,
+ UserMode,
+ 0,
+ &pdesk);
+
+ if(NT_SUCCESS(Status))
+ {
+ Win32Thread->ppi->hdeskStartup = hDesk;
+ Win32Thread->ppi->rpdeskStartup = pdesk;
+ }
+ }
+ }
+ else
+ {
+ DPRINT1("No Desktop handle for this Thread!\n");
+ }
+ }
+
+ if (Win32Thread->ppi->hdeskStartup != NULL)
+ {
+ if (!IntSetThreadDesktop(Win32Thread->ppi->hdeskStartup, FALSE))
+ {
+ DPRINT1("Unable to set thread desktop\n");
+ }
+ }
+