Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
89 views
in Technique[技术] by (71.8m points)

How to interpret the CorFlags flags?

How do I interpret the CorFlags flags and how should I use it to determine if a .NET assembly was built for x86 or x64?

Could it be the following?

corflags MyAssembly.dll
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Microsoft .NET 4.5 introduced a new option, Any CPU 32-bit Preferred. In the new version of CorFlags.exe, the 32BIT flag no longer exists, instead, two new flags were added, 32BITREQ and 32BITPREF.

Somewhere based on the below explanation, we can interpret new CorFlags 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 Preferred   PE32           0           1

Flags displayed by the CorFlags.exe located at C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Tools

Version   : Assembly's target framework.
Header    : 2.0/2.5 (Must have version of 2.5 or greater to run natively)
PE        : PE32 (32-bit)/PE32+ (64-bit)
CorFlags  : Hexadecimal value, computed based on below 4 flags.
ILONLY    : 1 if MSIL otherwise 0
32BITREQ  : 1 if 32-bit x86 only assembly otherwise 0
32BITPREF : 1 if 32-bit x86 only preferred in Any CPU architecture otherwise 0
Signed    : 1 if signed with strong name otherwise 0

The following example illustrates the output of C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 ToolsCorFlags.exe for different assemblies.

PresentationCore.dll from GAC_32

CorFlags.exe "C:WindowsMicrosoft.NETassemblyGAC_32PresentationCorev4.0_4.0.0.0__31bf3856ad364e35PresentationCore.dll"

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 0xb
ILONLY    : 1
32BITREQ  : 1
32BITPREF : 0
Signed    : 1

System.Data.dll from GAC_64

CorFlags.exe "C:WindowsMicrosoft.NETassemblyGAC_64System.Datav4.0_4.0.0.0__b77a5c561934e089System.Data.dll"

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32+
CorFlags  : 0x18
ILONLY    : 0
32BITREQ  : 0
32BITPREF : 0
Signed    : 1

System.dll from GAC_MSIL

CorFlags.exe "C:WindowsMicrosoft.NETassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll"

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 0x9
ILONLY    : 1
32BITREQ  : 0
32BITPREF : 0
Signed    : 1

To know more about Any CPU 32-bit Preferred assemblies refer What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...