Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requested Execution Level for a dll

I've got a WinForms application that I am working on. There is one small piece of functionality that needs to be run as an administrator in Vista/Win7. I understand how I can set the requestedExecutionLevel for the application in the manifest. The trick is, I don't want to require the user to run the entire application as an administrator, just one part of it. So I would like to have most of the functionality run asInvoker.

If I put the admin functionality in a dll, is there a way to mark it as requireAdministrator? I tried to use MT to add a manifest to the dll, but that didn't seem to work. What do I need to do?

like image 499
epotter Avatar asked Dec 10 '09 18:12

epotter


2 Answers

No there is no way to differentiate the execution level of an application on a DLL by DLL basis. This is a process wide setting. You'd have to invoke another process within your application that runs the code in that DLL with elevated privs.

One option you do have though is to use either the rundll or rundll32 program to run the DLL directly. This is a standalone windows program designed to load and run a particular DLL. You could elevate the rundll process and get the isolation you desire.

Googling for rundll will give you plenty of advice on how to use it :).

like image 162
JaredPar Avatar answered Nov 20 '22 07:11

JaredPar


Elevation is per-process, so you can't have a DLL elevated by itself. You need to look at hosting the DLL in a separate, elevated process; or you can look at the elevation COM moniker, and do it that way.

like image 3
Roger Lipscombe Avatar answered Nov 20 '22 05:11

Roger Lipscombe