mono-api-metadata.html
Metadata Loader Locking
The locking functions here are used by code in class.c and
metadata.c to lock access to the shared hashtables inside the
MonoImage
mono_loader_lock
Prototype: mono_loader_lock
mono_loader_unlock
Prototype: mono_loader_unlock
Metadata access API
This is the low-level API for accessing the metadata
images.
mono_cli_rva_image_map
Prototype: mono_cli_rva_image_map
mono_pe_file_open
MonoImage*
mono_pe_file_open (const char *fname, MonoImageOpenStatus *status)
Parameters
fname: filename that points to the module we want to openstatus: An error condition is returned in this field
Returns
An open image of type %MonoImage or NULL on error. if
NULL, then check the value of status for details on the error.
This variant for mono_image_open DOES NOT SET UP CLI METADATA.
It's just a PE file loader, used for FileVersionInfo. It also does
not use the image cache.
mono_meta_table_name
const char *
mono_meta_table_name (int table)
Parameters
table: table index
Returns
the name for the table index
mono_metadata_blob_heap
const char *
mono_metadata_blob_heap (MonoImage *meta, guint32 index)
Parameters
meta: metadata contextindex: index into the blob.
Returns
an in-memory pointer to the index in the Blob heap.
mono_metadata_compute_size
Prototype: mono_metadata_compute_size
mono_metadata_custom_attrs_from_index
Prototype: mono_metadata_custom_attrs_from_index
mono_metadata_decode_blob_size
guint32
mono_metadata_decode_blob_size (const char *xptr, const char **rptr)
Parameters
ptr: pointer to a blob objectrptr: the new position of the pointer
Returns
the size of the blob object
Remarks
This decodes a compressed size as described by 23.1.4 (a blob or user string object)
mono_metadata_decode_row_col
guint32
mono_metadata_decode_row_col (const MonoTableInfo *t, int idx, guint col)
Parameters
t: table to extract information from.idx: index for row in table.col: column in the row.
Remarks
This function returns the value of column
col from the
idx
row in the table
t.
mono_metadata_decode_row
void
mono_metadata_decode_row (const MonoTableInfo *t, int idx, guint32 *res, int res_size)
Parameters
t: table to extract information from.idx: index in table.res: array of res_size cols to store the results in
Remarks
This decompresses the metadata element
idx in table
t
into the guint32
res array that has res_size elements
mono_metadata_decode_signed_value
gint32
mono_metadata_decode_signed_value (const char *ptr, const char **rptr)
Parameters
ptr: pointer to decode fromrptr: the new position of the pointer
Returns
the decoded value
Remarks
This routine decompresses 32-bit signed values
(not specified in the spec)
mono_metadata_decode_value
guint32
mono_metadata_decode_value (const char *_ptr, const char **rptr)
Parameters
ptr: pointer to decode fromrptr: the new position of the pointer
Returns
the decoded value
Remarks
This routine decompresses 32-bit values as specified in the "Blob and
Signature" section (22.2)
mono_metadata_encode_value
Prototype: mono_metadata_encode_value
mono_metadata_events_from_typedef
Prototype: mono_metadata_events_from_typedef
mono_metadata_field_info
Prototype: mono_metadata_field_info
mono_metadata_free_array
Prototype: mono_metadata_free_array
mono_metadata_free_marshal_spec
Prototype: mono_metadata_free_marshal_spec
mono_metadata_free_mh
Prototype: mono_metadata_free_mh
mono_metadata_free_type
Prototype: mono_metadata_free_type
mono_metadata_generic_inst_equal
Prototype: mono_metadata_generic_inst_equal
mono_metadata_generic_inst_hash
Prototype: mono_metadata_generic_inst_hash
mono_metadata_generic_inst_is_valuetype
Prototype: mono_metadata_generic_inst_is_valuetype
mono_metadata_generic_method_equal
Prototype: mono_metadata_generic_method_equal
mono_metadata_get_constant_index
Prototype: mono_metadata_get_constant_index
mono_metadata_get_marshal_info
Prototype: mono_metadata_get_marshal_info
mono_metadata_get_table
Prototype: mono_metadata_get_table
mono_metadata_guid_heap
const char *
mono_metadata_guid_heap (MonoImage *meta, guint32 index)
Parameters
meta: metadata contextindex: index into the guid heap.
Returns
an in-memory pointer to the index in the guid heap.
mono_metadata_implmap_from_method
Prototype: mono_metadata_implmap_from_method
mono_metadata_interfaces_from_typedef_full
Prototype: mono_metadata_interfaces_from_typedef_full
mono_metadata_interfaces_from_typedef
Prototype: mono_metadata_interfaces_from_typedef
mono_metadata_load_generic_params
Prototype: mono_metadata_load_generic_params
mono_metadata_locate
const char *
mono_metadata_locate (MonoImage *meta, int table, int idx)
Parameters
meta: metadata contexttable: table code.idx: index of element to retrieve from table.
Returns
a pointer to the idx element in the metadata table
whose code is table.
mono_metadata_locate_token
const char *
mono_metadata_locate_token (MonoImage *meta, guint32 token)
Parameters
meta: metadata contexttoken: metadata token
Returns
a pointer to the data in the metadata represented by the
token token.
mono_metadata_methods_from_event
Prototype: mono_metadata_methods_from_event
mono_metadata_methods_from_property
Prototype: mono_metadata_methods_from_property
mono_metadata_nested_in_typedef
Prototype: mono_metadata_nested_in_typedef
mono_metadata_nesting_typedef
Prototype: mono_metadata_nesting_typedef
mono_metadata_packing_from_typedef
Prototype: mono_metadata_packing_from_typedef
mono_metadata_parse_array_full
Prototype: mono_metadata_parse_array_full
mono_metadata_parse_array
Prototype: mono_metadata_parse_array
mono_metadata_parse_custom_mod
Prototype: mono_metadata_parse_custom_mod
mono_metadata_parse_field_type
MonoType*
mono_metadata_parse_field_type (MonoImage *m, short field_flags, const char *ptr, const char **rptr)
Parameters
m: metadata context to extract information fromptr: pointer to the field signaturerptr: pointer updated to match the end of the decoded stream
Returns
The MonoType that was extracted from ptr.
Remarks
Parses the field signature, and returns the type information for it.
mono_metadata_parse_marshal_spec
Prototype: mono_metadata_parse_marshal_spec
mono_metadata_parse_method_signature_full
Prototype: mono_metadata_parse_method_signature_full
mono_metadata_parse_method_signature
Prototype: mono_metadata_parse_method_signature
mono_metadata_parse_mh_full
Prototype: mono_metadata_parse_mh_full
mono_metadata_parse_mh
Prototype: mono_metadata_parse_mh
mono_metadata_parse_param
MonoType*
mono_metadata_parse_param (MonoImage *m, const char *ptr, const char **rptr)
Parameters
m: metadata context to extract information fromptr: pointer to the param signaturerptr: pointer updated to match the end of the decoded stream
Returns
The MonoType that was extracted from ptr.
Remarks
Parses the param signature, and returns the type information for it.
mono_metadata_parse_signature_full
Prototype: mono_metadata_parse_signature_full
mono_metadata_parse_signature
Prototype: mono_metadata_parse_signature
mono_metadata_parse_typedef_or_ref
Prototype: mono_metadata_parse_typedef_or_ref
mono_metadata_parse_type_full
Prototype: mono_metadata_parse_type_full
mono_metadata_parse_type
MonoType*
mono_metadata_parse_type_full (MonoImage *m, MonoGenericContainer *container, MonoParseTypeMode mode,
short opt_attrs, const char *ptr, const char **rptr)
Parameters
m: metadata contextmode: king of type that may be found at ptropt_attrs: optional attributes to store in the returned typeptr: pointer to the type representationrptr: pointer updated to match the end of the decoded stream
Returns
a MonoType structure representing the decoded type.
Remarks
Decode a compressed type description found at
ptr in
m.
mode can be one of MONO_PARSE_MOD_TYPE, MONO_PARSE_PARAM, MONO_PARSE_RET,
MONO_PARSE_FIELD, MONO_PARSE_LOCAL, MONO_PARSE_TYPE.
This function can be used to decode type descriptions in method signatures,
field signatures, locals signatures etc.
To parse a generic type, `generic_container' points to the current class'es
(the `generic_container' field in the MonoClass) or the current generic method's
(the `generic_container' field in the MonoMethodNormal) generic container.
When we encounter any MONO_TYPE_VAR or MONO_TYPE_MVAR's, they're looked up in
this MonoGenericContainer.
This is a Mono runtime internal function.
LOCKING: Acquires the loader lock.
mono_metadata_properties_from_typedef
Prototype: mono_metadata_properties_from_typedef
mono_metadata_string_heap
const char *
mono_metadata_string_heap (MonoImage *meta, guint32 index)
Parameters
meta: metadata contextindex: index into the string heap.
Returns
an in-memory pointer to the index in the string heap.
mono_metadata_token_from_dor
Prototype: mono_metadata_token_from_dor
mono_metadata_typedef_from_field
guint32
mono_metadata_typedef_from_field (MonoImage *meta, guint32 index)
Parameters
meta: metadata contextindex: FieldDef token
Returns
the 1-based index into the TypeDef table of the type that
declared the field described by index, or 0 if not found.
mono_metadata_typedef_from_method
Prototype: mono_metadata_typedef_from_method
mono_metadata_type_equal
Prototype: mono_metadata_type_equal
mono_metadata_type_hash
Prototype: mono_metadata_type_hash
mono_metadata_user_string
const char *
mono_metadata_user_string (MonoImage *meta, guint32 index)
Parameters
meta: metadata contextindex: index into the user string heap.
Returns
an in-memory pointer to the index in the user string heap ("US").
mono_metadata_declsec_from_index
Prototype: mono_metadata_declsec_from_index
mono_metadata_free_method_signature
Prototype: mono_metadata_free_method_signature
Generics Support
mono_metadata_generic_class_is_valuetype
Prototype: mono_metadata_generic_class_is_valuetype
mono_metadata_has_generic_params
Prototype: mono_metadata_has_generic_params
mono_metadata_inflate_generic_inst
Prototype: mono_metadata_inflate_generic_inst
mono_metadata_parse_generic_inst
Prototype: mono_metadata_parse_generic_inst
Tokens
mono_ldtoken
Prototype: mono_ldtoken
mono_lookup_dynamic_token
Prototype: mono_lookup_dynamic_token
mono_ldstr
MonoString*
mono_ldstr (MonoDomain *domain, MonoImage *image, guint32 idx)
Parameters
domain: the domain where the string will be used.image: a metadata contextidx: index into the user string table.
Returns
a loaded string from the image/idx combination.
Remarks
Implementation for the ldstr opcode.
mono_exception_from_token
MonoException*
mono_exception_from_token (MonoImage *image, guint32 token)
Parameters
image: the Mono image where to look for the classtoken: The type token of the class
Returns
the initialized exception instance.
Remarks
Creates an exception of the type given by
token.
mono_create_jit_trampoline_from_token
Prototype: mono_create_jit_trampoline_from_token
Working with signatures
mono_signature_explicit_this
Prototype: mono_signature_explicit_this
mono_signature_get_call_conv
Prototype: mono_signature_get_call_conv
mono_signature_get_desc
Prototype: mono_signature_get_desc
mono_signature_get_param_count
Prototype: mono_signature_get_param_count
mono_signature_get_params
Prototype: mono_signature_get_params
mono_signature_get_return_type
Prototype: mono_signature_get_return_type
mono_signature_hash
Prototype: mono_signature_hash
mono_signature_is_instance
Prototype: mono_signature_is_instance
mono_signature_vararg_start
Prototype: mono_signature_vararg_start
OpCodes
mono_opcode_name
Prototype: mono_opcode_name
mono_opcode_value
Prototype: mono_opcode_value
Metadata Loading Errors
The routines in this section are used to cope with errors
during metadata loading. Errors in metadata handling can
happen for many reason, and these include (this is not an
exhaustive list).
- An assembly referenced is missing.
- Fields referenced are missing.
- Methods referenced are missing.
The mono_loader_set_* routines are invoked during
metadata loading to flag that an error has happened. The
class loading errros are flagged in a per-thread basis.
In various spots in the runtime the
mono_loader_get_last_error routine is called to check
if there was a problem, and then errors are propagated upwards
on the stack until we reach a point where an exception can be
raised and no runtime locks are held.
The mono_loader_error_prepare_exception takes a
MonoLoaderError structure (the value returned from
mono_loader_get_last_error), turns that into an
exception and clears the error condition from the current
thread.
mono_loader_set_error_field_load
Prototype: mono_loader_set_error_field_load
mono_loader_set_error_method_load
Prototype: mono_loader_set_error_method_load
mono_loader_set_error_type_load
void
mono_loader_set_error_type_load (const char *class_name, const char *assembly_name)
Remarks
Set the loader error for this thread.
mono_loader_get_last_error
Prototype: mono_loader_get_last_error
mono_loader_clear_error
void
mono_loader_clear_error (void)
Remarks
Disposes any loader error messages on this thread