I'm trying to use reflection to have a program look at itself and determine whether a certain control triggers UAC. I'd either like to be able to see that the event handler on the button creates a privileged process or to check whether a given button has the UAC shield enabled on it. Is this possible?
views:
39answers:
2I think this will only be possible by running the control's function and seeing if you get access denied. This is based on consider a control that creates a file in a location defined by its container. Changing the path gives a different answer to the "UAC needed?" question, and the paths than require UAC will also depend on the current user.
If you know what the control does (what system resources it tries to access) and the manifest of the containing application it should be possible to work it out on a case by case basis, but this might end up simply repeating the logic of the OS in cases of the registry, service management and filesystem where different objects have different access.
It should be possible to write something like what you are asking for using cciast.codeplex.com.
CCIAST lets you decompile methods. That way you can find out if the method runs a potentially priviliged process.
But depending on your software it might not produce the results you are hoping for.
Best, if possible, would probably be to refactor to only launch priviliged processes from a small and known set of methods and then use refactoring tools to find how uses them.