• 11
• 27
• 9
• 20
• 31

# dll with higher execution level on Windows7 (VS2005)

This topic is 2922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I have a dll that I distribute to people writing applications using the functions from that dll. When such an application is normally started in Windows7, some dll functions fail to execute (e.g. retrieve the HDD serial). However if that same application is started with the "execute as administrator" right mouse popup then everything works fine. What I now want to do is elevate the execution level of my dll. I searched the net and found that I should use a manifest file and embed it into my resource file. This however didn't change anything. I am wondering if I missed an important point? Here is what I have: my dll: v_rep.dll my manifest file (in the source directory): v_rep.dll.manifest This is the manifest file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="v_rep.app" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>


in my v_rep.rc file, I added following 2 lines:
#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "v_rep.dll.manifest"


That resource now appears in the "regular" resource viewer. It compiles without error, but I don't get elevated execution level. What did I do wrong? By the way I am using c++ and VS2005 Thanks for any help

##### Share on other sites
You can't elevate a DLL. Only processes can be elevated. A dll runs with whatever the priviledge level the host process has.

##### Share on other sites

That is annoying.. is there a way I could check if the client application is in elevated mode?

##### Share on other sites
I have not done this myself, but perhaps within your dll you could launch a new process with elevated permissions. Do what you need to do in that process, and then return.

My guess would be that when you do this, you'll get a UAC prompt the moment your dll starts the process (which seems perfectly natural to me, and fully exemplifies the reason UAC is helpful - it alerts the user when a program enters a high execution level).

##### Share on other sites
Thank you for the informations.

Actually I was using a third-party HDD serial number retrieving library that needs higher privileges under vista/7. I am wondering why this is so damn complicated to retrieve a simple serial number, even when using a professional library... I am wondering how most people do that (besides using the volume serial number).

##### Share on other sites
If any libraries in your program use anything that requires elevation, than the EXE itself has to request elevation at startup. That's the only way to really go about it.

if your EXE wasn't written to support UAC and you don't have the source code for it, then just right click it and choose Run as Administrator

##### Share on other sites
Quote:
 Original post by floatingwoodsActually I was using a third-party HDD serial number retrieving library that needs higher privileges under vista/7. I am wondering why this is so damn complicated to retrieve a simple serial number, even when using a professional library... I am wondering how most people do that (besides using the volume serial number).

Retrieving the actual hardware serial of a HDD requires a surprising amount of hacking. It requires several IOCTL calls, some retrieved by trial end error, because not all HDD models support the same calls. Acquiring a device handle for ioctl requires admin privileges under Vista/W7.

The less evil way of doing this is supposedly through WMI. But this almost always fails, the HDD serial is either empty or contains garbage. Same is true for the chipset / mainboard serial.

For all practical purposes, using HDD serials for licensing purposes doesn't work anymore under Vista/W7. You need a different system.