How to add Assembly manifest file to .exe file created using NetBeans IDE C ++ MinGW

How to add Assembly manifest file to .exe file created using NetBeans environment 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 to include this information in an exe file?

The problem is that in Windows Vista the file is marked with the UAC mark, but it is digitally signed. And I ask you to confirm that it runs every time I run it.

I found this explanation here : "First, you must create an XML manifest, indicating that version 6 of the Windows Windows shared management library must be loaded and injected into your application as a resource of type" RT_MANIFEST "(in fact, if you prefer, you can name the manifest "[application name] .exe.manifest" and include it in the same directory as exe, than embedding it as a resource, but it has the disadvantage that it can accidentally be deleted or go bad) "

+6
source share
1 answer

I found the answer myself, maybe it will be useful for others.

Actions:

  • Create ids.h header file
 #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 a resource.rc resource file 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" the name of the assembly manifest file. This file (the XML file, as you can see in my question above) should be in the path of the project class.

Now here are the properties of resource.rc :

enter image description here

  1. In the project properties - Linker options :

enter image description here

You can see "Additional Dependencies" - resource.o

And this all.exe file contains the assembly manifest file (also the icon and description) after compiling it.

Type of project:

enter image description here

View project files:

enter image description here

+2
source

Source: https://habr.com/ru/post/983686/


All Articles