[PR #15327] Slim down shell extension and elevate-shim #30595

Closed
opened 2026-01-31 09:41:45 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15327

State: closed
Merged: Yes


This simplifies the code (from the perspective of the CPU) by doing
some miniscule-feels-good optimizations like replacing snprintf with
regular string concatenation and by doing an actual optimization by
removing the remaining calls to the WinRT ApplicationModel namespace.

More importantly however it fixes a bug: The only reason elevate-shim
worked at all is because the shell extension passed "wrong" parameters
to CreateProcess. Instead of repeating the application path in the
command line argument again, as is convention in C and on Windows, and
getting the 2nd and following parameters as an argument to wWinMain,
it used GetCommandLineW to get the original, broken command line.
This fixes the issue by passing the application path as the first
argument, which allows elevate-shim to be called like any other app.

Validation Steps Performed

  • Deploy WT and restart explorer
  • Clicking "Open in Terminal (Dev)" works
  • Clicking "Open in Terminal (Dev)" while holding Ctrl+Shift
    opens WT as admin
**Original Pull Request:** https://github.com/microsoft/terminal/pull/15327 **State:** closed **Merged:** Yes --- This simplifies the code (from the perspective of the CPU) by doing some miniscule-feels-good optimizations like replacing `snprintf` with regular string concatenation and by doing an actual optimization by removing the remaining calls to the WinRT `ApplicationModel` namespace. More importantly however it fixes a bug: The only reason `elevate-shim` worked at all is because the shell extension passed "wrong" parameters to `CreateProcess`. Instead of repeating the application path in the command line argument again, as is convention in C and on Windows, and getting the 2nd and following parameters as an argument to `wWinMain`, it used `GetCommandLineW` to get the original, broken command line. This fixes the issue by passing the application path as the first argument, which allows `elevate-shim` to be called like any other app. ## Validation Steps Performed * Deploy WT and restart explorer * Clicking "Open in Terminal (Dev)" works ✅ * Clicking "Open in Terminal (Dev)" while holding Ctrl+Shift opens WT as admin ✅
claunia added the pull-request label 2026-01-31 09:41:45 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30595