Question:
I want to determine if native assembly is complied as x64 or x86 from a managed code application (c#). I think it must somewhere in the PE header since the OS loader needs to know this info but I couldn't find it. I prefer of course to do it in managed code but if it necessary I can use native C++.
Answer:
In case anyone is still looking for this (I just got here from google) there is an easy way to do this with corflags. Open Visual Studio Command Prompt and type "corflags [your assembly]". You'll get something like this:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>corflags "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll"
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 3.5.21022.8 Copyright (c) Microsoft Corporation. All rights reserved.
Version : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 24
ILONLY : 0
32BIT : 0
Signed : 1
You're looking at PE and 32BIT specifically.
-
AnyCpu:
PE: PE32
32BIT: 0 -
x86:
PE: PE32
32BIT: 1 -
x64:
PE: PE32+
32BIT: 0