views:

305

answers:

1

I have an ActiveX control that I'm loading with JavaScript in Internet Explorer. It needs to run as medium integrity under UAC in Vista and Win7. This is written in C/C++, compiled in Visual Studio.

One way to elevate privileges is to create a broker process that can request a medium integrity level. However, for this project, this is not a practical solution. I really need the ActiveX control itself to run elevated.

My question is: what's the easiest way to do this? Can I change the build options on the project to be an exe, and use the COM interprocess connect system to automatically handle the communications, or do I need to be more sophisticated? Do I need to do anything complicated like manually call CreateProcess and make some kind of broker, or can it just work as an ActiveX exe that elevates itself?

+1  A: 

It mostly depends what your ActiveX control does, how you embed it in a page and how it is implemented.

The simplest approach would probably be to implement it as a server EXE, register it as appropriate and then give the executable permissions to run at medium in the Low Rights Elevation Policy.

If you don't want to go that far you could write a simple custom out-of-process server which again you register and you implement your own IClassFactory to proxy creation requests into the existing DLL. You could even add an AppID key for your existing object and specify it is a DllSurrogate though (other than registering it as a COM+ application) you might not be easily able to force creation of the object in the surrogate (because the default for IE is to specify CLSCTX_ALL when creating objects which will pick up the in-process registration first).

Of course after all that if your code makes too many assumptions about where it is or uses any non-proxied interfaces it might not work anyway.

tyranid