3 * Routines for marshaling complex types in P/Invoke methods.
6 * Paolo Molaro (lupus@ximian.com)
8 * (C) 2002 Ximian, Inc. http://www.ximian.com
12 #ifndef __MONO_MARSHAL_H__
13 #define __MONO_MARSHAL_H__
15 #include <mono/metadata/class.h>
16 #include <mono/metadata/object-internals.h>
17 #include <mono/metadata/class-internals.h>
18 #include <mono/metadata/opcodes.h>
19 #include <mono/metadata/reflection.h>
20 #include <mono/metadata/method-builder.h>
21 #include <mono/metadata/remoting.h>
22 #include <mono/utils/mono-error.h>
23 #include <mono/metadata/icalls.h>
25 typedef gunichar2
*mono_bstr
;
26 typedef const gunichar2
*mono_bstr_const
;
28 #define mono_marshal_find_bitfield_offset(type, elem, byte_offset, bitmask) \
31 memset (&tmp, 0, sizeof (tmp)); \
33 mono_marshal_find_nonzero_bit_offset ((guint8*)&tmp, sizeof (tmp), (byte_offset), (bitmask)); \
37 GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(stringbuilder
)
41 * This structure holds the state kept by the emit_ marshalling functions.
42 * This is exported so it can be used by cominterop.c.
45 MonoMethodBuilder
*mb
;
46 MonoMethodSignature
*sig
;
47 MonoMethodPInvoke
*piinfo
;
48 int *orig_conv_args
; /* Locals containing the original values of byref args */
51 MonoClass
*retobj_class
;
52 MonoMethodSignature
*csig
; /* Might need to be changed due to MarshalAs directives */
53 MonoImage
*image
; /* The image to use for looking up custom marshallers */
58 * This is invoked to convert arguments from the current types to
59 * the underlying types expected by the platform routine. If required,
60 * the methods create a temporary variable with the proper type, and return
61 * the location for it (either the passed argument, or the newly allocated
64 MARSHAL_ACTION_CONV_IN
,
67 * This operation is called to push the actual value that was optionally
68 * converted on the first stage
73 * Convert byref arguments back or free resources allocated during the
76 MARSHAL_ACTION_CONV_OUT
,
79 * The result from the unmanaged call is at the top of the stack when
80 * this action is invoked. The result should be stored in the
81 * third local variable slot.
83 MARSHAL_ACTION_CONV_RESULT
,
85 MARSHAL_ACTION_MANAGED_CONV_IN
,
86 MARSHAL_ACTION_MANAGED_CONV_OUT
,
87 MARSHAL_ACTION_MANAGED_CONV_RESULT
91 * This is an extension of the MONO_WRAPPER_ enum to avoid adding more elements to that
96 /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
97 WRAPPER_SUBTYPE_ELEMENT_ADDR
,
98 WRAPPER_SUBTYPE_STRING_CTOR
,
99 /* Subtypes of MONO_WRAPPER_STELEMREF */
100 WRAPPER_SUBTYPE_VIRTUAL_STELEMREF
,
101 /* Subtypes of MONO_WRAPPER_OTHER */
102 WRAPPER_SUBTYPE_FAST_MONITOR_ENTER
,
103 WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4
,
104 WRAPPER_SUBTYPE_FAST_MONITOR_EXIT
,
105 WRAPPER_SUBTYPE_PTR_TO_STRUCTURE
,
106 WRAPPER_SUBTYPE_STRUCTURE_TO_PTR
,
107 /* Subtypes of MONO_WRAPPER_CASTCLASS */
108 WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE
,
109 WRAPPER_SUBTYPE_ISINST_WITH_CACHE
,
110 /* Subtypes of MONO_WRAPPER_RUNTIME_INVOKE */
111 WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL
,
112 WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC
,
113 WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT
,
114 WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL
,
115 /* Subtypes of MONO_WRAPPER_MANAGED_TO_NATIVE */
116 WRAPPER_SUBTYPE_ICALL_WRAPPER
, // specifically JIT icalls
117 WRAPPER_SUBTYPE_NATIVE_FUNC_AOT
,
118 WRAPPER_SUBTYPE_PINVOKE
,
119 /* Subtypes of MONO_WRAPPER_OTHER */
120 WRAPPER_SUBTYPE_SYNCHRONIZED_INNER
,
121 WRAPPER_SUBTYPE_GSHAREDVT_IN
,
122 WRAPPER_SUBTYPE_GSHAREDVT_OUT
,
123 WRAPPER_SUBTYPE_ARRAY_ACCESSOR
,
124 /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
125 WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER
,
126 /* Subtypes of MONO_WRAPPER_DELEGATE_INVOKE */
127 WRAPPER_SUBTYPE_DELEGATE_INVOKE_VIRTUAL
,
128 WRAPPER_SUBTYPE_DELEGATE_INVOKE_BOUND
,
129 /* Subtypes of MONO_WRAPPER_OTHER */
130 WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG
,
131 WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG
,
132 WRAPPER_SUBTYPE_INTERP_IN
,
133 WRAPPER_SUBTYPE_INTERP_LMF
,
134 WRAPPER_SUBTYPE_AOT_INIT
140 } NativeToManagedWrapperInfo
;
144 } StringCtorWrapperInfo
;
148 } VirtualStelemrefWrapperInfo
;
151 guint32 rank
, elem_size
;
152 } ElementAddrWrapperInfo
;
156 /* For WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL */
157 MonoMethodSignature
*sig
;
158 } RuntimeInvokeWrapperInfo
;
162 } ManagedToNativeWrapperInfo
;
166 } SynchronizedWrapperInfo
;
170 } SynchronizedInnerWrapperInfo
;
174 } GenericArrayHelperWrapperInfo
;
177 MonoJitICallId jit_icall_id
;
182 } ArrayAccessorWrapperInfo
;
191 } AllocatorWrapperInfo
;
199 } RemotingWrapperInfo
;
202 MonoMethodSignature
*sig
;
203 } GsharedvtWrapperInfo
;
207 } DelegateInvokeWrapperInfo
;
210 MonoMethodSignature
*sig
;
211 } InterpInWrapperInfo
;
215 AOT_INIT_METHOD_GSHARED_MRGCTX
= 1,
216 AOT_INIT_METHOD_GSHARED_THIS
= 2,
217 AOT_INIT_METHOD_GSHARED_VTABLE
= 3
218 } MonoAotInitSubtype
;
221 // We emit this code when we init the module,
222 // and later match up the native code with this method
224 MonoAotInitSubtype subtype
;
225 } AOTInitWrapperInfo
;
228 * This structure contains additional information to uniquely identify a given wrapper
229 * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
230 * of wrappers, i.e. ones which do not have a 1-1 association with a method/class.
233 WrapperSubtype subtype
;
235 /* RUNTIME_INVOKE_... */
236 RuntimeInvokeWrapperInfo runtime_invoke
;
238 StringCtorWrapperInfo string_ctor
;
240 ElementAddrWrapperInfo element_addr
;
241 /* VIRTUAL_STELEMREF */
242 VirtualStelemrefWrapperInfo virtual_stelemref
;
243 /* MONO_WRAPPER_NATIVE_TO_MANAGED */
244 NativeToManagedWrapperInfo native_to_managed
;
245 /* MONO_WRAPPER_MANAGED_TO_NATIVE */
246 ManagedToNativeWrapperInfo managed_to_native
;
248 SynchronizedWrapperInfo synchronized
;
249 /* SYNCHRONIZED_INNER */
250 SynchronizedInnerWrapperInfo synchronized_inner
;
251 /* GENERIC_ARRAY_HELPER */
252 GenericArrayHelperWrapperInfo generic_array_helper
;
254 ICallWrapperInfo icall
;
256 ArrayAccessorWrapperInfo array_accessor
;
257 /* PROXY_ISINST etc. */
258 ProxyWrapperInfo proxy
;
260 AllocatorWrapperInfo alloc
;
262 UnboxWrapperInfo unbox
;
263 /* MONO_WRAPPER_REMOTING_INVOKE/MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK/MONO_WRAPPER_XDOMAIN_INVOKE */
264 RemotingWrapperInfo remoting
;
265 /* GSHAREDVT_IN_SIG/GSHAREDVT_OUT_SIG */
266 GsharedvtWrapperInfo gsharedvt
;
267 /* DELEGATE_INVOKE */
268 DelegateInvokeWrapperInfo delegate_invoke
;
270 InterpInWrapperInfo interp_in
;
272 AOTInitWrapperInfo aot_init
;
277 STELEMREF_OBJECT
, /*no check at all*/
278 STELEMREF_SEALED_CLASS
, /*check vtable->klass->element_type */
279 STELEMREF_CLASS
, /*only the klass->parents check*/
280 STELEMREF_CLASS_SMALL_IDEPTH
, /* like STELEMREF_CLASS bit without the idepth check */
281 STELEMREF_INTERFACE
, /*interfaces without variant generic arguments. */
282 STELEMREF_COMPLEX
, /*arrays, MBR or types with variant generic args - go straight to icalls*/
287 #define MONO_MARSHAL_CALLBACKS_VERSION 4
291 int (*emit_marshal_array
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
292 int (*emit_marshal_boolean
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
293 int (*emit_marshal_ptr
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
294 int (*emit_marshal_char
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
295 int (*emit_marshal_scalar
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
297 int (*emit_marshal_custom
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
298 int (*emit_marshal_asany
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
299 int (*emit_marshal_vtype
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
300 int (*emit_marshal_string
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
301 int (*emit_marshal_safehandle
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
302 int (*emit_marshal_handleref
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
303 int (*emit_marshal_object
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
304 int (*emit_marshal_variant
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
305 void (*emit_castclass
) (MonoMethodBuilder
*mb
);
306 void (*emit_struct_to_ptr
) (MonoMethodBuilder
*mb
, MonoClass
*klass
);
307 void (*emit_ptr_to_struct
) (MonoMethodBuilder
*mb
, MonoClass
*klass
);
308 void (*emit_isinst
) (MonoMethodBuilder
*mb
);
309 void (*emit_virtual_stelemref
) (MonoMethodBuilder
*mb
, const char **param_names
, MonoStelemrefKind kind
);
310 void (*emit_stelemref
) (MonoMethodBuilder
*mb
);
311 void (*emit_array_address
) (MonoMethodBuilder
*mb
, int rank
, int elem_size
);
312 void (*emit_native_wrapper
) (MonoImage
*image
, MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
**mspecs
, gpointer func
, gboolean aot
, gboolean check_exceptions
, gboolean func_param
);
313 void (*emit_managed_wrapper
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*invoke_sig
, MonoMarshalSpec
**mspecs
, EmitMarshalContext
* m
, MonoMethod
*method
, uint32_t target_handle
);
314 void (*emit_runtime_invoke_body
) (MonoMethodBuilder
*mb
, const char **param_names
, MonoImage
*image
, MonoMethod
*method
, MonoMethodSignature
*sig
, MonoMethodSignature
*callsig
, gboolean virtual_
, gboolean need_direct_wrapper
);
315 void (*emit_runtime_invoke_dynamic
) (MonoMethodBuilder
*mb
);
316 void (*emit_delegate_begin_invoke
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
);
317 void (*emit_delegate_end_invoke
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
);
318 void (*emit_delegate_invoke_internal
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, MonoMethodSignature
*invoke_sig
, gboolean static_method_with_first_arg_bound
, gboolean callvirt
, gboolean closed_over_null
, MonoMethod
*method
, MonoMethod
*target_method
, MonoClass
*target_class
, MonoGenericContext
*ctx
, MonoGenericContainer
*container
);
319 void (*emit_synchronized_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoGenericContext
*ctx
, MonoGenericContainer
*container
, MonoMethod
*enter_method
, MonoMethod
*exit_method
, MonoMethod
*gettypefromhandle_method
);
320 void (*emit_unbox_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
);
321 void (*emit_array_accessor_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*sig
, MonoGenericContext
*ctx
);
322 void (*emit_generic_array_helper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
);
323 void (*emit_thunk_invoke_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
);
324 void (*emit_create_string_hack
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*csig
, MonoMethod
*res
);
325 void (*emit_native_icall_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
, gboolean check_exceptions
, gboolean aot
, MonoMethodPInvoke
*pinfo
);
326 void (*emit_icall_wrapper
) (MonoMethodBuilder
*mb
, MonoJitICallInfo
*callinfo
, MonoMethodSignature
*csig2
, gboolean check_exceptions
);
327 void (*emit_return
) (MonoMethodBuilder
*mb
);
328 void (*emit_vtfixup_ftnptr
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, int param_count
, guint16 type
);
329 void (*mb_skip_visibility
) (MonoMethodBuilder
*mb
);
330 void (*mb_set_dynamic
) (MonoMethodBuilder
*mb
);
331 void (*mb_emit_exception
) (MonoMethodBuilder
*mb
, const char *exc_nspace
, const char *exc_name
, const char *msg
);
332 void (*mb_emit_exception_for_error
) (MonoMethodBuilder
*mb
, const MonoError
*emitted_error
);
333 void (*mb_emit_byte
) (MonoMethodBuilder
*mb
, guint8 op
);
334 } MonoMarshalCallbacks
;
336 /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/
337 typedef MonoObject
*(*RuntimeInvokeFunction
) (MonoObject
*this_obj
, void **params
, MonoObject
**exc
, void* compiled_method
);
339 typedef void (*RuntimeInvokeDynamicFunction
) (void *args
, MonoObject
**exc
, void* compiled_method
);
342 mono_install_marshal_callbacks (MonoMarshalCallbacks
*cb
);
344 /* marshaling helper functions */
347 mono_marshal_init (void);
350 mono_marshal_init_tls (void);
353 mono_marshal_cleanup (void);
356 mono_class_native_size (MonoClass
*klass
, guint32
*align
);
359 mono_marshal_load_type_info (MonoClass
* klass
);
362 mono_marshal_type_size (MonoType
*type
, MonoMarshalSpec
*mspec
, guint32
*align
,
363 gboolean as_field
, gboolean unicode
);
366 mono_type_native_stack_size (MonoType
*type
, guint32
*alignment
);
369 mono_ptr_to_bstr (const gunichar2
* ptr
, int slen
);
371 void mono_delegate_free_ftnptr (MonoDelegate
*delegate
);
374 mono_marshal_ftnptr_eh_callback (guint32 gchandle
);
377 mono_marshal_set_last_error (void);
380 mono_type_to_ldind (MonoType
*type
);
383 mono_type_to_stind (MonoType
*type
);
385 /* functions to create various architecture independent helper functions */
388 mono_marshal_method_from_wrapper (MonoMethod
*wrapper
);
391 mono_wrapper_info_create (MonoMethodBuilder
*mb
, WrapperSubtype subtype
);
394 mono_marshal_set_wrapper_info (MonoMethod
*method
, WrapperInfo
*info
);
397 mono_marshal_get_wrapper_info (MonoMethod
*wrapper
) MONO_LLVM_INTERNAL
;
400 mono_marshal_get_delegate_begin_invoke (MonoMethod
*method
);
403 mono_marshal_get_delegate_end_invoke (MonoMethod
*method
);
406 mono_marshal_get_delegate_invoke (MonoMethod
*method
, MonoDelegate
*del
);
409 mono_marshal_get_delegate_invoke_internal (MonoMethod
*method
, gboolean callvirt
, gboolean static_method_with_first_arg_bound
, MonoMethod
*target_method
);
412 mono_marshal_get_runtime_invoke_full (MonoMethod
*method
, gboolean virtual_
, gboolean need_direct_wrapper
);
415 mono_marshal_get_runtime_invoke (MonoMethod
*method
, gboolean is_virtual
);
418 mono_marshal_get_runtime_invoke_dynamic (void);
421 mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature
*sig
);
424 mono_marshal_get_string_ctor_signature (MonoMethod
*method
);
427 mono_marshal_get_managed_wrapper (MonoMethod
*method
, MonoClass
*delegate_klass
, uint32_t this_loc
, MonoError
*exernal_error
);
430 mono_marshal_get_vtfixup_ftnptr (MonoImage
*image
, guint32 token
, guint16 type
);
433 mono_marshal_get_icall_wrapper (MonoJitICallInfo
*callinfo
, gboolean check_exceptions
);
436 mono_marshal_get_aot_init_wrapper (MonoAotInitSubtype subtype
) MONO_LLVM_INTERNAL
;
439 mono_marshal_get_aot_init_wrapper_name (MonoAotInitSubtype subtype
) MONO_LLVM_INTERNAL
;
442 mono_marshal_get_native_wrapper (MonoMethod
*method
, gboolean check_exceptions
, gboolean aot
);
445 mono_marshal_get_native_func_wrapper (MonoImage
*image
, MonoMethodSignature
*sig
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
**mspecs
, gpointer func
);
448 mono_marshal_get_native_func_wrapper_aot (MonoClass
*klass
);
451 mono_marshal_get_struct_to_ptr (MonoClass
*klass
);
454 mono_marshal_get_ptr_to_struct (MonoClass
*klass
);
457 mono_marshal_get_synchronized_wrapper (MonoMethod
*method
);
460 mono_marshal_get_synchronized_inner_wrapper (MonoMethod
*method
);
463 mono_marshal_get_unbox_wrapper (MonoMethod
*method
);
466 mono_marshal_get_castclass_with_cache (void);
469 mono_marshal_get_isinst_with_cache (void);
472 mono_marshal_get_stelemref (void);
475 mono_marshal_get_virtual_stelemref (MonoClass
*array_class
);
478 mono_marshal_get_virtual_stelemref_wrappers (int *nwrappers
);
481 mono_marshal_get_array_address (int rank
, int elem_size
);
484 mono_marshal_get_array_accessor_wrapper (MonoMethod
*method
);
487 mono_marshal_get_generic_array_helper (MonoClass
*klass
, const gchar
*name
, MonoMethod
*method
);
490 mono_marshal_get_thunk_invoke_wrapper (MonoMethod
*method
);
493 mono_marshal_get_gsharedvt_in_wrapper (void);
496 mono_marshal_get_gsharedvt_out_wrapper (void);
499 mono_marshal_free_dynamic_wrappers (MonoMethod
*method
);
502 mono_marshal_lock_internal (void);
505 mono_marshal_unlock_internal (void);
507 /* marshaling internal calls */
510 mono_marshal_alloc (gsize size
, MonoError
*error
);
513 mono_marshal_free (gpointer ptr
);
516 mono_marshal_free_array (gpointer
*ptr
, int size
);
519 mono_marshal_free_ccw (MonoObject
* obj
);
522 mono_cominterop_release_all_rcws (void);
525 mono_marshal_string_to_utf16 (MonoString
*s
);
528 mono_marshal_set_last_error_windows (int error
);
531 mono_struct_delete_old (MonoClass
*klass
, char *ptr
);
534 mono_object_isinst_icall (MonoObject
*obj
, MonoClass
*klass
);
537 mono_emit_marshal (EmitMarshalContext
*m
, int argnum
, MonoType
*t
,
538 MonoMarshalSpec
*spec
, int conv_arg
,
539 MonoType
**conv_arg_type
, MarshalAction action
);
542 mono_marshal_isinst_with_cache (MonoObject
*obj
, MonoClass
*klass
, uintptr_t *cache
);
545 mono_delegate_begin_invoke (MonoDelegate
*delegate
, gpointer
*params
);
548 mono_delegate_end_invoke (MonoDelegate
*delegate
, gpointer
*params
);
551 mono_marshal_get_string_encoding (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
554 mono_marshal_get_string_to_ptr_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
557 mono_marshal_get_stringbuilder_to_ptr_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
560 mono_marshal_get_ptr_to_stringbuilder_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
, gboolean
*need_free
);
563 mono_marshal_get_ptr_to_string_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
, gboolean
*need_free
);
566 mono_marshal_boolean_conv_in_get_local_type (MonoMarshalSpec
*spec
, guint8
*ldc_op
/*out*/);
569 mono_marshal_boolean_managed_conv_in_get_conv_arg_class (MonoMarshalSpec
*spec
, guint8
*ldop
/*out*/);
572 mono_pinvoke_is_unicode (MonoMethodPInvoke
*piinfo
);
575 mono_marshal_need_free (MonoType
*t
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
577 MonoObject
* mono_marshal_get_type_object (MonoClass
*klass
);
581 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void);
585 ves_icall_System_Runtime_InteropServices_Marshal_BufferToBSTR (const gunichar2
*ptr
, int len
);
589 ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem (void *ptr
);
593 ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal (void *ptr
);
597 ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (mono_bstr_const ptr
);
601 ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement (MonoArray
*arrayobj
, int index
);
605 ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (MonoIUnknown
*pUnk
);
609 ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUnknown
*pUnk
, gconstpointer riid
, gpointer
* ppv
);
613 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (MonoIUnknown
*pUnk
);
616 mono_win32_compat_CopyMemory (gpointer dest
, gconstpointer source
, gsize length
);
619 mono_win32_compat_FillMemory (gpointer dest
, gsize length
, guchar fill
);
622 mono_win32_compat_MoveMemory (gpointer dest
, gconstpointer source
, gsize length
);
625 mono_win32_compat_ZeroMemory (gpointer dest
, gsize length
);
628 mono_marshal_find_nonzero_bit_offset (guint8
*buf
, int len
, int *byte_offset
, guint8
*bitmask
) MONO_LLVM_INTERNAL
;
631 mono_signature_no_pinvoke (MonoMethod
*method
);
633 /* Called from cominterop.c/remoting.c */
636 mono_marshal_emit_native_wrapper (MonoImage
*image
, MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
**mspecs
, gpointer func
, gboolean aot
, gboolean check_exceptions
, gboolean func_param
);
639 mono_marshal_emit_managed_wrapper (MonoMethodBuilder
*mb
, MonoMethodSignature
*invoke_sig
, MonoMarshalSpec
**mspecs
, EmitMarshalContext
* m
, MonoMethod
*method
, uint32_t target_handle
);
642 mono_marshal_get_cache (GHashTable
**var
, GHashFunc hash_func
, GCompareFunc equal_func
);
645 mono_marshal_find_in_cache (GHashTable
*cache
, gpointer key
);
648 mono_mb_create_and_cache (GHashTable
*cache
, gpointer key
,
649 MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
652 mono_marshal_emit_thread_interrupt_checkpoint (MonoMethodBuilder
*mb
);
655 mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder
*mb
);
658 mono_marshal_use_aot_wrappers (gboolean use
);
661 mono_mb_emit_save_args (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, gboolean save_this
);
664 mono_mb_emit_restore_result (MonoMethodBuilder
*mb
, MonoType
*return_type
);
667 mono_mb_create (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
668 int max_stack
, WrapperInfo
*info
);
671 mono_mb_create_and_cache_full (GHashTable
*cache
, gpointer key
,
672 MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
673 int max_stack
, WrapperInfo
*info
, gboolean
*out_found
);
675 #endif /* __MONO_MARSHAL_H__ */