Featured Posts

HDDPhysic v1.1.0 is released! Today we've released a new updated version of HDDPhysic (v1.1.0) Here is what’s new in this version: improved hardware serial extraction in Vista and Windows 7. you don't need to have...

Readmore

Promote software on your website and get paid for it!... Join our affiliates network and get 25% commission on every sale you refer! Become a rlByte Software affiliate today!   To start selling, all you need to do is display product information...

Readmore

Special discount offer: -20% on purchase   Starting from today (27 April 2010 ) we offer a 20% discount for two of our products if they are purchased together: HDDPhysic : get the physical vendor information from the computer hard...

Readmore

Special discount offer: -20% on purchase   Starting from today (27 April 2010 ) we offer a 20% discount for two of our products if they are purchased together: HDDPhysic : get the physical vendor information from the computer hard...

Readmore

Subs Grabber v1.1.0.62 is released!  Today we've released a new updated version of Subs Grabber v1.1.0.62. Here is what's new in this version: Fixed: some utf8 characters doesn't display right in the movie list Modified: working...

Readmore

  • Prev
  • Next

USBPhysic and Win Vista / 7 UAC (workaround)

Posted on : 29-01-2010 | By : rlByte Team | In : USBPhysic

0

This workaround is not required anymore, starting from version 1.1.0 of USBPhysic you don’t need to have your application elevated in Windows Vista or 7, no admin rights required anymore. Now it works even with a guest account type.

Issue:

 Using USBPhysic to query hard drive physical data may fail sometimes on Vista / Windows 7 if UAC (User Account Control) is enabled and calling application is not launched with sufficient rights.

Workaround

 To work around this issue without forcing the user to disable UAC mark your application with a requestedExecutionLevel. To do that you must create and embed an application manifest with your application that tells the operating system what the application needs ( digital signing of the EXE is also a good idea).
This is the format:

<requestedExecutionLevel
level="asInvoker|highestAvailable|requireAdministrator"
uiAccess="true|false"/>

 To mark your application with a requestedExecutionLevel, first create an application manifest file to use with the target application. This file can be created by using any text editor. The application manifest file should have the same name as the target executable file with a .manifest extension. For example: IsUserAdmin.exe.manifest.
Example:

Executable: MyApp.exe
Manifest: MyApp.exe.manifest

Sample application 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="application name" type="win32"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
         <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator"/>
         </requestedPrivileges>
      </security>
   </trustInfo>
</assembly>

Next, you have to attach the application manifest to the executable by adding a line in the resource file of the application (the .rc file) to have Microsoft Visual Studio embed your manifest within the resource section of the PE file. To accomplish this, place the application manifest in the same directory as the source code for the project you are building and edit the resource file to include the following lines:

#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "MyApp.exe.manifest"

 After rebuilding the application, the application manifest should be embedded in the resource section of the executable. Check your exe file with a resource viewer, you should see something like this:



Tags: , , , , , , , , ,


Write a comment