1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // --------------------------------------------------------------------------------
8 // --------------------------------------------------------------------------------
12 #include "peinformation.h"
15 HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, PEKIND * pPeKind)
17 return TranslatePEToArchitectureType(CLRPeKind, dwImageType, 0, pPeKind);
20 HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, DWORD dwAssemblyFlags, PEKIND * pPeKind)
24 _ASSERTE(pPeKind != NULL);
26 if (CLRPeKind == peNot)
27 { // Not a PE. Shouldn't ever get here.
29 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
32 else if (IsAfPA_NoPlatform(dwAssemblyFlags))
39 if ((CLRPeKind & peILonly) &&
40 !(CLRPeKind & pe32Plus) &&
41 !(CLRPeKind & pe32BitRequired) &&
42 (dwImageType == IMAGE_FILE_MACHINE_I386))
44 // Processor-agnostic (MSIL)
47 else if (CLRPeKind & pe32Plus)
51 if (CLRPeKind & pe32BitRequired)
54 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
58 // Regardless of whether ILONLY is set or not, the architecture
59 // is the machine type.
61 if (dwImageType == IMAGE_FILE_MACHINE_IA64)
65 else if (dwImageType == IMAGE_FILE_MACHINE_AMD64)
70 { // We don't support other architectures
72 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);
78 // 32-bit, non-agnostic
80 if (dwImageType == IMAGE_FILE_MACHINE_I386)
84 else if (dwImageType == IMAGE_FILE_MACHINE_ARMNT)
91 hr = HRESULT_FROM_WIN32(ERROR_BAD_FORMAT);