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
,
135 WRAPPER_SUBTYPE_LLVM_FUNC
141 } NativeToManagedWrapperInfo
;
145 } StringCtorWrapperInfo
;
149 } VirtualStelemrefWrapperInfo
;
152 guint32 rank
, elem_size
;
153 } ElementAddrWrapperInfo
;
157 /* For WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL */
158 MonoMethodSignature
*sig
;
159 } RuntimeInvokeWrapperInfo
;
163 } ManagedToNativeWrapperInfo
;
167 } SynchronizedWrapperInfo
;
171 } SynchronizedInnerWrapperInfo
;
175 } GenericArrayHelperWrapperInfo
;
178 MonoJitICallId jit_icall_id
;
183 } ArrayAccessorWrapperInfo
;
192 } AllocatorWrapperInfo
;
200 } RemotingWrapperInfo
;
203 MonoMethodSignature
*sig
;
204 } GsharedvtWrapperInfo
;
208 } DelegateInvokeWrapperInfo
;
211 MonoMethodSignature
*sig
;
212 } InterpInWrapperInfo
;
216 AOT_INIT_METHOD_GSHARED_MRGCTX
= 1,
217 AOT_INIT_METHOD_GSHARED_THIS
= 2,
218 AOT_INIT_METHOD_GSHARED_VTABLE
= 3
219 } MonoAotInitSubtype
;
222 // We emit this code when we init the module,
223 // and later match up the native code with this method
225 MonoAotInitSubtype subtype
;
226 } AOTInitWrapperInfo
;
229 LLVM_FUNC_WRAPPER_GC_POLL
= 0
230 } MonoLLVMFuncWrapperSubtype
;
233 // We emit this code when we init the module,
234 // and later match up the native code with this method
236 MonoLLVMFuncWrapperSubtype subtype
;
237 } LLVMFuncWrapperInfo
;
240 * This structure contains additional information to uniquely identify a given wrapper
241 * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
242 * of wrappers, i.e. ones which do not have a 1-1 association with a method/class.
245 WrapperSubtype subtype
;
247 /* RUNTIME_INVOKE_... */
248 RuntimeInvokeWrapperInfo runtime_invoke
;
250 StringCtorWrapperInfo string_ctor
;
252 ElementAddrWrapperInfo element_addr
;
253 /* VIRTUAL_STELEMREF */
254 VirtualStelemrefWrapperInfo virtual_stelemref
;
255 /* MONO_WRAPPER_NATIVE_TO_MANAGED */
256 NativeToManagedWrapperInfo native_to_managed
;
257 /* MONO_WRAPPER_MANAGED_TO_NATIVE */
258 ManagedToNativeWrapperInfo managed_to_native
;
260 SynchronizedWrapperInfo synchronized
;
261 /* SYNCHRONIZED_INNER */
262 SynchronizedInnerWrapperInfo synchronized_inner
;
263 /* GENERIC_ARRAY_HELPER */
264 GenericArrayHelperWrapperInfo generic_array_helper
;
266 ICallWrapperInfo icall
;
268 ArrayAccessorWrapperInfo array_accessor
;
269 /* PROXY_ISINST etc. */
270 ProxyWrapperInfo proxy
;
272 AllocatorWrapperInfo alloc
;
274 UnboxWrapperInfo unbox
;
275 /* MONO_WRAPPER_REMOTING_INVOKE/MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK/MONO_WRAPPER_XDOMAIN_INVOKE */
276 RemotingWrapperInfo remoting
;
277 /* GSHAREDVT_IN_SIG/GSHAREDVT_OUT_SIG */
278 GsharedvtWrapperInfo gsharedvt
;
279 /* DELEGATE_INVOKE */
280 DelegateInvokeWrapperInfo delegate_invoke
;
282 InterpInWrapperInfo interp_in
;
284 AOTInitWrapperInfo aot_init
;
286 LLVMFuncWrapperInfo llvm_func
;
291 STELEMREF_OBJECT
, /*no check at all*/
292 STELEMREF_SEALED_CLASS
, /*check vtable->klass->element_type */
293 STELEMREF_CLASS
, /*only the klass->parents check*/
294 STELEMREF_CLASS_SMALL_IDEPTH
, /* like STELEMREF_CLASS bit without the idepth check */
295 STELEMREF_INTERFACE
, /*interfaces without variant generic arguments. */
296 STELEMREF_COMPLEX
, /*arrays, MBR or types with variant generic args - go straight to icalls*/
301 #define MONO_MARSHAL_CALLBACKS_VERSION 4
305 int (*emit_marshal_array
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
306 int (*emit_marshal_boolean
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
307 int (*emit_marshal_ptr
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
308 int (*emit_marshal_char
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
309 int (*emit_marshal_scalar
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
311 int (*emit_marshal_custom
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
312 int (*emit_marshal_asany
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
313 int (*emit_marshal_vtype
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
314 int (*emit_marshal_string
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
315 int (*emit_marshal_safehandle
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
316 int (*emit_marshal_handleref
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
317 int (*emit_marshal_object
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
318 int (*emit_marshal_variant
) (EmitMarshalContext
*m
, int argnum
, MonoType
*t
, MonoMarshalSpec
*spec
, int conv_arg
, MonoType
**conv_arg_type
, MarshalAction action
);
319 void (*emit_castclass
) (MonoMethodBuilder
*mb
);
320 void (*emit_struct_to_ptr
) (MonoMethodBuilder
*mb
, MonoClass
*klass
);
321 void (*emit_ptr_to_struct
) (MonoMethodBuilder
*mb
, MonoClass
*klass
);
322 void (*emit_isinst
) (MonoMethodBuilder
*mb
);
323 void (*emit_virtual_stelemref
) (MonoMethodBuilder
*mb
, const char **param_names
, MonoStelemrefKind kind
);
324 void (*emit_stelemref
) (MonoMethodBuilder
*mb
);
325 void (*emit_array_address
) (MonoMethodBuilder
*mb
, int rank
, int elem_size
);
326 void (*emit_native_wrapper
) (MonoImage
*image
, MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
**mspecs
, gpointer func
, gboolean aot
, gboolean check_exceptions
, gboolean func_param
);
327 void (*emit_managed_wrapper
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*invoke_sig
, MonoMarshalSpec
**mspecs
, EmitMarshalContext
* m
, MonoMethod
*method
, uint32_t target_handle
);
328 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
);
329 void (*emit_runtime_invoke_dynamic
) (MonoMethodBuilder
*mb
);
330 void (*emit_delegate_begin_invoke
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
);
331 void (*emit_delegate_end_invoke
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
);
332 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
);
333 void (*emit_synchronized_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoGenericContext
*ctx
, MonoGenericContainer
*container
, MonoMethod
*enter_method
, MonoMethod
*exit_method
, MonoMethod
*gettypefromhandle_method
);
334 void (*emit_unbox_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
);
335 void (*emit_array_accessor_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*sig
, MonoGenericContext
*ctx
);
336 void (*emit_generic_array_helper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
);
337 void (*emit_thunk_invoke_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
);
338 void (*emit_create_string_hack
) (MonoMethodBuilder
*mb
, MonoMethodSignature
*csig
, MonoMethod
*res
);
339 void (*emit_native_icall_wrapper
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, MonoMethodSignature
*csig
, gboolean check_exceptions
, gboolean aot
, MonoMethodPInvoke
*pinfo
);
340 void (*emit_icall_wrapper
) (MonoMethodBuilder
*mb
, MonoJitICallInfo
*callinfo
, MonoMethodSignature
*csig2
, gboolean check_exceptions
);
341 void (*emit_return
) (MonoMethodBuilder
*mb
);
342 void (*emit_vtfixup_ftnptr
) (MonoMethodBuilder
*mb
, MonoMethod
*method
, int param_count
, guint16 type
);
343 void (*mb_skip_visibility
) (MonoMethodBuilder
*mb
);
344 void (*mb_set_dynamic
) (MonoMethodBuilder
*mb
);
345 void (*mb_emit_exception
) (MonoMethodBuilder
*mb
, const char *exc_nspace
, const char *exc_name
, const char *msg
);
346 void (*mb_emit_exception_for_error
) (MonoMethodBuilder
*mb
, const MonoError
*emitted_error
);
347 void (*mb_emit_byte
) (MonoMethodBuilder
*mb
, guint8 op
);
348 } MonoMarshalCallbacks
;
350 /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/
351 typedef MonoObject
*(*RuntimeInvokeFunction
) (MonoObject
*this_obj
, void **params
, MonoObject
**exc
, void* compiled_method
);
353 typedef void (*RuntimeInvokeDynamicFunction
) (void *args
, MonoObject
**exc
, void* compiled_method
);
356 mono_install_marshal_callbacks (MonoMarshalCallbacks
*cb
);
358 /* marshaling helper functions */
361 mono_marshal_init (void);
364 mono_marshal_init_tls (void);
367 mono_marshal_cleanup (void);
370 mono_class_native_size (MonoClass
*klass
, guint32
*align
);
373 mono_marshal_load_type_info (MonoClass
* klass
);
376 mono_marshal_type_size (MonoType
*type
, MonoMarshalSpec
*mspec
, guint32
*align
,
377 gboolean as_field
, gboolean unicode
);
380 mono_type_native_stack_size (MonoType
*type
, guint32
*alignment
);
383 mono_ptr_to_bstr (const gunichar2
* ptr
, int slen
);
385 void mono_delegate_free_ftnptr (MonoDelegate
*delegate
);
388 mono_marshal_ftnptr_eh_callback (guint32 gchandle
);
391 mono_marshal_set_last_error (void);
394 mono_marshal_clear_last_error (void);
397 mono_type_to_ldind (MonoType
*type
);
400 mono_type_to_stind (MonoType
*type
);
402 /* functions to create various architecture independent helper functions */
405 mono_marshal_method_from_wrapper (MonoMethod
*wrapper
);
408 mono_wrapper_info_create (MonoMethodBuilder
*mb
, WrapperSubtype subtype
);
411 mono_marshal_set_wrapper_info (MonoMethod
*method
, WrapperInfo
*info
);
414 mono_marshal_get_wrapper_info (MonoMethod
*wrapper
) MONO_LLVM_INTERNAL
;
417 mono_marshal_get_delegate_begin_invoke (MonoMethod
*method
);
420 mono_marshal_get_delegate_end_invoke (MonoMethod
*method
);
423 mono_marshal_get_delegate_invoke (MonoMethod
*method
, MonoDelegate
*del
);
426 mono_marshal_get_delegate_invoke_internal (MonoMethod
*method
, gboolean callvirt
, gboolean static_method_with_first_arg_bound
, MonoMethod
*target_method
);
429 mono_marshal_get_runtime_invoke_full (MonoMethod
*method
, gboolean virtual_
, gboolean need_direct_wrapper
);
432 mono_marshal_get_runtime_invoke (MonoMethod
*method
, gboolean is_virtual
);
435 mono_marshal_get_runtime_invoke_dynamic (void);
438 mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature
*sig
);
441 mono_marshal_get_string_ctor_signature (MonoMethod
*method
);
444 mono_marshal_get_managed_wrapper (MonoMethod
*method
, MonoClass
*delegate_klass
, uint32_t this_loc
, MonoError
*exernal_error
);
447 mono_marshal_get_vtfixup_ftnptr (MonoImage
*image
, guint32 token
, guint16 type
);
450 mono_marshal_get_icall_wrapper (MonoJitICallInfo
*callinfo
, gboolean check_exceptions
);
453 mono_marshal_get_aot_init_wrapper (MonoAotInitSubtype subtype
) MONO_LLVM_INTERNAL
;
456 mono_marshal_get_aot_init_wrapper_name (MonoAotInitSubtype subtype
) MONO_LLVM_INTERNAL
;
459 mono_marshal_get_llvm_func_wrapper (MonoLLVMFuncWrapperSubtype subtype
) MONO_LLVM_INTERNAL
;
462 mono_marshal_get_native_wrapper (MonoMethod
*method
, gboolean check_exceptions
, gboolean aot
);
465 mono_marshal_get_native_func_wrapper (MonoImage
*image
, MonoMethodSignature
*sig
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
**mspecs
, gpointer func
);
468 mono_marshal_get_native_func_wrapper_aot (MonoClass
*klass
);
471 mono_marshal_get_struct_to_ptr (MonoClass
*klass
);
474 mono_marshal_get_ptr_to_struct (MonoClass
*klass
);
477 mono_marshal_get_synchronized_wrapper (MonoMethod
*method
);
480 mono_marshal_get_synchronized_inner_wrapper (MonoMethod
*method
);
483 mono_marshal_get_unbox_wrapper (MonoMethod
*method
);
486 mono_marshal_get_castclass_with_cache (void);
489 mono_marshal_get_isinst_with_cache (void);
492 mono_marshal_get_stelemref (void);
495 mono_marshal_get_virtual_stelemref (MonoClass
*array_class
);
498 mono_marshal_get_virtual_stelemref_wrappers (int *nwrappers
);
501 mono_marshal_get_array_address (int rank
, int elem_size
);
504 mono_marshal_get_array_accessor_wrapper (MonoMethod
*method
);
507 mono_marshal_get_generic_array_helper (MonoClass
*klass
, const gchar
*name
, MonoMethod
*method
);
510 mono_marshal_get_thunk_invoke_wrapper (MonoMethod
*method
);
513 mono_marshal_get_gsharedvt_in_wrapper (void);
516 mono_marshal_get_gsharedvt_out_wrapper (void);
519 mono_marshal_free_dynamic_wrappers (MonoMethod
*method
);
522 mono_marshal_lock_internal (void);
525 mono_marshal_unlock_internal (void);
527 /* marshaling internal calls */
530 mono_marshal_alloc (gsize size
, MonoError
*error
);
533 mono_marshal_free (gpointer ptr
);
536 mono_marshal_free_array (gpointer
*ptr
, int size
);
539 mono_marshal_free_ccw (MonoObject
* obj
);
542 mono_cominterop_release_all_rcws (void);
545 mono_marshal_string_to_utf16 (MonoString
*s
);
548 mono_marshal_set_last_error_windows (int error
);
551 mono_struct_delete_old (MonoClass
*klass
, char *ptr
);
554 mono_emit_marshal (EmitMarshalContext
*m
, int argnum
, MonoType
*t
,
555 MonoMarshalSpec
*spec
, int conv_arg
,
556 MonoType
**conv_arg_type
, MarshalAction action
);
559 mono_marshal_isinst_with_cache (MonoObject
*obj
, MonoClass
*klass
, uintptr_t *cache
);
562 mono_delegate_begin_invoke (MonoDelegate
*delegate
, gpointer
*params
);
565 mono_delegate_end_invoke (MonoDelegate
*delegate
, gpointer
*params
);
568 mono_marshal_get_string_encoding (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
571 mono_marshal_get_string_to_ptr_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
574 mono_marshal_get_stringbuilder_to_ptr_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
577 mono_marshal_get_ptr_to_stringbuilder_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
, gboolean
*need_free
);
580 mono_marshal_get_ptr_to_string_conv (MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
, gboolean
*need_free
);
583 mono_marshal_boolean_conv_in_get_local_type (MonoMarshalSpec
*spec
, guint8
*ldc_op
/*out*/);
586 mono_marshal_boolean_managed_conv_in_get_conv_arg_class (MonoMarshalSpec
*spec
, guint8
*ldop
/*out*/);
589 mono_pinvoke_is_unicode (MonoMethodPInvoke
*piinfo
);
592 mono_marshal_need_free (MonoType
*t
, MonoMethodPInvoke
*piinfo
, MonoMarshalSpec
*spec
);
594 MonoObject
* mono_marshal_get_type_object (MonoClass
*klass
);
598 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void);
602 ves_icall_System_Runtime_InteropServices_Marshal_SetLastWin32Error (guint32 err
);
606 ves_icall_System_Runtime_InteropServices_Marshal_BufferToBSTR (const gunichar2
*ptr
, int len
);
610 ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem (void *ptr
);
614 ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal (void *ptr
);
618 ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (mono_bstr_const ptr
);
622 ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (MonoIUnknown
*pUnk
);
626 ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUnknown
*pUnk
, gconstpointer riid
, gpointer
* ppv
);
630 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (MonoIUnknown
*pUnk
);
633 mono_win32_compat_CopyMemory (gpointer dest
, gconstpointer source
, gsize length
);
636 mono_win32_compat_FillMemory (gpointer dest
, gsize length
, guchar fill
);
639 mono_win32_compat_MoveMemory (gpointer dest
, gconstpointer source
, gsize length
);
642 mono_win32_compat_ZeroMemory (gpointer dest
, gsize length
);
645 mono_marshal_find_nonzero_bit_offset (guint8
*buf
, int len
, int *byte_offset
, guint8
*bitmask
) MONO_LLVM_INTERNAL
;
648 mono_signature_no_pinvoke (MonoMethod
*method
);
650 /* Called from cominterop.c/remoting.c */
653 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
);
656 mono_marshal_emit_managed_wrapper (MonoMethodBuilder
*mb
, MonoMethodSignature
*invoke_sig
, MonoMarshalSpec
**mspecs
, EmitMarshalContext
* m
, MonoMethod
*method
, uint32_t target_handle
);
659 mono_marshal_get_cache (GHashTable
**var
, GHashFunc hash_func
, GCompareFunc equal_func
);
662 mono_marshal_find_in_cache (GHashTable
*cache
, gpointer key
);
665 mono_mb_create_and_cache (GHashTable
*cache
, gpointer key
,
666 MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
669 mono_marshal_emit_thread_interrupt_checkpoint (MonoMethodBuilder
*mb
);
672 mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder
*mb
);
675 mono_marshal_use_aot_wrappers (gboolean use
);
678 mono_mb_emit_save_args (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
, gboolean save_this
);
681 mono_mb_emit_restore_result (MonoMethodBuilder
*mb
, MonoType
*return_type
);
684 mono_mb_create (MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
685 int max_stack
, WrapperInfo
*info
);
688 mono_mb_create_and_cache_full (GHashTable
*cache
, gpointer key
,
689 MonoMethodBuilder
*mb
, MonoMethodSignature
*sig
,
690 int max_stack
, WrapperInfo
*info
, gboolean
*out_found
);
692 #endif /* __MONO_MARSHAL_H__ */