-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable auto-elevation for a profile, redux #11310
Closed
zadjii-msft
wants to merge
23
commits into
dev/migrie/f/non-terminal-content-elevation-warning
from
dev/migrie/f/632-on-warning-dialog
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
efe42d1
stunned that this remotely works as well as it does
zadjii-msft abc0265
marginally reduce the risk of a merge conflict
zadjii-msft 974d18a
Merge remote-tracking branch 'origin/main' into dev/migrie/f/632-on-w…
zadjii-msft 8b8de52
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 8895e06
these are notes, but they're useless who tf am I kidding
zadjii-msft 9b1e30b
I can't believe how dumb this is (or how well it works)
zadjii-msft 904045b
Tons of comments
zadjii-msft 28bde43
Works with splitting panes again
zadjii-msft c2b759e
stick these projects in a utils folder because it's getting crowded
zadjii-msft 571b8a9
Merge remote-tracking branch 'origin/dev/migrie/f/non-terminal-conten…
zadjii-msft 4bcdfc3
This should have been in the parent
zadjii-msft 6717b4d
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft ab78ad4
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 8d7f726
spel
zadjii-msft 88da035
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 80fe386
tiny nits
zadjii-msft 7597114
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft fdd283d
other pr nits, test comments
zadjii-msft ebef341
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 370a7aa
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 3d41cba
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 1b4efad
Merge branch 'dev/migrie/f/non-terminal-content-elevation-warning' in…
zadjii-msft 7a3ec1e
Fix this test
zadjii-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include <string> | ||
zadjii-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#include <filesystem> | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
#include <wil/stl.h> | ||
#include <wil/resource.h> | ||
#include <wil/win32_helpers.h> | ||
#include <shellapi.h> | ||
|
||
// BODGY | ||
// | ||
// If we try to do this in the Terminal itself, then there's a bunch of weird | ||
// things that can go wrong and prevent the elevated Terminal window from | ||
// getting created. Specifically, if the origin Terminal exits right away after | ||
// spawning the elevated WT, then ShellExecute might not successfully complete | ||
// the elevation. What's even more, the Terminal will mysteriously crash | ||
// somewhere in XAML land. | ||
// | ||
// To mitigate this, the Terminal will call into us with the commandline it | ||
// wants elevated. We'll hang around until ShellExecute is finished, so that the | ||
// process can successfully elevate. | ||
|
||
#pragma warning(suppress : 26461) // we can't change the signature of wWinMain | ||
int __stdcall wWinMain(HINSTANCE, HINSTANCE, LPWSTR pCmdLine, int) | ||
{ | ||
// All of the args passed to us (something like `new-tab -p {guid}`) are in | ||
// pCmdLine | ||
|
||
// Get the path to WindowsTerminal.exe, which should live next to us. | ||
std::filesystem::path module{ wil::GetModuleFileNameW<std::wstring>(nullptr) }; | ||
// Swap elevate-shim.exe for WindowsTerminal.exe | ||
module.replace_filename(L"WindowsTerminal.exe"); | ||
|
||
// Go! | ||
SHELLEXECUTEINFOW seInfo{ 0 }; | ||
seInfo.cbSize = sizeof(seInfo); | ||
seInfo.fMask = SEE_MASK_DEFAULT; | ||
seInfo.lpVerb = L"runas"; // This asks the shell to elevate the process | ||
seInfo.lpFile = module.c_str(); // This is `...\WindowsTerminal.exe` | ||
seInfo.lpParameters = pCmdLine; // This is `new-tab -p {guid}` | ||
seInfo.nShow = SW_SHOWNORMAL; | ||
LOG_IF_WIN32_BOOL_FALSE(ShellExecuteExW(&seInfo)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Microsoft Visual C++ generated resource script. | ||
// | ||
#include "resource.h" | ||
|
||
#define APSTUDIO_READONLY_SYMBOLS | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 2 resource. | ||
// | ||
#include "winres.h" | ||
///////////////////////////////////////////////////////////////////////////// | ||
#undef APSTUDIO_READONLY_SYMBOLS | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// English (United States) resources | ||
|
||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
#pragma code_page(1252) | ||
|
||
#ifdef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// TEXTINCLUDE | ||
// | ||
|
||
1 TEXTINCLUDE | ||
BEGIN | ||
"resource.h\0" | ||
END | ||
|
||
2 TEXTINCLUDE | ||
BEGIN | ||
"#include ""winres.h""\0" | ||
END | ||
|
||
3 TEXTINCLUDE | ||
BEGIN | ||
"\r\n" | ||
"\0" | ||
END | ||
|
||
#endif // APSTUDIO_INVOKED | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Icon | ||
// | ||
|
||
// Icon with lowest ID value placed first to ensure application icon | ||
// remains consistent on all systems. | ||
IDI_APPICON ICON "..\\..\\..\\res\\terminal.ico" | ||
|
||
#endif // English (United States) resources | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
||
#ifndef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 3 resource. | ||
// | ||
|
||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#endif // not APSTUDIO_INVOKED | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{416fd703-baa7-4f6e-9361-64f550ec8fca}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>elevate-shim</RootNamespace> | ||
<ProjectName>elevate-shim</ProjectName> | ||
<TargetName>elevate-shim</TargetName> | ||
<ConfigurationType>Application</ConfigurationType> | ||
</PropertyGroup> | ||
|
||
<Import Project="..\..\..\common.openconsole.props" Condition="'$(OpenConsoleDir)'==''" /> | ||
<Import Project="$(OpenConsoleDir)src\common.build.pre.props" /> | ||
|
||
<!-- Source Files --> | ||
<ItemGroup> | ||
<ClCompile Include="elevate-shim.cpp"> | ||
<PrecompiledHeader>NotUsing</PrecompiledHeader> | ||
</ClCompile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ResourceCompile Include="elevate-shim.rc" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$(OpenConsoleDir)src\common.build.post.props" /> | ||
|
||
<ItemDefinitionGroup> | ||
<Link> | ||
<!-- Remove all non-onecore dependencies --> | ||
<AdditionalDependencies>onecore.lib</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//{{NO_DEPENDENCIES}} | ||
// Microsoft Visual C++ generated include file. | ||
// Used by wt.rc | ||
// | ||
#define IDI_APPICON 101 | ||
|
||
// Next default values for new objects | ||
// | ||
#ifdef APSTUDIO_INVOKED | ||
#ifndef APSTUDIO_READONLY_SYMBOLS | ||
#define _APS_NEXT_RESOURCE_VALUE 102 | ||
#define _APS_NEXT_COMMAND_VALUE 40001 | ||
#define _APS_NEXT_CONTROL_VALUE 1001 | ||
#define _APS_NEXT_SYMED_VALUE 101 | ||
#endif | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check if we want to remove any of these. I'm not sure what configs we want for
elevate-shim