4 ms·
> It says Windows, but is it x86 or x64? x64 > Can it make a binary that's both x86 and x64 for Windows? Seems to be a PE32+, so it won't run on 32-bit Windo
by poizan42 4y ago
> It says Windows, but is it x86 or x64?
x64
> Can it make a binary that's both x86 and x64 for Windows?
Seems to be a PE32+, so it won't run on 32-bit Windows.
> Is that even possible?
Yes, it should be. A 32-bit process on 64-bit Windows can run 64-bit code by changing the segment selector - make a far call or jump to 0x33:<address>. See [0] for more details.
There are some caveats though. kernel32.dll refuses to be loaded as both the 32-bit and 64-bit versions in the same executable. So the executable can probably only import ntdll. One thing one might do is just compile both a 32-bit and 64-bit version of the actual program as dll's and embed them inside the launcher and then extract and load them using only api's in ntdll. In the case of APE it would probably just embed an x64-on-x86 emulator and run the executable in that in case it's being run on x86.
Another solution might be to create a .NET AnyCPU executable which will run as 64-bit on 64-bit versions of Windows.
[0]: https://www.malwaretech.com/2014/02/the-0x33-segment-selector-heavens-gate.html https://www.malwaretech.com/2014/02/the-0x33-segment-selecto...
- gwbas1c 4y ago> Another solution might be to create a .NET AnyCPU executable which will run as 64-bit on 64-bit versions of Windows. But will that run on all the other OSes?
- poizan42 4y agoIf you just turn the PE part into a .NET executable and keep the rest as it is, yes. Windows will see a .NET executable and the other OSes will see a shell script just like it works now (and a BIOS will still see the boot sector)