Skip to content

Commit

Permalink
Marshal extension is finally working
Browse files Browse the repository at this point in the history
  • Loading branch information
bbepis committed Sep 4, 2020
1 parent 20a03cd commit 7328415
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 0 additions & 5 deletions mono/metadata/icall-def-netcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 5 additions & 3 deletions mono/metadata/icall-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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))
Expand Down
11 changes: 4 additions & 7 deletions mono/metadata/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 7328415

Please sign in to comment.