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

Unable to drag/drop a file to terminal with UAC turned off #7754

Closed
Genesis-Nova opened this issue Sep 27, 2020 · 16 comments · Fixed by #11221
Closed

Unable to drag/drop a file to terminal with UAC turned off #7754

Genesis-Nova opened this issue Sep 27, 2020 · 16 comments · Fixed by #11221
Assignees
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.

Comments

@Genesis-Nova
Copy link

Genesis-Nova commented Sep 27, 2020

Windows Version
10.0.19042.0
Terminal Version
1.3.2651

Any other software?
None open at the time

Steps to reproduce

Run windows terminal as administrator.
Try to drag a file/folder into the terminal to copy its path to the terminal window.
Does not work.

Expected behavior

I expected drag and drop for files/folders into the terminal window to behave the same as a command prompt or powershell window, both behave as expected in non-admin or administrator permission instances of the aforementioned programs.

Actual behavior

Path does not get copied during drag and drop into the terminal window, I just get the "deny" "not allowed" cursor icon when trying, unsure if this is related to the ongoing issue of being unable to rearrange tabs while in an admin window or not as seen in #6661

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 27, 2020
@Genesis-Nova Genesis-Nova changed the title Unable to drag/drop a file/folder to an elevated Unable to drag/drop a file/folder to an elevated instance of terminal Sep 27, 2020
@DHowett
Copy link
Member

DHowett commented Sep 28, 2020

This is standard across the entire OS. Unfortunately, the only accepted way to get a file path into an elevated application (even notepad!) is by using the clipboard (in Terminal's case) or the File>Open dialog.

@DHowett DHowett closed this as completed Sep 28, 2020
@DHowett DHowett closed this as completed Sep 28, 2020
@DHowett DHowett added Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered and removed Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 28, 2020
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Sep 28, 2020
@DHowett DHowett added Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. and removed Needs-Tag-Fix Doesn't match tag requirements labels Sep 28, 2020
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Sep 28, 2020
@DHowett DHowett added the Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. label Sep 28, 2020
@DHowett
Copy link
Member

DHowett commented Sep 28, 2020

This is a security measure implemented in Windows itself -- drag/drop is a form of messaging between applications, and messaging between non-admin and admin windows is very restricted.

@DHowett DHowett removed Resolution-Answered Related to questions that have been answered Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. labels Sep 28, 2020
@Genesis-Nova
Copy link
Author

Well like in the ticket I listed, 6661, I'm running with uac off so there is no integrity level separation so I just thought I'd bring it up.

@DHowett
Copy link
Member

DHowett commented Sep 29, 2020

Interesting! That would have been important to mention. I'll reopen this while we think about what's intended behavior.

@DHowett DHowett reopened this Sep 29, 2020
@DHowett DHowett added the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Oct 1, 2020
@zadjii-msft zadjii-msft changed the title Unable to drag/drop a file/folder to an elevated instance of terminal Unable to drag/drop a file to terminal with UAC turned off Oct 1, 2020
@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. and removed Issue-Question For questions or discussion Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. labels Oct 1, 2020
@ghost ghost closed this as completed in #11221 Sep 16, 2021
@ghost ghost removed the In-PR This issue has a related PR label Sep 16, 2021
ghost pushed a commit that referenced this issue Sep 16, 2021
When we're elevated, we disable drag/dropping tabs when elevated, because of a platform limitation that causes the app to _crash_ (see #4874). However, if the user has UAC disabled, this actually works alright. So I'm adding it back in that case.

I'm not positive if this is the best way to check if UAC is disabled, but normally, you'll get a [`TokenElevationTypeFull`] when elevated, not `TokenElevationTypeDefault`. If the app is elevated, but there's not a split token, that kinda implies there's no user account separation. If I'm wrong, it's just code, let's replace this with something that does work.

## Validation Steps Performed

Booted up a Win10 VM, set `enableLUA` to `0`, rebooted, and checked if this exploded. It didn't.

References #4874 
References #3581
Work done in pursuit of #11096
Closes #7754

[`TokenElevationTypeFull`]: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-token_elevation_type
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Sep 16, 2021
@ghost
Copy link

ghost commented Oct 20, 2021

🎉This issue was addressed in #11221, which has now been successfully released as Windows Terminal Preview v1.12.2922.0.:tada:

Handy links:

@zadjii-msft zadjii-msft removed this from the Terminal v2.0 milestone Jan 12, 2022
@zadjii-msft zadjii-msft added Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. and removed Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. labels Jan 12, 2022
@bpsib
Copy link

bpsib commented Jan 15, 2023

Using version 1.15.3466.0 in Windows 11 but this issue has NOT been fixed. Rearranging tabs with UAC disabled works but not drag and dropping files.

#11221 only mentions allowing reordering of tabs with UAC disabled in the title but states it also fixes this issue. Maybe some regression somewhere?

zadjii-msft added a commit that referenced this issue Mar 3, 2023
…/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`
@NyaMisty
Copy link

NyaMisty commented Mar 13, 2023

We should reopen this issue!

@bpsib has already said that this problem should be divided into 2 parts: dragging TABS & dragging FILES.

I can also confirm, on Windows 11, all the way from 22000.XXX to latest 25309, dragging files to Windows Terminal NEVER worked.

We don't know why @zadjii-msft closed this issue last year, but currently I highly doubt this problem is Windows Terminal-specific: The New Notepads uses exactly the same Tab pages provided by WinUI3, and it support drag & drop files under EnableLUA=0 out of box.

PS1: I've debugged the Windows Terminal, the DragOver callback never triggers under EnableLUA=0
PS2: New Notepad does not uses DataExchangeHost, it's receiving WM_DROPFILES and using DragQueryFile to handle the file dropping

DHowett pushed a commit that referenced this issue Mar 17, 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`
DHowett pushed a commit that referenced this issue 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
@antnesswcm
Copy link

antnesswcm commented Jul 19, 2023

My environment:

wt 1.17.230526001 zip version

uac dragged to the bottom

EnableLUA=0

Run profile as administrator (even if this option is not enabled, it still runs as administrator, possibly because I turned off EnableLUA)

I still can't drag files, it shows the prohibited symbol.

Is this issue resolved?

@zadjii-msft
Copy link
Member

@antnesswcm I'm pretty sure this was more correctly fixed in #14946, which was shipped in 1.18.

@NyaMisty
Copy link

@zadjii-msft Let me explain "more correctly fixed" more precisely.

The #14946 fixes drag & drop initiatied from Windows Terminal (e.g. drag & drop tabs).

But it DOES NOT fix the case when user drags files from other application to Windows Terminal.

AFAIK, this is problem in Windows.UI.Xaml, which DataExchangeHost refuses to pass on drag event, even if there's actually no limitation.

Here I sincerely ask for @zadjii-msft 's help:

  1. Previous discussion on DataExchangeHost was talking about cases where UAC-enabled & user requested elevation, but in our case, user directly turned off the whole UAC
    • The difference is, when UAC enabled, the drag should be forbidden, which is also what UIPI does
    • But when UAC disabled, UIPI will be fully turned off, but DataExchangeHost won't sync with UIPI's state, even UIPI get turned off in kernel, DataExchangeHost still refuses drag request as if UAC was still on.
  2. The key problem in this case was to make DataExchangeHost pass the drag event unconditionally when UAC disabled. I know that has nothing to do with WindowsTerminal, and required updates to OS itself. So I need someone inside MSFT to push the progress :)

