summaryrefslogtreecommitdiff
path: root/src/vm/securitydescriptorassembly.inl
blob: 44b49a32c92377c3abb3ba5be1c421a7541df01c (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
// 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.
// 

//

#ifndef __SECURITYDESCRIPTOR_ASSEMBLY_INL__
#define __SECURITYDESCRIPTOR_ASSEMBLY_INL__

#ifndef DACCESS_COMPILE

inline BOOL AssemblySecurityDescriptor::AlreadyPassedDemand(PsetCacheEntry *pCasDemands)
{
    LIMITED_METHOD_CONTRACT;

    BOOL result = false;
    for (UINT index = 0; index < m_dwNumPassedDemands; index++)
    {
        if (m_arrPassedLinktimeDemands[index] == pCasDemands)
        {
            result = true;
            break;
        }
    }

    return result;
}

inline void AssemblySecurityDescriptor::TryCachePassedDemand(PsetCacheEntry *pCasDemands)
{
    LIMITED_METHOD_CONTRACT;
    
    if (m_dwNumPassedDemands <= (MAX_PASSED_DEMANDS - 1))
        m_arrPassedLinktimeDemands[m_dwNumPassedDemands++] = pCasDemands;
}

#ifdef FEATURE_CAS_POLICY

inline BOOL AssemblySecurityDescriptor::IsAssemblyRequestsComputed() 
{
    LIMITED_METHOD_CONTRACT;
    return m_fAssemblyRequestsComputed;
}

inline BOOL AssemblySecurityDescriptor::IsSignatureLoaded()
{
    LIMITED_METHOD_CONTRACT;
    return m_fIsSignatureLoaded;
}

inline void AssemblySecurityDescriptor::SetSignatureLoaded()
{
    LIMITED_METHOD_CONTRACT;
    m_fIsSignatureLoaded = TRUE;
}

#endif // FEATURE_CAS_POLICY

#ifdef FEATURE_APTCA

inline BOOL AssemblySecurityDescriptor::IsConditionalAptca()
{
    WRAPPER_NO_CONTRACT;
    ModuleSecurityDescriptor *pMSD = ModuleSecurityDescriptor::GetModuleSecurityDescriptor(m_pAssem->GetAssembly());
    return (pMSD->GetTokenFlags() & TokenSecurityDescriptorFlags_ConditionalAPTCA) == TokenSecurityDescriptorFlags_ConditionalAPTCA;
}

#endif // FEATURE_APTCA

#endif // !DACCESS_COMPILE

inline AssemblyLoadSecurity::AssemblyLoadSecurity() :
    m_pEvidence(NULL),
    m_pAdditionalEvidence(NULL),
    m_pGrantSet(NULL),
    m_pRefusedSet(NULL),
    m_dwSpecialFlags(0),
    m_fCheckLoadFromRemoteSource(false),
    m_fSuppressSecurityChecks(false),
    m_fPropagatingAnonymouslyHostedDynamicMethodGrant(false)
{
    LIMITED_METHOD_CONTRACT;
    return;
}

// Should the assembly have policy resolved on it, or should it use a pre-determined grant set
inline bool AssemblyLoadSecurity::ShouldResolvePolicy()
{
    LIMITED_METHOD_CONTRACT;
    return m_pGrantSet == NULL;
}

#endif // #define __SECURITYDESCRIPTOR_ASSEMBLY_INL__