diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp index 5732a335b24c7..7d50390bf18ed 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp @@ -4977,6 +4977,10 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetObjectForCCW(CORDB_ADDRESS ccwPtr) OBJECTHANDLE ohCCW = NULL; +#ifdef FEATURE_COMWRAPPERS + if (DACTryGetComWrappersHandleFromCCW(ccwPtr, &ohCCW) != S_OK) + { +#endif #ifdef FEATURE_COMINTEROP ComCallWrapper *pCCW = DACGetCCWFromAddress(ccwPtr); if (pCCW) @@ -4984,6 +4988,9 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetObjectForCCW(CORDB_ADDRESS ccwPtr) ohCCW = pCCW->GetObjectHandle(); } #endif +#ifdef FEATURE_COMWRAPPERS + } +#endif VMPTR_OBJECTHANDLE vmObjHandle; vmObjHandle.SetDacTargetPtr(ohCCW); diff --git a/src/coreclr/src/debug/daccess/dacimpl.h b/src/coreclr/src/debug/daccess/dacimpl.h index fdea07159d26c..543a13c4da0b4 100644 --- a/src/coreclr/src/debug/daccess/dacimpl.h +++ b/src/coreclr/src/debug/daccess/dacimpl.h @@ -1490,6 +1490,11 @@ class ClrDataAccess static LONG s_procInit; +protected: +#ifdef FEATURE_COMWRAPPERS + HRESULT DACTryGetComWrappersHandleFromCCW(CLRDATA_ADDRESS ccwPtr, OBJECTHANDLE* objHandle); +#endif + public: // APIs for picking up the info needed for a debugger to look up an ngen image or IL image // from it's search path. diff --git a/src/coreclr/src/debug/daccess/request.cpp b/src/coreclr/src/debug/daccess/request.cpp index 99366e980e26d..1979c4bbffba2 100644 --- a/src/coreclr/src/debug/daccess/request.cpp +++ b/src/coreclr/src/debug/daccess/request.cpp @@ -4138,12 +4138,18 @@ TADDR ClrDataAccess::DACGetManagedObjectWrapperFromCCW(CLRDATA_ADDRESS ccwPtr) return managedObjectWrapperPtr; } -HRESULT ClrDataAccess::DACTryGetComWrappersObjectFromCCW(CLRDATA_ADDRESS ccwPtr, OBJECTREF* objRef) +HRESULT ClrDataAccess::DACTryGetComWrappersHandleFromCCW(CLRDATA_ADDRESS ccwPtr, OBJECTHANDLE* objHandle) { - if (ccwPtr == 0 || objRef == NULL) - return E_INVALIDARG; + HRESULT hr = E_FAIL; + TADDR ccw, managedObjectWrapperPtr; + ULONG32 bytesRead = 0; + OBJECTHANDLE handle; - SOSDacEnter(); + if (ccwPtr == 0 || objHandle == NULL) + { + hr = E_INVALIDARG; + goto ErrExit; + } if (!DACIsComWrappersCCW(ccwPtr)) { @@ -4151,18 +4157,16 @@ HRESULT ClrDataAccess::DACTryGetComWrappersObjectFromCCW(CLRDATA_ADDRESS ccwPtr, goto ErrExit; } - TADDR ccw = CLRDATA_ADDRESS_TO_TADDR(ccwPtr); + ccw = CLRDATA_ADDRESS_TO_TADDR(ccwPtr); // Return ManagedObjectWrapper as an OBJECTHANDLE. (The OBJECTHANDLE is guaranteed to live at offset 0). - TADDR managedObjectWrapperPtr = DACGetManagedObjectWrapperFromCCW(ccwPtr); + managedObjectWrapperPtr = DACGetManagedObjectWrapperFromCCW(ccwPtr); if (managedObjectWrapperPtr == NULL) { hr = E_FAIL; goto ErrExit; } - ULONG32 bytesRead = 0; - OBJECTHANDLE handle; IfFailGo(m_pTarget->ReadVirtual(managedObjectWrapperPtr, (PBYTE)&handle, sizeof(OBJECTHANDLE), &bytesRead)); if (bytesRead != sizeof(OBJECTHANDLE)) { @@ -4170,9 +4174,31 @@ HRESULT ClrDataAccess::DACTryGetComWrappersObjectFromCCW(CLRDATA_ADDRESS ccwPtr, goto ErrExit; } - *objRef = ObjectFromHandle(handle); + *objHandle = handle; - SOSDacLeave(); + return S_OK; + +ErrExit: return hr; +} + +HRESULT ClrDataAccess::DACTryGetComWrappersObjectFromCCW(CLRDATA_ADDRESS ccwPtr, OBJECTREF* objRef) +{ + HRESULT hr = E_FAIL; + + if (ccwPtr == 0 || objRef == NULL) + { + hr = E_INVALIDARG; + goto ErrExit; + } + + OBJECTHANDLE handle; + if (DACTryGetComWrappersHandleFromCCW(ccwPtr, &handle) != S_OK) + { + hr = E_FAIL; + goto ErrExit; + } + + *objRef = ObjectFromHandle(handle); return S_OK;