How do I get the PEKind and ImageFileMachine of an AMD64 assembly from an x86.NET application (and vice versa)?
I am writing an installation checker tool for our product and I need to get some PE information from multiple installed builds. Regardless of which platform our product is installed on, we ship AMD64, x86 and MSIL assemblies to specific locations to allow users to create deployment projects for those platforms.
The problem is that using the following code:
Module manifestModule = Assembly.LoadFile(fileName).ManifestModule;
ImageFileMachine m;
PortableExecutableKinds pe;
manifestModule.GetPEKind(out pe, out m);
Assembly.LoadFile (...) will break if the application runs as x86 and tries to load an AMD64 assembly or vice versa.
I found these related, but not quite:
- How can I tell if a .NET assembly was built for x86 or x64? It doesn't say how you could dig into an AMD64 assembly from x86.
- How can I determine which platform an executable is compiled on? I really need to get both ImageFileMachine and PEKinds because of the large mix of collections and properties we need to define.
0
a source to share