AceInfinity
Emeritus, Contributor
Alright, so I ran into this a few times, but at first I was not sure what was going on. I most recently had this issue with AutoBSA++, because I need this program to be invoked with administrator privileges...
The issue is with dragging and dropping.
The culprit is an aspect of UAC called UIPI (User Interface Privilege Isolation); it prevents unelevated programs from hijacking resources from an elevated one, and so interaction with dragging and dropping is also affected. Microsoft claims that it is an important security feature however, so the only thing you can do is learn about how to bypass this.
This is because UIPI blocks windows messages being sent from a process with a lower MIC level to another running at a higher MIC level. Drag and drop is implemented by Windows Messages however, so if you try to do anything involving a drag and drop from Windows Explorer for instance, which has a medium MIC (lower than a high MIC is the significant part here), then the messages are blocked, and the drag-drop action will not succeed, because it was never interpreted in the first place to take any action.
The answer to bypassing it is the ChangeWindowMessageFilter() function from user32.dll.
OLE drag and drop does not use Windows Messages however, but callbacks. If you review this link for RegisterDragDrop() it is evident, since you can only register one window at a time: RegisterDragDrop function (COM)
Here is the significant message I found: WM_DROPFILES message (Windows)
Information on this "feature" is found in this blog post by MSFT: Q: Why Doesn?t Drag-and-Drop work when my Application is Running Elevated? ? A: Mandatory Integrity Control and UIPI - Pat's Windows Development Blog - Site Home - MSDN Blogs
It's a bit ironic, as much as frustrating, that when you invoke the program with a higher level of permissions that you are given a more strict limitation as to what you can do in this regard.
Here is the end-all-be-all solution that the article gives:
Now, as a developer, that is completely useless to me I have to say... And as long as UAC is enabled, Explorer will run at medium MIC. Perhaps there are people out there using my program that will not understand why this is so, and perhaps they don't want to disable UAC however?
So they basically just say that you're screwed unless you just don't run the program as administrator, which will inevitably invoke the program to run with a higher MIC than explorer.exe (assuming UAC is enabled).
I spent so much time with hit testing and control transparency for click actions on the control here: FileDropTextBox Class... Which was added to my AutoBSA++ project to figure out why it did not work, and I couldn't see why it wouldn't work. Everything between my test project and my AutoBSA++ project during the tests seemed the exact same, but in my AutoBSA++ program, the drag drop wasn't working, this sparked in my head about elevated privileges, and after some searching I found this information.
I still need to actually test this... But at least now I know what's going on. I spent the last hour learning about MIC and UIPI. I think this is something that needs to be reconsidered in future versions of Windows...
The issue is with dragging and dropping.
The culprit is an aspect of UAC called UIPI (User Interface Privilege Isolation); it prevents unelevated programs from hijacking resources from an elevated one, and so interaction with dragging and dropping is also affected. Microsoft claims that it is an important security feature however, so the only thing you can do is learn about how to bypass this.
This is because UIPI blocks windows messages being sent from a process with a lower MIC level to another running at a higher MIC level. Drag and drop is implemented by Windows Messages however, so if you try to do anything involving a drag and drop from Windows Explorer for instance, which has a medium MIC (lower than a high MIC is the significant part here), then the messages are blocked, and the drag-drop action will not succeed, because it was never interpreted in the first place to take any action.
The answer to bypassing it is the ChangeWindowMessageFilter() function from user32.dll.
OLE drag and drop does not use Windows Messages however, but callbacks. If you review this link for RegisterDragDrop() it is evident, since you can only register one window at a time: RegisterDragDrop function (COM)
Here is the significant message I found: WM_DROPFILES message (Windows)
Information on this "feature" is found in this blog post by MSFT: Q: Why Doesn?t Drag-and-Drop work when my Application is Running Elevated? ? A: Mandatory Integrity Control and UIPI - Pat's Windows Development Blog - Site Home - MSDN Blogs
It's a bit ironic, as much as frustrating, that when you invoke the program with a higher level of permissions that you are given a more strict limitation as to what you can do in this regard.
Here is the end-all-be-all solution that the article gives:
The best solution is to only use drag and drop between the same MIC levels.
Now, as a developer, that is completely useless to me I have to say... And as long as UAC is enabled, Explorer will run at medium MIC. Perhaps there are people out there using my program that will not understand why this is so, and perhaps they don't want to disable UAC however?
So they basically just say that you're screwed unless you just don't run the program as administrator, which will inevitably invoke the program to run with a higher MIC than explorer.exe (assuming UAC is enabled).
I spent so much time with hit testing and control transparency for click actions on the control here: FileDropTextBox Class... Which was added to my AutoBSA++ project to figure out why it did not work, and I couldn't see why it wouldn't work. Everything between my test project and my AutoBSA++ project during the tests seemed the exact same, but in my AutoBSA++ program, the drag drop wasn't working, this sparked in my head about elevated privileges, and after some searching I found this information.
I still need to actually test this... But at least now I know what's going on. I spent the last hour learning about MIC and UIPI. I think this is something that needs to be reconsidered in future versions of Windows...