| 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 | // |
| 6 | |
| 7 | inline Module* DomainFile::GetCurrentModule() |
| 8 | { |
| 9 | LIMITED_METHOD_CONTRACT; |
| 10 | STATIC_CONTRACT_SO_TOLERANT; |
| 11 | SUPPORTS_DAC; |
| 12 | |
| 13 | return m_pModule; |
| 14 | } |
| 15 | |
| 16 | inline Module* DomainFile::GetLoadedModule() |
| 17 | { |
| 18 | LIMITED_METHOD_CONTRACT; |
| 19 | |
| 20 | { |
| 21 | // CheckLoaded() eventually calls PEFile::GetNativeImageWithRef(), which |
| 22 | // takes a reader lock on the file's m_pMetadataLock. However, this is |
| 23 | // only done in debug for the consistency check, so we can accept the lock violation. |
| 24 | CONTRACT_VIOLATION(TakesLockViolation); |
| 25 | CONSISTENCY_CHECK(CheckLoaded()); |
| 26 | } |
| 27 | |
| 28 | return m_pModule; |
| 29 | } |
| 30 | |
| 31 | inline Module* DomainFile::GetModule() |
| 32 | { |
| 33 | LIMITED_METHOD_CONTRACT; |
| 34 | SUPPORTS_DAC; |
| 35 | |
| 36 | { |
| 37 | // While executing the consistency check, we will take a lock. |
| 38 | // But since this is debug-only, we'll allow the lock violation so that |
| 39 | // CANNOT_TAKE_LOCK callers aren't penalized |
| 40 | CONTRACT_VIOLATION(TakesLockViolation); |
| 41 | CONSISTENCY_CHECK(CheckLoadLevel(FILE_LOAD_ALLOCATE)); |
| 42 | } |
| 43 | |
| 44 | return m_pModule; |
| 45 | } |
| 46 | |
| 47 | inline Assembly* DomainAssembly::GetCurrentAssembly() |
| 48 | { |
| 49 | LIMITED_METHOD_CONTRACT; |
| 50 | STATIC_CONTRACT_SO_TOLERANT; |
| 51 | |
| 52 | return m_pAssembly; |
| 53 | } |
| 54 | |
| 55 | inline Assembly* DomainAssembly::GetLoadedAssembly() |
| 56 | { |
| 57 | LIMITED_METHOD_DAC_CONTRACT; |
| 58 | |
| 59 | { |
| 60 | // CheckLoaded() eventually calls PEFile::GetNativeImageWithRef(), which |
| 61 | // takes a reader lock on the file's m_pMetadataLock. However, this is |
| 62 | // only done in debug for the consistency check, so we can accept the lock violation. |
| 63 | CONTRACT_VIOLATION(TakesLockViolation); |
| 64 | CONSISTENCY_CHECK(CheckLoaded()); |
| 65 | } |
| 66 | |
| 67 | return m_pAssembly; |
| 68 | } |
| 69 | |
| 70 | inline Assembly* DomainAssembly::GetAssembly() |
| 71 | { |
| 72 | LIMITED_METHOD_CONTRACT; |
| 73 | STATIC_CONTRACT_SO_TOLERANT; |
| 74 | |
| 75 | { |
| 76 | // CheckLoadLevel() is SO_INTOLERANT. However, this is only done in |
| 77 | // debug for the consistency check, so we can accept the SO violation. |
| 78 | CONTRACT_VIOLATION(SOToleranceViolation); |
| 79 | CONSISTENCY_CHECK(CheckLoadLevel(FILE_LOAD_ALLOCATE)); |
| 80 | } |
| 81 | return m_pAssembly; |
| 82 | } |
| 83 | |
| 84 | #ifndef DACCESS_COMPILE |
| 85 | inline void DomainFile::UpdatePEFileWorker(PTR_PEFile pFile) |
| 86 | { |
| 87 | LIMITED_METHOD_CONTRACT; |
| 88 | CONSISTENCY_CHECK(CheckPointer(pFile)); |
| 89 | if (pFile==m_pFile) |
| 90 | return; |
| 91 | _ASSERTE(m_pOriginalFile==NULL); |
| 92 | m_pOriginalFile=m_pFile; |
| 93 | pFile->AddRef(); |
| 94 | m_pFile=pFile; |
| 95 | } |
| 96 | |
| 97 | inline void DomainAssembly::UpdatePEFile(PTR_PEFile pFile) |
| 98 | { |
| 99 | CONTRACTL |
| 100 | { |
| 101 | THROWS; |
| 102 | GC_NOTRIGGER; |
| 103 | MODE_ANY; |
| 104 | CAN_TAKE_LOCK; |
| 105 | } |
| 106 | CONTRACTL_END; |
| 107 | |
| 108 | GetAppDomain()->UpdatePublishHostedAssembly(this, pFile); |
| 109 | } |
| 110 | |
| 111 | #endif // DACCESS_COMPILE |
| 112 | |
| 113 | inline ULONG DomainAssembly::HashIdentity() |
| 114 | { |
| 115 | WRAPPER_NO_CONTRACT; |
| 116 | return GetFile()->HashIdentity(); |
| 117 | } |
| 118 | |
| 119 | inline BOOL DomainAssembly::IsCollectible() |
| 120 | { |
| 121 | LIMITED_METHOD_CONTRACT; |
| 122 | return m_fCollectible; |
| 123 | } |
| 124 | |
| 125 | |