在单个可执行文件中组合 x86 和 x64 可执行文件(如 Sysinternals 工具) [英] Combine x86 and x64 executables in single executable (like Sysinternals tools)

查看:31
本文介绍了在单个可执行文件中组合 x86 和 x64 可执行文件(如 Sysinternals 工具)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用纯 Win32 API 编写 Visual C++ 程序.根据我的理解,我需要分别编译和生成 x86 和 x64 架构的可执行文件.

I am writing an Visual C++ program in pure Win32 API. As per my understanding, I need to separately compile and generate executable for x86 and x64 architecture.

如何将它们组合成单个可执行文件并在运行时发出 x64?我见过 Sysinternals 工具做同样的事情,但不知道它是如何以编程方式完成的.

How do I combine them into single executable and emit the x64 at runtime? I have seen Sysinternals tools doing the same , but don't know how it is done programmatically.

我是否必须将我的 x64 版本作为资源包含到 x86 中,然后写入文件系统并执行创建过程?

Do I have to include my x64 version as a resource into x86 and then write to filesystem and do CreateProcess ?

有什么指点吗?

推荐答案

是的,他们将操作特定的驱动程序作为资源嵌入.这是使用 File + Open + File 打开他们的 Handle.exe 实用程序后 Visual Studio 的屏幕截图:

Yes, they embed the operating specific driver as a resource. Here's a screenshot from Visual Studio after using File + Open + File to open their Handle.exe utility:

不确定它们是什么,但看起来它们肯定涵盖了 Windows 9x、32 位和 64 位.他们接下来要做的是使用资源 API 函数(FindResource、SizeofResource、LockResource)和 WriteFile() 将资源内容写入可写目录中的文件.然后使用 CreateService 和 StartService 加载驱动程序.

Not exactly sure what they are but it certainly looks like they cover Windows 9x, 32-bit and 64-bit. Next thing they'd do is use the resource API functions (FindResource, SizeofResource, LockResource) and WriteFile() the resource content to a file in a writable directory. Then load the driver with CreateService and StartService.

主程序是 x86,所以它可以在任何版本的 Windows 上运行.顺便说一句,在运行时生成二进制文件并不是一件对客户非常友好的事情,他们(和他们的病毒扫描程序)通常想知道什么来自哪里.

The main program is x86 so it runs on any version of Windows. Generating binaries at runtime isn't a very customer friendly thing to do btw, they (and their virus scanner) usually like to know what came from where.

这篇关于在单个可执行文件中组合 x86 和 x64 可执行文件(如 Sysinternals 工具)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