X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fimage.h;h=a42be33a3e4eaa981dab58f76627e2533816ac62;hb=0840a96eee4cf277f1d47b3a35784b41e580aee4;hp=a207d9697d042c06e096801395afdb09d053cd6c;hpb=594de034a4461c3cfbfd06a64569c6e39168f983;p=mono.git diff --git a/mono/metadata/image.h b/mono/metadata/image.h index a207d9697d0..a42be33a3e4 100644 --- a/mono/metadata/image.h +++ b/mono/metadata/image.h @@ -2,162 +2,14 @@ #define _MONONET_METADATA_IMAGE_H_ #include -#include -#include +#include -typedef struct _MonoImage MonoImage; - -typedef struct { - const char *name; - const char *culture; - const char *hash_value; - const guint8* public_key; - const char *public_tok_value; - guint32 hash_alg; - guint32 hash_len; - guint32 flags; - guint16 major, minor, build, revision; -} MonoAssemblyName; - -typedef struct { - int ref_count; - char *basedir; - gboolean in_gac; - MonoAssemblyName aname; - GModule *aot_module; - MonoImage *image; - /* Load files here */ - gboolean dynamic; -} MonoAssembly; - -typedef struct { - const char* data; - guint32 size; -} MonoStreamHeader; - -typedef struct { - guint32 rows, row_size; - const char *base; - - /* - * Tables contain up to 9 columns and the possible sizes of the - * fields in the documentation are 1, 2 and 4 bytes. So we - * can encode in 2 bits the size. - * - * A 32 bit value can encode the resulting size - * - * The top eight bits encode the number of columns in the table. - * we only need 4, but 8 is aligned no shift required. - */ - guint32 size_bitfield; -} MonoTableInfo; - -struct _MonoImage { - int ref_count; - FILE *f; - /* if f is NULL the image was loaded from raw data */ - char *raw_data; - guint32 raw_data_len; - gboolean raw_data_allocated; - char *name; - const char *assembly_name; - const char *module_name; - const char *version; - char *guid; - void *image_info; - - char *raw_metadata; - - gboolean idx_string_wide, idx_guid_wide, idx_blob_wide; - - MonoStreamHeader heap_strings; - MonoStreamHeader heap_us; - MonoStreamHeader heap_blob; - MonoStreamHeader heap_guid; - MonoStreamHeader heap_tables; - - const char *tables_base; - - MonoTableInfo tables [64]; - - /* - * references is initialized only by using the mono_assembly_open - * function, and not by using the lowlevel mono_image_open. - * - * It is NULL terminated. - */ - MonoAssembly **references; - - MonoImage **modules; - - MonoImage **files; - - /* - * The Assembly this image was loaded from. - */ - MonoAssembly *assembly; - - /* - * Indexed by method tokens and typedef tokens. - */ - GHashTable *method_cache; - GHashTable *class_cache; - /* - * Indexed by fielddef and memberref tokens - */ - GHashTable *field_cache; +MONO_BEGIN_DECLS - /* indexed by typespec tokens. */ - GHashTable *typespec_cache; - /* indexed by token */ - GHashTable *memberref_signatures; - - /* - * Indexed by MonoGenericInst. - */ - GHashTable *generic_inst_cache; - - /* - * Indexes namespaces to hash tables that map class name to typedef token. - */ - GHashTable *name_cache; - - /* - * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a - * maximal rank of 255 - */ - GHashTable *array_cache; - - /* - * indexed by MonoMethodSignature - */ - GHashTable *delegate_begin_invoke_cache; - GHashTable *delegate_end_invoke_cache; - GHashTable *delegate_invoke_cache; - - /* - * indexed by MonoMethod pointers - */ - GHashTable *runtime_invoke_cache; - GHashTable *managed_wrapper_cache; - GHashTable *native_wrapper_cache; - GHashTable *remoting_invoke_cache; - GHashTable *synchronized_cache; - - void *reflection_info; - - /* - * user_info is a public field and is not touched by the - * metadata engine - */ - void *user_info; - - /* dll map entries */ - GHashTable *dll_map; - - /* Whenever this is a dynamically emitted module */ - gboolean dynamic; -}; +typedef struct _MonoImage MonoImage; +typedef struct _MonoAssembly MonoAssembly; +typedef struct _MonoAssemblyName MonoAssemblyName; +typedef struct _MonoTableInfo MonoTableInfo; typedef enum { MONO_IMAGE_OK, @@ -167,13 +19,25 @@ typedef enum { } MonoImageOpenStatus; void mono_images_init (void); +void mono_images_cleanup (void); MonoImage *mono_image_open (const char *fname, MonoImageOpenStatus *status); -MonoImage *mono_image_open_from_data (char *data, guint32 data_len, gboolean need_copy, +MonoImage *mono_image_open_full (const char *fname, + MonoImageOpenStatus *status, mono_bool refonly); +MonoImage *mono_pe_file_open (const char *fname, + MonoImageOpenStatus *status); +MonoImage *mono_image_open_from_data (char *data, uint32_t data_len, mono_bool need_copy, MonoImageOpenStatus *status); +MonoImage *mono_image_open_from_data_full (char *data, uint32_t data_len, mono_bool need_copy, + MonoImageOpenStatus *status, mono_bool refonly); +MonoImage *mono_image_open_from_data_with_name (char *data, uint32_t data_len, mono_bool need_copy, + MonoImageOpenStatus *status, mono_bool refonly, const char *name); +void mono_image_fixup_vtable (MonoImage *image); MonoImage *mono_image_loaded (const char *name); +MonoImage *mono_image_loaded_full (const char *name, mono_bool refonly); MonoImage *mono_image_loaded_by_guid (const char *guid); +MonoImage *mono_image_loaded_by_guid_full (const char *guid, mono_bool refonly); void mono_image_init (MonoImage *image); void mono_image_close (MonoImage *image); void mono_image_addref (MonoImage *image); @@ -184,21 +48,36 @@ int mono_image_ensure_section (MonoImage *image, int mono_image_ensure_section_idx (MonoImage *image, int section); -guint32 mono_image_get_entry_point (MonoImage *image); -const char *mono_image_get_resource (MonoImage *image, guint32 offset, guint32 *size); +uint32_t mono_image_get_entry_point (MonoImage *image); +const char *mono_image_get_resource (MonoImage *image, uint32_t offset, uint32_t *size); MonoImage* mono_image_load_file_for_image (MonoImage *image, int fileidx); +MonoImage* mono_image_load_module (MonoImage *image, int idx); + +const char* mono_image_get_name (MonoImage *image); +const char* mono_image_get_filename (MonoImage *image); +const char * mono_image_get_guid (MonoImage *image); +MonoAssembly* mono_image_get_assembly (MonoImage *image); +mono_bool mono_image_is_dynamic (MonoImage *image); +char* mono_image_rva_map (MonoImage *image, uint32_t rva); + +const MonoTableInfo *mono_image_get_table_info (MonoImage *image, int table_id); +int mono_image_get_table_rows (MonoImage *image, int table_id); +int mono_table_info_get_rows (const MonoTableInfo *table); + /* This actually returns a MonoPEResourceDataEntry *, but declaring it * causes an include file loop. */ -gpointer mono_image_lookup_resource (MonoImage *image, guint32 res_id, - guint32 lang_id, gunichar2 *name); +void* mono_image_lookup_resource (MonoImage *image, uint32_t res_id, + uint32_t lang_id, mono_unichar2 *name); -const char* mono_image_get_public_key (MonoImage *image, guint32 *size); -const char* mono_image_get_strong_name (MonoImage *image, guint32 *size); -guint32 mono_image_strong_name_position (MonoImage *image, guint32 *size); +const char* mono_image_get_public_key (MonoImage *image, uint32_t *size); +const char* mono_image_get_strong_name (MonoImage *image, uint32_t *size); +uint32_t mono_image_strong_name_position (MonoImage *image, uint32_t *size); void mono_image_add_to_name_cache (MonoImage *image, - const char *nspace, - const char *name, guint32 idx); + const char *nspace, const char *name, uint32_t idx); +mono_bool mono_image_has_authenticode_entry (MonoImage *image); + +MONO_END_DECLS #endif