Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -762,17 +762,10 @@ private static extern bool Contains(
[UnsafeAccessorType(LicInfoHelperLicenseContextTypeName)] object? licInfoHelperContext,
string assemblyName);

[UnmanagedCallersOnly]
private static unsafe void Create(object* pResult, Exception* pException)
// Helper function to create an object from the native side
public static object Create()
{
try
{
*pResult = new LicenseInteropProxy();
}
catch (Exception ex)
{
*pException = ex;
}
return new LicenseInteropProxy();
}

// Determine if the type supports licensing
Expand Down Expand Up @@ -884,19 +877,6 @@ public void GetCurrentContextInfo(RuntimeTypeHandle rth, out bool isDesignTime,
bstrKey = Marshal.StringToBSTR((string)key!);
}

[UnmanagedCallersOnly]
private static unsafe void GetCurrentContextInfo(LicenseInteropProxy* pProxy, Type* pType, bool* pIsDesignTime, IntPtr* pBstrKey, Exception* pException)
{
try
{
pProxy->GetCurrentContextInfo(pType->TypeHandle, out *pIsDesignTime, out *pBstrKey);
}
catch (Exception ex)
{
*pException = ex;
}
}

// The CLR invokes this when instantiating a licensed COM
// object inside a designtime license context.
// It's purpose is to save away the license key that the CLR
Expand All @@ -912,18 +892,5 @@ public void SaveKeyInCurrentContext(IntPtr bstrKey)

SetSavedLicenseKey(_licContext!, _targetRcwType!, key);
}

[UnmanagedCallersOnly]
private static unsafe void SaveKeyInCurrentContext(LicenseInteropProxy* pProxy, IntPtr bstrKey, Exception* pException)
{
try
{
pProxy->SaveKeyInCurrentContext(bstrKey);
}
catch (Exception ex)
{
*pException = ex;
}
}
}
}
6 changes: 3 additions & 3 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ DEFINE_METHOD(COM_OBJECT, CTOR, .ctor,
#endif // FOR_ILLINK

DEFINE_CLASS(LICENSE_INTEROP_PROXY, InternalInteropServices, LicenseInteropProxy)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, CREATE, Create, SM_PtrObj_PtrException_RetVoid)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, GETCURRENTCONTEXTINFO, GetCurrentContextInfo, SM_PtrLicenseInteropProxy_PtrType_PtrBool_PtrIntPtr_PtrException_RetVoid)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, SAVEKEYINCURRENTCONTEXT, SaveKeyInCurrentContext, SM_PtrLicenseInteropProxy_IntPtr_PtrException_RetVoid)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, CREATE, Create, SM_RetObj)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, GETCURRENTCONTEXTINFO, GetCurrentContextInfo, IM_RuntimeTypeHandle_RefBool_RefIntPtr_RetVoid)
DEFINE_METHOD(LICENSE_INTEROP_PROXY, SAVEKEYINCURRENTCONTEXT, SaveKeyInCurrentContext, IM_IntPtr_RetVoid)

#endif // FEATURE_COMINTEROP
END_ILLINK_FEATURE_SWITCH()
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/metasig.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ DEFINE_METASIG_T(SM(PtrResolver_Int_PtrStr_PtrException_RetVoid, P(C(RESOLVER))
#ifdef FEATURE_COMINTEROP
DEFINE_METASIG_T(SM(PtrClass_PtrStr_Int_PtrObj_PtrArrObj_PtrArrBool_PtrArrInt_PtrArrType_PtrType_PtrObj_PtrException_RetVoid, P(C(CLASS)) P(s) i P(j) P(a(j)) P(a(F)) P(a(i)) P(a(C(TYPE))) P(C(TYPE)) P(j) P(C(EXCEPTION)), v))
DEFINE_METASIG_T(SM(PtrComObject_PtrClass_PtrObj_PtrException_RetVoid, P(C(COM_OBJECT)) P(C(CLASS)) P(j) P(C(EXCEPTION)), v))
DEFINE_METASIG_T(SM(PtrLicenseInteropProxy_IntPtr_PtrException_RetVoid, P(C(LICENSE_INTEROP_PROXY)) I P(C(EXCEPTION)), v))
DEFINE_METASIG_T(SM(PtrLicenseInteropProxy_PtrType_PtrBool_PtrIntPtr_PtrException_RetVoid, P(C(LICENSE_INTEROP_PROXY)) P(C(TYPE)) P(F) P(I) P(C(EXCEPTION)), v))
#endif // FEATURE_COMINTEROP
DEFINE_METASIG_T(SM(PtrObj_PtrObj_PtrException_RetVoid, P(j) P(j) P(C(EXCEPTION)), v))
DEFINE_METASIG_T(SM(PtrObj_PtrObj_PtrObj_PtrException_RetVoid, P(j) P(j) P(j) P(C(EXCEPTION)), v))
Expand Down
24 changes: 15 additions & 9 deletions src/coreclr/vm/runtimecallablewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF
GCPROTECT_BEGIN(gc);

// Create an instance of the object
UnmanagedCallersOnlyCaller createObj(METHOD__LICENSE_INTEROP_PROXY__CREATE);
createObj.InvokeThrowing(&gc.pProxy);
MethodDescCallSite createObj(METHOD__LICENSE_INTEROP_PROXY__CREATE);
gc.pProxy = createObj.Call_RetOBJECTREF(NULL);
gc.pType = rth.GetManagedClassObject();

// Query the current licensing context
UnmanagedCallersOnlyCaller getCurrentContextInfo(METHOD__LICENSE_INTEROP_PROXY__GETCURRENTCONTEXTINFO);
MethodDescCallSite getCurrentContextInfo(METHOD__LICENSE_INTEROP_PROXY__GETCURRENTCONTEXTINFO, &gc.pProxy);
CLR_BOOL fDesignTime = FALSE;
INT_PTR bstrKeyRaw = NULL;
getCurrentContextInfo.InvokeThrowing(&gc.pProxy, &gc.pType, &fDesignTime, &bstrKeyRaw);
bstrKey = (BSTR)bstrKeyRaw;
ARG_SLOT args[4];
args[0] = ObjToArgSlot(gc.pProxy);
args[1] = ObjToArgSlot(gc.pType);
args[2] = (ARG_SLOT)&fDesignTime;
args[3] = (ARG_SLOT)(BSTR*)&bstrKey;

getCurrentContextInfo.Call(args);

if (fDesignTime)
{
Expand Down Expand Up @@ -177,9 +181,11 @@ IUnknown *ComClassFactory::CreateInstanceFromClassFactory(IClassFactory *pClassF
// Store the requested license key
if (SUCCEEDED(hr))
{
UnmanagedCallersOnlyCaller saveKeyInCurrentContext(METHOD__LICENSE_INTEROP_PROXY__SAVEKEYINCURRENTCONTEXT);
BSTR bstrKeyValue = (BSTR)bstrKey;
saveKeyInCurrentContext.InvokeThrowing(&gc.pProxy, reinterpret_cast<INT_PTR>(bstrKeyValue));
MethodDescCallSite saveKeyInCurrentContext(METHOD__LICENSE_INTEROP_PROXY__SAVEKEYINCURRENTCONTEXT, &gc.pProxy);

args[0] = ObjToArgSlot(gc.pProxy);
args[1] = (ARG_SLOT)(BSTR)bstrKey;
saveKeyInCurrentContext.Call(args);
}
}

Expand Down
Loading