Any tools available for packing 32bit/64bit executables together? [closed]

蹲街弑〆低调 提交于 2019-12-04 05:26:51

Mark Russinovich of SysInternals fame describes their method here. They do embed an x64 image in an x86 image. Unfortunately above blog post doesn't actually go into too much detail but mentions that their technique is based on a much older article found here.

John Parker

This appears to have been covered already (although it's quite shallow on detail) within...

Roll 64-bit and 32-bit versions of an app into the same binary?

Not a tool, but it seems fairly easy to embed your executables in a VC++ project as resources, and run the correct one after checking the OS environment.

Use the IsWow64Process function to detect 32 or 64 bit, and here is a nice writeup including source code on how to embed the executables: http://www.codeproject.com/KB/winsdk/binaryresources.aspx .

While this is possible, I would consider it a bad practice since most of those applications (e.g. Process Explorer) extract that file in working directory. If you like to put programs in "Program Files" folder, that clashes with that directory being read-only.

For me it just seems easier to have two programs separated and make shortcut just to x86 file. If that version detects 64-bits, it just needs to launch x64 file.

If you have really good reason to combine those two, than embeedding it as resource seems like a correct path.

Here is a guide to compiling an AutoIT script which does the job, although you don't have any control over how the packing & stub launcher works.

I will reproduce the AutoIT script here in case the link disappears:

; Check if we’re on 64-bit OS…
If EnvGet(“PROCESSOR_ARCHITEW6432″)=”” Then
    ; No we’re not – run x86 version…
    FileInstall(“D:\Support\ETrustCheck_x86.exe”,@TempDir & “\ETrustCheck_x86.exe”)
    RunWait(“D:\Support\ETrustCheck_x86.exe”,@TempDir & “\ETrustCheck_x86.exe”)
    FileDelete(@TempDir & “\ETrustCheck_x86.exe”)
Else
    ; Yes we are – run x64 version..
    FileInstall(“D:\Support\ETrustCheck_x64.exe”,@TempDir & “\ETrustCheck_x64.exe”)
    RunWait(“D:\Support\ETrustCheck_x86.exe”,@TempDir & “\ETrustCheck_x64.exe”)
    FileDelete(@TempDir & “\ETrustCheck_x64.exe”)
EndIf

; The END

This script can be wrapped by the AutoIT script editor into 32bit launcher with your two executables packed into it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!