Skip to content

Remove the explicit desktop field when creating a Windows process#13930

Merged
OneBlue merged 1 commit intomasterfrom
user/oneblue/desktop
Dec 17, 2025
Merged

Remove the explicit desktop field when creating a Windows process#13930
OneBlue merged 1 commit intomasterfrom
user/oneblue/desktop

Conversation

@OneBlue
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue commented Dec 17, 2025

Summary of the Pull Request

This change removes the explicit lpDesktop flag when creating a Windows process.

Windows threads inherit their parent's desktop by default. See: https://learn.microsoft.com/en-us/windows/win32/winstation/thread-connection-to-a-desktop

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings December 17, 2025 00:29
@OneBlue OneBlue requested a review from a team as a code owner December 17, 2025 00:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes the explicit desktop field functionality when creating Windows processes in WSL. The change is based on the principle that Windows threads inherit their parent's desktop by default, making the explicit lpDesktop setting unnecessary. The PR removes the SetDesktop method and its call site, but the implementation is incomplete.

Key changes:

  • Removed the SetDesktop(LPCWSTR Desktop) method declaration and implementation from the SubProcess class
  • Removed the call to process.SetDesktop(L"winsta0\\default") in the interop process creation flow

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/windows/common/interop.cpp Removes the explicit call to SetDesktop that was setting the desktop to "winsta0\default"
src/windows/common/SubProcess.h Removes the SetDesktop method declaration from the SubProcess class interface
src/windows/common/SubProcess.cpp Removes the SetDesktop method implementation

Critical Issue Identified: The refactoring is incomplete. While the SetDesktop method has been removed, the m_desktop member variable (line 58 in SubProcess.h) still exists and is still being used at line 187 in SubProcess.cpp where it assigns to StartupInfo.StartupInfo.lpDesktop. Both the member variable declaration and this assignment need to be removed to properly complete this change.

Comments suppressed due to low confidence (1)

src/windows/common/SubProcess.cpp:98

  • The removal of the SetDesktop method is incomplete. The member variable m_desktop (declared at line 58 in SubProcess.h) still exists and is still being used at line 187 in this file (StartupInfo.StartupInfo.lpDesktop = const_cast<LPWSTR>(m_desktop);). Both the member variable declaration and its usage in the Start() method need to be removed to complete this refactoring. Without these changes, lpDesktop will always be set to nullptr (the default value), which may be the intended behavior, but the dead code should be cleaned up.
void SubProcess::SetToken(HANDLE Token)
{
    m_token = Token;
}

@OneBlue OneBlue merged commit 1e3ef15 into master Dec 17, 2025
12 checks passed
benhillis added a commit that referenced this pull request Dec 20, 2025
* cleanup: minor tweaks to path translation failed messages (#13892)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Localization change from build: 135812430 (#13905)

* Localization change from build: 135812430

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* remove unused string

---------

Co-authored-by: WSL localization <noreply@microsoft.com>
Co-authored-by: Ben Hillis <benhillis@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Resolve issue with config file writing sections outside of their expected header. (#13898)

* Resolve issue with config file writing sections outside of their expected header.

* add more writewslconfig variations

* formatting

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Resolve issue with buttons on notifications not working correctly (#13921)

* Resolve issue with buttons on notifications not working correctly

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Fix minor typo in UserConfig.cmake.sample (.exe instead of .dll) (#13926)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* test: extend networking test coverage (#13914)

* test: extend coverage of virtioproxy networking mode

* test: add dns test variations to all networking classes

* remove bridged dns variations

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* cleanup: remove duplicate AppId registration for wsldevicehost.dll (#13928)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* Remove the explicit desktop field when creating a Windows process (#13930)

* [GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR (#13929)

* [GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* test: add more path translation variations (#13927)

* test: add more path translation variations

* Update test/windows/SimpleTests.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* virtiofs: enable additional test cases and skip one racey test (#13933)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* cleanup: add scsi disks during VM creation (#13939)

* cleanup: add scsi disks during VM creation

* pr feedback

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* cleanup: hcs logging improvements (#13942)

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

* cleanup: switch drvfs.cpp to use common MountUtil helper (#13890)

* cleanup: switch drvfs.cpp to use common MountUtil helper

* adjust mount.drvfs error logging

* adjust mount.drvfs error logging

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

---------

Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Co-authored-by: Blue <OneBlue@users.noreply.github.com>
Co-authored-by: WSL localization <noreply@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@benhillis benhillis deleted the user/oneblue/desktop branch April 23, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants