[英]Embed manifest file to require administrator execution level with mingw32
I'm cross compiling an application with i586-mingw32msvc under ubuntu. 我正在用ubuntu下的i586-mingw32msvc交叉编译应用程序。
I'm having difficulties understanding how to embed a manifest file to require administrator execution level with mingw32. 我在理解如何嵌入清单文件以要求管理员使用mingw32执行级别时遇到困难。
For my example I used this hello.c
: 对于我的示例,我使用了此
hello.c
:
int main() {
return 0;
}
this resource file hello.rc
: 该资源文件
hello.rc
:
1 Manifest "hello.exe.manifest"
this manifest file hello.exe.manifest
: 此清单文件
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 compile my resource file with: 我用以下命令编译资源文件:
i586-mingw32msvc-windres hello.rc hello.o
I compile my final application with: 我用以下命令编译最终应用程序:
i586-mingw32msvc-gcc -O3 -Os -s -o hello.exe hello.c hello.o
SigCheck does not show the manifest file running sigcheck -m hello.exe
. SigCheck不显示正在运行的清单文件
sigcheck -m hello.exe
。
Now when I run my application under Windows it does not trigger the UAC (=does not run as administrator) while when I attach the hello.exe.manifest
file in the same folder it does trigger the UAC (as expected). 现在,当我在Windows下运行应用程序时,它不会触发UAC(=不以管理员身份运行),而当我将
hello.exe.manifest
文件附加在同一文件夹中时,它会触发UAC(如预期的那样)。
What did I miss? 我错过了什么?
EDIT1: Playing with Resource Hacker I've opened a Setup.exe
file I've created with NSIS, the only sensible difference is that Manifest
is written MANIFEST
in my hello.exe
and Manifest
in Setup.exe
though in hello.rc
it's written Manifest. EDIT1:和Resource Hacker 一起玩我已经打开了用NSIS创建的
Setup.exe
文件,唯一的区别是Manifest
是在我的hello.exe
写的MANIFEST
,而在Setup.exe
是Manifest
,尽管是在hello.rc
写的表现。 O_o O_o
EDIT2: I've changed the Manifest
group manually with Resource Hacker: EDIT2:我已经使用Resource Hacker手动更改了
Manifest
组:
Now hello.exe
is acting normally triggering the UAC alert and running as an administrator. 现在
hello.exe
可以正常触发UAC警报并以管理员身份运行。 Seems like a "bug" with i586-mingw32msvc-windres
. 看起来像
i586-mingw32msvc-windres
的“错误”。 :-) :-)
With regard to the magic voodoo numbers 1 and 24: 关于数字1和24的巫毒巫师:
1 24 "hello.exe.manifest"
That line translates to somthing like this: 那行翻译成这样的东西:
ID_MANIFEST RT_MANIFEST "hello.exe.manifest"
where those defines are as defined as follows: 这些定义的定义如下:
#define ID_MANIFEST 1
#ifndef RT_MANIFEST
#define RT_MANIFEST MAKEINTRESOURCE(24)
#endif
As shown above by the conditional wrappers, the RT_MANIFEST might already be defined and if you do a Google search for that RT_MANIFEST term you will find lots of hits with more details on what is going on. 如上面的条件包装所示, RT_MANIFEST可能已经定义好了,如果您在Google上搜索该RT_MANIFEST字词,您会发现很多匹配项,其中包含发生情况的更多详细信息。
With some intense voodoo I got it to work with this on my hello.rc
file: 用一些伏都
hello.rc
,我hello.rc
在hello.rc
文件中使用它:
1 24 "hello.exe.manifest"
Won't even search to know what the 24 is for (resource type manifest?!).. :-) 甚至不会搜索以了解24的含义(资源类型清单?!).. :-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.