问题
I really like the way the SysInternals utilities (e.g. Process Explorer) handle 64bit compatibility. It looks like the 32bit executable has the 64bit version embedded in it, and extracts it if necessary.
I'd like a tool which automates this - i.e. takes 32bit and 64bit executables, packs them together somehow, and inserts stub code to launch the right executable according to which platform its gets run on.
Before I start to roll my own, does anyone know of something like this which already exists?
回答1:
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.
回答2:
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?
回答3:
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 .
回答4:
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.
回答5:
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.
来源:https://stackoverflow.com/questions/1170643/any-tools-available-for-packing-32bit-64bit-executables-together