summaryrefslogtreecommitdiff
path: root/src/vm/coreclr/corebindresult.inl
blob: 1b48b3fa47e1826a081bbb98cada132c0b80bae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ============================================================
//
// CoreBindResult.inl
// 

//
// Implements the CoreBindResult class
// ============================================================

#ifndef __CORE_BIND_RESULT_INL__
#define __CORE_BIND_RESULT_INL__

#include "clrprivbinderutil.h"

inline BOOL CoreBindResult::IsFromGAC()
{
    LIMITED_METHOD_CONTRACT;
    return m_bIsFromGAC;
};

inline BOOL CoreBindResult::IsOnTpaList()
{
    LIMITED_METHOD_CONTRACT;
    return m_bIsOnTpaList;
};

inline BOOL CoreBindResult::Found()
{
    LIMITED_METHOD_CONTRACT;
    return (m_pAssembly!=NULL);
};

inline BOOL CoreBindResult::IsMscorlib()
{
    CONTRACTL
    {
        THROWS;
        MODE_ANY;
        PRECONDITION(Found());
    }
    CONTRACTL_END;

    BINDER_SPACE::Assembly* pAssembly = BINDER_SPACE::GetAssemblyFromPrivAssemblyFast(m_pAssembly);
#ifndef CROSSGEN_COMPILE
    return pAssembly->GetAssemblyName()->IsMscorlib();
#else
    return (pAssembly->GetPath()).EndsWithCaseInsensitive(SString(W("mscorlib.dll")), PEImage::GetFileSystemLocale());
#endif
}

inline void CoreBindResult::GetBindAssembly(ICLRPrivAssembly** ppAssembly)
{
    CONTRACTL
    {
        NOTHROW;
        MODE_ANY;
        PRECONDITION(Found());
    }
    CONTRACTL_END;
    
    m_pAssembly->AddRef();
    *ppAssembly = m_pAssembly;
}


inline PEImage* CoreBindResult::GetPEImage()
{
    WRAPPER_NO_CONTRACT;
    return m_pAssembly?BINDER_SPACE::GetAssemblyFromPrivAssemblyFast(m_pAssembly)->GetNativeOrILPEImage():NULL;
};

inline void CoreBindResult::Init(ICLRPrivAssembly* pAssembly, BOOL bFromGAC, BOOL bOnTpaList = FALSE)
{
    WRAPPER_NO_CONTRACT;
    m_pAssembly=pAssembly;
    if(pAssembly)
        pAssembly->AddRef();
    m_bIsFromGAC=bFromGAC;
    m_bIsOnTpaList = bOnTpaList;
    m_hrBindResult = S_OK;
}

inline void CoreBindResult::Reset()
{
    WRAPPER_NO_CONTRACT;
    m_pAssembly=NULL;
    m_bIsFromGAC=FALSE;
    m_bIsOnTpaList=FALSE;
    m_hrBindResult = S_OK;
}
#ifdef FEATURE_PREJIT
inline BOOL CoreBindResult::HasNativeImage()
{
    LIMITED_METHOD_CONTRACT;
    BINDER_SPACE::Assembly* pAssembly = BINDER_SPACE::GetAssemblyFromPrivAssemblyFast(m_pAssembly);
    return pAssembly->GetNativePEImage() != NULL;
}
inline PEImage* CoreBindResult::GetNativeImage()
{
    WRAPPER_NO_CONTRACT;
    _ASSERTE(HasNativeImage());
    BINDER_SPACE::Assembly* pAssembly = BINDER_SPACE::GetAssemblyFromPrivAssemblyFast(m_pAssembly);
    return pAssembly->GetNativePEImage();
}

inline PEImage* CoreBindResult::GetILImage()
{
    WRAPPER_NO_CONTRACT;
    return m_pAssembly?BINDER_SPACE::GetAssemblyFromPrivAssemblyFast(m_pAssembly)->GetPEImage():NULL;
};
#endif

inline void CoreBindResult::SetHRBindResult(HRESULT hrBindResult)
{
    WRAPPER_NO_CONTRACT;
    m_hrBindResult = hrBindResult;
}

inline HRESULT CoreBindResult::GetHRBindResult()
{
    WRAPPER_NO_CONTRACT;
    return m_hrBindResult;
}

#endif // __CORE_BIND_RESULT_INL__