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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/15327
Author: @lhecker
Created: 5/10/2023
Status: Merged
Merged: 8/9/2024
Merged by: @lhecker

Base: mainHead: dev/lhecker/simplify-shell-extension


📝 Commits (2)

  • 9350316 Slim down shell extension and elevate-shim
  • 9582213 Merge remote-tracking branch 'origin/main' into dev/lhecker/simplify-shell-extension

📊 Changes

4 files changed (+54 additions, -68 deletions)

View changed files

📝 src/cascadia/ElevateShim/elevate-shim.cpp (+29 -47)
📝 src/cascadia/ShellExtension/OpenTerminalHere.cpp (+11 -12)
📝 src/cascadia/ShellExtension/pch.h (+4 -6)
📝 src/cascadia/WinRTUtils/inc/WtExeUtils.h (+10 -3)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/15327 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 5/10/2023 **Status:** ✅ Merged **Merged:** 8/9/2024 **Merged by:** [@lhecker](https://github.com/lhecker) **Base:** `main` ← **Head:** `dev/lhecker/simplify-shell-extension` --- ### 📝 Commits (2) - [`9350316`](https://github.com/microsoft/terminal/commit/935031685b74cacd2682c795d1098a5a7ffb4eef) Slim down shell extension and elevate-shim - [`9582213`](https://github.com/microsoft/terminal/commit/9582213fe79bd3130b7e957806c78fe5e614db24) Merge remote-tracking branch 'origin/main' into dev/lhecker/simplify-shell-extension ### 📊 Changes **4 files changed** (+54 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/ElevateShim/elevate-shim.cpp` (+29 -47) 📝 `src/cascadia/ShellExtension/OpenTerminalHere.cpp` (+11 -12) 📝 `src/cascadia/ShellExtension/pch.h` (+4 -6) 📝 `src/cascadia/WinRTUtils/inc/WtExeUtils.h` (+10 -3) </details> ### 📄 Description 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 ✅ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:41:44 +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#30590