-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Convert more COM interop MethodDescCallSite to UCO #125508
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
Changes from all commits
96197f1
83f8dd6
3247c98
e4b6de6
3e5088f
988e82a
68e943f
dc0cc4a
dd50f41
5057a6a
3ed9700
f1fc86a
81e4f93
61f5e70
792f177
140e394
dfc2a5d
7397553
e25f424
cdaee50
e4e5d2a
a08de0d
5693443
0f433ae
a2eb88b
563d118
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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2314,52 +2314,6 @@ IUnknown* ComCallWrapper::GetBasicIP(bool inspectionOnly) | |||||||||||||||||||||
| RETURN ((cbRef != 0xbadf00d) ? pIntf : NULL); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| struct InvokeICustomQueryInterfaceGetInterfaceArgs | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| ComCallWrapper *pWrap; | ||||||||||||||||||||||
| GUID *pGuid; | ||||||||||||||||||||||
| IUnknown **ppUnk; | ||||||||||||||||||||||
| CustomQueryInterfaceResult *pRetVal; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| VOID __stdcall InvokeICustomQueryInterfaceGetInterface_CallBack(LPVOID ptr) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| CONTRACTL | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| THROWS; | ||||||||||||||||||||||
| GC_TRIGGERS; | ||||||||||||||||||||||
| MODE_ANY; | ||||||||||||||||||||||
| PRECONDITION(CheckPointer(ptr)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| CONTRACTL_END; | ||||||||||||||||||||||
| InvokeICustomQueryInterfaceGetInterfaceArgs *pArgs = (InvokeICustomQueryInterfaceGetInterfaceArgs*)ptr; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| { | ||||||||||||||||||||||
| GCX_COOP(); | ||||||||||||||||||||||
| OBJECTREF pObj = pArgs->pWrap->GetObjectRef(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| GCPROTECT_BEGIN(pObj); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // 1. Get MD | ||||||||||||||||||||||
| MethodDesc *pMD = pArgs->pWrap->GetSimpleWrapper()->GetComCallWrapperTemplate()->GetICustomQueryInterfaceGetInterfaceMD(); | ||||||||||||||||||||||
|
am11 marked this conversation as resolved.
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // 2. Get Object Handle | ||||||||||||||||||||||
| OBJECTHANDLE hndCustomQueryInterface = pArgs->pWrap->GetObjectHandle(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // 3 construct the MethodDescCallSite | ||||||||||||||||||||||
| MethodDescCallSite GetInterface(pMD, hndCustomQueryInterface); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ARG_SLOT Args[] = { | ||||||||||||||||||||||
| ObjToArgSlot(pObj), | ||||||||||||||||||||||
| PtrToArgSlot(pArgs->pGuid), | ||||||||||||||||||||||
| PtrToArgSlot(pArgs->ppUnk), | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| *(pArgs->pRetVal) = (CustomQueryInterfaceResult)GetInterface.Call_RetArgSlot(Args); | ||||||||||||||||||||||
| GCPROTECT_END(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| //-------------------------------------------------------------------------- | ||||||||||||||||||||||
| // check if the interface is supported, return a index into the IMap | ||||||||||||||||||||||
| // returns -1, if pIntfMT is not supported | ||||||||||||||||||||||
|
|
@@ -2601,9 +2555,21 @@ static bool GetComIPFromCCW_HandleCustomQI( | |||||||||||||||||||||
| guid = riid; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| InvokeICustomQueryInterfaceGetInterfaceArgs args = {pWrap, &guid, ppUnkOut, &retVal}; | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| GCX_COOP(); | ||||||||||||||||||||||
| OBJECTREF pObj = pWrap->GetObjectRef(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| InvokeICustomQueryInterfaceGetInterface_CallBack(&args); | ||||||||||||||||||||||
| GCPROTECT_BEGIN(pObj); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| INT_PTR queriedInterface = reinterpret_cast<INT_PTR>(*ppUnkOut); | ||||||||||||||||||||||
| INT32 result = static_cast<INT32>(CustomQueryInterfaceResult::NotHandled); | ||||||||||||||||||||||
| UnmanagedCallersOnlyCaller callICustomQueryInterface(METHOD__STUBHELPERS__CALL_ICUSTOM_QUERY_INTERFACE); | ||||||||||||||||||||||
| callICustomQueryInterface.InvokeThrowing(&pObj, &guid, &queriedInterface, &result); | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is also |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| *ppUnkOut = reinterpret_cast<IUnknown*>(queriedInterface); | ||||||||||||||||||||||
|
Comment on lines
+2564
to
+2569
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
We do not need a local copy of the IUnknown. This should also reduce changes that the IUknown reference leak if an exception is thrown in a specific spot. |
||||||||||||||||||||||
| retVal = static_cast<CustomQueryInterfaceResult>(result); | ||||||||||||||||||||||
| GCPROTECT_END(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // return if user already handle the QI | ||||||||||||||||||||||
| if (retVal == Handled) | ||||||||||||||||||||||
|
|
@@ -4674,7 +4640,6 @@ ComCallWrapperTemplate* ComCallWrapperTemplate::CreateTemplate(TypeHandle thClas | |||||||||||||||||||||
| pTemplate->m_pClassComMT = NULL; // Defer setting this up. | ||||||||||||||||||||||
| pTemplate->m_pBasicComMT = NULL; | ||||||||||||||||||||||
| pTemplate->m_pDefaultItf = NULL; | ||||||||||||||||||||||
| pTemplate->m_pICustomQueryInterfaceGetInterfaceMD = NULL; | ||||||||||||||||||||||
| pTemplate->m_flags = 0; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Determine the COM visibility of classes in our hierarchy. | ||||||||||||||||||||||
|
|
@@ -4794,7 +4759,6 @@ ComCallWrapperTemplate *ComCallWrapperTemplate::CreateTemplateForInterface(Metho | |||||||||||||||||||||
| pTemplate->m_pClassComMT = NULL; | ||||||||||||||||||||||
| pTemplate->m_pBasicComMT = NULL; | ||||||||||||||||||||||
| pTemplate->m_pDefaultItf = pItfMT; | ||||||||||||||||||||||
| pTemplate->m_pICustomQueryInterfaceGetInterfaceMD = NULL; | ||||||||||||||||||||||
| pTemplate->m_flags = enum_RepresentsVariantInterface; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Initialize the one ComMethodTable | ||||||||||||||||||||||
|
|
@@ -4928,24 +4892,6 @@ ComMethodTable *ComCallWrapperTemplate::SetupComMethodTableForClass(MethodTable | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| MethodDesc * ComCallWrapperTemplate::GetICustomQueryInterfaceGetInterfaceMD() | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| CONTRACT (MethodDesc*) | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| THROWS; | ||||||||||||||||||||||
| GC_TRIGGERS; | ||||||||||||||||||||||
| MODE_ANY; | ||||||||||||||||||||||
| PRECONDITION(m_flags & enum_ImplementsICustomQueryInterface); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| CONTRACT_END; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (m_pICustomQueryInterfaceGetInterfaceMD == NULL) | ||||||||||||||||||||||
| m_pICustomQueryInterfaceGetInterfaceMD = m_thClass.GetMethodTable()->GetMethodDescForInterfaceMethod( | ||||||||||||||||||||||
| CoreLibBinder::GetMethod(METHOD__ICUSTOM_QUERYINTERFACE__GET_INTERFACE), | ||||||||||||||||||||||
| TRUE /* throwOnConflict */); | ||||||||||||||||||||||
| RETURN m_pICustomQueryInterfaceGetInterfaceMD; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| //-------------------------------------------------------------------------- | ||||||||||||||||||||||
| // Module* ComCallMethodDesc::GetModule() | ||||||||||||||||||||||
| // Get Module | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1053,6 +1053,9 @@ DEFINE_METHOD(STUBHELPERS, GET_PENDING_EXCEPTION_OBJECT, GetPendingExce | |||||
| DEFINE_METHOD(STUBHELPERS, CREATE_CUSTOM_MARSHALER, CreateCustomMarshaler, SM_IntPtr_Int_IntPtr_RetObj) | ||||||
| #ifdef FEATURE_COMINTEROP | ||||||
| DEFINE_METHOD(STUBHELPERS, GET_IENUMERATOR_TO_ENUM_VARIANT_MARSHALER, GetIEnumeratorToEnumVariantMarshaler, SM_PtrObj_PtrException_RetVoid) | ||||||
| DEFINE_METHOD(STUBHELPERS, GET_DISPATCH_EX_PROPERTY_FLAGS, GetDispatchExPropertyFlags, SM_PtrPropertyInfo_PtrInt_PtrException_RetVoid) | ||||||
| DEFINE_METHOD(STUBHELPERS, CALL_ICUSTOM_QUERY_INTERFACE, CallICustomQueryInterface, SM_PtrICustomQueryInterface_PtrGuid_PtrIntPtr_PtrInt_PtrException_RetVoid) | ||||||
| DEFINE_METHOD(STUBHELPERS, INVOKE_CONNECTION_POINT_PROVIDER_METHOD, InvokeConnectionPointProviderMethod, SM_PtrObj_IntPtr_PtrObj_IntPtr_PtrObj_IntPtr_Bool_PtrException_RetVoid) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This should be nosig now that it has unmanaged pointers in the signatures (encoding the unmanaged pointers in the signature here is not worth the pain). |
||||||
| #endif // FEATURE_COMINTEROP | ||||||
|
|
||||||
| DEFINE_METHOD(STUBHELPERS, CHECK_STRING_LENGTH, CheckStringLength, SM_Int_RetVoid) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.