diff options
-rw-r--r-- | src/inc/vptr_list.h | 6 | ||||
-rw-r--r-- | src/inc/zapper.h | 8 | ||||
-rw-r--r-- | src/vm/appdomain.cpp | 114 | ||||
-rw-r--r-- | src/vm/appdomain.hpp | 5 | ||||
-rw-r--r-- | src/vm/assembly.cpp | 378 | ||||
-rw-r--r-- | src/vm/assembly.hpp | 19 | ||||
-rw-r--r-- | src/vm/assemblynative.cpp | 114 | ||||
-rw-r--r-- | src/vm/ceeload.cpp | 110 | ||||
-rw-r--r-- | src/vm/commodule.cpp | 40 | ||||
-rw-r--r-- | src/vm/commodule.h | 6 | ||||
-rw-r--r-- | src/vm/domainfile.cpp | 411 | ||||
-rw-r--r-- | src/vm/domainfile.h | 109 | ||||
-rw-r--r-- | src/vm/domainfile.inl | 8 | ||||
-rw-r--r-- | src/vm/pefile.cpp | 402 | ||||
-rw-r--r-- | src/vm/pefile.h | 79 | ||||
-rw-r--r-- | src/vm/pefile.inl | 100 | ||||
-rw-r--r-- | src/zap/zapper.cpp | 140 |
17 files changed, 0 insertions, 2049 deletions
diff --git a/src/inc/vptr_list.h b/src/inc/vptr_list.h index fe45684a80..4e50fe52a8 100644 --- a/src/inc/vptr_list.h +++ b/src/inc/vptr_list.h @@ -31,9 +31,6 @@ VPTR_CLASS(SharedDomain) VPTR_CLASS(SystemDomain) VPTR_CLASS(DomainAssembly) -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -VPTR_CLASS(DomainModule) -#endif #ifdef FEATURE_REMOTING #ifdef _TARGET_AMD64_ // HAS_REMOTING_PRECODE VPTR_CLASS(CNonVirtualThunkMgr) @@ -54,9 +51,6 @@ VPTR_CLASS(DelegateInvokeStubManager) VPTR_CLASS(TailCallStubManager) VPTR_CLASS(PEFile) VPTR_CLASS(PEAssembly) -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -VPTR_CLASS(PEModule) -#endif VPTR_CLASS(PEImageLayout) VPTR_CLASS(RawImageLayout) VPTR_CLASS(ConvertedImageLayout) diff --git a/src/inc/zapper.h b/src/inc/zapper.h index 80229fc528..a55ddbe75f 100644 --- a/src/inc/zapper.h +++ b/src/inc/zapper.h @@ -310,14 +310,6 @@ class Zapper void CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); ZapImage * CompileModule(CORINFO_MODULE_HANDLE hModule, IMetaDataAssemblyEmit *pEmit); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - void CompileNonManifestModules(ULONG hashAlgId, SArray<HANDLE> &hFiles); - static void * GetMapViewOfFile( - HANDLE hFile, - DWORD * pdwFileLen); - static void ComputeHashValue(HANDLE hFile, int hashAlg, - BYTE **ppHashValue, DWORD *cbHashValue); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES void InstallCompiledAssembly(LPCWSTR szAssemblyName, LPCWSTR szNativeImagePath, HANDLE hFile, SArray<HANDLE> &hFiles); HRESULT GetExceptionHR(); diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index c28af7ce9e..3b4be97cd0 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -5939,109 +5939,6 @@ DomainAssembly *AppDomain::LoadDomainAssemblyInternal(AssemblySpec* pIdentity, RETURN result; } // AppDomain::LoadDomainAssembly -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - -#ifndef CROSSGEN_COMPILE -// Thread stress -class LoadDomainModuleStress : APIThreadStress -{ -public: - AppDomain *pThis; - DomainAssembly *pAssembly; - PEModule *pFile; - FileLoadLevel targetLevel; - - LoadDomainModuleStress(AppDomain *pThis, DomainAssembly *pAssembly, PEModule *pFile, FileLoadLevel targetLevel) - : pThis(pThis), pAssembly(pAssembly), pFile(pFile), targetLevel(targetLevel) {LIMITED_METHOD_CONTRACT;} - - void Invoke() - { - WRAPPER_NO_CONTRACT; - STATIC_CONTRACT_SO_INTOLERANT; - SetupThread(); - pThis->LoadDomainModule(pAssembly, pFile, targetLevel); - } -}; -#endif // CROSSGEN_COMPILE - -DomainModule *AppDomain::LoadDomainModule(DomainAssembly *pAssembly, PEModule *pFile, - FileLoadLevel targetLevel) -{ - CONTRACT(DomainModule *) - { - GC_TRIGGERS; - THROWS; - MODE_ANY; - PRECONDITION(CheckPointer(pAssembly)); - PRECONDITION(CheckPointer(pFile)); - POSTCONDITION(CheckPointer(RETVAL)); - POSTCONDITION(RETVAL->GetLoadLevel() >= GetThreadFileLoadLevel() - || RETVAL->GetLoadLevel() >= targetLevel); - POSTCONDITION(RETVAL->CheckNoError(targetLevel)); - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END; - - GCX_PREEMP(); - -#ifndef CROSSGEN_COMPILE - // Thread stress - LoadDomainModuleStress ts (this, pAssembly, pFile, targetLevel); -#endif - - // Check for existing fully loaded assembly - DomainModule *result = pAssembly->FindModule(pFile); - if (result == NULL) - { - LoadLockHolder lock(this); - - // Check again in case we were racing - result = pAssembly->FindModule(pFile); - if (result == NULL) - { - // Find the list lock entry - FileLoadLock *fileLock = (FileLoadLock *) lock->FindFileLock(pFile); - if (fileLock == NULL) - { - // We are the first one in - create the DomainModule - NewHolder<DomainModule> pDomainModule(new DomainModule(this, pAssembly, pFile)); - fileLock = FileLoadLock::Create(lock, pFile, pDomainModule); - pDomainModule.SuppressRelease(); - } - else - fileLock->AddRef(); - - lock.Release(); - - // We pass our ref on fileLock to LoadDomainFile to release. - - // Note that if we throw here, we will poison fileLock with an error condition, - // so it will not be removed until app domain unload. So there is no need - // to release our ref count. - - result = (DomainModule *) LoadDomainFile(fileLock, targetLevel); - } - else - { - lock.Release(); - result->EnsureLoadLevel(targetLevel); - } - - } - else - result->EnsureLoadLevel(targetLevel); - - // Malformed metadata may contain an Assembly reference to what is actually - // a Module. In this case we need to throw an exception, since returning a - // DomainAssembly as a DomainModule is a type safety violation. - if (result->IsAssembly()) - { - ThrowHR(COR_E_ASSEMBLY_NOT_EXPECTED); - } - - RETURN result; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES struct LoadFileArgs { @@ -6402,19 +6299,8 @@ DomainFile *AppDomain::LoadDomainNeutralModuleDependency(Module *pModule, FileLo ThrowHR(SECURITY_E_INCOMPATIBLE_SHARE); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (pModule == pAssembly->GetManifestModule()) - pDomainFile = pDomainAssembly; - else - { - pDomainFile = LoadDomainModule(pDomainAssembly, (PEModule*) pModule->GetFile(), targetLevel); - STRESS_LOG4(LF_CLASSLOADER, LL_INFO100,"LDNMD: DF: for %p[%p/%p] is %p", - pModule,pDomainAssembly,pModule->GetFile(),pDomainFile); - } -#else _ASSERTE (pModule == pAssembly->GetManifestModule()); pDomainFile = pDomainAssembly; -#endif } else { diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index 9ecb820ae0..c0d3bf157d 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -2356,11 +2356,6 @@ public: FileLoadLevel targetLevel, AssemblyLoadSecurity *pLoadSecurity = NULL); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - DomainModule *LoadDomainModule(DomainAssembly *pAssembly, - PEModule *pFile, - FileLoadLevel targetLevel); -#endif CHECK CheckValidModule(Module *pModule); #ifdef FEATURE_LOADER_OPTIMIZATION diff --git a/src/vm/assembly.cpp b/src/vm/assembly.cpp index 3d05368317..7801c9b9ed 100644 --- a/src/vm/assembly.cpp +++ b/src/vm/assembly.cpp @@ -114,10 +114,6 @@ enum ReasonForNotSharing //---------------------------------------------------------------------------------------------- Assembly::Assembly(BaseDomain *pDomain, PEAssembly* pFile, DebuggerAssemblyControlFlags debuggerFlags, BOOL fIsCollectible) : m_FreeFlag(0), -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - m_pAllowedFiles(NULL), - m_crstAllowedFiles(CrstAllowedFiles), -#endif m_pDomain(pDomain), m_pClassLoader(NULL), m_pEntryPoint(NULL), @@ -243,9 +239,6 @@ void Assembly::Init(AllocMemTracker *pamTracker, LoaderAllocator *pLoaderAllocat m_pSharedSecurityDesc = Security::CreateSharedSecurityDescriptor(this); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - m_pAllowedFiles = new EEUtf8StringHashTable(); -#endif COUNTER_ONLY(GetPerfCounters().m_Loading.cAssemblies++); @@ -352,10 +345,6 @@ Assembly::~Assembly() if (m_pwStrongNameKeyContainer && (m_FreeFlag & FREE_KEY_CONTAINER)) delete[] m_pwStrongNameKeyContainer; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (m_pAllowedFiles) - delete(m_pAllowedFiles); -#endif if (IsDynamic()) { if (m_pOnDiskManifest) // clear the on disk manifest if it is not cleared yet. @@ -945,87 +934,6 @@ Assembly *Assembly::CreateDynamic(AppDomain *pDomain, CreateDynamicAssemblyArgs RETURN pRetVal; } // Assembly::CreateDynamic -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -ReflectionModule *Assembly::CreateDynamicModule(LPCWSTR wszModuleName, LPCWSTR wszFileName, BOOL fIsTransient, INT32* ptkFile) -{ - CONTRACT(ReflectionModule *) - { - STANDARD_VM_CHECK; - POSTCONDITION(CheckPointer(RETVAL)); - } - CONTRACT_END; - - AllocMemTracker amTracker; - - // Add a manifest entry for the module - mdFile token; - IMetaDataAssemblyEmit *pAssemblyEmit = GetManifestFile()->GetAssemblyEmitter(); - IfFailThrow(pAssemblyEmit->DefineFile(wszFileName, NULL, 0, 0, &token)); - - if (ptkFile) - *ptkFile = (INT32)token; - - GetManifestModule()->UpdateDynamicMetadataIfNeeded(); - - // Define initial metadata for the module - SafeComHolder<IMetaDataEmit> pEmit; - PEFile::DefineEmitScope(IID_IMetaDataEmit, (void **)&pEmit); - - // the module name will be set later when we create the ReflectionModule - - // Create the PEFile for the module - PEModuleHolder pFile(PEModule::Create(GetManifestFile(), token, pEmit)); - - // Create the DomainModule - NewHolder<DomainModule> pDomainModule(new DomainModule(::GetAppDomain(), GetDomainAssembly(), pFile)); - - // Create the module itself - ReflectionModuleHolder pWrite(ReflectionModule::Create(this, pFile, &amTracker, wszModuleName, fIsTransient)); - - amTracker.SuppressRelease(); //@todo: OOM: is this the right place to commit the tracker? - pWrite->SetIsTenured(); - - // Modules take the DebuggerAssemblyControlFlags down from its parent Assembly initially. - // By default, this turns on JIT optimization. - - pWrite->SetDebuggerInfoBits(GetDebuggerInfoBits()); - - // Associate the two - pDomainModule->SetModule(pWrite); - m_pManifest->StoreFileThrowing(token, pWrite); - - // Simulate loading process - pDomainModule->Begin(); - pDomainModule->DeliverSyncEvents(); - pDomainModule->DeliverAsyncEvents(); - pDomainModule->FinishLoad(); - pDomainModule->ClearLoading(); - pDomainModule->m_level = FILE_ACTIVE; - - pDomainModule.SuppressRelease(); - ReflectionModule *pModule = pWrite.Extract(); - - LPCSTR szUTF8FileName; - CQuickBytes qbLC; - - // Get the UTF8 file name - IfFailThrow(m_pManifest->GetMDImport()->GetFileProps(token, &szUTF8FileName, NULL, NULL, NULL)); - UTF8_TO_LOWER_CASE(szUTF8FileName, qbLC); - LPCSTR szUTF8FileNameLower = (LPUTF8) qbLC.Ptr(); - - CrstHolder lock(&m_crstAllowedFiles); - - // insert the value into manifest's look up table. - // Need to perform case insensitive hashing as well. - m_pAllowedFiles->InsertValue(szUTF8FileName, (HashDatum)(size_t)token, TRUE); - m_pAllowedFiles->InsertValue(szUTF8FileNameLower, (HashDatum)(size_t)token, TRUE); - - // Now make file token associate with the loaded module - m_pManifest->StoreFileThrowing(token, pModule); - - RETURN pModule; -} // Assembly::CreateDynamicModule -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // CROSSGEN_COMPILE @@ -1207,37 +1115,7 @@ void Assembly::SetParent(BaseDomain* pParent) mdFile Assembly::GetManifestFileToken(LPCSTR name) { -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - FORBID_FAULT; - MODE_ANY; - SUPPORTS_DAC; - } - CONTRACTL_END; - - HashDatum datum; - // Note: We're doing a case sensitive lookup - // This is OK because the lookup string and the string we insert into the hashtable - // are obtained from the same place. - - // m_pAllowedFiles only grows - entries are never deleted from it. So we do not take - // a lock around GetValue. If the code is modified such that we delete entries from m_pAllowedFiles, - // reconsider whether the callers that consume the mdFile should take the m_crstAllowedFiles lock. - if (m_pAllowedFiles->GetValue(name, &datum)) { - - if (datum != NULL) // internal module - return (mdFile)(size_t)PTR_TO_TADDR(datum); - else // manifest file - return mdFileNil; - } - else - return mdTokenNil; // not found -#else return mdFileNil; -#endif } mdFile Assembly::GetManifestFileToken(IMDInternalImport *pImport, mdFile kFile) @@ -1661,105 +1539,6 @@ void Assembly::CacheManifestExportedTypes(AllocMemTracker *pamTracker) } void Assembly::CacheManifestFiles() { -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - CONTRACT_VOID - { - THROWS; - GC_TRIGGERS; - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END; - - mdToken tkFile; - LPCSTR pszFileName; - CQuickBytes qbLC; - - HENUMInternalHolder phEnum(GetManifestImport()); - phEnum.EnumInit(mdtFile, - mdTokenNil); - - - DWORD dwCount = GetManifestImport()->EnumGetCount(&phEnum); - LockOwner lockOwner = { &m_crstAllowedFiles, IsOwnerOfCrst }; - if (!m_pAllowedFiles->Init(dwCount+1, &lockOwner)) - ThrowOutOfMemory(); - - CrstHolder lock(&m_crstAllowedFiles); - - m_nextAvailableModuleIndex = dwCount+1; - - while (GetManifestImport()->EnumNext(&phEnum, &tkFile)) - { - if (TypeFromToken(tkFile) == mdtFile) - { - IfFailThrow(GetManifestImport()->GetFileProps( - tkFile, - &pszFileName, - NULL, // hash - NULL, // hash len - NULL)); // flags - - // Add to hash table - m_pAllowedFiles->InsertValue(pszFileName, (HashDatum)(size_t)tkFile, TRUE); - - // Need to perform case insensitive hashing as well. - { - UTF8_TO_LOWER_CASE(pszFileName, qbLC); - pszFileName = (LPUTF8) qbLC.Ptr(); - } - - // Add each internal module - m_pAllowedFiles->InsertValue(pszFileName, (HashDatum)(size_t)tkFile, TRUE); - } - } - - HENUMInternalHolder phEnumModules(GetManifestImport()); - phEnumModules.EnumInit(mdtModuleRef, mdTokenNil); - mdToken tkModuleRef; - - while (GetManifestImport()->EnumNext(&phEnumModules, &tkModuleRef)) - { - LPCSTR pszModuleRefName, pszModuleRefNameLower; - - if (TypeFromToken(tkModuleRef) == mdtModuleRef) - { - IfFailThrow(GetManifestImport()->GetModuleRefProps(tkModuleRef, &pszModuleRefName)); - - // Convert to lower case and lookup - { - UTF8_TO_LOWER_CASE(pszModuleRefName, qbLC); - pszModuleRefNameLower = (LPUTF8) qbLC.Ptr(); - } - - HashDatum datum; - if (m_pAllowedFiles->GetValue(pszModuleRefNameLower, &datum)) - { - mdFile tkFileForModuleRef = (mdFile)(size_t)datum; - m_pAllowedFiles->InsertValue(pszModuleRefName, (HashDatum)(size_t)tkFileForModuleRef); - } - } - } - - // Add the manifest file - if (!GetManifestImport()->IsValidToken(GetManifestImport()->GetModuleFromScope())) - { - ThrowHR(COR_E_BADIMAGEFORMAT); - } - IfFailThrow(GetManifestImport()->GetScopeProps(&pszFileName, NULL)); - - // Add to hash table - m_pAllowedFiles->InsertValue(pszFileName, NULL, TRUE); - - // Need to perform case insensitive hashing as well. - { - UTF8_TO_LOWER_CASE(pszFileName, qbLC); - pszFileName = (LPUTF8) qbLC.Ptr(); - } - - m_pAllowedFiles->InsertValue(pszFileName, NULL, TRUE); - - RETURN; -#endif } @@ -1814,25 +1593,6 @@ void Assembly::PublishModuleIntoAssembly(Module *module) -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -Module* Assembly::FindModule(PEFile *pFile, BOOL includeLoading) -{ - CONTRACT(Module *) - { - THROWS; - GC_TRIGGERS; - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END; - - DomainFile *pModule = GetDomainAssembly()->FindModule(pFile, includeLoading); - - if (pModule == NULL) - RETURN NULL; - else - RETURN pModule->GetModule(); -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES //***************************************************************************** @@ -2587,144 +2347,6 @@ BOOL Assembly::FileNotFound(HRESULT hr) (hr == CLR_E_BIND_TYPE_NOT_FOUND); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -PEModule * Assembly::LoadModule_AddRef(mdFile kFile, BOOL fLoadResource) -{ - CONTRACT(PEModule *) - { - INSTANCE_CHECK; - THROWS; - GC_TRIGGERS; - MODE_ANY; - POSTCONDITION(CheckPointer(RETVAL, fLoadResource ? NULL_NOT_OK : NULL_OK)); - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END - - if (! ((TypeFromToken(kFile) == mdtFile) && - GetManifestImport()->IsValidToken(kFile)) ) - { - ThrowHR(COR_E_BADIMAGEFORMAT, BFA_INVALID_FILE_TOKEN); - } - - LPCSTR psModuleName; - DWORD dwFlags; - IfFailThrow(GetManifestImport()->GetFileProps( - kFile, - &psModuleName, - NULL, - NULL, - &dwFlags)); - - if (! (IsFfContainsMetaData(dwFlags) || fLoadResource) ) - RETURN NULL; - - SString name(SString::Utf8, psModuleName); - PEModule * pModule = NULL; - - if (AssemblySpec::VerifyBindingString((LPCWSTR)name)) - { - EX_TRY - { - GCX_PREEMP(); - - if (!m_pManifestFile->GetPath().IsEmpty()) { - StackSString path = m_pManifestFile->GetPath(); - - SString::Iterator i = path.End()-1; - - if (PEAssembly::FindLastPathSeparator(path, i)) { - path.Truncate(++i); - path.Insert(i, name); - } - pModule = PEModule::Open(m_pManifestFile, kFile, path); - } - } - EX_CATCH - { - Exception *ex = GET_EXCEPTION(); - if (FileNotFound(ex->GetHR()) || - (ex->GetHR() == FUSION_E_INVALID_NAME)) - pModule = RaiseModuleResolveEvent_AddRef(psModuleName, kFile); - - if (pModule == NULL) - { - EEFileLoadException::Throw(name, ex->GetHR(), ex); - } - } - EX_END_CATCH(SwallowAllExceptions) - } - - if (pModule == NULL) - { - pModule = RaiseModuleResolveEvent_AddRef(psModuleName, kFile); - if (pModule == NULL) - { - EEFileLoadException::Throw(name, HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); - } - } - - RETURN pModule; -} - -PEModule * Assembly::RaiseModuleResolveEvent_AddRef(LPCSTR szName, mdFile kFile) -{ - CONTRACT(PEModule *) - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM();); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - Module* pModule = NULL; - -#ifndef CROSSGEN_COMPILE - GCX_COOP(); - - struct _gc { - OBJECTREF AssemblyRef; - STRINGREF str; - } gc; - ZeroMemory(&gc, sizeof(gc)); - - GCPROTECT_BEGIN(gc); - if ((gc.AssemblyRef = GetExposedObject()) != NULL) - { - MethodDescCallSite onModuleResolve(METHOD__ASSEMBLY__ON_MODULE_RESOLVE, &gc.AssemblyRef); - gc.str = StringObject::NewString(szName); - ARG_SLOT args[2] = { - ObjToArgSlot(gc.AssemblyRef), - ObjToArgSlot(gc.str) - }; - - REFLECTMODULEBASEREF ResultingModuleRef = - (REFLECTMODULEBASEREF) onModuleResolve.Call_RetOBJECTREF(args); - - if (ResultingModuleRef != NULL) - { - pModule = ResultingModuleRef->GetModule(); - } - } - GCPROTECT_END(); - - if (pModule && ( (!(pModule->IsIntrospectionOnly())) != !(IsIntrospectionOnly()) )) - { - COMPlusThrow(kFileLoadException, IDS_CLASSLOAD_MODULE_RESOLVE_INTROSPECTION_MISMATCH); - } - - if ((pModule != NULL) && - (pModule == m_pManifest->LookupFile(kFile))) - { - RETURN clr::SafeAddRef((PEModule *)pModule->GetFile()); - } -#endif // CROSSGEN_COMPILE - - RETURN NULL; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource, PBYTE *pbInMemoryResource, Assembly** pAssemblyRef, diff --git a/src/vm/assembly.hpp b/src/vm/assembly.hpp index e3f647c461..23e303a38c 100644 --- a/src/vm/assembly.hpp +++ b/src/vm/assembly.hpp @@ -130,9 +130,6 @@ public: BOOL IsSystem() { WRAPPER_NO_CONTRACT; return m_pManifestFile->IsSystem(); } static Assembly *CreateDynamic(AppDomain *pDomain, CreateDynamicAssemblyArgs *args); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - ReflectionModule *CreateDynamicModule(LPCWSTR szModuleName, LPCWSTR szFileName, BOOL fIsTransient, INT32* ptkFile = NULL); -#endif MethodDesc *GetEntryPoint(); @@ -237,12 +234,6 @@ public: return ModuleIterator(this); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - //**************************************************************************************** - // - // Find the module - Module* FindModule(PEFile *pFile, BOOL includeLoading = FALSE); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES //**************************************************************************************** // @@ -619,10 +610,6 @@ public: //**************************************************************************************** // -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - PEModule * LoadModule_AddRef(mdFile kFile, BOOL fLoadResource); - PEModule * RaiseModuleResolveEvent_AddRef(LPCSTR szName, mdFile kFile); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES static BOOL FileNotFound(HRESULT hr); //**************************************************************************************** @@ -721,12 +708,6 @@ protected: // Keep track of the vars that need to be freed. short int m_FreeFlag; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - // Hash of files in manifest by name to File token - PTR_EEUtf8StringHashTable m_pAllowedFiles; - // Critical section guarding m_pAllowedFiles - Crst m_crstAllowedFiles; -#endif private: diff --git a/src/vm/assemblynative.cpp b/src/vm/assemblynative.cpp index 8daa851c74..0a303bf45c 100644 --- a/src/vm/assemblynative.cpp +++ b/src/vm/assemblynative.cpp @@ -790,92 +790,6 @@ Assembly* AssemblyNative::GetPostPolicyAssembly(PEAssembly *pFile, RETURN GetAppDomain()->LoadAssembly(NULL, pFile, FILE_LOADED, pLoadSecurity); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -void QCALLTYPE AssemblyNative::LoadModule(QCall::AssemblyHandle pAssembly, - LPCWSTR wszModuleName, - LPCBYTE pRawModule, INT32 cbModule, - LPCBYTE pRawSymbolStore, INT32 cbSymbolStore, - QCall::ObjectHandleOnStack retModule) -{ - QCALL_CONTRACT; - - BEGIN_QCALL; - - Module * pModule = NULL; - - if(CorHost2::IsLoadFromBlocked()) - COMPlusThrow(kFileLoadException, FUSION_E_LOADFROM_BLOCKED); - - if (wszModuleName == NULL) - COMPlusThrow(kArgumentNullException, W("ArgumentNull_FileName")); - - if (pRawModule == NULL) - COMPlusThrow(kArgumentNullException, W("ArgumentNull_Array")); - - if (*wszModuleName == '\0') - COMPlusThrow(kArgumentException, W("Argument_EmptyFileName")); - - CQuickBytes qbLC; - - MAKE_UTF8PTR_FROMWIDE(pName, wszModuleName); - LPCSTR psModuleName = pName; - - // Need to perform case insensitive lookup. - { - UTF8_TO_LOWER_CASE(psModuleName, qbLC); - psModuleName = (LPUTF8) qbLC.Ptr(); - } - - HashDatum datum; - mdFile kFile = NULL; - // m_pAllowedFiles only grows - entries are never deleted from it. So we do not take - // a lock around GetValue. If the code is modified such that we delete entries from m_pAllowedFiles, - // reconsider whether we should take the m_crstAllowedFiles lock here (see the uses of kFile below). - if (pAssembly->GetAssembly()->m_pAllowedFiles->GetValue(psModuleName, &datum)) - kFile = (mdFile)(size_t)datum; - - // If the name doesn't match one of the File def names, don't load this module. - // If this name matches the manifest file (datum was NULL), don't load either. - if (!kFile) - COMPlusThrow(kArgumentException, W("Arg_InvalidFileName")); - - - PEModuleHolder pFile(PEModule::OpenMemory(pAssembly->GetFile(), kFile, - pRawModule, cbModule)); - - DomainModule *pDomainModule = GetAppDomain()->LoadDomainModule(pAssembly->GetDomainAssembly(), - pFile, FILE_LOADED); - pModule = pDomainModule->GetModule(); - - if (!pFile->Equals(pModule->GetFile())) - COMPlusThrow(kArgumentException, W("Argument_ModuleAlreadyLoaded")); - - LOG((LF_CLASSLOADER, - LL_INFO100, - "\tLoaded in-memory module\n")); - -#ifdef DEBUGGING_SUPPORTED - if (!pModule->IsResource()) - { - // If we were given symbols, hold onto a copy - if (pRawSymbolStore != NULL) - { - pModule->SetSymbolBytes(pRawSymbolStore, cbSymbolStore); - } - } -#endif // DEBUGGING_SUPPORTED - - if (pModule != NULL) - { - GCX_COOP(); - retModule.Set(pModule->GetExposedObject()); - } - - END_QCALL; - - return; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES void QCALLTYPE AssemblyNative::GetLocation(QCall::AssemblyHandle pAssembly, QCall::StringHandleOnStack retString) { @@ -1222,33 +1136,6 @@ void QCALLTYPE AssemblyNative::GetModule(QCall::AssemblyHandle pAssembly, LPCWST MAKE_UTF8PTR_FROMWIDE(szModuleName, wszFileName); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - // Need to perform case insensitive lookup. - { - UTF8_TO_LOWER_CASE(szModuleName, qbLC); - szModuleName = (LPUTF8) qbLC.Ptr(); - } - - HashDatum datum = NULL; - - // m_pAllowedFiles only grows - entries are never deleted from it. So we do not take - // a lock around GetValue. If the code is modified such that we delete entries from m_pAllowedFiles, - // reconsider whether we should take the m_crstAllowedFiles lock here (see the uses of datum below). - if (pAssembly->GetAssembly()->m_pAllowedFiles->GetValue(szModuleName, &datum)) - { - if (datum) - { - // internal module - mdFile tokFile = (mdFile)(UINT_PTR)datum; - - pModule = pAssembly->GetModule()->LoadModule(GetAppDomain(), tokFile)->GetModule(); - } - else - { // manifest module - pModule = pAssembly->GetDomainAssembly()->GetModule(); - } - } -#else LPCUTF8 pModuleName = NULL; @@ -1258,7 +1145,6 @@ void QCALLTYPE AssemblyNative::GetModule(QCall::AssemblyHandle pAssembly, LPCWST pModule = pAssembly->GetDomainAssembly()->GetModule(); } -#endif if (pModule != NULL) { diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index fafb8efa3c..f90e06f768 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -5792,15 +5792,6 @@ Module *Module::GetModuleIfLoaded(mdFile kFile, BOOL onlyLoadedInAppDomain, BOOL pModule = NULL; #ifndef DACCESS_COMPILE -#if defined(FEATURE_MULTIMODULE_ASSEMBLIES) - // check if actually loaded, unless happens during GC (GC works only with loaded assemblies) - if (!GCHeapUtilities::IsGCInProgress() && onlyLoadedInAppDomain && pModule && !pModule->IsManifest()) - { - DomainModule *pDomainModule = pModule->FindDomainModule(GetAppDomain()); - if (pDomainModule == NULL || !pDomainModule->IsLoaded()) - pModule = NULL; - } -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // !DACCESS_COMPILE RETURN pModule; } @@ -5822,99 +5813,6 @@ DomainFile *Module::LoadModule(AppDomain *pDomain, mdFile kFile, } CONTRACT_END; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - - // Handle the module ref case - if (TypeFromToken(kFile) == mdtModuleRef) - { - LPCSTR moduleName; - IfFailThrow(GetMDImport()->GetModuleRefProps(kFile, &moduleName)); - - mdFile kFileLocal = GetAssembly()->GetManifestFileToken(moduleName); - - if (kFileLocal == mdTokenNil) - { - COMPlusThrowHR(COR_E_BADIMAGEFORMAT); - } - - RETURN GetAssembly()->GetManifestModule()->LoadModule(pDomain, kFileLocal, permitResources, bindOnly); - } - - // First, make sure the assembly is loaded in our domain - - DomainAssembly *pDomainAssembly = GetAssembly()->FindDomainAssembly(pDomain); - if (!bindOnly) - { - if (pDomainAssembly == NULL) - pDomainAssembly = GetAssembly()->GetDomainAssembly(pDomain); - pDomain->LoadDomainFile(pDomainAssembly, FILE_LOADED); - } - - if (kFile == mdFileNil) - RETURN pDomainAssembly; - - if (pDomainAssembly == NULL) - RETURN NULL; - - // Now look for the module in the rid maps - - Module *pModule = LookupFile(kFile); - if (pModule == NULL && !IsManifest()) - { - // If we didn't find it there, look at the "master rid map" in the manifest file - Assembly *pAssembly = GetAssembly(); - mdFile kMatch = pAssembly->GetManifestFileToken(GetMDImport(), kFile); - if (IsNilToken(kMatch)) { - if (kMatch == mdFileNil) - pModule = pAssembly->GetManifestModule(); - else - COMPlusThrowHR(COR_E_BADIMAGEFORMAT); - } - else - pModule = pAssembly->GetManifestModule()->LookupFile(kMatch); - } - - // Get a DomainModule for our domain - - DomainModule *pDomainModule = NULL; - if (pModule) - { - pDomainModule = pModule->FindDomainModule(pDomain); - - if (!bindOnly && (permitResources || !pModule->IsResource())) - { - if (pDomainModule == NULL) - pDomainModule = pDomain->LoadDomainModule(pDomainAssembly, (PEModule*) pModule->GetFile(), FILE_LOADED); - else - pDomain->LoadDomainFile(pDomainModule, FILE_LOADED); - } - } - else if (!bindOnly) - { - PEModuleHolder pFile(GetAssembly()->LoadModule_AddRef(kFile, permitResources)); - if (pFile) - pDomainModule = pDomain->LoadDomainModule(pDomainAssembly, pFile, FILE_LOADED); - } - - if (pDomainModule != NULL && pDomainModule->GetCurrentModule() != NULL) - { - // Make sure the module we're loading isn't its own assembly - if (pDomainModule->GetCurrentModule()->IsManifest()) - COMPlusThrowHR(COR_E_ASSEMBLY_NOT_EXPECTED); - - // Cache the result in the rid map - StoreFileThrowing(kFile, pDomainModule->GetCurrentModule()); - } - - // Make sure we didn't load a different module than what was in the rid map - CONSISTENCY_CHECK(pDomainModule == NULL || pModule == NULL || pDomainModule->GetModule() == pModule); - - // We may not want to return a resource module - if (!permitResources && pDomainModule != NULL && pDomainModule->GetFile()->IsResource()) - pDomainModule = NULL; - - RETURN pDomainModule; -#else //!FEATURE_MULTIMODULE_ASSEMBLIES if (bindOnly) { RETURN NULL; @@ -5939,7 +5837,6 @@ DomainFile *Module::LoadModule(AppDomain *pDomain, mdFile kFile, SString name(SString::Utf8, psModuleName); EEFileLoadException::Throw(name, COR_E_MULTIMODULEASSEMBLIESDIALLOWED, NULL); } -#endif // FEATURE_MULTIMODULE_ASSEMBLIES } #endif // !DACCESS_COMPILE @@ -13266,15 +13163,8 @@ ReflectionModule *ReflectionModule::Create(Assembly *pAssembly, PEFile *pFile, A // Hoist CONTRACT into separate routine because of EX incompatibility mdFile token; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (pFile->IsAssembly()) - token = mdFileNil; - else - token = ((PEModule *)pFile)->GetToken(); -#else _ASSERTE(pFile->IsAssembly()); token = mdFileNil; -#endif // Initial memory block for Modules must be zero-initialized (to make it harder // to introduce Destruct crashes arising from OOM's during initialization.) diff --git a/src/vm/commodule.cpp b/src/vm/commodule.cpp index e3a7e3dbdd..d9fd02eaf6 100644 --- a/src/vm/commodule.cpp +++ b/src/vm/commodule.cpp @@ -115,46 +115,6 @@ static ISymUnmanagedWriter **CreateISymWriterForDynamicModule(ReflectionModule * } } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -//**************************************** -// This function creates a dynamic module underneath the current assembly. -//**************************************** -void QCALLTYPE COMModule::DefineDynamicModule(QCall::AssemblyHandle pContainingAssembly, BOOL emitSymbolInfo, LPCWSTR pModuleName, LPCWSTR pFilename, QCall::StackCrawlMarkHandle stackMark, LPVOID* ppInternalSymWriter, QCall::ObjectHandleOnStack retModule, BOOL fIsTransient, INT32* ptkFile) -{ - QCALL_CONTRACT; - - ReflectionModule * mod = NULL; - - BEGIN_QCALL; - - Assembly * pAssembly = pContainingAssembly->GetAssembly(); - _ASSERTE(pAssembly); - - // always create a dynamic module. Note that the name conflict - // checking is done in managed side. - - mod = pAssembly->CreateDynamicModule(pModuleName, pFilename, fIsTransient, ptkFile); - - mod->SetCreatingAssembly( SystemDomain::GetCallersAssembly( stackMark ) ); - - // If we need to emit symbol info, we setup the proper symbol - // writer for this module now. - if (emitSymbolInfo) - { - ISymUnmanagedWriter **pWriter = CreateISymWriterForDynamicModule(mod, pFilename); - if (ppInternalSymWriter) - { - *ppInternalSymWriter = pWriter; - } - } - - GCX_COOP(); - retModule.Set(mod->GetExposedObject()); - END_QCALL; - - return; -} -#endif //FEATURE_MULTIMODULE_ASSEMBLIES //=============================================================================================== // Attaches an unmanaged symwriter to a newly created dynamic module. //=============================================================================================== diff --git a/src/vm/commodule.h b/src/vm/commodule.h index 4ec82e7cd8..837a432b17 100644 --- a/src/vm/commodule.h +++ b/src/vm/commodule.h @@ -18,12 +18,6 @@ public: // Attaches an unmanaged symwriter to a newly created dynamic module. static FCDECL2(LPVOID, nCreateISymWriterForDynamicModule, ReflectModuleBaseObject* reflectionModuleUNSAFE, StringObject* filenameUNSAFE); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - // DefineDynamicModule - // This method will create a dynamic module given an assembly - static - void QCALLTYPE DefineDynamicModule(QCall::AssemblyHandle pContainingAssembly, BOOL emitSymbolInfo, LPCWSTR pModuleName, LPCWSTR pFilename, QCall::StackCrawlMarkHandle stackMark, LPVOID* ppInternalSymWriter, QCall::ObjectHandleOnStack retModule, BOOL fIsTransient, INT32* ptkFile); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES // IsTransient // Determine if a Module is transient diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index e280cb1898..253ebbbd52 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -407,19 +407,8 @@ DomainAssembly *DomainFile::GetDomainAssembly() } CONTRACTL_END; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (IsAssembly()) - { - return dac_cast<PTR_DomainAssembly>(this); - } - else - { - return dac_cast<PTR_DomainModule>(this)->GetDomainAssembly(); - } -#else _ASSERTE(IsAssembly()); return (DomainAssembly *) this; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES } BOOL DomainFile::IsIntrospectionOnly() @@ -1707,26 +1696,6 @@ void DomainAssembly::SetAssembly(Assembly* pAssembly) pAssembly->SetDomainAssembly(this); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -void DomainAssembly::AddModule(DomainModule *pModule) -{ - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - DWORD index = RidFromToken(pModule->GetToken()); - - while (index >= m_Modules.GetCount()) - IfFailThrow(m_Modules.Append(NULL)); - - m_Modules.Set(index, pModule); -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #ifndef CROSSGEN_COMPILE //--------------------------------------------------------------------------------------- @@ -1837,28 +1806,6 @@ CMD_State DomainAssembly::CheckMissingDependencies() #endif // FEATURE_LOADER_OPTIMIZATION -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -DomainFile* DomainAssembly::FindModule(PEFile *pFile, BOOL includeLoading) -{ - CONTRACT (DomainFile*) - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - MODE_ANY; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - ModuleIterator i = IterateModules(includeLoading ? kModIterIncludeLoading : kModIterIncludeLoaded); - while (i.Next()) - { - if (i.GetDomainFile()->Equals(pFile)) - RETURN i.GetDomainFile(); - } - RETURN NULL; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES DomainFile* DomainAssembly::FindIJWModule(HMODULE hMod) { @@ -2401,138 +2348,6 @@ BOOL DomainAssembly::GetResource(LPCSTR szName, DWORD *cbResource, this->m_pDomain ); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -BOOL DomainAssembly::GetModuleResource(mdFile mdResFile, LPCSTR szResName, - DWORD *cbResource, PBYTE *pbInMemoryResource, - LPCSTR *szFileName, DWORD *dwLocation, - BOOL fIsPublic, StackCrawlMark *pStackMark, - BOOL fSkipSecurityCheck) -{ - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACTL_END; - - const char *szName; - DWORD dwFlags; - DomainFile *pModule = NULL; - DWORD dwOffset = 0; - - if (! ((TypeFromToken(mdResFile) == mdtFile) && - GetMDImport()->IsValidToken(mdResFile)) ) - { - ThrowHR(COR_E_BADIMAGEFORMAT, BFA_INVALID_FILE_TOKEN); - } - - IfFailThrow(GetMDImport()->GetFileProps( - mdResFile, - &szName, - NULL, - NULL, - &dwFlags)); - - if (IsFfContainsMetaData(dwFlags)) - { - // The resource is embedded in a manifest-containing file. - mdManifestResource mdResource; - mdToken mdLinkRef; - DWORD dwResourceFlags; - - Module *pContainerModule = GetCurrentModule(); - // Use the real assembly with a rid map if possible - if (pContainerModule != NULL) - pModule = pContainerModule->LoadModule(m_pDomain, mdResFile, FALSE); - else - { - PEModuleHolder pFile(GetAssembly()->LoadModule_AddRef(mdResFile, FALSE)); - pModule = m_pDomain->LoadDomainModule(this, pFile, FILE_LOADED); - } - - if (FAILED(pModule->GetMDImport()->FindManifestResourceByName(szResName, - &mdResource))) - return FALSE; - - IfFailThrow(pModule->GetMDImport()->GetManifestResourceProps( - mdResource, - NULL, //&szName, - &mdLinkRef, - &dwOffset, - &dwResourceFlags)); - - if (mdLinkRef != mdFileNil) - { - ThrowHR(COR_E_BADIMAGEFORMAT, BFA_CANT_GET_LINKREF); - } - fIsPublic = IsMrPublic(dwResourceFlags); - } - -#ifndef CROSSGEN_COMPILE - if (!fIsPublic && pStackMark && !fSkipSecurityCheck) - { - Assembly *pCallersAssembly = SystemDomain::GetCallersAssembly(pStackMark); - if (pCallersAssembly && // full trust for interop - (!pCallersAssembly->GetManifestFile()->Equals(GetFile()))) - { - RefSecContext sCtx(AccessCheckOptions::kMemberAccess); - - AccessCheckOptions accessCheckOptions( - AccessCheckOptions::kMemberAccess, /*accessCheckType*/ - NULL, /*pAccessContext*/ - FALSE, /*throwIfTargetIsInaccessible*/ - (MethodTable *) NULL /*pTargetMT*/ - ); - - // SL: return TRUE only if the caller is critical - // Desktop: return TRUE only if demanding MemberAccess succeeds - if (!accessCheckOptions.DemandMemberAccessOrFail(&sCtx, NULL, TRUE /*visibilityCheck*/)) - return FALSE; - } - } -#endif // CROSSGEN_COMPILE - - if (IsFfContainsMetaData(dwFlags)) { - if (dwLocation) { - *dwLocation = *dwLocation | 1; // ResourceLocation.embedded - *szFileName = szName; - return TRUE; - } - - pModule->GetFile()->GetEmbeddedResource(dwOffset, cbResource, - pbInMemoryResource); - - return TRUE; - } - - // The resource is linked (it's in its own file) - if (szFileName) { - *szFileName = szName; - return TRUE; - } - - Module *pContainerModule = GetCurrentModule(); - - // Use the real assembly with a rid map if possible - if (pContainerModule != NULL) - pModule = pContainerModule->LoadModule(m_pDomain, mdResFile); - else - { - PEModuleHolder pFile(GetAssembly()->LoadModule_AddRef(mdResFile, TRUE)); - pModule = m_pDomain->LoadDomainModule(this, pFile, FILE_LOADED); - } - - COUNT_T size; - const void *contents = pModule->GetFile()->GetManagedFileContents(&size); - - *pbInMemoryResource = (BYTE *) contents; - *cbResource = size; - - return TRUE; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #ifdef FEATURE_PREJIT @@ -3247,220 +3062,6 @@ void DomainAssembly::EnumStaticGCRefs(promote_func* fn, ScanContext* sc) -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -//-------------------------------------------------------------------------------- -// DomainModule -//-------------------------------------------------------------------------------- - -DomainModule::DomainModule(AppDomain *pDomain, DomainAssembly *pAssembly, PEFile *pFile) - : DomainFile(pDomain, pFile), - m_pDomainAssembly(pAssembly) -{ - STANDARD_VM_CONTRACT; -} - -DomainModule::~DomainModule() -{ - WRAPPER_NO_CONTRACT; -} - -void DomainModule::SetModule(Module* pModule) -{ - STANDARD_VM_CONTRACT; - - UpdatePEFile(pModule->GetFile()); - pModule->SetDomainFile(this); - // SetDomainFile can throw and will unwind to DomainModule::Allocate at which - // point pModule->Destruct will be called in the catch handler. if we set - // m_pModule = pModule before the call to SetDomainFile then we can end up with - // a bad m_pModule pointer when SetDomainFile throws. so we set m_pModule IIF - // the call to SetDomainFile succeeds. - m_pModule = pModule; -} - -void DomainModule::Begin() -{ - STANDARD_VM_CONTRACT; - m_pDomainAssembly->AddModule(this); -} - -#ifdef FEATURE_PREJIT - -void DomainModule::FindNativeImage() -{ - LIMITED_METHOD_CONTRACT; - - // Resource files are never prejitted. -} - -#endif // FEATURE_PREJIT - - -void DomainModule::Allocate() -{ - CONTRACTL - { - INSTANCE_CHECK; - STANDARD_VM_CHECK; - } - CONTRACTL_END; - - // We can now rely on the fact that our MDImport will not change so we can stop refcounting it. - GetFile()->MakeMDImportPersistent(); - - AllocMemTracker amTracker; - AllocMemTracker *pamTracker = &amTracker; - - Assembly *pAssembly = m_pDomainAssembly->GetCurrentAssembly(); - Module *pModule = NULL; - - if (pAssembly->IsDomainNeutral()) - { - // For shared assemblies, the module may be already in the assembly list, even - // though we haven't loaded it here yet. - - pModule = pAssembly->GetManifestModule()->GetModuleIfLoaded(GetToken(),FALSE, TRUE); - if (pModule != NULL) - { - SetModule(pModule); - return; - } - else - { -#ifdef FEATURE_LOADER_OPTIMIZATION - SharedDomain *pSharedDomain = SharedDomain::GetDomain(); - SharedFileLockHolder pFileLock(pSharedDomain, GetFile()); -#else // FEATURE_LOADER_OPTIMIZATION - _ASSERTE(IsSystem()); -#endif // FEATURE_LOADER_OPTIMIZATION - - pModule = pAssembly->GetManifestModule()->GetModuleIfLoaded(GetToken(), FALSE, TRUE); - if (pModule != NULL) - { - SetModule(pModule); - return; - } - else - { - pModule = Module::Create(pAssembly, GetToken(), m_pFile, pamTracker); - - EX_TRY - { - pAssembly->PrepareModuleForAssembly(pModule, pamTracker); - SetModule(pModule); //@todo: This innocent-looking call looks like a mixture of allocations and publishing code - it probably needs to be split. - } - EX_HOOK - { - //! It's critical we destruct the manifest Module prior to the AllocMemTracker used to initialize it. - //! Otherwise, we will leave dangling pointers inside the Module that Module::Destruct will attempt - //! to dereference. - pModule->Destruct(); - } - EX_END_HOOK - - { - CANNOTTHROWCOMPLUSEXCEPTION(); - FAULT_FORBID(); - - //Cannot fail after this point. - pamTracker->SuppressRelease(); - pModule->SetIsTenured(); - - pAssembly->PublishModuleIntoAssembly(pModule); - - - - return; // Explicit return to let you know you are NOT welcome to add code after the CANNOTTHROW/FAULT_FORBID expires - } - - - - } - } - - } - else - { - pModule = Module::Create(pAssembly, GetToken(), m_pFile, pamTracker); - EX_TRY - { - pAssembly->PrepareModuleForAssembly(pModule, pamTracker); - SetModule(pModule); //@todo: This innocent-looking call looks like a mixture of allocations and publishing code - it probably needs to be split. - } - EX_HOOK - { - //! It's critical we destruct the manifest Module prior to the AllocMemTracker used to initialize it. - //! Otherwise, we will leave dangling pointers inside the Module that Module::Destruct will attempt - //! to dereference. - pModule->Destruct(); - } - EX_END_HOOK - - - { - CANNOTTHROWCOMPLUSEXCEPTION(); - FAULT_FORBID(); - - //Cannot fail after this point. - pamTracker->SuppressRelease(); - pModule->SetIsTenured(); - pAssembly->PublishModuleIntoAssembly(pModule); - - - return; // Explicit return to let you know you are NOT welcome to add code after the CANNOTTHROW/FAULT_FORBID expires - } - - } - - -} - - - -void DomainModule::DeliverAsyncEvents() -{ - LIMITED_METHOD_CONTRACT; - return; -} - -void DomainModule::DeliverSyncEvents() -{ - CONTRACTL - { - INSTANCE_CHECK; - THROWS; - GC_TRIGGERS; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM();); - SO_INTOLERANT; - } - CONTRACTL_END; - - GetCurrentModule()->NotifyEtwLoadFinished(S_OK); - -#ifdef PROFILING_SUPPORTED - if (!IsProfilerNotified()) - { - SetProfilerNotified(); - GetCurrentModule()->NotifyProfilerLoadFinished(S_OK); - } -#endif - -#ifdef DEBUGGING_SUPPORTED - GCX_COOP(); - if(!IsDebuggerNotified()) - { - SetShouldNotifyDebugger(); - { - // Always give the module a chance to notify the debugger. If no debugger is attached, the - // module can skip out on the notification. - m_pModule->NotifyDebuggerLoad(m_pDomain, this, ATTACH_MODULE_LOAD, FALSE); - SetDebuggerNotified(); - } - } -#endif -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // #ifndef DACCESS_COMPILE @@ -3511,18 +3112,6 @@ DomainAssembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) } } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -void -DomainModule::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) -{ - SUPPORTS_DAC; - DomainFile::EnumMemoryRegions(flags); - if (m_pDomainAssembly.IsValid()) - { - m_pDomainAssembly->EnumMemoryRegions(flags); - } -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // #ifdef DACCESS_COMPILE diff --git a/src/vm/domainfile.h b/src/vm/domainfile.h index a6efbaa79c..a0ebbca481 100644 --- a/src/vm/domainfile.h +++ b/src/vm/domainfile.h @@ -535,14 +535,6 @@ public: #endif // FEATURE_LOADER_OPTIMIZATION #ifndef DACCESS_COMPILE -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - DomainFile *FindModule(PEFile *pFile, BOOL includeLoading = FALSE); - DomainModule *FindModule(PEModule *pFile, BOOL includeLoading = FALSE) - { - WRAPPER_NO_CONTRACT; - return (DomainModule *) FindModule((PEFile *) pFile, includeLoading); - } -#endif // FEATURE_MULTIMODULE_ASSEMBLIES void ReleaseFiles(); #endif // DACCESS_COMPILE @@ -673,9 +665,6 @@ public: return pModule->GetModule(); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - void AddModule(DomainModule *pModule); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES // ------------------------------------------------------------ // Resource access @@ -687,13 +676,6 @@ public: StackCrawlMark *pStackMark, BOOL fSkipSecurityCheck, BOOL fSkipRaiseResolveEvent); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - BOOL GetModuleResource(mdFile mdResFile, LPCSTR szResName, - DWORD *cbResource, PBYTE *pbInMemoryResource, - LPCSTR *szFileName, DWORD *dwLocation, - BOOL fIsPublic, StackCrawlMark *pStackMark, - BOOL fSkipSecurityCheck); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #ifdef FEATURE_PREJIT // ------------------------------------------------------------ // Prejitting API @@ -823,95 +805,4 @@ typedef DomainAssembly::ModuleIterator DomainModuleIterator; // -------------------------------------------------------------------------------- // DomainModule is a subclass of DomainFile which specifically represents a module. // -------------------------------------------------------------------------------- -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - -class DomainModule : public DomainFile -{ - VPTR_VTABLE_CLASS(DomainModule, DomainFile); - - private: - PTR_DomainAssembly m_pDomainAssembly; - - void UpdatePEFile(PTR_PEFile pFile); - - public: - - // ------------------------------------------------------------ - // Public API - // ------------------------------------------------------------ - - DomainAssembly *GetDomainAssembly() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - return m_pDomainAssembly; - } - - Module *GetModule() - { - LIMITED_METHOD_CONTRACT; - - return m_pModule; - } - - LPCSTR GetName() - { - WRAPPER_NO_CONTRACT; - return GetFile()->GetSimpleName(); - } - - mdFile GetToken() - { - WRAPPER_NO_CONTRACT; - return GetFile()->GetToken(); - } - - PEModule *GetFile() - { - WRAPPER_NO_CONTRACT; - return PTR_PEModule(m_pFile); - } - - BOOL IsAssembly() - { - LIMITED_METHOD_DAC_CONTRACT; - return FALSE; - } - - void SetModule(Module *pModule); - -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - - // ------------------------------------------------------------ - // Loader API - // ------------------------------------------------------------ - - friend class COMModule; - -#ifndef DACCESS_COMPILE - DomainModule(AppDomain *pDomain, DomainAssembly *pAssembly, PEFile *pFile); - ~DomainModule(); -#endif - - // ------------------------------------------------------------ - // Internal routines - // ------------------------------------------------------------ - -#ifndef DACCESS_COMPILE - void Begin(); - void Allocate(); - void LoadSharers(); - void DeliverSyncEvents(); - void DeliverAsyncEvents(); -#endif - -#ifdef FEATURE_PREJIT -#ifndef DACCESS_COMPILE - void FindNativeImage(); -#endif -#endif // FEATURE_PREJIT -}; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // _DOMAINFILE_H_ diff --git a/src/vm/domainfile.inl b/src/vm/domainfile.inl index 18ff564939..e82ee3ed70 100644 --- a/src/vm/domainfile.inl +++ b/src/vm/domainfile.inl @@ -108,14 +108,6 @@ inline void DomainAssembly::UpdatePEFile(PTR_PEFile pFile) GetAppDomain()->UpdatePublishHostedAssembly(this, pFile); } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -inline void DomainModule::UpdatePEFile(PTR_PEFile pFile) -{ - LIMITED_METHOD_CONTRACT; - - this->UpdatePEFileWorker(pFile); -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // DACCESS_COMPILE inline ULONG DomainAssembly::HashIdentity() diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp index e322b26ddb..16c66b516d 100644 --- a/src/vm/pefile.cpp +++ b/src/vm/pefile.cpp @@ -1891,18 +1891,7 @@ BOOL PEFile::GetResource(LPCSTR szName, DWORD *cbResource, return TRUE; } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - // The resource is either linked or embedded in a non-manifest-containing file - if (pDomainAssembly == NULL) - return FALSE; - - return pDomainAssembly->GetModuleResource(mdLinkRef, szName, cbResource, - pbInMemoryResource, szFileName, - dwLocation, IsMrPublic(dwResourceFlags), - pStackMark, fSkipSecurityCheck); -#else return FALSE; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES default: ThrowHR(COR_E_BADIMAGEFORMAT, BFA_INVALID_TOKEN_IN_MANIFESTRES); @@ -2733,383 +2722,6 @@ HRESULT PEFile::GetVersion(USHORT *pMajor, USHORT *pMinor, USHORT *pBuild, USHOR return hr; } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -// ================================================================================ -// PEModule class - a PEFile which represents a satellite module -// ================================================================================ - -PEModule::PEModule(PEImage *image, PEAssembly *assembly, mdFile token, IMetaDataEmit *pEmit) - : PEFile(image), - m_assembly(NULL), - m_token(token), - m_bIsResource(-1) -{ - CONTRACTL - { - PRECONDITION(CheckPointer(image, NULL_OK)); - PRECONDITION(CheckPointer(assembly)); - PRECONDITION(!IsNilToken(token)); - PRECONDITION(CheckPointer(pEmit, NULL_OK)); - PRECONDITION(image != NULL || pEmit != NULL); - CONSTRUCTOR_CHECK; - STANDARD_VM_CHECK; - } - CONTRACTL_END; - - DWORD flags; - - // get only the data which is required, here - flags - // this helps avoid unnecessary memory touches - IfFailThrow(assembly->GetPersistentMDImport()->GetFileProps(token, NULL, NULL, NULL, &flags)); - - if (image != NULL) - { - if (IsFfContainsMetaData(flags) && !image->CheckILFormat()) - ThrowHR(COR_E_BADIMAGEFORMAT); - - if (assembly->IsIStream()) - { - m_flags |= PEFILE_ISTREAM; -#ifdef FEATURE_PREJIT - m_fCanUseNativeImage = FALSE; -#endif - } - } - - assembly->AddRef(); - - m_assembly = assembly; - - m_flags |= PEFILE_MODULE; - if (assembly->IsSystem()) - { - m_flags |= PEFILE_SYSTEM; - } - else - { - if (assembly->IsIntrospectionOnly()) - { - m_flags |= PEFILE_INTROSPECTIONONLY; -#ifdef FEATURE_PREJIT - SetCannotUseNativeImage(); -#endif - } - } - - - // Verify module format. Note that some things have already happened: - // - Fusion has verified the name matches the metadata - // - PEimage has performed PE file format validation - - if (assembly->NeedsModuleHashChecks()) - { - ULONG size; - const void *hash; - IfFailThrow(assembly->GetPersistentMDImport()->GetFileProps(token, NULL, &hash, &size, NULL)); - - if (!CheckHash(assembly->GetHashAlgId(), hash, size)) - ThrowHR(COR_E_MODULE_HASH_CHECK_FAILED); - } - -#if defined(FEATURE_PREJIT) && !defined(CROSSGEN_COMPILE) - // Find the native image - if (IsFfContainsMetaData(flags) - && m_fCanUseNativeImage - && assembly->HasNativeImage() - && assembly->GetFusionAssembly() != NULL) - { - IAssemblyLocation *pIAssemblyLocation = assembly->GetNativeAssemblyLocation(); - - WCHAR wzPath[MAX_LONGPATH]; - WCHAR *pwzTemp = NULL; - DWORD dwCCPath = MAX_LONGPATH; - SString path; - SString moduleName(SString::Utf8, GetSimpleName()); - - // Compute the module path from the manifest module path - IfFailThrow(pIAssemblyLocation->GetPath(wzPath, &dwCCPath)); - pwzTemp = PathFindFileName(wzPath); - *pwzTemp = (WCHAR) 0x00; - - // <TODO>@todo: GetAppDomain????</TODO> - path.Set(wzPath); - path.Append((LPCWSTR) moduleName); - - SetNativeImage(path); - } -#endif // FEATURE_PREJIT && !CROSSGEN_COMPILE - -#if _DEBUG - GetCodeBaseOrName(m_debugName); - m_pDebugName = m_debugName; -#endif - - if (IsFfContainsMetaData(flags)) - { - if (image != NULL) - { - OpenMDImport_Unsafe(); //constructor. cannot race with anything - } - else - { - _ASSERTE(!m_bHasPersistentMDImport); - IfFailThrow(GetMetaDataInternalInterfaceFromPublic(pEmit, IID_IMDInternalImport, - (void **)&m_pMDImport)); - m_pEmitter = pEmit; - pEmit->AddRef(); - m_bHasPersistentMDImport=TRUE; - m_MDImportIsRW_Debugger_Use_Only = TRUE; - } - - // Fusion probably checks this, but we need to check this ourselves if - // this file didn't come from Fusion - if (!m_pMDImport->IsValidToken(m_pMDImport->GetModuleFromScope())) - COMPlusThrowHR(COR_E_BADIMAGEFORMAT); - } - else - { - // Go ahead and "load" image since it is essentially a noop, but will enable - // more operations on the module earlier in the loading process. - LoadLibrary(); - } -#ifdef FEATURE_PREJIT - if (IsResource() || IsDynamic()) - m_fCanUseNativeImage = FALSE; -#endif -} - -PEModule::~PEModule() -{ - CONTRACTL - { - DESTRUCTOR_CHECK; - NOTHROW; - MODE_ANY; - } - CONTRACTL_END; - - m_assembly->Release(); -} - -/* static */ -PEModule *PEModule::Open(PEAssembly *assembly, mdFile token, - const SString &fileName) -{ - STANDARD_VM_CONTRACT; - - PEModule *result = NULL; - - EX_TRY - { - result = DoOpen(assembly, token, fileName); - } - EX_HOOK - { - Exception *ex = GET_EXCEPTION(); - - // Rethrow non-transient exceptions as file load exceptions with proper - // context - - if (!ex->IsTransient()) - EEFileLoadException::Throw(fileName, ex->GetHR(), ex); - } - EX_END_HOOK; - - return result; -} -// Thread stress -class DoOpenPathStress : APIThreadStress -{ -public: - PEAssembly *assembly; - mdFile token; - const SString &fileName; - DoOpenPathStress(PEAssembly *assembly, mdFile token, - const SString &fileName) - : assembly(assembly), token(token), fileName(fileName) - { - WRAPPER_NO_CONTRACT; - fileName.Normalize(); - } - void Invoke() - { - WRAPPER_NO_CONTRACT; - PEModuleHolder result(PEModule::Open(assembly, token, fileName)); - } -}; - -/* static */ -PEModule *PEModule::DoOpen(PEAssembly *assembly, mdFile token, - const SString &fileName) -{ - CONTRACT(PEModule *) - { - PRECONDITION(CheckPointer(assembly)); - PRECONDITION(CheckValue(fileName)); - PRECONDITION(!IsNilToken(token)); - PRECONDITION(!fileName.IsEmpty()); - POSTCONDITION(CheckPointer(RETVAL)); - STANDARD_VM_CHECK; - } - CONTRACT_END; - - DoOpenPathStress ts(assembly, token, fileName); - - // If this is a resource module, we must explicitly request a flat mapping - DWORD flags; - IfFailThrow(assembly->GetPersistentMDImport()->GetFileProps(token, NULL, NULL, NULL, &flags)); - - PEImageHolder image; - { - image = PEImage::OpenImage(fileName); - } - - if (flags & ffContainsNoMetaData) - image->LoadNoMetaData(assembly->IsIntrospectionOnly()); - - PEModuleHolder module(new PEModule(image, assembly, token, NULL)); - - RETURN module.Extract(); -} - -/* static */ -PEModule *PEModule::OpenMemory(PEAssembly *assembly, mdFile token, - const void *flat, COUNT_T size) -{ - STANDARD_VM_CONTRACT; - - PEModule *result = NULL; - - EX_TRY - { - result = DoOpenMemory(assembly, token, flat, size); - } - EX_HOOK - { - Exception *ex = GET_EXCEPTION(); - - // Rethrow non-transient exceptions as file load exceptions with proper - // context - if (!ex->IsTransient()) - EEFileLoadException::Throw(assembly, flat, size, ex->GetHR(), ex); - } - EX_END_HOOK; - return result; -} - -// Thread stress -class DoOpenTokenStress : APIThreadStress -{ -public: - PEAssembly *assembly; - mdFile token; - const void *flat; - COUNT_T size; - DoOpenTokenStress(PEAssembly *assembly, mdFile token, - const void *flat, COUNT_T size) - : assembly(assembly), token(token), flat(flat), size(size) {LIMITED_METHOD_CONTRACT;} - void Invoke() - { - WRAPPER_NO_CONTRACT; - PEModuleHolder result(PEModule::OpenMemory(assembly, token, flat, size)); - } -}; - -// REVIEW: do we need to know the creator module which emitted the module (separately -// from the assembly parent) for security reasons? -/* static */ -PEModule *PEModule::DoOpenMemory(PEAssembly *assembly, mdFile token, - const void *flat, COUNT_T size) -{ - CONTRACT(PEModule *) - { - PRECONDITION(CheckPointer(assembly)); - PRECONDITION(!IsNilToken(token)); - PRECONDITION(CheckPointer(flat)); - POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - GC_TRIGGERS; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END; - - DoOpenTokenStress ts(assembly, token, flat, size); - - PEImageHolder image(PEImage::LoadFlat(flat, size)); - - RETURN new PEModule(image, assembly, token, NULL); -} - -/* static */ -PEModule *PEModule::Create(PEAssembly *assembly, mdFile token, IMetaDataEmit *pEmit) -{ - CONTRACT(PEModule *) - { - PRECONDITION(CheckPointer(assembly)); - PRECONDITION(!IsNilToken(token)); - STANDARD_VM_CHECK; - POSTCONDITION(CheckPointer(RETVAL)); - } - CONTRACT_END; - - RETURN new PEModule(NULL, assembly, token, pEmit); -} - -// ------------------------------------------------------------ -// Logging -// ------------------------------------------------------------ -#ifdef FEATURE_PREJIT -void PEModule::ExternalVLog(DWORD facility, DWORD level, const WCHAR *fmt, va_list args) -{ - CONTRACT_VOID - { - THROWS; - GC_TRIGGERS; - } - CONTRACT_END; - - m_assembly->ExternalVLog(facility, level, fmt, args); - - RETURN; -} - -void PEModule::FlushExternalLog() -{ - CONTRACT_VOID - { - THROWS; - GC_TRIGGERS; - } - CONTRACT_END; - - m_assembly->FlushExternalLog(); - - RETURN; -} - -// ------------------------------------------------------------ -// Loader support routines -// ------------------------------------------------------------ -void PEModule::SetNativeImage(const SString &fullPath) -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckValue(fullPath)); - PRECONDITION(!fullPath.IsEmpty()); - STANDARD_VM_CHECK; - } - CONTRACTL_END; - - PEImageHolder image(PEImage::OpenImage(fullPath)); - image->Load(); - - PEFile::SetNativeImage(image); -} -#endif // FEATURE_PREJIT - -#endif // FEATURE_MULTIMODULE_ASSEMBLIES void PEFile::EnsureImageOpened() @@ -3174,20 +2786,6 @@ PEAssembly::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) } } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -void -PEModule::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) -{ - WRAPPER_NO_CONTRACT; - - PEFile::EnumMemoryRegions(flags); - - if (m_assembly.IsValid()) - { - m_assembly->EnumMemoryRegions(flags); - } -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #endif // #ifdef DACCESS_COMPILE diff --git a/src/vm/pefile.h b/src/vm/pefile.h index 421297303c..d4f375565d 100644 --- a/src/vm/pefile.h +++ b/src/vm/pefile.h @@ -871,90 +871,11 @@ class PEAssembly : public PEFile } }; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - -class PEModule : public PEFile -{ - VPTR_VTABLE_CLASS(PEModule, PEFile) - - public: - - // ------------------------------------------------------------ - // Public API - // ------------------------------------------------------------ - - static PEModule *Open(PEAssembly *assembly, mdFile token, - const SString &fileName); - - static PEModule *OpenMemory(PEAssembly *assembly, mdFile kToken, - const void *flat, COUNT_T size); - - static PEModule *Create(PEAssembly *assembly, mdFile kToken, IMetaDataEmit *pEmit); - -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - - private: - // Private helpers for crufty exception handling reasons - static PEModule *DoOpen(PEAssembly *assembly, mdFile token, - const SString &fileName); - - static PEModule *DoOpenMemory(PEAssembly *assembly, mdFile kToken, - const void *flat, COUNT_T size); - public: - - // ------------------------------------------------------------ - // Metadata access - // ------------------------------------------------------------ - - PEAssembly *GetAssembly(); - mdFile GetToken(); - BOOL IsResource(); - BOOL IsIStream(); - LPCUTF8 GetSimpleName(); - - // ------------------------------------------------------------ - // Logging - // ------------------------------------------------------------ -#ifdef FEATURE_PREJIT - void ExternalVLog(DWORD facility, DWORD level, const WCHAR *fmt, va_list args) DAC_EMPTY(); - void FlushExternalLog() DAC_EMPTY(); -#endif -private: - // ------------------------------------------------------------ - // Loader access API - // ------------------------------------------------------------ - - friend class DomainModule; -#ifdef FEATURE_PREJIT - void SetNativeImage(const SString &fullPath); -#endif // FEATURE_PREJIT - -private: - -#ifndef DACCESS_COMPILE - PEModule(PEImage *image, PEAssembly *assembly, mdFile token, IMetaDataEmit *pEmit); - virtual ~PEModule(); -#endif - - // ------------------------------------------------------------ - // Instance fields - // ------------------------------------------------------------ - - PTR_PEAssembly m_assembly; - mdFile m_token; - BOOL m_bIsResource; -}; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES typedef ReleaseHolder<PEFile> PEFileHolder; typedef ReleaseHolder<PEAssembly> PEAssemblyHolder; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -typedef ReleaseHolder<PEModule> PEModuleHolder; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES // A small shim around PEAssemblies/IBindResult that allow us to write Fusion/CLR-agnostic diff --git a/src/vm/pefile.inl b/src/vm/pefile.inl index 3d5e946110..9bd478e137 100644 --- a/src/vm/pefile.inl +++ b/src/vm/pefile.inl @@ -336,11 +336,7 @@ inline BOOL PEFile::IsResource() const WRAPPER_NO_CONTRACT; SUPPORTS_DAC; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - return IsModule() && dac_cast<PTR_PEModule>(this)->IsResource(); -#else return FALSE; -#endif // FEATURE_MULTIMODULE_ASSEMBLIES } inline BOOL PEFile::IsIStream() const @@ -354,13 +350,6 @@ inline BOOL PEFile::IsIntrospectionOnly() const { WRAPPER_NO_CONTRACT; STATIC_CONTRACT_SO_TOLERANT; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (IsModule()) - { - return dac_cast<PTR_PEModule>(this)->GetAssembly()->IsIntrospectionOnly(); - } - else -#endif // FEATURE_MULTIMODULE_ASSEMBLIES { return (m_flags & PEFILE_INTROSPECTIONONLY) != 0; } @@ -370,16 +359,9 @@ inline BOOL PEFile::IsIntrospectionOnly() const inline PEAssembly *PEFile::GetAssembly() const { WRAPPER_NO_CONTRACT; -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - if (IsAssembly()) - return dac_cast<PTR_PEAssembly>(this); - else - return dac_cast<PTR_PEModule>(this)->GetAssembly(); -#else _ASSERTE(IsAssembly()); return dac_cast<PTR_PEAssembly>(this); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES } // ------------------------------------------------------------ @@ -610,10 +592,6 @@ inline LPCUTF8 PEFile::GetSimpleName() if (IsAssembly()) RETURN dac_cast<PTR_PEAssembly>(this)->GetSimpleName(); -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - else if (IsModule()) - RETURN dac_cast<PTR_PEModule>(this)->GetSimpleName(); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES else { LPCUTF8 szScopeName; @@ -1853,84 +1831,6 @@ inline BOOL PEAssembly::IsFullySigned() // ------------------------------------------------------------ // Metadata access // ------------------------------------------------------------ -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -inline PEAssembly *PEModule::GetAssembly() -{ - CONTRACT(PEAssembly *) - { - POSTCONDITION(CheckPointer(RETVAL)); - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - CANNOT_TAKE_LOCK; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACT_END; - - RETURN m_assembly; -} - -inline BOOL PEModule::IsResource() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACTL_END; -#ifdef DACCESS_COMPILE - _ASSERTE(m_bIsResource!=-1); -#else - if (m_bIsResource==-1) - { - DWORD flags; - if (FAILED(m_assembly->GetPersistentMDImport()->GetFileProps(m_token, NULL, NULL, NULL, &flags))) - { - _ASSERTE(!"If this fires, then we have to throw for corrupted images"); - flags = 0; - } - m_bIsResource=((flags & ffContainsNoMetaData) != 0); - } -#endif - - return m_bIsResource; -} - -inline LPCUTF8 PEModule::GetSimpleName() -{ - CONTRACT(LPCUTF8) - { - POSTCONDITION(CheckPointer(RETVAL)); - POSTCONDITION(strlen(RETVAL) > 0); - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACT_END; - - LPCUTF8 name; - - if (FAILED(m_assembly->GetPersistentMDImport()->GetFileProps(m_token, &name, NULL, NULL, NULL))) - { - _ASSERTE(!"If this fires, then we have to throw for corrupted images"); - name = ""; - } - - RETURN name; -} - -inline mdFile PEModule::GetToken() -{ - LIMITED_METHOD_CONTRACT; - return m_token; -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES #ifndef DACCESS_COMPILE inline void PEFile::RestoreMDImport(IMDInternalImport* pImport) diff --git a/src/zap/zapper.cpp b/src/zap/zapper.cpp index 502e5935f6..904b9d1539 100644 --- a/src/zap/zapper.cpp +++ b/src/zap/zapper.cpp @@ -1558,9 +1558,6 @@ void Zapper::CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig) // assembly to be ngen-ed. // -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES - CompileNonManifestModules(hashAlgId, hFiles); -#endif // FEATURE_MULTIMODULE_ASSEMBLIES // // Record the version info @@ -1614,143 +1611,6 @@ void Zapper::CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig) } -#ifdef FEATURE_MULTIMODULE_ASSEMBLIES -void * Zapper::GetMapViewOfFile( - HANDLE file, - DWORD * pdwFileLen) -{ - // - // Create a file-mapping to read the file contents - // - - DWORD dwFileLen = SafeGetFileSize(file, 0); - if (dwFileLen == INVALID_FILE_SIZE) - ThrowHR(HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY)); - - HandleHolder mapFile(WszCreateFileMapping( - file, // hFile - NULL, // lpAttributes - PAGE_READONLY, // flProtect - 0, // dwMaximumSizeHigh - 0, // dwMaximumSizeLow - NULL)); // lpName (of the mapping object) - if (mapFile == NULL) - ThrowLastError(); - - MapViewHolder mapView(MapViewOfFile(mapFile, // hFileMappingObject, - FILE_MAP_READ, // dwDesiredAccess, - 0, // dwFileOffsetHigh, - 0, // dwFileOffsetLow, - 0)); // dwNumberOfBytesToMap - if (mapView == NULL) - ThrowLastError(); - - *pdwFileLen = dwFileLen; - return mapView.Extract(); -} - -void Zapper::ComputeHashValue(HANDLE hFile, int iHashAlg, - BYTE **ppHashValue, DWORD *pcHashValue) -{ - - DWORD dwFileLen; - MapViewHolder mapView(GetMapViewOfFile(hFile, &dwFileLen)); - - BYTE * pbBuffer = (BYTE *) mapView.GetValue(); - - // - // Hash the file - // - - DWORD dwCount = sizeof(DWORD); - DWORD cbHashValue = 0; - NewArrayHolder<BYTE> pbHashValue; - - HandleCSPHolder hProv; - HandleHashHolder hHash; - - if ((!WszCryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) || - (!CryptCreateHash(hProv, iHashAlg, 0, 0, &hHash)) || - (!CryptHashData(hHash, pbBuffer, dwFileLen, 0)) || - (!CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE *) &cbHashValue, &dwCount, 0))) - ThrowLastError(); - - pbHashValue = new BYTE[cbHashValue]; - - if(!CryptGetHashParam(hHash, HP_HASHVAL, pbHashValue, &cbHashValue, 0)) - ThrowLastError(); - - *ppHashValue = pbHashValue.Extract(); - *pcHashValue = cbHashValue; -} - -void Zapper::CompileNonManifestModules(ULONG hashAlgId, SArray<HANDLE> &hFiles) -{ - // - // Iterate all non-manifest modules in the assembly, and compile them - // - - IMDInternalImport * pMDImport = m_pAssemblyImport; - - HENUMInternalHolder hEnum(pMDImport); - hEnum.EnumAllInit(mdtFile); - - mdFile tkFile; - while (pMDImport->EnumNext(&hEnum, &tkFile)) - { - LPCSTR szName; - DWORD flags; - IfFailThrow(pMDImport->GetFileProps(tkFile, &szName, NULL, NULL, &flags)); - - if (!IsFfContainsMetaData(flags)) - continue; - - SString strFileName(SString::Utf8, szName); - LPCWSTR wszFileName = strFileName.GetUnicode(); - - // - // We want to compile this file. - // - - CORINFO_MODULE_HANDLE hModule; - - IfFailThrow(m_pEECompileInfo->LoadAssemblyModule(m_hAssembly, - tkFile, &hModule)); - - SString strNativeImagePath; - HANDLE hFile; - - { - NewHolder<ZapImage> pModule; - pModule = CompileModule(hModule, NULL); - - { - SString strFileNameWithoutExt(strFileName); - SString::CIterator fileNameIterator = strFileNameWithoutExt.End(); - if (!strFileNameWithoutExt.FindBack(fileNameIterator, '.')) - ThrowHR(E_FAIL); - strFileNameWithoutExt.Truncate(fileNameIterator.ConstCast()); - - pModule->SetPdbFileName(SString(strFileNameWithoutExt, SL(W(".ni.pdb")))); - - strNativeImagePath.Set(m_outputPath, SL(W("\\")), wszFileName); - - hFile = pModule->SaveImage(strNativeImagePath.GetUnicode(), NULL); - hFiles.Append(hFile); - } - } - - { - NewArrayHolder<BYTE> pbHashValue; - DWORD cbHashValue; - ComputeHashValue(hFile, hashAlgId, &pbHashValue, &cbHashValue); - - mdFile token; - IfFailThrow(m_pAssemblyEmit->DefineFile(wszFileName, pbHashValue, cbHashValue, 0, &token)); - } - } -} -#endif // FEATURE_MULTIMODULE_ASSEMBLIES ZapImage * Zapper::CompileModule(CORINFO_MODULE_HANDLE hModule, IMetaDataAssemblyEmit *pAssemblyEmit) |