Skip to content
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

Clearly differentiate running elevated vs. drag/drop breaking #14946

Merged
merged 7 commits into from
Mar 17, 2023

Conversation

zadjii-msft
Copy link
Member

Credit where credit is due - @jboelter did literally all the hard work.

I just separated this out to two elements:

  • Are we running elevated?
  • Can we drag drop?

As we learned in #7754, the builtin administrator can drag drop. But critically, they are also running as admin! The way we had this logic before, we're treat them as unelevated, because we had been overloading the meaning here.

This splits these into two separate functions. Comes with the added benefit of re-adding the elevation shield to the Terminal window for users with UAC disabled (which was missing before) (and can still be disabled).

Closes #13928

Tested on a Win10 VM with EnableLua=0

…/drop

Credit where credit is due - @jboelter did literally all the hard work.

I just separated this out to two elements:
* Are we running elevated?
* Can we drag drop?

As we learned in #7754, the builtin administrator _can_ drag drop. But
critically, they are also running as admin! The way we had this logic before,
we're treat them as unelevated, because we had been overloading the meaning
here.

This splits these into two separate functions. Comes with the added benefit of
re-adding the elevation shield to the Terminal window for users with UAC
disabled (which was missing before) (and can _still_ be disabled).

Closes #13928

Tested on a Win10 VM with `EnableLua=0`
@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Windowing Window frame, quake mode, tearout Priority-1 A description (P1) Product-Terminal The new Windows Terminal. labels Mar 3, 2023
@github-actions

This comment has been minimized.

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/types/utils.cpp Outdated Show resolved Hide resolved
src/types/utils.cpp Outdated Show resolved Hide resolved
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 3, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 8, 2023
@NyaMisty
Copy link

Thanks God! Finally someone spotted this!
I've just revesed engineered win32k stuffs and experimented a lot with UIPI.
I was just going to say "New Notepad can drag&drop files perfectly, so why WT can't?", then I found this PR.

But my tests on Windows 11 shows that drag&drop file is still not working (with EnableLUA=0)

@zadjii-msft zadjii-msft requested a review from DHowett March 14, 2023 10:56
@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Mar 17, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Second It's a PR that needs another sign-off label Mar 17, 2023
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Letting you handle merging this in case you want to apply my suggestions.

}
}();

return !isDragDropBroken;
Copy link
Member

Choose a reason for hiding this comment

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

I mean, you did the hard part of writing the logic. Why not remove the double negative by...

  • isDragDropBroken --> canDragDrop
  • L681 false --> true
  • L693 true --> false
  • L697 !isDragDropBroken --> canDragDrop

(pipe the ! into the returned results, basically)

Comment on lines +139 to +140
_isElevated = ::Microsoft::Console::Utils::IsRunningElevated();
_canDragDrop = ::Microsoft::Console::Utils::CanUwpDragDrop();
Copy link
Member

Choose a reason for hiding this comment

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

I guess this kinda isn't relevant to this PR but why do these two members exist? We're using magic statics in Utils, so what's the point in caching these values?

@DHowett DHowett changed the title Clearly differentiate between running elevated and being able to drag/drop Clearly differentiate running elevated vs. drag/drop breaking Mar 17, 2023
@DHowett DHowett merged commit c5c15e8 into main Mar 17, 2023
@DHowett DHowett deleted the dev/migrie/b/13928-can-drag-drop branch March 17, 2023 22:01
@DHowett
Copy link
Member

DHowett commented Mar 17, 2023

(I chose to merge without seeing your comments -- @zadjii-msft, mind tracking them?)

DHowett pushed a commit that referenced this pull request May 15, 2023
Credit where credit is due - @jboelter did literally all the hard work.

I just separated this out to two elements:
* Are we running elevated?
* Can we drag drop?

As we learned in #7754, the builtin administrator _can_ drag drop. But
critically, they are also running as admin! The way we had this logic
before, we're treat them as unelevated, because we had been overloading
the meaning here.

This splits these into two separate functions. Comes with the added
benefit of re-adding the elevation shield to the Terminal window for
users with UAC disabled (which was missing before) (and can _still_ be
disabled).

Closes #13928

Tested on a Win10 VM with `EnableLua=0`

(cherry picked from commit c5c15e8)
Service-Card-Id: 88484047
Service-Version: 1.17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Windowing Window frame, quake mode, tearout Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run as Admin shortcut + elevate:true -> crash loop
4 participants