5 #ifndef __MONO_METADATA_INTERNALS_H__
6 #define __MONO_METADATA_INTERNALS_H__
8 #include "mono/utils/mono-forward-internal.h"
9 #include "mono/metadata/image.h"
10 #include "mono/metadata/blob.h"
11 #include "mono/metadata/cil-coff.h"
12 #include "mono/metadata/mempool.h"
13 #include "mono/metadata/domain-internals.h"
14 #include "mono/metadata/mono-hash.h"
15 #include "mono/utils/mono-compiler.h"
16 #include "mono/utils/mono-dl.h"
17 #include "mono/utils/monobitset.h"
18 #include "mono/utils/mono-property-hash.h"
19 #include "mono/utils/mono-value-hash.h"
20 #include <mono/utils/mono-error.h>
21 #include "mono/utils/mono-conc-hashtable.h"
22 #include "mono/utils/refcount.h"
26 MonoClass
*klass
; /* for VALUETYPE and CLASS */
27 MonoType
*type
; /* for PTR */
28 MonoArrayType
*array
; /* for ARRAY */
29 MonoMethodSignature
*method
;
30 MonoGenericParam
*generic_param
; /* for VAR and MVAR */
31 MonoGenericClass
*generic_class
; /* for GENERICINST */
33 unsigned int attrs
: 16; /* param attributes or field flags */
34 MonoTypeEnum type
: 8;
35 unsigned int has_cmods
: 1;
36 unsigned int byref
: 1;
37 unsigned int pinned
: 1; /* valid when included in a local var signature */
41 unsigned int required
: 1;
43 } MonoSingleCustomMod
;
45 /* Aggregate custom modifiers can happen if a generic VAR or MVAR is inflated,
46 * and both the VAR and the type that will be used to inflated it have custom
47 * modifiers, but they come from different images. (e.g. inflating 'class G<T>
48 * {void Test (T modopt(IsConst) t);}' with 'int32 modopt(IsLong)' where G is
49 * in image1 and the int32 is in image2.)
51 * Moreover, we can't just store an image and a type token per modifier, because
52 * Roslyn and C++/CLI sometimes create modifiers that mention generic parameters that must be inflated, like:
53 * void .CL1`1.Test(!0 modopt(System.Nullable`1<!0>))
54 * So we have to store a resolved MonoType*.
56 * Because the types come from different images, we allocate the aggregate
57 * custom modifiers container object in the mempool of a MonoImageSet to ensure
58 * that it doesn't have dangling image pointers.
62 MonoSingleCustomMod modifiers
[1]; /* Actual length is count */
63 } MonoAggregateModContainer
;
65 /* ECMA says upto 64 custom modifiers. It's possible we could see more at
66 * runtime due to modifiers being appended together when we inflate type. In
67 * that case we should revisit the places where this define is used to make
68 * sure that we don't blow up the stack (or switch to heap allocation for
71 #define MONO_MAX_EXPECTED_CMODS 64
75 gboolean is_aggregate
;
77 MonoCustomModContainer cmods
;
78 /* the actual aggregate modifiers are in a MonoImageSet mempool
79 * that includes all the images of all the modifier types and
80 * also the type that this aggregate container is a part of.*/
81 MonoAggregateModContainer
*amods
;
83 } MonoTypeWithModifiers
;
86 mono_type_is_aggregate_mods (const MonoType
*t
);
89 mono_type_with_mods_init (MonoType
*dest
, uint8_t num_mods
, gboolean is_aggregate
)
96 MonoTypeWithModifiers
*dest_full
= (MonoTypeWithModifiers
*)dest
;
97 dest_full
->is_aggregate
= !!is_aggregate
;
99 dest_full
->mods
.amods
= NULL
;
101 dest_full
->mods
.cmods
.count
= num_mods
;
104 MonoCustomModContainer
*
105 mono_type_get_cmods (const MonoType
*t
);
107 MonoAggregateModContainer
*
108 mono_type_get_amods (const MonoType
*t
);
111 mono_type_set_amods (MonoType
*t
, MonoAggregateModContainer
*amods
);
113 static inline uint8_t
114 mono_type_custom_modifier_count (const MonoType
*t
)
118 MonoTypeWithModifiers
*full
= (MonoTypeWithModifiers
*)t
;
119 if (full
->is_aggregate
)
120 return full
->mods
.amods
->count
;
122 return full
->mods
.cmods
.count
;
126 mono_type_get_custom_modifier (const MonoType
*ty
, uint8_t idx
, gboolean
*required
, MonoError
*error
);
128 // Note: sizeof (MonoType) is dangerous. It can copy the num_mods
129 // field without copying the variably sized array. This leads to
130 // memory unsafety on the stack and/or heap, when we try to traverse
133 // Use mono_sizeof_monotype
134 // to get the size of the memory to copy.
135 #define MONO_SIZEOF_TYPE sizeof (MonoType)
138 mono_sizeof_type_with_mods (uint8_t num_mods
, gboolean aggregate
);
141 mono_sizeof_type (const MonoType
*ty
);
144 mono_sizeof_aggregate_modifiers (uint8_t num_mods
);
146 MonoAggregateModContainer
*
147 mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer
*candidate
);
149 #define MONO_SECMAN_FLAG_INIT(x) (x & 0x2)
150 #define MONO_SECMAN_FLAG_GET_VALUE(x) (x & 0x1)
151 #define MONO_SECMAN_FLAG_SET_VALUE(x,y) do { x = ((y) ? 0x3 : 0x2); } while (0)
153 #define MONO_PUBLIC_KEY_TOKEN_LENGTH 17
155 #define MONO_PROCESSOR_ARCHITECTURE_NONE 0
156 #define MONO_PROCESSOR_ARCHITECTURE_MSIL 1
157 #define MONO_PROCESSOR_ARCHITECTURE_X86 2
158 #define MONO_PROCESSOR_ARCHITECTURE_IA64 3
159 #define MONO_PROCESSOR_ARCHITECTURE_AMD64 4
160 #define MONO_PROCESSOR_ARCHITECTURE_ARM 5
162 struct _MonoAssemblyName
{
165 const char *hash_value
;
166 const mono_byte
* public_key
;
167 // string of 16 hex chars + 1 NULL
168 mono_byte public_key_token
[MONO_PUBLIC_KEY_TOKEN_LENGTH
];
172 #ifdef ENABLE_NETCORE
173 int major
, minor
, build
, revision
, arch
;
175 uint16_t major
, minor
, build
, revision
, arch
;
179 struct MonoTypeNameParse
{
182 MonoAssemblyName assembly
;
183 GList
*modifiers
; /* 0 -> byref, -1 -> pointer, > 0 -> array rank */
184 GPtrArray
*type_arguments
;
189 typedef enum MonoAssemblyContextKind
{
190 /* Default assembly context: Load(String) and assembly references */
191 MONO_ASMCTX_DEFAULT
= 0,
192 /* Reflection-only only context: ReflectionOnlyLoad and ReeflectionOnlyLoadFrom */
193 MONO_ASMCTX_REFONLY
= 1,
194 /* LoadFrom context: LoadFrom() and references */
195 MONO_ASMCTX_LOADFROM
= 2,
196 /* Individual assembly context (.NET Framework docs call this "not in
197 * any context"): LoadFile(String) and Load(byte[]) are here.
199 MONO_ASMCTX_INDIVIDUAL
= 3,
202 } MonoAssemblyContextKind
;
204 typedef struct _MonoAssemblyContext
{
205 MonoAssemblyContextKind kind
;
206 } MonoAssemblyContext
;
208 struct _MonoAssembly
{
210 * The number of appdomains which have this assembly loaded plus the number of
211 * assemblies referencing this assembly through an entry in their image->references
212 * arrays. The latter is needed because entries in the image->references array
213 * might point to assemblies which are only loaded in some appdomains, and without
214 * the additional reference, they can be freed at any time.
215 * The ref_count is initially 0.
217 int ref_count
; /* use atomic operations only */
219 MonoAssemblyName aname
;
221 GSList
*friend_assembly_names
; /* Computed by mono_assembly_load_friends () */
222 guint8 friend_assembly_names_inited
;
225 guint8 corlib_internal
;
226 MonoAssemblyContext context
;
227 guint8 wrap_non_exception_throws
;
228 guint8 wrap_non_exception_throws_inited
;
229 guint8 jit_optimizer_disabled
;
230 guint8 jit_optimizer_disabled_inited
;
231 /* security manager flags (one bit is for lazy initialization) */
232 guint32 ecma
:2; /* Has the ECMA key */
233 guint32 aptc
:2; /* Has the [AllowPartiallyTrustedCallers] attributes */
234 guint32 fulltrust
:2; /* Has FullTrust permission */
235 guint32 unmanaged
:2; /* Has SecurityPermissionFlag.UnmanagedCode permission */
236 guint32 skipverification
:2; /* Has SecurityPermissionFlag.SkipVerification permission */
241 * indexed by MonoMethodSignature
242 * Protected by the marshal lock
244 GHashTable
*delegate_invoke_cache
;
245 GHashTable
*delegate_begin_invoke_cache
;
246 GHashTable
*delegate_end_invoke_cache
;
247 GHashTable
*runtime_invoke_signature_cache
;
248 GHashTable
*runtime_invoke_sig_cache
;
251 * indexed by SignaturePointerPair
253 GHashTable
*delegate_abstract_invoke_cache
;
256 * indexed by MonoMethod pointers
257 * Protected by the marshal lock
259 GHashTable
*runtime_invoke_method_cache
;
260 GHashTable
*managed_wrapper_cache
;
262 GHashTable
*native_wrapper_cache
;
263 GHashTable
*native_wrapper_aot_cache
;
264 GHashTable
*native_wrapper_check_cache
;
265 GHashTable
*native_wrapper_aot_check_cache
;
267 GHashTable
*native_func_wrapper_aot_cache
;
268 GHashTable
*remoting_invoke_cache
;
269 GHashTable
*synchronized_cache
;
270 GHashTable
*unbox_wrapper_cache
;
271 GHashTable
*cominterop_invoke_cache
;
272 GHashTable
*cominterop_wrapper_cache
; /* LOCKING: marshal lock */
273 GHashTable
*thunk_invoke_cache
;
281 struct _MonoTableInfo
{
287 * Tables contain up to 9 columns and the possible sizes of the
288 * fields in the documentation are 1, 2 and 4 bytes. So we
289 * can encode in 2 bits the size.
291 * A 32 bit value can encode the resulting size
293 * The top eight bits encode the number of columns in the table.
294 * we only need 4, but 8 is aligned no shift required.
296 guint32 size_bitfield
;
299 #define REFERENCE_MISSING ((gpointer) -1)
301 typedef struct _MonoDllMap MonoDllMap
;
304 gboolean (*match
) (MonoImage
*);
305 gboolean (*load_pe_data
) (MonoImage
*);
306 gboolean (*load_cli_data
) (MonoImage
*);
307 gboolean (*load_tables
) (MonoImage
*);
310 /* Represents the physical bytes (usually on disk, but could be in memory) for
313 * The MonoImageStorage owns the raw data for an image and is responsible for
316 * May be shared by multiple MonoImage objects if they opened the same
317 * underlying file or byte blob in memory.
319 * There is an abstract string key (usually a file path, but could be formed in
320 * other ways) that is used to share MonoImageStorage objects among images.
326 /* key used for lookups. owned by this image storage. */
329 /* If the raw data was allocated from a source such as mmap, the allocator may store resource tracking information here. */
330 void *raw_data_handle
;
332 guint32 raw_data_len
;
333 guint8 raw_buffer_used
: 1;
334 guint8 raw_data_allocated
: 1;
335 guint8 fileio_used
: 1;
338 /* Module was loaded using LoadLibrary. */
339 guint8 is_module_handle
: 1;
341 /* Module entry point is _CorDllMain. */
342 guint8 has_entry_point
: 1;
348 * This count is incremented during these situations:
349 * - An assembly references this MonoImage though its 'image' field
350 * - This MonoImage is present in the 'files' field of an image
351 * - This MonoImage is present in the 'modules' field of an image
352 * - A thread is holding a temporary reference to this MonoImage between
353 * calls to mono_image_open and mono_image_close ()
357 MonoImageStorage
*storage
;
359 /* Whenever this is a dynamically emitted module */
362 /* Whenever this is a reflection only image */
365 /* Whenever this image contains uncompressed metadata */
366 guint8 uncompressed_metadata
: 1;
368 /* Whenever this image contains metadata only without PE data */
369 guint8 metadata_only
: 1;
371 /* Whether this image belongs to load-from context */
372 guint8 load_from_context
: 1;
374 guint8 checked_module_cctor
: 1;
375 guint8 has_module_cctor
: 1;
377 guint8 idx_string_wide
: 1;
378 guint8 idx_guid_wide
: 1;
379 guint8 idx_blob_wide
: 1;
381 /* Whenever this image is considered as platform code for the CoreCLR security model */
382 guint8 core_clr_platform_code
: 1;
384 /* The path to the file for this image or an arbitrary name for images loaded from data. */
387 /* The path to the file for this image or NULL */
390 /* The assembly name reported in the file for this image (expected to be NULL for a netmodule) */
391 const char *assembly_name
;
393 /* The module name reported in the file for this image (could be NULL for a malformed file) */
394 const char *module_name
;
395 guint32 time_date_stamp
;
398 gint16 md_version_major
, md_version_minor
;
400 MonoCLIImageInfo
*image_info
;
401 MonoMemPool
*mempool
; /*protected by the image lock*/
405 MonoStreamHeader heap_strings
;
406 MonoStreamHeader heap_us
;
407 MonoStreamHeader heap_blob
;
408 MonoStreamHeader heap_guid
;
409 MonoStreamHeader heap_tables
;
410 MonoStreamHeader heap_pdb
;
412 const char *tables_base
;
415 guint64 referenced_tables
;
416 int *referenced_table_rows
;
419 MonoTableInfo tables
[MONO_TABLE_NUM
];
422 * references is initialized only by using the mono_assembly_open
423 * function, and not by using the lowlevel mono_image_open.
425 * It is NULL terminated.
427 MonoAssembly
**references
;
430 /* Code files in the assembly. The main assembly has a "file" table and also a "module"
431 * table, where the module table is a subset of the file table. We track both lists,
432 * and because we can lazy-load them at different times we reference-increment both.
435 guint32 module_count
;
436 gboolean
*modules_loaded
;
441 MonoAotModule
*aot_module
;
446 * The Assembly this image was loaded from.
448 MonoAssembly
*assembly
;
451 * Indexed by method tokens and typedef tokens.
453 GHashTable
*method_cache
; /*protected by the image lock*/
454 MonoInternalHashTable class_cache
;
456 /* Indexed by memberref + methodspec tokens */
457 GHashTable
*methodref_cache
; /*protected by the image lock*/
460 * Indexed by fielddef and memberref tokens
462 MonoConcurrentHashTable
*field_cache
; /*protected by the image lock*/
464 /* indexed by typespec tokens. */
465 MonoConcurrentHashTable
*typespec_cache
; /* protected by the image lock */
466 /* indexed by token */
467 GHashTable
*memberref_signatures
;
469 /* Indexed by blob heap indexes */
470 GHashTable
*method_signatures
;
473 * Indexes namespaces to hash tables that map class name to typedef token.
475 GHashTable
*name_cache
; /*protected by the image lock*/
478 * Indexed by MonoClass
480 GHashTable
*array_cache
;
481 GHashTable
*ptr_cache
;
483 GHashTable
*szarray_cache
;
484 /* This has a separate lock to improve scalability */
485 mono_mutex_t szarray_cache_lock
;
488 * indexed by SignaturePointerPair
490 GHashTable
*delegate_bound_static_invoke_cache
;
491 GHashTable
*native_func_wrapper_cache
;
494 * indexed by MonoMethod pointers
496 GHashTable
*wrapper_param_names
;
497 GHashTable
*array_accessor_cache
;
500 * indexed by MonoClass pointers
502 GHashTable
*ldfld_wrapper_cache
;
503 GHashTable
*ldflda_wrapper_cache
;
504 GHashTable
*stfld_wrapper_cache
;
505 GHashTable
*isinst_cache
;
507 GHashTable
*icall_wrapper_cache
;
508 GHashTable
*castclass_cache
;
509 GHashTable
*proxy_isinst_cache
;
510 GHashTable
*rgctx_template_hash
; /* LOCKING: templates lock */
512 /* Contains rarely used fields of runtime structures belonging to this image */
513 MonoPropertyHash
*property_hash
;
515 void *reflection_info
;
518 * user_info is a public field and is not touched by the
523 /* dll map entries */
526 /* interfaces IDs from this image */
527 /* protected by the classes lock */
528 MonoBitSet
*interface_bitset
;
530 /* when the image is being closed, this is abused as a list of
531 malloc'ed regions to be freed. */
532 GSList
*reflection_info_unregister_classes
;
534 /* List of dependent image sets containing this image */
535 /* Protected by image_sets_lock */
538 /* Caches for wrappers that DO NOT reference generic */
540 MonoWrapperCaches wrapper_caches
;
542 /* Pre-allocated anon generic params for the first N generic
543 * parameters, for a small N */
544 MonoGenericParam
*var_gparam_cache_fast
;
545 MonoGenericParam
*mvar_gparam_cache_fast
;
546 /* Anon generic parameters past N, if needed */
547 MonoConcurrentHashTable
*var_gparam_cache
;
548 MonoConcurrentHashTable
*mvar_gparam_cache
;
550 /* Maps malloc-ed char* pinvoke scope -> MonoDl* */
551 GHashTable
*pinvoke_scopes
;
553 /* Maps malloc-ed char* pinvoke scope -> malloced-ed char* filename */
554 GHashTable
*pinvoke_scope_filenames
;
556 /* Indexed by MonoGenericParam pointers */
557 GHashTable
**gshared_types
;
558 /* The length of the above array */
559 int gshared_types_len
;
561 /* The loader used to load this image */
562 MonoImageLoader
*loader
;
564 // Containers for MonoGenericParams associated with this image but not with any specific class or method. Created on demand.
565 // This could happen, for example, for MonoTypes associated with TypeSpec table entries.
566 MonoGenericContainer
*anonymous_generic_class_container
;
567 MonoGenericContainer
*anonymous_generic_method_container
;
569 gboolean weak_fields_inited
;
570 /* Contains 1 based indexes */
571 GHashTable
*weak_field_indexes
;
574 * No other runtime locks must be taken while holding this lock.
575 * It's meant to be used only to mutate and query structures part of this image.
581 * Generic instances and aggregated custom modifiers depend on many images, and they need to be deleted if one
582 * of the images they depend on is unloaded. For example,
583 * List<Foo> depends on both List's image and Foo's image.
584 * A MonoImageSet is the owner of all generic instances depending on the same set of
591 // Generic-specific caches
592 GHashTable
*ginst_cache
, *gmethod_cache
, *gsignature_cache
;
593 MonoConcurrentHashTable
*gclass_cache
;
595 /* mirror caches of ones already on MonoImage. These ones contain generics */
596 GHashTable
*szarray_cache
, *array_cache
, *ptr_cache
;
598 MonoWrapperCaches wrapper_caches
;
600 GHashTable
*aggregate_modifiers_cache
;
605 * Memory for generic instances owned by this image set should be allocated from
606 * this mempool, using the mono_image_set_alloc family of functions.
608 MonoMemPool
*mempool
;
621 guint32 alloc_size
; /* malloced bytes */
623 guint32 offset
; /* from start of metadata */
629 guint8 row_size
; /* calculated later with column_sizes */
632 guint32
*values
; /* rows * columns */
635 /* "Dynamic" assemblies and images arise from System.Reflection.Emit */
636 struct _MonoDynamicAssembly
{
637 MonoAssembly assembly
;
639 guint32 strong_name_size
;
645 struct _MonoDynamicImage
{
649 guint32 metadata_rva
;
651 guint32 cli_header_offset
;
655 guint32 imp_names_offset
;
661 } sections
[MONO_SECTION_MAX
];
662 GHashTable
*typespec
;
664 GHashTable
*handleref
;
665 MonoGHashTable
*tokens
;
666 GHashTable
*blob_cache
;
667 GHashTable
*standalonesig_cache
;
668 GList
*array_methods
;
669 GPtrArray
*gen_params
;
670 MonoGHashTable
*token_fixups
;
671 GHashTable
*method_to_table_idx
;
672 GHashTable
*field_to_table_idx
;
673 GHashTable
*method_aux_hash
;
674 GHashTable
*vararg_aux_hash
;
675 MonoGHashTable
*generic_def_objects
;
677 * Maps final token values to the object they describe.
679 MonoGHashTable
*remapped_tokens
;
682 gboolean initial_image
;
683 guint32 pe_kind
, machine
;
685 guint32 strong_name_size
;
687 guint32 win32_res_size
;
690 MonoDynamicStream sheap
;
691 MonoDynamicStream code
; /* used to store method headers and bytecode */
692 MonoDynamicStream resources
; /* managed embedded resources */
693 MonoDynamicStream us
;
694 MonoDynamicStream blob
;
695 MonoDynamicStream tstream
;
696 MonoDynamicStream guid
;
697 MonoDynamicTable tables
[MONO_TABLE_NUM
];
698 MonoClass
*wrappers_type
; /*wrappers are bound to this type instead of <Module>*/
701 /* Contains information about assembly binding */
702 typedef struct _MonoAssemblyBindingInfo
{
705 guchar public_key_token
[MONO_PUBLIC_KEY_TOKEN_LENGTH
];
708 AssemblyVersionSet old_version_bottom
;
709 AssemblyVersionSet old_version_top
;
710 AssemblyVersionSet new_version
;
711 guint has_old_version_bottom
: 1;
712 guint has_old_version_top
: 1;
713 guint has_new_version
: 1;
715 gint32 domain_id
; /*Needed to unload per-domain binding*/
716 } MonoAssemblyBindingInfo
;
718 struct _MonoMethodHeader
{
719 const unsigned char *code
;
720 #ifdef MONO_SMALL_CONFIG
725 guint16 max_stack
: 15;
726 unsigned int is_transient
: 1; /* mono_metadata_free_mh () will actually free this header */
727 unsigned int num_clauses
: 15;
728 /* if num_locals != 0, then the following apply: */
729 unsigned int init_locals
: 1;
731 MonoExceptionClause
*clauses
;
732 MonoBitSet
*volatile_args
;
733 MonoBitSet
*volatile_locals
;
734 MonoType
*locals
[MONO_ZERO_LEN_ARRAY
];
738 const unsigned char *code
;
741 gboolean has_clauses
;
743 } MonoMethodHeaderSummary
;
745 // FIXME? offsetof (MonoMethodHeader, locals)?
746 #define MONO_SIZEOF_METHOD_HEADER (sizeof (struct _MonoMethodHeader) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
748 struct _MonoMethodSignature
{
750 #ifdef MONO_SMALL_CONFIG
753 unsigned int generic_param_count
: 5;
757 unsigned int generic_param_count
: 16;
759 unsigned int call_convention
: 6;
760 unsigned int hasthis
: 1;
761 unsigned int explicit_this
: 1;
762 unsigned int pinvoke
: 1;
763 unsigned int is_inflated
: 1;
764 unsigned int has_type_parameters
: 1;
765 MonoType
*params
[MONO_ZERO_LEN_ARRAY
];
769 * AOT cache configuration loaded from config files.
770 * Doesn't really belong here.
774 * Enable aot caching for applications whose main assemblies are in
780 } MonoAotCacheConfig
;
782 #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
784 static inline gboolean
785 image_is_dynamic (MonoImage
*image
)
787 #ifdef DISABLE_REFLECTION_EMIT
790 return image
->dynamic
;
794 static inline gboolean
795 assembly_is_dynamic (MonoAssembly
*assembly
)
797 #ifdef DISABLE_REFLECTION_EMIT
800 return assembly
->dynamic
;
804 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
805 guint
mono_aligned_addr_hash (gconstpointer ptr
);
808 mono_image_check_for_module_cctor (MonoImage
*image
);
811 mono_image_alloc (MonoImage
*image
, guint size
);
814 mono_image_alloc0 (MonoImage
*image
, guint size
);
816 #define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
819 mono_image_strdup (MonoImage
*image
, const char *s
);
822 mono_image_strdup_vprintf (MonoImage
*image
, const char *format
, va_list args
);
825 mono_image_strdup_printf (MonoImage
*image
, const char *format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
828 mono_g_list_prepend_image (MonoImage
*image
, GList
*list
, gpointer data
);
831 mono_g_slist_append_image (MonoImage
*image
, GSList
*list
, gpointer data
);
834 mono_image_lock (MonoImage
*image
);
837 mono_image_unlock (MonoImage
*image
);
840 mono_image_property_lookup (MonoImage
*image
, gpointer subject
, guint32 property
);
843 mono_image_property_insert (MonoImage
*image
, gpointer subject
, guint32 property
, gpointer value
);
846 mono_image_property_remove (MonoImage
*image
, gpointer subject
);
849 mono_image_close_except_pools (MonoImage
*image
);
852 mono_image_close_finish (MonoImage
*image
);
854 typedef void (*MonoImageUnloadFunc
) (MonoImage
*image
, gpointer user_data
);
857 mono_install_image_unload_hook (MonoImageUnloadFunc func
, gpointer user_data
);
860 mono_remove_image_unload_hook (MonoImageUnloadFunc func
, gpointer user_data
);
863 mono_install_image_loader (const MonoImageLoader
*loader
);
866 mono_image_append_class_to_reflection_info_set (MonoClass
*klass
);
869 mono_image_set_alloc (MonoImageSet
*set
, guint size
);
872 mono_image_set_alloc0 (MonoImageSet
*set
, guint size
);
875 mono_image_set_lock (MonoImageSet
*set
);
878 mono_image_set_unlock (MonoImageSet
*set
);
881 mono_image_set_strdup (MonoImageSet
*set
, const char *s
);
884 mono_metadata_get_image_set_for_aggregate_modifiers (MonoAggregateModContainer
*amods
);
886 #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
889 mono_image_load_cli_header (MonoImage
*image
, MonoCLIImageInfo
*iinfo
);
892 mono_image_load_metadata (MonoImage
*image
, MonoCLIImageInfo
*iinfo
);
895 mono_metadata_string_heap_checked (MonoImage
*meta
, uint32_t table_index
, MonoError
*error
);
897 mono_metadata_blob_heap_checked (MonoImage
*meta
, uint32_t table_index
, MonoError
*error
);
899 mono_metadata_decode_row_checked (const MonoImage
*image
, const MonoTableInfo
*t
, int idx
, uint32_t *res
, int res_size
, MonoError
*error
);
902 mono_metadata_get_shared_type (MonoType
*type
);
905 mono_metadata_clean_for_image (MonoImage
*image
);
908 mono_metadata_clean_generic_classes_for_image (MonoImage
*image
);
911 mono_metadata_cleanup (void);
913 const char * mono_meta_table_name (int table
);
914 void mono_metadata_compute_table_bases (MonoImage
*meta
);
917 mono_metadata_interfaces_from_typedef_full (MonoImage
*image
,
919 MonoClass
***interfaces
,
921 gboolean heap_alloc_result
,
922 MonoGenericContext
*context
,
925 MONO_API MonoMethodSignature
*
926 mono_metadata_parse_method_signature_full (MonoImage
*image
,
927 MonoGenericContainer
*generic_container
,
933 MONO_API MonoMethodHeader
*
934 mono_metadata_parse_mh_full (MonoImage
*image
,
935 MonoGenericContainer
*container
,
939 MonoMethodSignature
*mono_metadata_parse_signature_checked (MonoImage
*image
,
944 mono_method_get_header_summary (MonoMethod
*method
, MonoMethodHeaderSummary
*summary
);
946 int* mono_metadata_get_param_attrs (MonoImage
*m
, int def
, int param_count
);
947 gboolean
mono_metadata_method_has_param_attrs (MonoImage
*m
, int def
);
950 mono_metadata_generic_context_hash (const MonoGenericContext
*context
);
953 mono_metadata_generic_context_equal (const MonoGenericContext
*g1
,
954 const MonoGenericContext
*g2
);
957 mono_metadata_parse_generic_inst (MonoImage
*image
,
958 MonoGenericContainer
*container
,
965 mono_metadata_get_generic_inst (int type_argc
,
966 MonoType
**type_argv
);
969 mono_metadata_get_canonical_generic_inst (MonoGenericInst
*candidate
);
972 mono_metadata_lookup_generic_class (MonoClass
*gclass
,
973 MonoGenericInst
*inst
,
974 gboolean is_dynamic
);
976 MonoGenericInst
* mono_metadata_inflate_generic_inst (MonoGenericInst
*ginst
, MonoGenericContext
*context
, MonoError
*error
);
979 mono_metadata_generic_param_hash (MonoGenericParam
*p
);
982 mono_metadata_generic_param_equal (MonoGenericParam
*p1
, MonoGenericParam
*p2
);
984 void mono_dynamic_stream_reset (MonoDynamicStream
* stream
);
985 MONO_API
void mono_assembly_addref (MonoAssembly
*assembly
);
986 void mono_assembly_load_friends (MonoAssembly
* ass
);
987 gboolean
mono_assembly_has_skip_verification (MonoAssembly
* ass
);
989 void mono_assembly_release_gc_roots (MonoAssembly
*assembly
);
990 gboolean
mono_assembly_close_except_image_pools (MonoAssembly
*assembly
);
991 void mono_assembly_close_finish (MonoAssembly
*assembly
);
994 gboolean
mono_public_tokens_are_equal (const unsigned char *pubt1
, const unsigned char *pubt2
);
996 void mono_config_parse_publisher_policy (const char *filename
, MonoAssemblyBindingInfo
*binding_info
);
997 void mono_config_parse_assembly_bindings (const char *filename
, int major
, int minor
, void *user_data
,
998 void (*infocb
)(MonoAssemblyBindingInfo
*info
, void *user_data
));
1001 mono_assembly_name_parse_full (const char *name
,
1002 MonoAssemblyName
*aname
,
1003 gboolean save_public_key
,
1004 gboolean
*is_version_defined
,
1005 gboolean
*is_token_defined
);
1008 mono_assembly_fill_assembly_name_full (MonoImage
*image
, MonoAssemblyName
*aname
, gboolean copyBlobs
);
1011 MONO_API guint32
mono_metadata_get_generic_param_row (MonoImage
*image
, guint32 token
, guint32
*owner
);
1014 mono_metadata_create_anon_gparam (MonoImage
*image
, gint32 param_num
, gboolean is_mvar
);
1016 void mono_unload_interface_ids (MonoBitSet
*bitset
);
1019 MonoType
*mono_metadata_type_dup (MonoImage
*image
, const MonoType
*original
);
1020 MonoType
*mono_metadata_type_dup_with_cmods (MonoImage
*image
, const MonoType
*original
, const MonoType
*cmods_source
);
1022 MonoMethodSignature
*mono_metadata_signature_dup_full (MonoImage
*image
,MonoMethodSignature
*sig
);
1023 MonoMethodSignature
*mono_metadata_signature_dup_mempool (MonoMemPool
*mp
, MonoMethodSignature
*sig
);
1024 MonoMethodSignature
*mono_metadata_signature_dup_add_this (MonoImage
*image
, MonoMethodSignature
*sig
, MonoClass
*klass
);
1027 mono_get_shared_generic_inst (MonoGenericContainer
*container
);
1030 mono_type_stack_size_internal (MonoType
*t
, int *align
, gboolean allow_open
);
1032 MONO_API
void mono_type_get_desc (GString
*res
, MonoType
*type
, mono_bool include_namespace
);
1035 mono_metadata_type_equal_full (MonoType
*t1
, MonoType
*t2
, gboolean signature_only
);
1038 mono_metadata_parse_marshal_spec_full (MonoImage
*image
, MonoImage
*parent_image
, const char *ptr
);
1040 guint
mono_metadata_generic_inst_hash (gconstpointer data
);
1041 gboolean
mono_metadata_generic_inst_equal (gconstpointer ka
, gconstpointer kb
);
1044 mono_metadata_field_info_with_mempool (
1046 guint32 table_index
,
1049 MonoMarshalSpec
**marshal_spec
);
1052 mono_metadata_get_corresponding_field_from_generic_type_definition (MonoClassField
*field
);
1055 mono_metadata_get_corresponding_event_from_generic_type_definition (MonoEvent
*event
);
1058 mono_metadata_get_corresponding_property_from_generic_type_definition (MonoProperty
*property
);
1061 mono_metadata_signature_size (MonoMethodSignature
*sig
);
1063 guint
mono_metadata_str_hash (gconstpointer v1
);
1065 gboolean
mono_image_load_pe_data (MonoImage
*image
);
1067 gboolean
mono_image_load_cli_data (MonoImage
*image
);
1069 void mono_image_load_names (MonoImage
*image
);
1071 MonoImage
*mono_image_open_raw (const char *fname
, MonoImageOpenStatus
*status
);
1073 MonoImage
*mono_image_open_metadata_only (const char *fname
, MonoImageOpenStatus
*status
);
1075 MonoImage
*mono_image_open_from_data_internal (char *data
, guint32 data_len
, gboolean need_copy
, MonoImageOpenStatus
*status
, gboolean refonly
, gboolean metadata_only
, const char *name
);
1077 MonoException
*mono_get_exception_field_access_msg (const char *msg
);
1079 MonoException
*mono_get_exception_method_access_msg (const char *msg
);
1081 MonoMethod
* mono_method_from_method_def_or_ref (MonoImage
*m
, guint32 tok
, MonoGenericContext
*context
, MonoError
*error
);
1083 MonoMethod
*mono_get_method_constrained_with_method (MonoImage
*image
, MonoMethod
*method
, MonoClass
*constrained_class
, MonoGenericContext
*context
, MonoError
*error
);
1084 MonoMethod
*mono_get_method_constrained_checked (MonoImage
*image
, guint32 token
, MonoClass
*constrained_class
, MonoGenericContext
*context
, MonoMethod
**cil_method
, MonoError
*error
);
1086 void mono_type_set_alignment (MonoTypeEnum type
, int align
);
1088 MonoAotCacheConfig
*mono_get_aot_cache_config (void);
1090 mono_type_create_from_typespec_checked (MonoImage
*image
, guint32 type_spec
, MonoError
*error
);
1092 MonoMethodSignature
*
1093 mono_method_get_signature_checked (MonoMethod
*method
, MonoImage
*image
, guint32 token
, MonoGenericContext
*context
, MonoError
*error
);
1096 mono_get_method_checked (MonoImage
*image
, guint32 token
, MonoClass
*klass
, MonoGenericContext
*context
, MonoError
*error
);
1099 mono_metadata_localscope_from_methoddef (MonoImage
*meta
, guint32 index
);
1102 mono_wrapper_caches_free (MonoWrapperCaches
*cache
);
1105 mono_method_get_wrapper_cache (MonoMethod
*method
);
1108 mono_method_get_wrapper_cache (MonoMethod
*method
);
1111 mono_metadata_parse_type_checked (MonoImage
*m
, MonoGenericContainer
*container
, short opt_attrs
, gboolean transient
, const char *ptr
, const char **rptr
, MonoError
*error
);
1113 MonoGenericContainer
*
1114 mono_get_anonymous_container_for_image (MonoImage
*image
, gboolean is_mvar
);
1117 mono_image_set_description (MonoImageSet
*);
1120 mono_find_image_set_owner (void *ptr
);
1123 mono_loader_register_module (const char *name
, MonoDl
*module
);
1126 mono_assembly_is_problematic_version (const char *name
, guint16 major
, guint16 minor
, guint16 build
, guint16 revision
);
1129 mono_ginst_get_desc (GString
*str
, MonoGenericInst
*ginst
);
1132 mono_loader_set_strict_strong_names (gboolean enabled
);
1135 mono_loader_get_strict_strong_names (void);
1138 mono_type_in_image (MonoType
*type
, MonoImage
*image
);
1141 mono_type_is_valid_generic_argument (MonoType
*type
);
1143 MonoAssemblyContextKind
1144 mono_asmctx_get_kind (const MonoAssemblyContext
*ctx
);
1146 #define MONO_CLASS_IS_INTERFACE_INTERNAL(c) ((mono_class_get_flags (c) & TYPE_ATTRIBUTE_INTERFACE) || mono_type_is_generic_parameter (m_class_get_byval_arg (c)))
1149 m_image_get_raw_data (MonoImage
*image
)
1151 return image
->storage
? image
->storage
->raw_data
: NULL
;
1154 static inline guint32
1155 m_image_get_raw_data_len (MonoImage
*image
)
1157 return image
->storage
? image
->storage
->raw_data_len
: 0;
1160 static inline gboolean
1161 m_image_is_raw_data_allocated (MonoImage
*image
)
1163 return image
->storage
? image
->storage
->raw_data_allocated
: FALSE
;
1166 static inline gboolean
1167 m_image_is_fileio_used (MonoImage
*image
)
1169 return image
->storage
? image
->storage
->fileio_used
: FALSE
;
1173 static inline gboolean
1174 m_image_is_module_handle (MonoImage
*image
)
1176 return image
->storage
? image
->storage
->is_module_handle
: FALSE
;
1179 static inline gboolean
1180 m_image_has_entry_point (MonoImage
*image
)
1182 return image
->storage
? image
->storage
->has_entry_point
: FALSE
;
1187 #endif /* __MONO_METADATA_INTERNALS_H__ */