Just a quick blog about the different types of managed PE files.
Here's a table:
The MSIL 32 bit preferred and ARM types are new in .NET 4.5. I've left out Itanium, because it's not that interesting.
For legacy reasons pure MSIL files specify x86 as the machine type and when you really want to target just x86 you need to set the (confusingly named) COMIMAGE_FLAGS_32BITREQUIRED flag.
When the COMIMAGE_FLAGS_32BITREQUIRED flag was introduced (back in .NET 1.0) they probably intended it to just mean that the image required a 32 bit architecture (not necessarily x86), but then the C# compiler mapped the /platform:x86 switch to this flag and they were locked into it meaning just x86.
Starting with Visual Studio 2010, the default platform target project setting for executables changed from Any CPU to x86. This was probably because x64 systems were becoming more popular and more people started running into the poor x64 JIT performance and its many bugs.
With the introduction of ARM support in Windows 8 there was now a need for a new flag to avoid the x64 JIT, but still be cross platform, so the COMIMAGE_FLAGS_32BITPREFERRED flag was invented. For downward compatibility, this flag is not set by itself, but instead modifies the meaning of the COMIMAGE_FLAGS_32BITREQUIRED flag, to allow .NET 4.0 systems to continue to run the executable in 32 bit mode (they simply ignore the new flag) while on ARM systems the system can see that the executable is not x86 specific because the new flag is set.
Finally, when your PE file contains unmanaged exports the ILONLY flag must not be set or the loader will refuse to load the file.
Remember Me
I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.
Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)
Powered by: newtelligence dasBlog 2.3.12105.0
© Copyright 2021, Jeroen Frijters
E-mail