| 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 | // Assembly.inl |
| 7 | // |
| 8 | |
| 9 | |
| 10 | // |
| 11 | // Implements the inline methods of Assembly |
| 12 | // |
| 13 | // ============================================================ |
| 14 | |
| 15 | #ifndef __BINDER__ASSEMBLY_INL__ |
| 16 | #define __BINDER__ASSEMBLY_INL__ |
| 17 | |
| 18 | PEImage *Assembly::GetPEImage(BOOL fAddRef /* = FALSE */) |
| 19 | { |
| 20 | PEImage *pPEImage = m_pPEImage; |
| 21 | |
| 22 | if (fAddRef) |
| 23 | { |
| 24 | BinderAddRefPEImage(pPEImage); |
| 25 | } |
| 26 | |
| 27 | return pPEImage; |
| 28 | } |
| 29 | |
| 30 | PEImage *Assembly::GetNativePEImage(BOOL fAddRef /* = FALSE */) |
| 31 | { |
| 32 | PEImage *pNativePEImage = m_pNativePEImage; |
| 33 | |
| 34 | if (fAddRef) |
| 35 | { |
| 36 | BinderAddRefPEImage(pNativePEImage); |
| 37 | } |
| 38 | |
| 39 | return pNativePEImage; |
| 40 | } |
| 41 | |
| 42 | PEImage *Assembly::GetNativeOrILPEImage(BOOL fAddRef /* = FALSE */) |
| 43 | { |
| 44 | PEImage* pPEImage = GetNativePEImage(fAddRef); |
| 45 | if (pPEImage == NULL) |
| 46 | pPEImage = GetPEImage(fAddRef); |
| 47 | return pPEImage; |
| 48 | } |
| 49 | |
| 50 | void Assembly::SetPEImage(PEImage *pPEImage) |
| 51 | { |
| 52 | BinderAddRefPEImage(pPEImage); |
| 53 | m_pPEImage = pPEImage; |
| 54 | } |
| 55 | |
| 56 | void Assembly::SetNativePEImage(PEImage *pNativePEImage) |
| 57 | { |
| 58 | BinderAddRefPEImage(pNativePEImage); |
| 59 | m_pNativePEImage = pNativePEImage; |
| 60 | } |
| 61 | |
| 62 | AssemblyName *Assembly::GetAssemblyName(BOOL fAddRef /* = FALSE */) |
| 63 | { |
| 64 | AssemblyName *pAssemblyName = m_pAssemblyName; |
| 65 | |
| 66 | if (fAddRef && (pAssemblyName != NULL)) |
| 67 | { |
| 68 | pAssemblyName->AddRef(); |
| 69 | } |
| 70 | return pAssemblyName; |
| 71 | } |
| 72 | |
| 73 | void Assembly::SetAssemblyName(AssemblyName *pAssemblyName, |
| 74 | BOOL fAddRef /* = TRUE */) |
| 75 | { |
| 76 | SAFE_RELEASE(m_pAssemblyName); |
| 77 | |
| 78 | m_pAssemblyName = pAssemblyName; |
| 79 | |
| 80 | if (fAddRef && (pAssemblyName != NULL)) |
| 81 | { |
| 82 | pAssemblyName->AddRef(); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | BOOL Assembly::GetInspectionOnly() |
| 87 | { |
| 88 | return ((m_dwAssemblyFlags & FLAG_INSPECTION_ONLY) != 0); |
| 89 | } |
| 90 | |
| 91 | void Assembly::SetInspectionOnly(BOOL fInspectionOnly) |
| 92 | { |
| 93 | if (fInspectionOnly) |
| 94 | { |
| 95 | m_dwAssemblyFlags |= FLAG_INSPECTION_ONLY; |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | m_dwAssemblyFlags &= ~FLAG_INSPECTION_ONLY; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | BOOL Assembly::GetIsInGAC() |
| 104 | { |
| 105 | return ((m_dwAssemblyFlags & FLAG_IS_IN_GAC) != 0); |
| 106 | } |
| 107 | |
| 108 | void Assembly::SetIsInGAC(BOOL fIsInGAC) |
| 109 | { |
| 110 | if (fIsInGAC) |
| 111 | { |
| 112 | m_dwAssemblyFlags |= FLAG_IS_IN_GAC; |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | m_dwAssemblyFlags &= ~FLAG_IS_IN_GAC; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | BOOL Assembly::GetIsDynamicBind() |
| 121 | { |
| 122 | return ((m_dwAssemblyFlags & FLAG_IS_DYNAMIC_BIND) != 0); |
| 123 | } |
| 124 | |
| 125 | void Assembly::SetIsDynamicBind(BOOL fIsDynamicBind) |
| 126 | { |
| 127 | if (fIsDynamicBind) |
| 128 | { |
| 129 | m_dwAssemblyFlags |= FLAG_IS_DYNAMIC_BIND; |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | m_dwAssemblyFlags &= ~FLAG_IS_DYNAMIC_BIND; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | BOOL Assembly::GetIsByteArray() |
| 138 | { |
| 139 | return ((m_dwAssemblyFlags & FLAG_IS_BYTE_ARRAY) != 0); |
| 140 | } |
| 141 | |
| 142 | void Assembly::SetIsByteArray(BOOL fIsByteArray) |
| 143 | { |
| 144 | if (fIsByteArray) |
| 145 | { |
| 146 | m_dwAssemblyFlags |= FLAG_IS_BYTE_ARRAY; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | m_dwAssemblyFlags &= ~FLAG_IS_BYTE_ARRAY; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | BOOL Assembly::GetIsSharable() |
| 155 | { |
| 156 | return ((m_dwAssemblyFlags & FLAG_IS_SHARABLE) != 0); |
| 157 | } |
| 158 | |
| 159 | void Assembly::SetIsSharable(BOOL fIsSharable) |
| 160 | { |
| 161 | if (fIsSharable) |
| 162 | { |
| 163 | m_dwAssemblyFlags |= FLAG_IS_SHARABLE; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | m_dwAssemblyFlags &= ~FLAG_IS_SHARABLE; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | SString &Assembly::GetPath() |
| 172 | { |
| 173 | return m_assemblyPath; |
| 174 | } |
| 175 | |
| 176 | IMDInternalImport *Assembly::GetMDImport() |
| 177 | { |
| 178 | return m_pMDImport; |
| 179 | } |
| 180 | |
| 181 | void Assembly::SetMDImport(IMDInternalImport *pMDImport) |
| 182 | { |
| 183 | SAFE_RELEASE(m_pMDImport); |
| 184 | |
| 185 | m_pMDImport = pMDImport; |
| 186 | m_pMDImport->AddRef(); |
| 187 | } |
| 188 | |
| 189 | mdAssembly *Assembly::GetAssemblyRefTokens() |
| 190 | { |
| 191 | return m_pAssemblyRefTokens; |
| 192 | } |
| 193 | |
| 194 | DWORD Assembly::GetNbAssemblyRefTokens() |
| 195 | { |
| 196 | return m_dwCAssemblyRefTokens; |
| 197 | } |
| 198 | |
| 199 | void Assembly::SetNbAsssemblyRefTokens(DWORD dwCAssemblyRefTokens) |
| 200 | { |
| 201 | m_dwCAssemblyRefTokens = dwCAssemblyRefTokens; |
| 202 | } |
| 203 | |
| 204 | BINDER_SPACE::Assembly* GetAssemblyFromPrivAssemblyFast(ICLRPrivAssembly *pPrivAssembly) |
| 205 | { |
| 206 | #ifdef _DEBUG |
| 207 | if(pPrivAssembly != nullptr) |
| 208 | { |
| 209 | // Ensure the pPrivAssembly we are about to cast is indeed a valid Assembly |
| 210 | DWORD dwImageType = 0; |
| 211 | pPrivAssembly->GetAvailableImageTypes(&dwImageType); |
| 212 | _ASSERTE((dwImageType & ASSEMBLY_IMAGE_TYPE_ASSEMBLY) == ASSEMBLY_IMAGE_TYPE_ASSEMBLY); |
| 213 | } |
| 214 | #endif |
| 215 | return (BINDER_SPACE::Assembly *)pPrivAssembly; |
| 216 | } |
| 217 | |
| 218 | #endif |
| 219 |