diff --git a/mono/metadata/icall-def-netcore.h b/mono/metadata/icall-def-netcore.h index 896100914eb1..60283d09e9da 100644 --- a/mono/metadata/icall-def-netcore.h +++ b/mono/metadata/icall-def-netcore.h @@ -344,11 +344,6 @@ HANDLES(GCH_2, "InternalFree", ves_icall_System_GCHandle_InternalFree, void, 1, HANDLES(GCH_3, "InternalGet", ves_icall_System_GCHandle_InternalGet, MonoObject, 1, (gpointer)) HANDLES(GCH_4, "InternalSet", ves_icall_System_GCHandle_InternalSet, void, 2, (gpointer, MonoObject)) - -ICALL_TYPE(MONOEXT, "BepInEx.MonoExtensions", MONOEXT_1) -HANDLES(MONOEXT_1, "GetFunctionPointerForDelegateInternal2", ves_icall_BepInEx_MonoExtensions_GetFunctionPointerForDelegateInternal2, gpointer, 2, (MonoDelegate, gint32)) - - ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_2) NOHANDLES(ICALL(MARSHAL_2, "AllocCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem)) NOHANDLES(ICALL(MARSHAL_3, "AllocHGlobal", ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal)) diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 7edc6dbcbc4d..af8a10df26e3 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -111,6 +111,11 @@ #include "icall-def-netcore.h" #else + + +ICALL_TYPE(MONOEXT, "BepInEx.MonoExtensions", MONOEXT_1) +HANDLES(MONOEXT_1, "GetFunctionPointerForDelegateInternal2", ves_icall_BepInEx_MonoExtensions_GetFunctionPointerForDelegateInternal2, gpointer, 2, (MonoDelegate, gint32)) + ICALL_TYPE(CLR_INTEROP_SYS, "Interop/Sys", CLR_INTEROP_SYS_1) NOHANDLES(ICALL(CLR_INTEROP_SYS_1, "DoubleToString", ves_icall_Interop_Sys_DoubleToString)) @@ -748,9 +753,6 @@ HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, gpointer, 3, (MonoObject, gpointer, gint32)) -ICALL_TYPE(MONOEXT, "BepInEx.MonoExtensions", MONOEXT_1) -HANDLES(MONOEXT_1, "GetFunctionPointerForDelegateInternal2", ves_icall_BepInEx_MonoExtensions_GetFunctionPointerForDelegateInternal2, gpointer, 2, (MonoDelegate, gint32)) - #if !defined(DISABLE_COM) || defined (HOST_WIN32) ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_1) NOHANDLES(ICALL(MARSHAL_1, "AddRefInternal", ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal)) diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index d11ed7b0a7a0..65ae77c56111 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -4055,13 +4055,10 @@ mono_marshal_get_managed_wrapper_2 (MonoMethod *method, MonoClass *delegate_klas * options. */ - if (callConv < 0) - { - cache = get_cache (&mono_method_get_wrapper_cache (method)->managed_wrapper_cache, mono_aligned_addr_hash, NULL); + cache = get_cache (&mono_method_get_wrapper_cache (method)->managed_wrapper_cache, mono_aligned_addr_hash, NULL); - if (!target_handle && (res = mono_marshal_find_in_cache (cache, method))) - return res; - } + if (callConv < 0 && !target_handle && (res = mono_marshal_find_in_cache (cache, method))) + return res; if (G_UNLIKELY (!delegate_klass)) { /* creating a wrapper for a function pointer with UnmanagedCallersOnlyAttribute */ @@ -4191,7 +4188,7 @@ mono_marshal_get_managed_wrapper_2 (MonoMethod *method, MonoClass *delegate_klas } if (callConv > -1) - csig->call_convention = callConv; + csig->call_convention = callConv - 1; mono_marshal_emit_managed_wrapper (mb, invoke_sig, mspecs, &m, method, target_handle);