Writing a Cross-Platform (32-bit and 64-bit compatible) Program for Windows (like AnyCPU in .NET)

前端 未结 2 1824
庸人自扰
庸人自扰 2021-01-05 04:45

It\'s been baffling me how the \"AnyCPU\" feature in .NET works: It loads the executable as native 32-bit if the system is 32-bit, and as 64-bit if the system is 64-bit (whi

2条回答
  •  伪装坚强ぢ
    2021-01-05 05:19

    You actually can have x64 code in an x86 executable if the system has a WOW64 emulation layer (Windows Vista+, dunno about XP). http://vxheavens.com/lib/vrg02.html

    I have tested this technique and it works on Win7 as well as WinVista. I wrote a little stub in assembly to resolve imports and load up some C code that was compiled for AMD64.

    Microsoft just says you can't transition back and forth because they might change it, but I doubt this will change until the underlying architecture changes to allow something like 128 bit to run as well... at that point I doubt WOW64 will be around :), WOW128 ftl.

提交回复
热议问题