diff options
author | David Wrighton <davidwr@microsoft.com> | 2017-02-15 02:35:19 +0300 |
---|---|---|
committer | David Wrighton <davidwr@microsoft.com> | 2017-02-15 02:35:19 +0300 |
commit | 720e17f599c1d8aca941dbca8a9492f3474f3b05 (patch) | |
tree | 544ecb53dbff7736b2945c7b58c5b6f997ee4734 /src/Native/Runtime/RuntimeInstance.cpp | |
parent | 1a8e729b2e9e3915947cace8c3bf316237d519e6 (diff) |
Refactor use of TypeManager and Module pointers within the BCL
- Move from using an IntPtr which may represent a TypeManager* or a OS module pointer to using a struct TypeManagerHandle consistently
- Except for RuntimeSignature, which has a third possible meaning of its IntPtr. That work will be done in a seperate change, and wil result in removal of nearly all of the new TypeManagerHandle calls in this delta.
- This struct contains a bit which indicates which form of pointer is being worked with, as well as routines for performing RVA access as appropriate
- Added new api to redhawk to get the OS module list (Used in crash dump generation)
- Added new api to get the OS module of of a pointer. These are not yet enabled for TypeManager based scenarios, but that will be done in a followon change. Eventually these will exclusively be use for instruction pointers, and will tie into diagnostic scenarios around stack traces, etc. Currently, it is also used in a few reflection scenarios. Those code patterns will be removed soon.
- Similarly distinguished between getting the OS module for an EEType, and getting the module for an EEType. This is used in error message scenarios.
- Update RhFindBlob to work with both types of module pointers
[tfs-changeset: 1647831]
Diffstat (limited to 'src/Native/Runtime/RuntimeInstance.cpp')
-rw-r--r-- | src/Native/Runtime/RuntimeInstance.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/Native/Runtime/RuntimeInstance.cpp b/src/Native/Runtime/RuntimeInstance.cpp index f1420d9eb..1be7583e1 100644 --- a/src/Native/Runtime/RuntimeInstance.cpp +++ b/src/Native/Runtime/RuntimeInstance.cpp @@ -429,11 +429,44 @@ bool RuntimeInstance::RegisterTypeManager(TypeManager * pTypeManager) return true; } -COOP_PINVOKE_HELPER(void*, RhpCreateTypeManager, (void* pModuleHeader)) +COOP_PINVOKE_HELPER(TypeManagerHandle, RhpCreateTypeManager, (HANDLE osModule, void* pModuleHeader)) { - TypeManager * typeManager = TypeManager::Create(pModuleHeader); + TypeManager * typeManager = TypeManager::Create(osModule, pModuleHeader); GetRuntimeInstance()->RegisterTypeManager(typeManager); - return typeManager; + return TypeManagerHandle::Create(typeManager); +} + +COOP_PINVOKE_HELPER(void*, RhpRegisterOsModule, (HANDLE hOsModule)) +{ + RuntimeInstance::OsModuleEntry * pEntry = new (nothrow) RuntimeInstance::OsModuleEntry(); + if (NULL == pEntry) + return nullptr; // Return null on failure. + + pEntry->m_osModule = hOsModule; + + { + RuntimeInstance *pRuntimeInstance = GetRuntimeInstance(); + ReaderWriterLock::WriteHolder write(&pRuntimeInstance->GetTypeManagerLock()); + + pRuntimeInstance->GetOsModuleList().PushHead(pEntry); + } + + return hOsModule; // Return non-null on success +} + +RuntimeInstance::TypeManagerList& RuntimeInstance::GetTypeManagerList() +{ + return m_TypeManagerList; +} + +RuntimeInstance::OsModuleList& RuntimeInstance::GetOsModuleList() +{ + return m_OsModuleList; +} + +ReaderWriterLock& RuntimeInstance::GetTypeManagerLock() +{ + return m_ModuleListLock; } // static |