// --------------------------------------------------------------------------- // CCache::RetrievTransCacheEntry // Retrieves transport entry from transport cache //--------------------------------------------------------------------------- HRESULT CCache::RetrieveTransCacheEntry(IAssemblyName *pName, DWORD dwFlags, CTransCache **ppTransCache) { HRESULT hr; DWORD dwCmpMask = 0; DWORD dwVerifyFlags; CTransCache *pTransCache = NULL; CTransCache *pTransCacheMax = NULL; if (IsGacType(dwFlags) || IsZapType(dwFlags)) { dwVerifyFlags = SN_INFLAG_ADMIN_ACCESS; } else { _ASSERTE(dwFlags & CACHE_DOWNLOAD); dwVerifyFlags = SN_INFLAG_USER_ACCESS; } // Fully specified - direct lookup. // Partial - enum global cache only. // If fully specified, do direct lookup. if (!(CAssemblyName::IsPartial(pName, &dwCmpMask))) { // Create a transcache entry from name. if (FAILED(hr = TransCacheEntryFromName(pName, dwFlags, &pTransCache))) goto exit; // Retrieve this record from the database. if (FAILED(hr = pTransCache->Retrieve())) goto exit; } // Ref is partial - enum global cache. else { // Should only be in here if enumerating global cache or retrieving custom assembly. _ASSERTE (IsGacType(dwFlags) || IsZapType(dwFlags) || (dwCmpMask & ASM_CMPF_CUSTOM)); // Create a transcache entry from name. if (FAILED(hr = TransCacheEntryFromName(pName, dwFlags, &pTransCache))) goto exit; // Retrieve the max entry. if (FAILED(hr = pTransCache->Retrieve(&pTransCacheMax, dwCmpMask))) goto exit; } exit: // Failure. if (FAILED(hr) || (hr == S_FALSE)) { SAFERELEASE(pTransCache); SAFERELEASE(pTransCacheMax); } // Success. else { if (pTransCacheMax) { *ppTransCache = pTransCacheMax; SAFERELEASE(pTransCache); } else { *ppTransCache = pTransCache; } } return hr; }
// --------------------------------------------------------------------------- // CCache::GetGlobalMax //--------------------------------------------------------------------------- HRESULT CCache::GetGlobalMax(IAssemblyName *pName, IAssemblyName **ppNameGlobal, CTransCache **ppTransCache) { HRESULT hr = NOERROR; DWORD dwCmpMask = 0; BOOL fIsPartial = FALSE; CTransCache *pTransCache = NULL, *pTransCacheMax = NULL; IAssemblyName *pNameGlobal = NULL; CCache *pCache = NULL; if (FAILED(hr = Create(&pCache, NULL))) goto exit; // Create query trans cache object. if (FAILED(hr = pCache->TransCacheEntryFromName( pName, CACHE_GAC, &pTransCache))) goto exit; // For both full and partially specified, mask off version. fIsPartial = CAssemblyName::IsPartial(pName, &dwCmpMask); if (!fIsPartial) dwCmpMask = ASM_CMPF_NAME | ASM_CMPF_CULTURE | ASM_CMPF_PUBLIC_KEY_TOKEN | ASM_CMPF_CUSTOM; else dwCmpMask &= ~(ASM_CMPF_MAJOR_VERSION | ASM_CMPF_MINOR_VERSION | ASM_CMPF_REVISION_NUMBER | ASM_CMPF_BUILD_NUMBER); // Retrieve the max entry. if (FAILED(hr = pTransCache->Retrieve(&pTransCacheMax, dwCmpMask))) goto exit; // Found a match. if (hr == S_OK) { // If version matches or exceeds, return. ULONGLONG ullVer = 0; hr = CAssemblyName::GetVersion(pName, FALSE, &ullVer); if (FAILED(hr)) { goto exit; } if (pTransCacheMax->GetVersion() >= ullVer) { hr = S_OK; if (FAILED(hr = CCache::NameFromTransCacheEntry( pTransCacheMax, &pNameGlobal))) goto exit; } else { hr = S_FALSE; } } exit: if (hr == S_OK) { *ppTransCache = pTransCacheMax; *ppNameGlobal = pNameGlobal; } else { SAFERELEASE(pTransCacheMax); SAFERELEASE(pNameGlobal); } SAFERELEASE(pTransCache); SAFERELEASE(pCache); return hr; }
// --------------------------------------------------------------------------- // CCache::RetrievTransCacheEntry // Retrieves transport entry from transport cache //--------------------------------------------------------------------------- HRESULT CCache::RetrieveTransCacheEntry(IAssemblyName *pName, DWORD dwFlags, CTransCache **ppTransCache) { HRESULT hr; DWORD dwCmpMask = 0; DWORD dwVerifyFlags; CTransCache *pTransCache = NULL; CTransCache *pTransCacheMax = NULL; if ((dwFlags & ASM_CACHE_GAC) || (dwFlags & ASM_CACHE_ZAP)) { dwVerifyFlags = SN_INFLAG_ADMIN_ACCESS; } else { ASSERT(dwFlags & ASM_CACHE_DOWNLOAD); dwVerifyFlags = SN_INFLAG_USER_ACCESS; } // Fully specified - direct lookup. // Partial - enum global cache only. // If fully specified, do direct lookup. if (!(CAssemblyName::IsPartial(pName, &dwCmpMask))) { // Create a transcache entry from name. if (FAILED(hr = TransCacheEntryFromName(pName, dwFlags, &pTransCache))) goto exit; // Retrieve this record from the database. if (FAILED(hr = pTransCache->Retrieve())) goto exit; } // Ref is partial - enum global cache. else { // Should only be in here if enumerating global cache or retrieving custom assembly. ASSERT ((dwFlags & ASM_CACHE_GAC) || (dwFlags & ASM_CACHE_ZAP) || (dwCmpMask & ASM_CMPF_CUSTOM)); // Create a transcache entry from name. if (FAILED(hr = TransCacheEntryFromName(pName, dwFlags, &pTransCache))) goto exit; // Retrieve the max entry. if (FAILED(hr = pTransCache->Retrieve(&pTransCacheMax, dwCmpMask))) goto exit; } // If the assembly was comitted as delay-signed, re-verify. CTransCache *pTC; pTC = pTransCacheMax ? pTransCacheMax : pTransCache; if (pTC && (pTC->_pInfo->dwType & ASM_DELAY_SIGNED)) { hr = VerifySignatureHelper(pTC, dwVerifyFlags); } exit: // Failure. if (FAILED(hr) || (hr == DB_S_NOTFOUND)) { SAFERELEASE(pTransCache); SAFERELEASE(pTransCacheMax); } // Success. else { if (pTransCacheMax) { *ppTransCache = pTransCacheMax; SAFERELEASE(pTransCache); } else { *ppTransCache = pTransCache; } } return hr; }