Determine platform affinity 32 bit, 64 bit or Any CPU for a managed .Net PE
In my earlier post, I discussed how PEs in .Net can target different platforms and the subtle differences between them. In this post I’ll discuss how one can determine the platform (architecture) that a managed .Net PE targets.
For this, we’ll use a tool called CorFlags
which come automatically installed with Visual Studio IDE. We’ll use the Visual Studio Developer Command Prompt to use this tool.
Syntax:
CorFlags.exe assembly [options]
For more details on the options refer to the msdn link.
Now, based on the way in which the PE has been compiled we can determine the platform affinity as follows…
CPU Architecture | PE | 32BITREQ | 32BITPREF |
---|---|---|---|
x86(32-bit) | PE32 | 1 | 0 |
x64(64-bit) | PE32+ | 0 | 0 |
Any CPU | PE32 | 0 | 0 |
Any CPU 32-bit prefered | PE32 | 0 | 1 |
The default case in Visual Studio IDE is Any CPU
with 32-bit preferred.
Hence, if we run CorFlags
tool in this case we’ll get…
As can be seen above, this is the case whereby the exe
targets the default option of Any CPU
with 32-bit preferred.
Similarly, as shown in the the table, we can determine the platform affinity for other managed dlls too.
Hope this was useful!
Abbreviations:
PE : Process Executables (exe’s and dll’s)
References:
Leave a Comment