How to combine 64-bit and 32-bit executable files into one?

Okay, so my idea was to bundle both 64-bit and 32-bit into one application, so if it does not run the 64-bit version, it will try to use the 32-bit version.

I read about PE and learned a little about the MS-DOS Real Mode Stub, and it says how it calls the application (usually this error message). But every time I tried to research the MS-DOS Real Mode Stub, it only displayed error messages. So my idea was to overwrite STUB with my 32 bit application.

My self-understanding is that when a 32-bit operating system launches a 64-bit executable, it will fail, and then it will launch the stub file.

Is there a way to make my 32bit / 64bit executable independent?

+6
source share
2 answers

It is not possible to create a single executable file containing both x86 and x64 code. However, you can create separate 32-bit and 64-bit applications, the x64 app package into x86 application resources. At the beginning of the program, you can verify that you are using the x64 environment using IsWow64Process , and then, if necessary, unzip your x64 version and run it

+8
source

MacOS, Linux, and DOS (or hybrid DOS-Windows) have fat binaries but not 32 and 64-bit Windows

You can compile individual versions of the program, and then select the script of another executable file

Another way is to install only the correct version during installation. This is used by many programs such as CCleaner. The installer is a 32-bit application or a universal one, such as .NET, so that it can work anywhere. If it detects 64-bit Windows, then it installs only the 64-bit version, the same as in the 32-bit version.

More details:

+2
source

All Articles