views:

56

answers:

2

Hello,

I know that on Mac OS X, you can combine multiple binaries that target different architectures into a single binary using lipo. I am wondering if there is a similar solution on the Windows side. Thank you.

+2  A: 

Unfortunately all the Windows architectures use the same structures in the PE header, so no. It is possible to fuse a Windows executable and a DOS executable though, since DOS uses the MZ header instead.

Ignacio Vazquez-Abrams
Ah! Well, thats a bummer, but thanks for answering the question.
gutsblow
But you could make an installer that would install different versions, based on architecture? Not the same, but maybe good enough?
Neeme Praks
Yes, I can create an installer that would install different versions. I was just looking for a better solution, so that it'll be on par with the Mac OS X version.
gutsblow
A: 

I think you are reffering to the ADS, that has been added to the NTFS to provide similar functionality as on Mac. Although NTFS supports multiple streams, the PE loader should choose the right one, and I'm not sure if it's implemented.

ruslik
This doesn't sound right at all. Can you please point me to some MSDN links that support this?
mrduclaw
@mrduclaw Try this one: http://msdn.microsoft.com/en-us/library/bb540537%28v=VS.85%29.aspx
ruslik
Sorry, maybe I wasn't explicit; English is not my first language. I understand what Alternate Data Streams are and how to use them. I've just never read anything about the Windows loader using them to choose which binary to load. Wouldn't the IMAGE_NT_HEADERS need to have this field somewhere in it so that the IMAGE_OPTIONAL_HEADER points to the correct AddressOfEntry? So MSDN links discussing the Windows loader using them is what I'm looking for.
mrduclaw
@mrduclaw On Mac, the common way to store resources of an executable is to put them in its ADS. This also could include different versions for the executable. NTFS supports this way of storing files, but I'm not sure if PE loader is able to choose the right binary from ADS (if any) for the current architecture. COFF header has a field `Machine` that specifies the architecture for which the binary is built. There is no need to have several optional headers, because we are speaking of different files here.
ruslik