Background:
Within my VSPackage I have process.Attach()
instruction. I also have UAC (User Account Control Settings) set to default level:
Use cases:
When I run sample application under admin privileges:
and then attach to such process using my VSPackage from Visual Studio running under lower, current user privileges (non-admin), I get following
COMException
:Which is correct I suppose and indicates I'm not authorized to perform such attach operation.
When I run sample application as current user:
and then attach to it – everything works as expected (debugger is attached). Then if in the second instance of Visual Studio (also started under the same, current, non-admin user) I make an attempt to attach to the same process once again, I get following
COMException
:The HRESULT is the same as before...
Question:
As you can see the HRESULTs are same for these 2 different actions. Why? How to distinguish the fact that in the second case I’m trying to attach to process to which the debugger is already attached (which is different that first case - attaching to process to which we simply have no rights)?