views:

196

answers:

2

I'm trying to figure out if there's a way to use SetWindowsHookEx and be able to affect apps that are run with Admin rights on Vista, with UAC enabled. This is an app that will need to add a small button to the caption bar of other windows to enable some multi-monitor-aware handling. I would have thought this couldn't be done, but I've seen one app that appears to do this. As far as I can tell, this other apps is not being run with Admin rights, and yet it can affect all apps in the system, including those with Admin privilege.

It would seem that there's a way to do this, then, but I'm at a loss on how. My app only needs to be able to draw on window title bars and be able to affect their movement and size. I don't need to do anything else.

+1  A: 

You can't, as administrative processes are isolated from non-administrative processes running on the same user desktop. You can't even drag and drop between admin and non-admin processes.

This is an in-dept analysis: http://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx

About the application you are referencing, it probably uses some administrative code running in background (usually as a service) so it can interact with administrative processes.

Lorenzo
A: 

Lorenzo,

Thanks, I realize that. If I hadn't seen this other app do it, I would've thought it was impossible, too. I checked fairly carefully on this app, and as far as I can tell:

1) It use a hook, although I haven't tried to figure out which hook(s) exactly

2) It doesn't seem to use any services. At least, I don't see any new services loaded either while it's running, or after it was installed.

I guess I may just have to do more analysis on it to see if I can find out how it's managing this. Maybe it can load up a dynamic service briefly to get admin rights so it can load its hook? But whatever it's doing, it doesn't cause any UAC prompts to appear.

Warner Young
Okay, I now have some idea on this. It looks like if you do the following, you can essentially get the desired results:1) Make sure you have 'level="asInvoker"' and 'uiAccess="true"' in your application manifest.2) Digitally sign your app.3) Make sure the certificate you use is in the trusted store.4) Install the app to a trusted directory, like Program Files or Windows.When the app is run, it will be silently elevated to Admin status without a UAC prompt.
Warner Young