在单个可执行文件中组合 x86 和 x64 可执行文件(如 Sysinternals 工具)

编程入门 行业动态 更新时间:2024-10-11 07:33:02
本文介绍了在单个可执行文件中组合 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 工具)

本文发布于:2023-10-29 00:22:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538188.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可执行文件   组合   工具   Sysinternals

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!