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 comes automatically installed with Visual Studio IDE. We'll use the Visual Studio Developer Command Prompt to use this tool.
CorFlags.exe assembly [options]
For more details on the options refer to the MSDN link.
Now, based on how the PE has been compiled we can determine the platform affinity as follows...
|Any CPU 32-bit preferred||PE32||0||1|
The default case in Visual Studio IDE is
Any CPU with 32-bit is preferred. Hence, if we run
CorFlags tool in this case we'll get...
E:\Dev\Projects\TestApp\TestApp\bin\Debug>corflags TestApp.exe Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.6.1055.0 Copyright (c) Microsoft Corporation. All rights reserved. Version : v4.0.30319 CLR Header: 2.5 PE : PE32 CorFlags : 0x20003 ILONLY : 1 32BITREQ : 0 32BITPREF : 1 Signed : 0
As can be seen above, this is the case whereby the
exe targets the default option of
Any CPU with 32-bit is preferred.
Similarly, as shown in the table, we can determine the platform affinity for other managed dlls too.
Hope this was useful!
PE: Process Executables (exe's and dll's)