microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.27k stars 8.27k forks source link

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

Closed Genesis-Nova closed 3 years ago

Genesis-Nova commented 4 years ago

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

DHowett commented 4 years ago

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 commented 4 years ago

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.

Genesis-Nova commented 4 years ago

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 commented 4 years ago

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

zadjii-msft commented 3 years ago

@Genesis-Nova Hey just to be sure I'm fixing this correctly, how did you disable UAC? Just by sliding the User Account Control slider all the way down, or by setting EnableLUA to 0 in the registry? I think I have a way to detect the second scenario, but not the first.

ghost commented 2 years ago

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

Handy links:

bpsib commented 1 year ago

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?

NyaMisty commented 1 year ago

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

antnesswcm commented 1 year ago

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 commented 1 year ago

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

NyaMisty commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 7 months ago

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 commented 4 months ago

It still doesn't work.

Genesis-Nova commented 2 months ago

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.