Insert manifest file requiring admin run level using mingw32

I cross-compile the application with i586-mingw32msvc under ubuntu.

I'm having difficulty understanding how to embed a manifest file that requires an administrator run level using mingw32.

In my example, I used this hello.c :

 int main() { return 0; } 

this hello.rc resource hello.rc :

 1 Manifest "hello.exe.manifest" 

this manifest file hello.exe.manifest :

 <?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="hello" type="win32"/> <description>Hello World</description> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly> 

I will compile my resource file with

 i586-mingw32msvc-windres hello.rc hello.o 

I will compile my final application with:

 i586-mingw32msvc-gcc -O3 -Os -s -o hello.exe hello.c hello.o 

SigCheck does not display a manifest file with sigcheck -m hello.exe .

Now, when I run my application under Windows, it does not start UAC (= does not start as an administrator), and when I attach the file hello.exe.manifest in the same folder, it starts UAC (as expected).

What did I miss?

EDIT1: Playing with Resource Hacker I opened the Setup.exe file that I created using NSIS, the only reasonable difference is that Manifest written to Manifest in my hello.exe and Manifest to Setup.exe , although he wrote in hello.rc Manifest. O_o

NSIS Installer vs hello.exe

EDIT2: I changed the Manifest group manually using the Resource Hacker:

Modified using resource hacker

Now hello.exe acts fine, starting the UAC alert and working as an administrator. There seems to be an β€œerror” with i586-mingw32msvc-windres . i586-mingw32msvc-windres

+8
c linux windows uac mingw32
source share
2 answers

With some intense voodoo, I got it to work with this in my hello.rc file:

 1 24 "hello.exe.manifest" 

Will not even look for what 24 is (a resource type manifest ?!) :-)

+1
source share

As for the voodoo magic numbers 1 and 24:

 1 24 "hello.exe.manifest" 

This string is converted to something like this:

 ID_MANIFEST RT_MANIFEST "hello.exe.manifest" 

where they are defined are defined as follows:

 #define ID_MANIFEST 1 #ifndef RT_MANIFEST #define RT_MANIFEST MAKEINTRESOURCE(24) #endif 

As shown by the conditional shells, RT_MANIFEST can already be defined, and if you do a Google search for this term RT_MANIFEST, you will find many hits with more detailed information about what is happening.

+1
source share

All Articles