Would Like To Programmatically Obtain The Same Information As CorFlags RRS feed

  • Question

  • When you use CorFlags to obtain the CLR Header information of an assembly you see something like...

    Version : v2.0.50727
    CLR Header: 2.5
    PE : PE32
    CorFlags : 3
    ILONLY : 1
    32BIT : 1
    Signed : 0


    Version : v2.0.50727
    CLR Header: 2.5
    PE : PE32
    CorFlags : 1
    ILONLY : 1
    32BIT : 0
    Signed : 0

    Version : v2.0.50727
    CLR Header: 2.5
    PE : PE32+
    CorFlags : 1
    ILONLY : 1
    32BIT : 0
    Signed : 0

    This information lets you see what platform the assembly was targeted for (x86, AnyCPU or x64), on what .NET Framework version it was built and what CLR version it was made.

    I am hoping to be able to do the same without loading the assembly.  While I can use the PECOFF_V8.DOCX to inspect an assembly for the PE value, I have not been able to determine how to find either of the following:

        (1) 32BIT flag


        (2) either the VERSION information OR the CLR HEADER information

    similar to what CorFlags provides.

    My guess would be that it is stored in the CLR HEADER RUNTIME Data Dictionary (as described in the PECOFF_V8.DOCX) but I am unable to map the Relative Virtual Address of the CLR HEADER RUNTIME and base address of the image to determine its location and see if it is even there.

    Any help in PROGRAMMATICALLY determining the values for 32BIT and either VERSION or CLR HEADER for an assembly (similar to what CorFlags is doing) would be much appreciated!!!

    • Edited by johnson321 Friday, October 15, 2010 7:27 AM typo
    Friday, October 15, 2010 7:26 AM


All replies

  • The CCI has a peReader class that'll probably already perform all the tricks you need to get to the data you want, take a look at it, its a pretty neat project.

    Saturday, October 16, 2010 7:14 PM
  • Hi johnson321,

    May I know the issue status? does Ray's suggestion help? if you have any concern, please feel free to let us know.

    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, October 18, 2010 1:00 AM
  • Hi Eric,

    I took a quick look at the PeReader and I am not sure it will obtain the information I require.  Even if it does, I really don't want to reference an entire library to obtain the two pieces of additional information I need.

    The best solution would be if the person at Microsoft who wrote CorFlags reviewed my post I'm sure they would be able to help explain how these two pieces of data are obtained from the PECOFF.

    Or, the PECOFF_V8.DOCX could be updated with an actual example of how to obtain the CLR HEADER RUNTIME Data Dictionary as the lack of any examples makes the document very confusing since the textual description of how to do this is lacking sufficient details.

    Or, if the source could be made available for CorFlags that would allow me to review the algorithm CorFlags uses so I could use something similar internal to my application.  I think there are a lot of people that would benefit from this information.


    • Edited by johnson321 Thursday, October 21, 2010 11:51 PM typo
    Thursday, October 21, 2010 11:46 PM
  • Hi Johnson,




    should do the trick. It is adapted from the Gallileo project. The source file has no dependencies to other projects. You can import it directly via source.



       Alois Kraus


    • Marked as answer by johnson321 Monday, October 25, 2010 4:08 AM
    Friday, October 22, 2010 11:37 PM
  • Hi Alois,

    Thank you for that link!!!

    I was able to review their code and see how they were accessing the CLR RUNTIME HEADER information.  I am now able to obtain the Major and Minor Framework Version Numbers and CorFlags value and have intergrated similar code into my application.

    Thanks again!


    Monday, October 25, 2010 4:08 AM