@NyaMisty
Copy link

NyaMisty commented Jul 19, 2023

Also I've pinpointed the problem & made a hook fix:

https://github.com/NyaMisty/PunchDataExchangeHost

With this, DataExchangeHost will be able to properly handle drag requests even when UAC disabled.

@antnesswcm probably you can also have a try

@Genesis-Nova
Copy link
Author

Also I've pinpointed the problem & made a hook fix:

https://github.com/NyaMisty/PunchDataExchangeHost

With this, DataExchangeHost will be able to properly handle drag requests even when UAC disabled.

@antnesswcm probably you can also have a try

This is fantastic @NyaMisty, works perfectly in my limited testing.

@spudpiggy
Copy link

I run terminal as admin (I'm on Windows 10, version 22H2/build 19045.4046), and can confirm that this is broken even if UAC is on. I was literally just looking it up to see if anyone had a solution.

@i486
Copy link

i486 commented Jun 9, 2024

It still doesn't work.

@Genesis-Nova
Copy link
Author

Also I've pinpointed the problem & made a hook fix:

https://github.com/NyaMisty/PunchDataExchangeHost

With this, DataExchangeHost will be able to properly handle drag requests even when UAC disabled.

@antnesswcm probably you can also have a try

Would recommend anyone having the drag-drop issue try this.
This is in no way, shape, or form related to dragging tabs, this is related to dragging files into terminal and having it work as it does for a normal cmd or powershell window.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants