【发布时间】:2016-01-05 03:40:14
【问题描述】:
我在ubuntu下用i586-mingw32msvc交叉编译一个应用程序。
我很难理解如何使用 mingw32 嵌入清单文件以要求管理员执行级别。
在我的例子中,我使用了这个hello.c:
int main() {
return 0;
}
这个资源文件hello.rc:
1 Manifest "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>
我编译我的资源文件:
i586-mingw32msvc-windres hello.rc hello.o
我编译我的最终应用程序:
i586-mingw32msvc-gcc -O3 -Os -s -o hello.exe hello.c hello.o
SigCheck 不显示运行 sigcheck -m hello.exe 的清单文件。
现在,当我在 Windows 下运行我的应用程序时,它不会触发 UAC(=不以管理员身份运行),而当我将 hello.exe.manifest 文件附加到同一文件夹中时,它会触发 UAC(如预期的那样)。
我错过了什么?
EDIT1: 玩Resource Hacker 我打开了一个我用NSIS 创建的Setup.exe 文件,唯一明显的区别是Manifest 在我的@ 中写入MANIFEST 987654343@ 和 Manifest 在 Setup.exe 虽然在 hello.rc 它是书面清单。 O_o
EDIT2:我已经使用 Resource Hacker 手动更改了 Manifest 组:
现在hello.exe 正在正常运行,触发 UAC 警报并以管理员身份运行。似乎是i586-mingw32msvc-windres 的“错误”。 :-)
【问题讨论】:
-
@JonathonReinhart 谢谢,但我也尝试了该链接上描述的内容.. 和the link it linked to 也.. 但没有任何改变.. 我已将我的
hello.rc文件更新为1 Manifest "hello.exe.manifest".. 使用 Resource Hacker 我打开了一个需要管理员的 NSIS 安装程序(我用 makensis 编译),一切都一样;唯一不同的是清单字段在Setup.exe文件中写入“Manifest”,在我的hello.exe文件中写入“MANIFEST”! (See here) -
通常你把.rc文件编译成
.res文件(不是.o) -
请帮帮我,imgur 图片在哪里?
标签: c linux windows uac mingw32