diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
index 22a918584a567..8bf969b604081 100644
--- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
+++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
@@ -300,18 +300,11 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
throw new ArgumentNullException(nameof(o));
}
- return GetIUnknownForObjectNative(o, false);
+ return GetIUnknownForObjectNative(o);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern IntPtr /* IUnknown* */ GetIUnknownForObjectNative(object o, bool onlyInContext);
-
- ///
- /// Return the raw IUnknown* for a COM Object not related to current.
- /// Does not call AddRef.
- ///
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern IntPtr /* IUnknown* */ GetRawIUnknownForComObjectNoAddRef(object o);
+ private static extern IntPtr /* IUnknown* */ GetIUnknownForObjectNative(object o);
///
/// Return the IDispatch* for an Object.
@@ -324,11 +317,11 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
throw new ArgumentNullException(nameof(o));
}
- return GetIDispatchForObjectNative(o, false);
+ return GetIDispatchForObjectNative(o);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern IntPtr /* IDispatch* */ GetIDispatchForObjectNative(object o, bool onlyInContext);
+ private static extern IntPtr /* IDispatch* */ GetIDispatchForObjectNative(object o);
///
/// Return the IUnknown* representing the interface for the Object.
@@ -347,7 +340,7 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
throw new ArgumentNullException(nameof(T));
}
- return GetComInterfaceForObjectNative(o, T, false, true);
+ return GetComInterfaceForObjectNative(o, T, true);
}
[SupportedOSPlatform("windows")]
@@ -372,11 +365,11 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
}
bool bEnableCustomizedQueryInterface = ((mode == CustomQueryInterfaceMode.Allow) ? true : false);
- return GetComInterfaceForObjectNative(o, T, false, bEnableCustomizedQueryInterface);
+ return GetComInterfaceForObjectNative(o, T, bEnableCustomizedQueryInterface);
}
[MethodImpl(MethodImplOptions.InternalCall)]
- private static extern IntPtr /* IUnknown* */ GetComInterfaceForObjectNative(object o, Type t, bool onlyInContext, bool fEnableCustomizedQueryInterface);
+ private static extern IntPtr /* IUnknown* */ GetComInterfaceForObjectNative(object o, Type t, bool fEnableCustomizedQueryInterface);
///
/// Return the managed object representing the IUnknown*
diff --git a/src/coreclr/src/vm/cominterfacemarshaler.cpp b/src/coreclr/src/vm/cominterfacemarshaler.cpp
index d2f47cd279d0b..99561e0b12a2a 100644
--- a/src/coreclr/src/vm/cominterfacemarshaler.cpp
+++ b/src/coreclr/src/vm/cominterfacemarshaler.cpp
@@ -456,35 +456,6 @@ VOID COMInterfaceMarshaler::InitializeExistingComObject(OBJECTREF *pComObj, IUnk
CreateObjectRef(NeedUniqueObject(), pComObj, ppIncomingIP, /* pIncomingItfMT = */ NULL, /* bIncomingIPAddRefed = */ true);
}
-//--------------------------------------------------------------------------------
-// Helper to wrap an IUnknown with COM object
-//--------------------------------------------------------------------------------
-OBJECTREF COMInterfaceMarshaler::WrapWithComObject()
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- }
- CONTRACTL_END;
-
- OBJECTREF oref = NULL;
- GCPROTECT_BEGIN(oref)
- {
- CreateObjectRef(
- TRUE, // fDuplicate
- &oref, // pComObj
- NULL, // ppIncomingIP
- NULL, // pIncomingItfMT
- false // bIncomingIPAddRefed
- );
- }
- GCPROTECT_END();
-
- return oref;
-}
-
//--------------------------------------------------------------------------------
// VOID EnsureCOMInterfacesSupported(OBJECTREF oref, MethodTable* pClassMT)
// Make sure the oref supports all the COM interfaces in the class
diff --git a/src/coreclr/src/vm/cominterfacemarshaler.h b/src/coreclr/src/vm/cominterfacemarshaler.h
index 38b206425444e..7d972728bc114 100644
--- a/src/coreclr/src/vm/cominterfacemarshaler.h
+++ b/src/coreclr/src/vm/cominterfacemarshaler.h
@@ -56,8 +56,6 @@ class COMInterfaceMarshaler
OBJECTREF FindOrCreateObjectRef(IUnknown **ppIncomingIP, MethodTable *pIncomingItfMT = NULL);
OBJECTREF FindOrCreateObjectRef(IUnknown *pIncomingIP, MethodTable *pIncomingItfMT = NULL);
- OBJECTREF WrapWithComObject();
-
VOID InitializeExistingComObject(OBJECTREF *pComObj, IUnknown **ppIncomingIP);
private:
diff --git a/src/coreclr/src/vm/dllimport.cpp b/src/coreclr/src/vm/dllimport.cpp
index 4a1f1a0b01efb..259af70a1e62d 100644
--- a/src/coreclr/src/vm/dllimport.cpp
+++ b/src/coreclr/src/vm/dllimport.cpp
@@ -2537,7 +2537,7 @@ void PInvokeStaticSigInfo::PreInit(MethodDesc* pMD)
}
PInvokeStaticSigInfo::PInvokeStaticSigInfo(
- MethodDesc* pMD, LPCUTF8 *pLibName, LPCUTF8 *pEntryPointName, ThrowOnError throwOnError)
+ MethodDesc* pMD, LPCUTF8 *pLibName, LPCUTF8 *pEntryPointName)
{
CONTRACTL
{
@@ -2549,8 +2549,7 @@ PInvokeStaticSigInfo::PInvokeStaticSigInfo(
DllImportInit(pMD, pLibName, pEntryPointName);
- if (throwOnError)
- ReportErrors();
+ ReportErrors();
}
PInvokeStaticSigInfo::PInvokeStaticSigInfo(MethodDesc* pMD, ThrowOnError throwOnError)
@@ -2654,7 +2653,7 @@ PInvokeStaticSigInfo::PInvokeStaticSigInfo(MethodDesc* pMD, ThrowOnError throwOn
}
PInvokeStaticSigInfo::PInvokeStaticSigInfo(
- Signature sig, Module* pModule, ThrowOnError throwOnError)
+ Signature sig, Module* pModule)
{
CONTRACTL
{
@@ -2671,8 +2670,7 @@ PInvokeStaticSigInfo::PInvokeStaticSigInfo(
SetIsStatic (!(MetaSig::GetCallingConvention(pModule, sig) & IMAGE_CEE_CS_CALLCONV_HASTHIS));
InitCallConv((CorPinvokeMap)0, FALSE);
- if (throwOnError)
- ReportErrors();
+ ReportErrors();
}
void PInvokeStaticSigInfo::DllImportInit(MethodDesc* pMD, LPCUTF8 *ppLibName, LPCUTF8 *ppEntryPointName)
@@ -4293,9 +4291,9 @@ static void CreateNDirectStubAccessMetadata(
}
}
-void NDirect::PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo, BOOL throwOnError /*= TRUE*/)
+void NDirect::PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo)
{
- if (pNMD->IsSynchronized() && throwOnError)
+ if (pNMD->IsSynchronized())
COMPlusThrow(kTypeLoadException, IDS_EE_NOSYNCHRONIZED);
WORD ndirectflags = 0;
@@ -4303,8 +4301,7 @@ void NDirect::PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSi
ndirectflags |= NDirectMethodDesc::kVarArgs;
LPCUTF8 szLibName = NULL, szEntryPointName = NULL;
- new (pSigInfo) PInvokeStaticSigInfo(pNMD, &szLibName, &szEntryPointName,
- (throwOnError ? PInvokeStaticSigInfo::THROW_ON_ERROR : PInvokeStaticSigInfo::NO_THROW_ON_ERROR));
+ new (pSigInfo) PInvokeStaticSigInfo(pNMD, &szLibName, &szEntryPointName);
if (pSigInfo->GetCharSet() == nltAnsi)
ndirectflags |= NDirectMethodDesc::kNativeAnsi;
@@ -5249,7 +5246,7 @@ MethodDesc* NDirect::GetILStubMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticS
MethodDesc* pStubMD = NULL;
- if (!pNMD->IsVarArgs() || SF_IsForNumParamBytes(dwStubFlags))
+ if (!pNMD->IsVarArgs())
{
if (pNMD->IsClassConstructorTriggeredByILStub())
{
@@ -5258,7 +5255,7 @@ MethodDesc* NDirect::GetILStubMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticS
pStubMD = CreateCLRToNativeILStub(
pSigInfo,
- dwStubFlags & ~NDIRECTSTUB_FL_FOR_NUMPARAMBYTES,
+ dwStubFlags,
pNMD);
}
@@ -5354,14 +5351,11 @@ PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD,
if (NULL == *ppStubMD)
{
PInvokeStaticSigInfo sigInfo;
- NDirect::PopulateNDirectMethodDesc(pNMD, &sigInfo, /* throwOnError = */ !SF_IsForNumParamBytes(dwStubFlags));
+ NDirect::PopulateNDirectMethodDesc(pNMD, &sigInfo);
*ppStubMD = NDirect::GetILStubMethodDesc(pNMD, &sigInfo, dwStubFlags);
}
- if (SF_IsForNumParamBytes(dwStubFlags))
- return NULL;
-
if (*ppStubMD)
{
pStub = JitILStub(*ppStubMD);
diff --git a/src/coreclr/src/vm/dllimport.h b/src/coreclr/src/vm/dllimport.h
index b24ab6e3e6c8e..ba2b20d13b387 100644
--- a/src/coreclr/src/vm/dllimport.h
+++ b/src/coreclr/src/vm/dllimport.h
@@ -87,7 +87,7 @@ class NDirect
_In_opt_ PCCOR_SIGNATURE pSig = NULL,
_In_opt_ Module* pModule = NULL,
_In_ bool unmanagedCallersOnlyRequiresMarshalling = true);
- static void PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo, BOOL throwOnError = TRUE);
+ static void PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo);
static MethodDesc* CreateCLRToNativeILStub(
StubSigDesc* pSigDesc,
@@ -161,7 +161,7 @@ enum NDirectStubFlags
#endif // FEATURE_COMINTEROP
// internal flags -- these won't ever show up in an NDirectStubHashBlob
- NDIRECTSTUB_FL_FOR_NUMPARAMBYTES = 0x10000000, // do just enough to return the right value from Marshal.NumParamBytes
+ // unused = 0x10000000,
#ifdef FEATURE_COMINTEROP
NDIRECTSTUB_FL_COMLATEBOUND = 0x20000000, // we use a generic stub for late bound calls
@@ -210,7 +210,6 @@ inline bool SF_IsNGENedStubForProfiling(DWORD dwStubFlags) { LIMITED_METHOD_CONT
inline bool SF_IsDebuggableStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL)); }
inline bool SF_IsCALLIStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_UNMANAGED_CALLI)); }
inline bool SF_IsStubWithCctorTrigger (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_TRIGGERCCTOR)); }
-inline bool SF_IsForNumParamBytes (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_FOR_NUMPARAMBYTES)); }
inline bool SF_IsStructMarshalStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_STRUCT_MARSHAL)); }
#ifdef FEATURE_ARRAYSTUB_AS_IL
@@ -320,11 +319,11 @@ struct PInvokeStaticSigInfo
public:
PInvokeStaticSigInfo() { LIMITED_METHOD_CONTRACT; }
- PInvokeStaticSigInfo(Signature sig, Module* pModule, ThrowOnError throwOnError = THROW_ON_ERROR);
+ PInvokeStaticSigInfo(Signature sig, Module* pModule);
PInvokeStaticSigInfo(MethodDesc* pMdDelegate, ThrowOnError throwOnError = THROW_ON_ERROR);
- PInvokeStaticSigInfo(MethodDesc* pMD, LPCUTF8 *pLibName, LPCUTF8 *pEntryPointName, ThrowOnError throwOnError = THROW_ON_ERROR);
+ PInvokeStaticSigInfo(MethodDesc* pMD, LPCUTF8 *pLibName, LPCUTF8 *pEntryPointName);
public:
void ReportErrors();
@@ -563,7 +562,6 @@ class NDirectStubLinker : public ILStubLinker
#endif // DACCESS_COMPILE
// This attempts to guess whether a target is an API call that uses SetLastError to communicate errors.
-BOOL HeuristicDoesThisLooksLikeAnApiCall(LPBYTE pTarget);
BOOL HeuristicDoesThisLookLikeAGetLastErrorCall(LPBYTE pTarget);
DWORD STDMETHODCALLTYPE FalseGetLastError();
diff --git a/src/coreclr/src/vm/ecalllist.h b/src/coreclr/src/vm/ecalllist.h
index d24d0dc3b2adc..2c8e41ac831e7 100644
--- a/src/coreclr/src/vm/ecalllist.h
+++ b/src/coreclr/src/vm/ecalllist.h
@@ -786,7 +786,6 @@ FCFuncStart(gInteropMarshalFuncs)
#ifdef FEATURE_COMINTEROP
FCFuncElement("GetHRForException", MarshalNative::GetHRForException)
- FCFuncElement("GetRawIUnknownForComObjectNoAddRef", MarshalNative::GetRawIUnknownForComObjectNoAddRef)
FCFuncElement("IsComObject", MarshalNative::IsComObject)
FCFuncElement("GetObjectForIUnknownNative", MarshalNative::GetObjectForIUnknownNative)
FCFuncElement("GetUniqueObjectForIUnknownNative", MarshalNative::GetUniqueObjectForIUnknownNative)
diff --git a/src/coreclr/src/vm/marshalnative.cpp b/src/coreclr/src/vm/marshalnative.cpp
index 91f311b58e309..a2e2295cf7fca 100644
--- a/src/coreclr/src/vm/marshalnative.cpp
+++ b/src/coreclr/src/vm/marshalnative.cpp
@@ -37,64 +37,12 @@
#ifdef FEATURE_COMINTEROP
#include "comcallablewrapper.h"
-#include "cominterfacemarshaler.h"
#include "commtmemberinfomap.h"
#include "runtimecallablewrapper.h"
#include "olevariant.h"
#include "interoputil.h"
-#include "stubhelpers.h"
#endif // FEATURE_COMINTEROP
-#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
-#include "olecontexthelpers.h"
-#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
-
-//
-// NumParamBytes
-// Counts # of parameter bytes
-INT32 QCALLTYPE MarshalNative::NumParamBytes(MethodDesc * pMD)
-{
- QCALL_CONTRACT;
-
- // Arguments are check on managed side
- PRECONDITION(pMD != NULL);
-
- INT32 cbParamBytes = 0;
-
- BEGIN_QCALL;
-
- if (!(pMD->IsNDirect()))
- COMPlusThrow(kArgumentException, IDS_EE_NOTNDIRECT);
-
- // Read the unmanaged stack size from the stub MethodDesc. For vararg P/Invoke,
- // this function returns size of the fixed portion of the stack.
- // Note that the following code does not throw if the DllImport declaration is
- // incorrect (such as a vararg method not marked as CallingConvention.Cdecl).
-
- MethodDesc * pStubMD = NULL;
-
- PCODE pTempStub = NULL;
- pTempStub = GetStubForInteropMethod(pMD, NDIRECTSTUB_FL_FOR_NUMPARAMBYTES, &pStubMD);
- _ASSERTE(pTempStub == NULL);
-
- _ASSERTE(pStubMD != NULL && pStubMD->IsILStub());
-
- cbParamBytes = pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize();
-
-#ifdef HOST_X86
- if (((NDirectMethodDesc *)pMD)->IsThisCall())
- {
- // The size of 'this' is not included in native stack arg size.
- cbParamBytes += sizeof(LPVOID);
- }
-#endif // HOST_X86
-
- END_QCALL;
-
- return cbParamBytes;
-}
-
-
// Prelink
// Does advance loading of an N/Direct library
VOID QCALLTYPE MarshalNative::Prelink(MethodDesc * pMD)
@@ -697,7 +645,7 @@ FCIMPLEND
//====================================================================
// return the IUnknown* for an Object.
//====================================================================
-FCIMPL2(IUnknown*, MarshalNative::GetIUnknownForObjectNative, Object* orefUNSAFE, CLR_BOOL fOnlyInContext)
+FCIMPL1(IUnknown*, MarshalNative::GetIUnknownForObjectNative, Object* orefUNSAFE)
{
FCALL_CONTRACT;
@@ -709,47 +657,7 @@ FCIMPL2(IUnknown*, MarshalNative::GetIUnknownForObjectNative, Object* orefUNSAFE
// Ensure COM is started up.
EnsureComStarted();
- if (fOnlyInContext && !IsObjectInContext(&oref))
- retVal = NULL;
- else
- retVal = GetComIPFromObjectRef(&oref, ComIpType_OuterUnknown, NULL);
-
- HELPER_METHOD_FRAME_END();
- return retVal;
-}
-FCIMPLEND
-
-//====================================================================
-// return the raw IUnknown* for a COM Object not related to current
-// context.
-// Does not AddRef the returned pointer
-//====================================================================
-FCIMPL1(IUnknown*, MarshalNative::GetRawIUnknownForComObjectNoAddRef, Object* orefUNSAFE)
-{
- FCALL_CONTRACT;
-
- IUnknown* retVal = NULL;
- OBJECTREF oref = (OBJECTREF) orefUNSAFE;
- HELPER_METHOD_FRAME_BEGIN_RET_1(oref);
-
- HRESULT hr = S_OK;
-
- if(!oref)
- COMPlusThrowArgumentNull(W("o"));
-
- MethodTable* pMT = oref->GetMethodTable();
- PREFIX_ASSUME(pMT != NULL);
- if(!pMT->IsComObjectType())
- COMPlusThrow(kArgumentException, IDS_EE_SRC_OBJ_NOT_COMOBJECT);
-
- // Ensure COM is started up.
- EnsureComStarted();
-
- RCWHolder pRCW(GetThread());
- pRCW.Init(oref);
-
- // Retrieve raw IUnknown * without AddRef for better performance
- retVal = pRCW->GetRawIUnknown_NoAddRef();
+ retVal = GetComIPFromObjectRef(&oref, ComIpType_OuterUnknown, NULL);
HELPER_METHOD_FRAME_END();
return retVal;
@@ -759,7 +667,7 @@ FCIMPLEND
//====================================================================
// return the IDispatch* for an Object.
//====================================================================
-FCIMPL2(IDispatch*, MarshalNative::GetIDispatchForObjectNative, Object* orefUNSAFE, CLR_BOOL fOnlyInContext)
+FCIMPL1(IDispatch*, MarshalNative::GetIDispatchForObjectNative, Object* orefUNSAFE)
{
FCALL_CONTRACT;
@@ -771,10 +679,7 @@ FCIMPL2(IDispatch*, MarshalNative::GetIDispatchForObjectNative, Object* orefUNSA
// Ensure COM is started up.
EnsureComStarted();
- if (fOnlyInContext && !IsObjectInContext(&oref))
- retVal = NULL;
- else
- retVal = (IDispatch*)GetComIPFromObjectRef(&oref, ComIpType_Dispatch, NULL);
+ retVal = (IDispatch*)GetComIPFromObjectRef(&oref, ComIpType_Dispatch, NULL);
HELPER_METHOD_FRAME_END();
return retVal;
@@ -785,7 +690,7 @@ FCIMPLEND
// return the IUnknown* representing the interface for the Object
// Object o should support Type T
//====================================================================
-FCIMPL4(IUnknown*, MarshalNative::GetComInterfaceForObjectNative, Object* orefUNSAFE, ReflectClassBaseObject* refClassUNSAFE, CLR_BOOL fOnlyInContext, CLR_BOOL bEnableCustomizedQueryInterface)
+FCIMPL3(IUnknown*, MarshalNative::GetComInterfaceForObjectNative, Object* orefUNSAFE, ReflectClassBaseObject* refClassUNSAFE, CLR_BOOL bEnableCustomizedQueryInterface)
{
FCALL_CONTRACT;
@@ -820,10 +725,7 @@ FCIMPL4(IUnknown*, MarshalNative::GetComInterfaceForObjectNative, Object* orefUN
if (!::IsTypeVisibleFromCom(th))
COMPlusThrowArgumentException(W("t"), W("Argument_TypeMustBeVisibleFromCom"));
- if (fOnlyInContext && !IsObjectInContext(&oref))
- retVal = NULL;
- else
- retVal = GetComIPFromObjectRef(&oref, th.GetMethodTable(), bEnableCustomizedQueryInterface);
+ retVal = GetComIPFromObjectRef(&oref, th.GetMethodTable(), bEnableCustomizedQueryInterface);
HELPER_METHOD_FRAME_END();
return retVal;
@@ -880,28 +782,6 @@ FCIMPL1(Object*, MarshalNative::GetUniqueObjectForIUnknownNative, IUnknown* pUnk
}
FCIMPLEND
-FCIMPL1(Object*, MarshalNative::GetUniqueObjectForIUnknownWithoutUnboxing, IUnknown* pUnk)
-{
- FCALL_CONTRACT;
-
- OBJECTREF oref = NULL;
- HELPER_METHOD_FRAME_BEGIN_RET_1(oref);
-
- HRESULT hr = S_OK;
-
- if(!pUnk)
- COMPlusThrowArgumentNull(W("pUnk"));
-
- // Ensure COM is started up.
- EnsureComStarted();
-
- GetObjectRefFromComIP(&oref, pUnk, NULL, NULL, ObjFromComIP::UNIQUE_OBJECT);
-
- HELPER_METHOD_FRAME_END();
- return OBJECTREFToObject(oref);
-}
-FCIMPLEND
-
//====================================================================
// return an Object for IUnknown, using the Type T,
// NOTE:
@@ -1396,44 +1276,6 @@ FCIMPL1(int, MarshalNative::GetEndComSlot, ReflectClassBaseObject* tUNSAFE)
}
FCIMPLEND
-//+----------------------------------------------------------------------------
-//
-// Method: MarshalNative::WrapIUnknownWithComObject
-// Synopsis: unmarshal the buffer and return IUnknown
-//
-
-//
-//+----------------------------------------------------------------------------
-FCIMPL1(Object*, MarshalNative::WrapIUnknownWithComObject, IUnknown* pUnk)
-{
- CONTRACTL
- {
- FCALL_CHECK;
- PRECONDITION(CheckPointer(pUnk, NULL_OK));
- }
- CONTRACTL_END;
-
- OBJECTREF cref = NULL;
- HELPER_METHOD_FRAME_BEGIN_RET_0();
-
- if(pUnk == NULL)
- COMPlusThrowArgumentNull(W("punk"));
-
- EnsureComStarted();
-
- COMInterfaceMarshaler marshaler;
- marshaler.Init(pUnk, g_pBaseCOMObject, GET_THREAD());
-
- cref = marshaler.WrapWithComObject();
-
- if (cref == NULL)
- COMPlusThrowOM();
-
- HELPER_METHOD_FRAME_END();
- return OBJECTREFToObject(cref);
-}
-FCIMPLEND
-
FCIMPL2(void, MarshalNative::ChangeWrapperHandleStrength, Object* orefUNSAFE, CLR_BOOL fIsWeak)
{
FCALL_CONTRACT;
@@ -1512,43 +1354,6 @@ int MarshalNative::GetComSlotInfo(MethodTable *pMT, MethodTable **ppDefItfMT)
}
}
-BOOL MarshalNative::IsObjectInContext(OBJECTREF *pObj)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_COOPERATIVE;
- PRECONDITION(pObj != NULL);
- }
- CONTRACTL_END;
-
- SyncBlock* pBlock = (*pObj)->GetSyncBlock();
-
- InteropSyncBlockInfo* pInteropInfo = pBlock->GetInteropInfo();
-
- ComCallWrapper* pCCW = pInteropInfo->GetCCW();
-
- if((pCCW) || (!pInteropInfo->RCWWasUsed()))
- {
- // We are dealing with a CCW. Since CCW's are agile, they are always in the
- // correct context.
- return TRUE;
- }
- else
- {
- RCWHolder pRCW(GetThread());
- pRCW.Init(pBlock);
-
- // We are dealing with an RCW, we need to check to see if the current
- // context is the one it was first seen in.
- LPVOID pCtxCookie = GetCurrentCtxCookie();
- _ASSERTE(pCtxCookie != NULL);
-
- return pCtxCookie == pRCW->GetWrapperCtxCookie();
- }
-}
-
void QCALLTYPE MarshalNative::GetTypeFromCLSID(REFCLSID clsid, PCWSTR wszServer, QCall::ObjectHandleOnStack retType)
{
QCALL_CONTRACT;
diff --git a/src/coreclr/src/vm/marshalnative.h b/src/coreclr/src/vm/marshalnative.h
index aa2803fa5a509..fc92e26028a7f 100644
--- a/src/coreclr/src/vm/marshalnative.h
+++ b/src/coreclr/src/vm/marshalnative.h
@@ -16,28 +16,9 @@
#define MAX_UTF8_CHAR_SIZE 3
-//!!! Must be kept in sync with ArrayWithOffset class layout.
-struct ArrayWithOffsetData
-{
- BASEARRAYREF m_Array;
- INT32 m_cbOffset;
- INT32 m_cbCount;
-};
-
-
-#ifdef FEATURE_COMINTEROP
-enum ComMemberType
-{
- CMT_Method = 0,
- CMT_PropGet = 1,
- CMT_PropSet = 2
-};
-#endif // FEATURE_COMINTEROP
-
class MarshalNative
{
public:
- static INT32 QCALLTYPE NumParamBytes(MethodDesc * pMD);
static VOID QCALLTYPE Prelink(MethodDesc * pMD);
//====================================================================
@@ -71,25 +52,18 @@ class MarshalNative
//====================================================================
// return the IUnknown* for an Object
//====================================================================
- static FCDECL2(IUnknown*, GetIUnknownForObjectNative, Object* orefUNSAFE, CLR_BOOL fOnlyInContext);
-
- //====================================================================
- // return the raw IUnknown* for a COM Object not related to current
- // context
- // Does not AddRef the returned pointer
- //====================================================================
- static FCDECL1(IUnknown*, GetRawIUnknownForComObjectNoAddRef, Object* orefUNSAFE);
+ static FCDECL1(IUnknown*, GetIUnknownForObjectNative, Object* orefUNSAFE);
//====================================================================
// return the IDispatch* for an Object
//====================================================================
- static FCDECL2(IDispatch*, GetIDispatchForObjectNative, Object* orefUNSAFE, CLR_BOOL fOnlyInContext);
+ static FCDECL1(IDispatch*, GetIDispatchForObjectNative, Object* orefUNSAFE);
//====================================================================
// return the IUnknown* representing the interface for the Object
// Object o should support Type T
//====================================================================
- static FCDECL4(IUnknown*, GetComInterfaceForObjectNative, Object* orefUNSAFE, ReflectClassBaseObject* refClassUNSAFE, CLR_BOOL fOnlyInContext, CLR_BOOL bEnableCustomizedQueryInterface);
+ static FCDECL3(IUnknown*, GetComInterfaceForObjectNative, Object* orefUNSAFE, ReflectClassBaseObject* refClassUNSAFE, CLR_BOOL bEnableCustomizedQueryInterface);
//====================================================================
// return an Object for IUnknown
@@ -101,11 +75,6 @@ class MarshalNative
//====================================================================
static FCDECL1(Object*, GetUniqueObjectForIUnknownNative, IUnknown* pUnk);
- //====================================================================
- // return a unique cacheless Object for IUnknown
- //====================================================================
- static FCDECL1(Object*, GetUniqueObjectForIUnknownWithoutUnboxing, IUnknown* pUnk);
-
//====================================================================
// return an Object for IUnknown, using the Type T,
// NOTE:
@@ -164,8 +133,6 @@ class MarshalNative
static FCDECL1(int, GetStartComSlot, ReflectClassBaseObject* tUNSAFE);
static FCDECL1(int, GetEndComSlot, ReflectClassBaseObject* tUNSAFE);
- static FCDECL1(Object*, WrapIUnknownWithComObject, IUnknown* pUnk);
-
static FCDECL2(void, ChangeWrapperHandleStrength, Object* orefUNSAFE, CLR_BOOL fIsWeak);
//====================================================================
@@ -175,7 +142,6 @@ class MarshalNative
private:
static int GetComSlotInfo(MethodTable *pMT, MethodTable **ppDefItfMT);
- static BOOL IsObjectInContext(OBJECTREF *pObj);
#endif // FEATURE_COMINTEROP
};