Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

1. I have created a project on Windows 7 and part of this project I have created one C++ application and C++ DLL. In DLL I have the logic which needs admin privileges to get executed.

2. I want to run my application always with standard user privileges and I would want to load my dll from my application with elevated access, So that whenever I load the DLL, user should be prompted for admin credentials.

My first question is, is it possible to load a DLL with elevated access from a application with standard admin privileges?

And I need help on how to create a manifest for my DLL.

Thanks,
Arjun
Posted

I am not sure about the first question, but you can add the privilege level to your DLL from the Linker options in the Project Properties. A quick test should be able to answer your first question.
 
Share this answer
 
Elevation is a property of a process.
If an EXE is already running without elevation, the process has already been created and loading a DLL whose linker option is set to requireAdministrator will have no effect or will be ignored by the loader.

One way to do what you want would be to start another elevated process and then communicate between both processes using a named pipe. This way the elevated process can perform elevated tasks on behalf of the requesting process.
 
Share this answer
 
Comments
Richard MacCutchan 22-Oct-11 6:35am    
Thanks, I had a feeling this was the answer but did not have time to confirm it.
Arjun Annam 24-Oct-11 2:34am    
Thanks Santosh for your solution.

Santosh, from your answer "If the process has already been created and loading a DLL whose linker option is set to requireAdministrator will have no effect or will be ignored by the loader."

That's right and and "If the process has already been created with admin privileges and loading a DLL whose linker option is set to requireAdministrator will load the the library with admin privileges without asking the user for access elevation."

Then in which all scenarios, "linker option as requireAdministrator for a DLL" will be useful.

Thanks,
Arjun
«_Superman_» 25-Oct-11 7:12am    
This option is not useful for a DLL. The only use I can think of is an EXE querying this property to check if the DLL needs to be loaded elevated and then invoke a process with the necessary privileges.
Arjun Annam 6-Nov-11 4:01am    
Thanks Santosh, As you suggested I'm invoking a new process to perform the tasks which need admin privileges.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900