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// --------------------------------------------------------------------------------
5// PEInformation.h
6//
7
8// --------------------------------------------------------------------------------
9
10#ifndef PEINFORMATION_H
11#define PEINFORMATION_H
12
13#ifndef PEKIND_ENUM_DEFINED
14#define PEKIND_ENUM_DEFINED
15// This must match the definition of pekind in fusion.idl
16typedef enum _tagPEKIND
17{
18 peNone = 0x00000000,
19 peMSIL = 0x00000001,
20 peI386 = 0x00000002,
21 peIA64 = 0x00000003,
22 peAMD64 = 0x00000004,
23 peARM = 0x00000005,
24 peARM64 = 0x00000006,
25 peInvalid = 0xffffffff
26} PEKIND;
27
28#endif
29
30
31inline bool IsPE64(PEKIND x)
32{
33 return ( (x == peIA64) || (x == peAMD64) || (x == peARM64) );
34}
35
36inline bool IsPE32(PEKIND x)
37{
38 return ( (x == peI386) || (x == peARM) );
39}
40
41inline bool IsPEMSIL(PEKIND x)
42{
43 return ( (x == peMSIL) );
44}
45
46#ifdef _WIN64
47inline bool IsProcess32() { return false; }
48#else
49inline bool IsProcess32() { return true; }
50#endif
51
52#if defined(_TARGET_X86_)
53inline PEKIND TargetNativePEKIND() { return peI386; }
54#elif defined(_TARGET_AMD64_)
55inline PEKIND TargetNativePEKIND() { return peAMD64; }
56#elif defined(_TARGET_ARM_)
57inline PEKIND TargetNativePEKIND() { return peARM; }
58#elif defined(_TARGET_ARM64_)
59inline PEKIND TargetNativePEKIND() { return peARM64; }
60#else
61#error Need to define valid TargetNativePEKIND()
62#endif
63
64STDAPI RuntimeIsValidAssemblyOnThisPlatform_CheckProcessorArchitecture(PEKIND processorArchitecture, BOOL bForInstall);
65
66//*****************************************************************************
67// Intreprets CLRPeKind and dwImageType to get PeKind as per the CLRBitness
68// API, CLRPeKind and dwImageType can be recoved from GetPEKind() if you
69// have the metadata, or retrieved directly from the headers as per the
70// implementation in shim.cpp:_CorValidateImage.
71//*****************************************************************************
72HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, PEKIND * PeKind);
73HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, DWORD dwAssemblyFlags, PEKIND * PeKind);
74
75#endif // PEINFORMATION_H
76