-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Convert IDacDbiInterface to COM interface #125074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3f45dad
ebff3ba
7973bcf
22de087
e577c58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -222,7 +222,7 @@ template<class T> void DeleteDbiArrayMemory(T *p, int count) | |||||||||||||
| // pAllocator - pointer to client allocator object. This lets DD allocate objects and | ||||||||||||||
| // pass them out back to the client, which can then delete them. | ||||||||||||||
| // DD takes a weak ref to this, so client must keep it alive until it | ||||||||||||||
| // calls Destroy. | ||||||||||||||
| // calls Release. | ||||||||||||||
| // pMetadataLookup - callback interface to do internal metadata lookup. This is because | ||||||||||||||
| // metadata is not dac-ized. | ||||||||||||||
| // ppInterface - mandatory out-parameter | ||||||||||||||
|
|
@@ -238,7 +238,7 @@ template<class T> void DeleteDbiArrayMemory(T *p, int count) | |||||||||||||
| // This will yield an IDacDbiInterface to provide structured access to the | ||||||||||||||
| // data-target. | ||||||||||||||
| // | ||||||||||||||
| // Must call Destroy to on interface to free its resources. | ||||||||||||||
| // Must call Release on interface to free its resources. | ||||||||||||||
| // | ||||||||||||||
| //--------------------------------------------------------------------------------------- | ||||||||||||||
| STDAPI | ||||||||||||||
|
|
@@ -295,7 +295,7 @@ DacDbiInterfaceInstance( | |||||||||||||
| // pAllocator - pointer to client allocator object. This lets DD allocate objects and | ||||||||||||||
| // pass them out back to the client, which can then delete them. | ||||||||||||||
| // DD takes a weak ref to this, so client must keep it alive until it | ||||||||||||||
| // calls Destroy. | ||||||||||||||
| // calls Release. | ||||||||||||||
| // pMetadataLookup - callback interface to do internal metadata lookup. This is because | ||||||||||||||
| // metadata is not dac-ized. | ||||||||||||||
| // | ||||||||||||||
|
|
@@ -333,7 +333,7 @@ DacDbiInterfaceImpl::DacDbiInterfaceImpl( | |||||||||||||
| // Destructor. | ||||||||||||||
| // | ||||||||||||||
| // Notes: | ||||||||||||||
| // This gets invoked after Destroy(). | ||||||||||||||
| // This gets invoked when the ref count drops to 0 via Release(). | ||||||||||||||
| //----------------------------------------------------------------------------- | ||||||||||||||
| DacDbiInterfaceImpl::~DacDbiInterfaceImpl() | ||||||||||||||
| { | ||||||||||||||
|
|
@@ -441,19 +441,30 @@ interface IMDInternalImport* DacDbiInterfaceImpl::GetMDImport( | |||||||||||||
| // See DacDbiInterface.h for full descriptions of all of these functions | ||||||||||||||
| //----------------------------------------------------------------------------- | ||||||||||||||
|
|
||||||||||||||
| // Destroy the connection, freeing up any resources. | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::Destroy() | ||||||||||||||
| // IUnknown implementation for DacDbiInterfaceImpl. | ||||||||||||||
| // Delegates to ClrDataAccess's ref-counting and adds support for IDacDbiInterface IID. | ||||||||||||||
| STDMETHODIMP | ||||||||||||||
| DacDbiInterfaceImpl::QueryInterface(THIS_ IN REFIID interfaceId, OUT PVOID* iface) | ||||||||||||||
| { | ||||||||||||||
| HRESULT hr = S_OK; | ||||||||||||||
| EX_TRY | ||||||||||||||
| if (IsEqualIID(interfaceId, __uuidof(IDacDbiInterface))) | ||||||||||||||
| { | ||||||||||||||
| m_pAllocator = NULL; | ||||||||||||||
|
|
||||||||||||||
| this->Release(); | ||||||||||||||
| // Memory is deleted, don't access this object any more | ||||||||||||||
| AddRef(); | ||||||||||||||
| *iface = static_cast<IDacDbiInterface*>(this); | ||||||||||||||
| return S_OK; | ||||||||||||||
| } | ||||||||||||||
| EX_CATCH_HRESULT(hr); | ||||||||||||||
| return hr; | ||||||||||||||
| return ClrDataAccess::QueryInterface(interfaceId, iface); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| STDMETHODIMP_(ULONG) | ||||||||||||||
| DacDbiInterfaceImpl::AddRef(THIS) | ||||||||||||||
| { | ||||||||||||||
| return ClrDataAccess::AddRef(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| STDMETHODIMP_(ULONG) | ||||||||||||||
| DacDbiInterfaceImpl::Release(THIS) | ||||||||||||||
| { | ||||||||||||||
| return ClrDataAccess::Release(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Check whether the version of the DBI matches the version of the runtime. | ||||||||||||||
|
|
@@ -495,7 +506,7 @@ HRESULT DacDbiInterfaceImpl::FlushCache() | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // enable or disable DAC target consistency checks | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::DacSetTargetConsistencyChecks(bool fEnableAsserts) | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::DacSetTargetConsistencyChecks(BOOL fEnableAsserts) | ||||||||||||||
| { | ||||||||||||||
| HRESULT hr = S_OK; | ||||||||||||||
| EX_TRY | ||||||||||||||
|
|
@@ -1172,8 +1183,11 @@ mdSignature DacDbiInterfaceImpl::GetILCodeAndSigHelper(Module * pModule, | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| HRESULT DacDbiInterfaceImpl::GetMetaDataFileInfoFromPEFile(VMPTR_PEAssembly vmPEAssembly, DWORD & dwTimeStamp, DWORD & dwImageSize, IStringHolder* pStrFilename, OUT bool * pResult) | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::GetMetaDataFileInfoFromPEFile(VMPTR_PEAssembly vmPEAssembly, DWORD * pTimeStamp, DWORD * pImageSize, IStringHolder* pStrFilename, OUT BOOL * pResult) | ||||||||||||||
| { | ||||||||||||||
| if (pTimeStamp == NULL || pImageSize == NULL || pStrFilename == NULL || pResult == NULL) | ||||||||||||||
| return E_POINTER; | ||||||||||||||
|
|
||||||||||||||
| DD_ENTER_MAY_THROW; | ||||||||||||||
|
|
||||||||||||||
| HRESULT hr = S_OK; | ||||||||||||||
|
|
@@ -1186,15 +1200,15 @@ HRESULT DacDbiInterfaceImpl::GetMetaDataFileInfoFromPEFile(VMPTR_PEAssembly vmPE | |||||||||||||
| _ASSERTE(pPEAssembly != NULL); | ||||||||||||||
| if (pPEAssembly == NULL) | ||||||||||||||
| { | ||||||||||||||
| *pResult = false; | ||||||||||||||
| *pResult = FALSE; | ||||||||||||||
| } | ||||||||||||||
| else | ||||||||||||||
| { | ||||||||||||||
| WCHAR wszFilePath[MAX_LONGPATH] = {0}; | ||||||||||||||
| DWORD cchFilePath = MAX_LONGPATH; | ||||||||||||||
| bool ret = ClrDataAccess::GetMetaDataFileInfoFromPEFile(pPEAssembly, | ||||||||||||||
| dwTimeStamp, | ||||||||||||||
| dwImageSize, | ||||||||||||||
| *pTimeStamp, | ||||||||||||||
| *pImageSize, | ||||||||||||||
| dwDataSize, | ||||||||||||||
| dwRvaHint, | ||||||||||||||
| wszFilePath, | ||||||||||||||
|
|
@@ -2743,8 +2757,11 @@ HRESULT DacDbiInterfaceImpl::GetApproxTypeHandle(TypeInfoList * pTypeData, OUT V | |||||||||||||
| // DacDbiInterface API: Get the exact type handle from type data | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::GetExactTypeHandle(DebuggerIPCE_ExpandedTypeData * pTypeData, | ||||||||||||||
| ArgInfoList * pArgInfo, | ||||||||||||||
| VMPTR_TypeHandle& vmTypeHandle) | ||||||||||||||
| VMPTR_TypeHandle * pVmTypeHandle) | ||||||||||||||
| { | ||||||||||||||
| if (pVmTypeHandle == NULL) | ||||||||||||||
| return E_POINTER; | ||||||||||||||
|
|
||||||||||||||
| DD_ENTER_MAY_THROW; | ||||||||||||||
|
|
||||||||||||||
| LOG((LF_CORDB, LL_INFO10000, "D::GETH: getting info.\n")); | ||||||||||||||
|
|
@@ -2753,12 +2770,12 @@ HRESULT DacDbiInterfaceImpl::GetExactTypeHandle(DebuggerIPCE_ExpandedTypeData * | |||||||||||||
|
|
||||||||||||||
| EX_TRY | ||||||||||||||
| { | ||||||||||||||
| vmTypeHandle = vmTypeHandle.NullPtr(); | ||||||||||||||
| *pVmTypeHandle = VMPTR_TypeHandle::NullPtr(); | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
2758
to
2774
|
||||||||||||||
| // convert the type information to a type handle | ||||||||||||||
| TypeHandle typeHandle = ExpandedTypeInfoToTypeHandle(pTypeData, pArgInfo); | ||||||||||||||
| _ASSERTE(!typeHandle.IsNull()); | ||||||||||||||
| vmTypeHandle.SetDacTargetPtr(typeHandle.AsTAddr()); | ||||||||||||||
| pVmTypeHandle->SetDacTargetPtr(typeHandle.AsTAddr()); | ||||||||||||||
| } | ||||||||||||||
| EX_CATCH_HRESULT(hr); | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -3732,8 +3749,11 @@ HRESULT DacDbiInterfaceImpl::GetLoaderHeapMemoryRanges(DacDbiArrayList<COR_MEMOR | |||||||||||||
| return hr; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| HRESULT DacDbiInterfaceImpl::GetStackFramesFromException(VMPTR_Object vmObject, DacDbiArrayList<DacExceptionCallStackData>& dacStackFrames) | ||||||||||||||
| HRESULT DacDbiInterfaceImpl::GetStackFramesFromException(VMPTR_Object vmObject, DacDbiArrayList<DacExceptionCallStackData>* pDacStackFrames) | ||||||||||||||
| { | ||||||||||||||
| if (pDacStackFrames == NULL) | ||||||||||||||
| return E_POINTER; | ||||||||||||||
|
|
||||||||||||||
| DD_ENTER_MAY_THROW; | ||||||||||||||
|
|
||||||||||||||
| HRESULT hr = S_OK; | ||||||||||||||
|
|
@@ -3761,12 +3781,12 @@ HRESULT DacDbiInterfaceImpl::GetStackFramesFromException(VMPTR_Object vmObject, | |||||||||||||
|
|
||||||||||||||
| if (dacStackFramesLength > 0) | ||||||||||||||
| { | ||||||||||||||
|
||||||||||||||
| { | |
| { | |
| if (pDacStackFrames == NULL) | |
| { | |
| ThrowHR(E_POINTER); | |
| } |
max-charlamb marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsWinRTModule changed from an out reference to an out pointer (pIsWinRT) but still writes to it unconditionally. Add a null check and return E_POINTER when pIsWinRT is null (consistent with other APIs in this layer that validate out pointers).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DacDbiInterfaceImpl::QueryInterface dereferences
ifacewithout a null check. If a caller passes a null out-pointer (or uses it incorrectly), this will AV before you can return an HRESULT. Consider matching COM expectations here by returning E_POINTER whenifaceis null and (optionally) setting*iface = nullptrbefore any IID checks.