Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Assembly Manifest file to .exe file created with NetBeans IDE C++ MinGW

How to add Assembly Manifest file to .exe file created with NetBeans IDE using MinGW, C++? The file looks like (just an example):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="7.0.0.0"
   processorArchitecture="X86"
   name="nbexec.exe"
   type="win32"/>

<description>nbexec Process.</description>
<dependency>
  <dependentAssembly>
    <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="*"
      publicKeyToken="6595b64144ccf1df"
      language="*"
    />
  </dependentAssembly>
</dependency>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel
        level="asInvoker"
        uiAccess="false"/>
      </requestedPrivileges>
     </security>
</trustInfo>
</assembly>

How can I include this information in EXE file?

The problem is that in Windows Vista the file is marked with UAC sign, but it is digitally signed. And I'm asked to confirm to let it execute every time I launch it..

I found such explanation here: "Firstly, you must create an XML manifest specifying that version 6 of the Windows common controls library must be loaded by Windows, and embed it into your application as a resource with type “RT_MANIFEST” (actually, if you prefer you can name the manifest “[application name].exe.manifest” and include it in the same directory as the exe, rather than embedding it as a resource, but that does have the disadvantage that it can become accidentally deleted or corrupted)."

like image 735
Ernestas Gruodis Avatar asked Mar 12 '15 07:03

Ernestas Gruodis


1 Answers

Found the answer myself, maybe it will be useful for others too.

Actions:

  1. Create header file ids.h
#ifndef RESOURCE_H
#define   RESOURCE_H

#ifdef    __cplusplus
extern "C" {
#endif

#define IDI_ICON_128  101

#ifdef    __cplusplus
}
#endif

#endif    /* RESOURCE_H */

#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 /*Defined manifest file*/
#define RT_MANIFEST                       24
  1. Create resource file resource.rc and include ids.h
#include "ids.h" 

CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "Some.exe.manifest"

IDI_ICON_128 ICON "SomeIcon.ico"

1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "080904E4"
    BEGIN
      VALUE "CompanyName", "Some company"
      VALUE "FileDescription", "Some description"
      VALUE "FileVersion", "1.0"
      VALUE "InternalName", "Some file name"
      VALUE "LegalCopyright", "Some copyright"
      VALUE "OriginalFilename", "Some.exe"
      VALUE "ProductName", "Some product name"
      VALUE "ProductVersion", "1.0"
    END
  END

  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x809, 1252
  END
END

You can see "Some.exe.manifest" assembly manifest file name This file (XML file, as you can see in my question above) should be in project class path.

Now here are resource.rc properties:

enter image description here

  1. In project properties - Linker options:

enter image description here

You can see "Additional Dependencies" - resource.o

And that's all - .exe file contains assembly manifest file (also icon and description) after compiling it.

Project view:

enter image description here

Project files view:

enter image description here

like image 84
Ernestas Gruodis Avatar answered Sep 20 '22 16:09

Ernestas Gruodis