2 #ifndef __MONO_METADATA_INTERNALS_H__
3 #define __MONO_METADATA_INTERNALS_H__
5 #include "mono/metadata/image.h"
6 #include "mono/metadata/blob.h"
7 #include "mono/metadata/mempool.h"
8 #include "mono/metadata/domain-internals.h"
9 #include "mono/utils/mono-hash.h"
11 struct _MonoAssembly {
12 int ref_count; /* use atomic operations only */
14 MonoAssemblyName aname;
19 guint8 corlib_internal;
21 /* security manager flags (one bit is for lazy initialization) */
22 guint32 ecma:2; /* Has the ECMA key */
23 guint32 aptc:2; /* Has the [AllowPartiallyTrustedCallers] attributes */
24 guint32 fulltrust:2; /* Has FullTrust permission */
25 guint32 unmanaged:2; /* Has SecurityPermissionFlag.UnmanagedCode permission */
33 struct _MonoTableInfo {
39 * Tables contain up to 9 columns and the possible sizes of the
40 * fields in the documentation are 1, 2 and 4 bytes. So we
41 * can encode in 2 bits the size.
43 * A 32 bit value can encode the resulting size
45 * The top eight bits encode the number of columns in the table.
46 * we only need 4, but 8 is aligned no shift required.
48 guint32 size_bitfield;
54 /* if file_descr is NULL the image was loaded from raw data */
57 guint8 raw_data_allocated;
59 /* Whenever this is a dynamically emitted module */
62 /* Whenever this is a reflection only image */
66 const char *assembly_name;
67 const char *module_name;
69 gint16 md_version_major, md_version_minor;
76 guint8 idx_string_wide, idx_guid_wide, idx_blob_wide;
78 MonoStreamHeader heap_strings;
79 MonoStreamHeader heap_us;
80 MonoStreamHeader heap_blob;
81 MonoStreamHeader heap_guid;
82 MonoStreamHeader heap_tables;
84 const char *tables_base;
87 MonoTableInfo tables [MONO_TABLE_NUM];
90 * references is initialized only by using the mono_assembly_open
91 * function, and not by using the lowlevel mono_image_open.
93 * It is NULL terminated.
95 MonoAssembly **references;
103 * The Assembly this image was loaded from.
105 MonoAssembly *assembly;
108 * Indexed by method tokens and typedef tokens.
110 GHashTable *method_cache;
111 GHashTable *class_cache;
113 * Indexed by fielddef and memberref tokens
115 GHashTable *field_cache;
117 /* indexed by typespec tokens. */
118 GHashTable *typespec_cache;
119 /* indexed by token */
120 GHashTable *memberref_signatures;
121 GHashTable *helper_signatures;
124 * Indexes namespaces to hash tables that map class name to typedef token.
126 GHashTable *name_cache;
129 * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
130 * maximal rank of 255
132 GHashTable *array_cache;
135 * indexed by MonoMethodSignature
137 GHashTable *delegate_begin_invoke_cache;
138 GHashTable *delegate_end_invoke_cache;
139 GHashTable *delegate_invoke_cache;
142 * indexed by MonoMethod pointers
144 GHashTable *runtime_invoke_cache;
145 GHashTable *managed_wrapper_cache;
146 GHashTable *native_wrapper_cache;
147 GHashTable *remoting_invoke_cache;
148 GHashTable *synchronized_cache;
149 GHashTable *unbox_wrapper_cache;
151 void *reflection_info;
154 * user_info is a public field and is not touched by the
159 /* dll map entries */
173 guint32 alloc_size; /* malloced bytes */
175 guint32 offset; /* from start of metadata */
181 guint8 row_size; /* calculated later with column_sizes */
184 guint32 *values; /* rows * columns */
187 struct _MonoDynamicAssembly {
188 MonoAssembly assembly;
190 guint32 strong_name_size;
195 struct _MonoDynamicImage {
199 guint32 metadata_rva;
201 guint32 cli_header_offset;
205 guint32 imp_names_offset;
211 } sections [MONO_SECTION_MAX];
212 GHashTable *typespec;
214 GHashTable *handleref;
215 MonoGHashTable *tokens;
216 GHashTable *blob_cache;
217 GList *array_methods;
218 GPtrArray *gen_params;
219 MonoGHashTable *token_fixups;
220 GHashTable *method_to_table_idx;
221 GHashTable *field_to_table_idx;
222 GHashTable *method_aux_hash;
225 gboolean initial_image;
226 guint32 pe_kind, machine;
228 guint32 strong_name_size;
230 guint32 win32_res_size;
231 MonoDynamicStream sheap;
232 MonoDynamicStream code; /* used to store method headers and bytecode */
233 MonoDynamicStream resources; /* managed embedded resources */
234 MonoDynamicStream us;
235 MonoDynamicStream blob;
236 MonoDynamicStream tstream;
237 MonoDynamicStream guid;
238 MonoDynamicTable tables [MONO_TABLE_NUM];
241 /* Contains information about assembly binding */
242 typedef struct _MonoAssemblyBindingInfo {
245 guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
248 AssemblyVersionSet old_version_bottom;
249 AssemblyVersionSet old_version_top;
250 AssemblyVersionSet new_version;
251 guint has_old_version_bottom : 1;
252 guint has_old_version_top : 1;
253 guint has_new_version : 1;
255 } MonoAssemblyBindingInfo;
257 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
258 guint mono_aligned_addr_hash (gconstpointer ptr);
260 const char * mono_meta_table_name (int table);
261 void mono_metadata_compute_table_bases (MonoImage *meta);
264 mono_metadata_interfaces_from_typedef_full (MonoImage *image,
266 MonoClass ***interfaces,
268 MonoGenericContext *context);
271 mono_metadata_parse_array_full (MonoImage *image,
272 MonoGenericContext *generic_context,
277 mono_metadata_parse_type_full (MonoImage *image,
278 MonoGenericContext *generic_context,
279 MonoParseTypeMode mode,
285 mono_type_create_from_typespec_full (MonoImage *image,
286 MonoGenericContext *generic_context,
289 MonoMethodSignature *
290 mono_metadata_parse_signature_full (MonoImage *image,
291 MonoGenericContainer *generic_container,
294 MonoMethodSignature *
295 mono_metadata_parse_method_signature_full (MonoImage *image,
296 MonoGenericContainer *generic_container,
302 mono_metadata_parse_mh_full (MonoImage *image,
303 MonoGenericContext *generic_context,
307 mono_metadata_generic_method_hash (MonoGenericMethod *gmethod);
310 mono_metadata_generic_method_equal (MonoGenericMethod *g1,
311 MonoGenericMethod *g2);
314 mono_metadata_parse_generic_inst (MonoImage *image,
315 MonoGenericContext *generic_context,
321 mono_metadata_lookup_generic_inst (MonoGenericInst *ginst);
324 mono_metadata_lookup_generic_class (MonoGenericClass *gclass);
327 mono_metadata_inflate_generic_inst (MonoGenericInst *ginst,
328 MonoGenericContext *context);
330 void mono_dynamic_stream_reset (MonoDynamicStream* stream);
331 void mono_assembly_addref (MonoAssembly *assembly);
333 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info);
336 mono_assembly_name_parse_full (const char *name,
337 MonoAssemblyName *aname,
338 gboolean save_public_key,
339 gboolean *is_version_defined);
341 guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
343 #endif /* __MONO_METADATA_INTERNALS_H__ */