> csc a.cs > corflags a.exe Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 1 ILONLY : 1 32BIT : 0 Signed : 0 |
项目 | 含义 | 对应 |
Version | Assembly所对应的Framework版本 | IMAGE_COR20_HEADER.dwMajorRuntimeVersion IMAGE_COR20_HEADER.dwMinorRuntimeVersion |
CLR Header | CLR文件头的版本号 | IMAGE_COR20_HEDER.MetaData |
PE | PE文件的类型,包含PE32/PE32+ | Magic= IMAGE_NT_OPTIONAL_HDR32_MAGIC or IMAGE_NT_OPTIONAL_HDR64_MAGIC |
CorFlags | | IMAGE_COR20_HEADER.Flags CorFlags根据这个值来解析下面的选项 |
ILONLY | 是否仅仅包含IL代码,0/1 | COMIMAGE_FLAGS_ILONLY=0x1 |
32 BIT | 是否仅以32BIT运行,0/1 | COMIMAGE_FLAGS_32BITREQUIRED=0x2 |
Signed | 是否经过签名 | COMIMAGE_FLAGS_STRONGNAMESIGNED =0x8 |
平台 | PE32/PE32+ | IL Only? | 32-Bit? |
Any CPU | PE32 | 1 | 0 |
Pure x86 | PE32 | 1 | 1 |
Pure x64 | PE32+ | 1 | 0 |
Mixed x86 | PE32 | 0 | 0 |
Mixed x64 | PE32+ | 0 | 0 |
> corflags C:\windows\microsoft.net\Framework\v2.0.50727\System.dll Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 9 ILONLY : 1 32BIT : 0 Signed : 1 |
可以看到我机器上面32Bit的.NET Framework 2.0 RTM版本里面的System.DLL是对应v2.0.50727版本的,属于PE32文件,是IL Only,不是32Bit的,因此这个是用AnyCPU来编译的。Corflags = 9 = COMIMAGE_FLAGS_ILONLY (1) + COMIMAGE_FLAGS_STRONGNAMESIGNED (8)
>cl /clr a.cpp Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for Microsoft (R) .NET Framework version 2.00.50727.1416 Copyright (C) Microsoft Corporation. All rights reserved. a.cpp Microsoft (R) Incremental Linker Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. /out:a.exe a.obj > corflags a.exe Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 0 ILONLY : 0 32BIT : 0 Signed : 0 |
可以看到用/CLR编译选项编译出来的C++/CLI的代码总是混合的,因此是 ILONLY=0,值得注意的是其32BIT=0,说明当ILONLY=0的时候,CLR不需要32BIT=0就可以判断出这个PE32文件必然要在32BIT下面运行。
作者: 张羿(ATField)
Blog: http://blog.csdn.net/atfield
http://blogs.msdn.com/yizhang
转载请注明出处
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1814408