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;
75 guint8 idx_string_wide, idx_guid_wide, idx_blob_wide;
77 MonoStreamHeader heap_strings;
78 MonoStreamHeader heap_us;
79 MonoStreamHeader heap_blob;
80 MonoStreamHeader heap_guid;
81 MonoStreamHeader heap_tables;
83 const char *tables_base;
86 MonoTableInfo tables [MONO_TABLE_NUM];
89 * references is initialized only by using the mono_assembly_open
90 * function, and not by using the lowlevel mono_image_open.
92 * It is NULL terminated.
94 MonoAssembly **references;
102 * The Assembly this image was loaded from.
104 MonoAssembly *assembly;
107 * Indexed by method tokens and typedef tokens.
109 GHashTable *method_cache;
110 GHashTable *class_cache;
112 * Indexed by fielddef and memberref tokens
114 GHashTable *field_cache;
116 /* indexed by typespec tokens. */
117 GHashTable *typespec_cache;
118 /* indexed by token */
119 GHashTable *memberref_signatures;
120 GHashTable *helper_signatures;
123 * Indexes namespaces to hash tables that map class name to typedef token.
125 GHashTable *name_cache;
128 * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
129 * maximal rank of 255
131 GHashTable *array_cache;
134 * indexed by MonoMethodSignature
136 GHashTable *delegate_begin_invoke_cache;
137 GHashTable *delegate_end_invoke_cache;
138 GHashTable *delegate_invoke_cache;
141 * indexed by MonoMethod pointers
143 GHashTable *runtime_invoke_cache;
144 GHashTable *managed_wrapper_cache;
145 GHashTable *native_wrapper_cache;
146 GHashTable *remoting_invoke_cache;
147 GHashTable *synchronized_cache;
148 GHashTable *unbox_wrapper_cache;
150 void *reflection_info;
153 * user_info is a public field and is not touched by the
158 /* dll map entries */
172 guint32 alloc_size; /* malloced bytes */
174 guint32 offset; /* from start of metadata */
180 guint8 row_size; /* calculated later with column_sizes */
183 guint32 *values; /* rows * columns */
186 struct _MonoDynamicAssembly {
187 MonoAssembly assembly;
189 guint32 strong_name_size;
194 struct _MonoDynamicImage {
198 guint32 metadata_rva;
200 guint32 cli_header_offset;
204 guint32 imp_names_offset;
210 } sections [MONO_SECTION_MAX];
211 GHashTable *typespec;
213 GHashTable *handleref;
214 MonoGHashTable *tokens;
215 GHashTable *blob_cache;
216 GList *array_methods;
217 GPtrArray *gen_params;
218 MonoGHashTable *token_fixups;
219 GHashTable *method_to_table_idx;
220 GHashTable *field_to_table_idx;
221 GHashTable *method_aux_hash;
224 gboolean initial_image;
225 guint32 pe_kind, machine;
227 guint32 strong_name_size;
229 guint32 win32_res_size;
230 MonoDynamicStream sheap;
231 MonoDynamicStream code; /* used to store method headers and bytecode */
232 MonoDynamicStream resources; /* managed embedded resources */
233 MonoDynamicStream us;
234 MonoDynamicStream blob;
235 MonoDynamicStream tstream;
236 MonoDynamicStream guid;
237 MonoDynamicTable tables [MONO_TABLE_NUM];
240 /* Contains information about assembly binding */
241 typedef struct _MonoAssemblyBindingInfo {
244 guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
247 AssemblyVersionSet old_version_bottom;
248 AssemblyVersionSet old_version_top;
249 AssemblyVersionSet new_version;
250 guint has_old_version_bottom : 1;
251 guint has_old_version_top : 1;
252 guint has_new_version : 1;
254 } MonoAssemblyBindingInfo;
256 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
257 guint mono_aligned_addr_hash (gconstpointer ptr);
259 const char * mono_meta_table_name (int table);
260 void mono_metadata_compute_table_bases (MonoImage *meta);
263 mono_metadata_interfaces_from_typedef_full (MonoImage *image,
266 MonoGenericContext *context);
269 mono_metadata_parse_array_full (MonoImage *image,
270 MonoGenericContext *generic_context,
275 mono_metadata_parse_type_full (MonoImage *image,
276 MonoGenericContext *generic_context,
277 MonoParseTypeMode mode,
283 mono_type_create_from_typespec_full (MonoImage *image,
284 MonoGenericContext *generic_context,
287 MonoMethodSignature *
288 mono_metadata_parse_signature_full (MonoImage *image,
289 MonoGenericContext *generic_context,
292 MonoMethodSignature *
293 mono_metadata_parse_method_signature_full (MonoImage *image,
294 MonoGenericContext *generic_context,
300 mono_metadata_parse_mh_full (MonoImage *image,
301 MonoGenericContext *generic_context,
305 mono_metadata_generic_method_hash (MonoGenericMethod *gmethod);
308 mono_metadata_generic_method_equal (MonoGenericMethod *g1,
309 MonoGenericMethod *g2);
312 mono_metadata_parse_generic_inst (MonoImage *image,
313 MonoGenericContext *generic_context,
319 mono_metadata_lookup_generic_inst (MonoGenericInst *ginst);
322 mono_metadata_lookup_generic_class (MonoGenericClass *gclass);
325 mono_metadata_inflate_generic_inst (MonoGenericInst *ginst,
326 MonoGenericContext *context);
328 void mono_dynamic_stream_reset (MonoDynamicStream* stream);
329 void mono_assembly_addref (MonoAssembly *assembly);
331 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info);
333 #endif /* __MONO_METADATA_INTERNALS_H__ */