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"
10 #include "mono/utils/mono-compiler.h"
12 struct _MonoAssembly {
13 int ref_count; /* use atomic operations only */
15 MonoAssemblyName aname;
20 guint8 corlib_internal;
22 /* security manager flags (one bit is for lazy initialization) */
23 guint32 ecma:2; /* Has the ECMA key */
24 guint32 aptc:2; /* Has the [AllowPartiallyTrustedCallers] attributes */
25 guint32 fulltrust:2; /* Has FullTrust permission */
26 guint32 unmanaged:2; /* Has SecurityPermissionFlag.UnmanagedCode permission */
34 struct _MonoTableInfo {
40 * Tables contain up to 9 columns and the possible sizes of the
41 * fields in the documentation are 1, 2 and 4 bytes. So we
42 * can encode in 2 bits the size.
44 * A 32 bit value can encode the resulting size
46 * The top eight bits encode the number of columns in the table.
47 * we only need 4, but 8 is aligned no shift required.
49 guint32 size_bitfield;
55 /* if file_descr is NULL the image was loaded from raw data */
58 guint8 raw_data_allocated;
60 /* Whenever this is a dynamically emitted module */
63 /* Whenever this is a reflection only image */
67 const char *assembly_name;
68 const char *module_name;
70 gint16 md_version_major, md_version_minor;
77 guint8 idx_string_wide, idx_guid_wide, idx_blob_wide;
79 MonoStreamHeader heap_strings;
80 MonoStreamHeader heap_us;
81 MonoStreamHeader heap_blob;
82 MonoStreamHeader heap_guid;
83 MonoStreamHeader heap_tables;
85 const char *tables_base;
88 MonoTableInfo tables [MONO_TABLE_NUM];
91 * references is initialized only by using the mono_assembly_open
92 * function, and not by using the lowlevel mono_image_open.
94 * It is NULL terminated.
96 MonoAssembly **references;
104 * The Assembly this image was loaded from.
106 MonoAssembly *assembly;
109 * Indexed by method tokens and typedef tokens.
111 GHashTable *method_cache;
112 GHashTable *class_cache;
114 * Indexed by fielddef and memberref tokens
116 GHashTable *field_cache;
118 /* indexed by typespec tokens. */
119 GHashTable *typespec_cache;
120 /* indexed by token */
121 GHashTable *memberref_signatures;
122 GHashTable *helper_signatures;
125 * Indexes namespaces to hash tables that map class name to typedef token.
127 GHashTable *name_cache;
130 * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
131 * maximal rank of 255
133 GHashTable *array_cache;
136 * indexed by MonoMethodSignature
138 GHashTable *delegate_begin_invoke_cache;
139 GHashTable *delegate_end_invoke_cache;
140 GHashTable *delegate_invoke_cache;
143 * indexed by MonoMethod pointers
145 GHashTable *runtime_invoke_cache;
146 GHashTable *managed_wrapper_cache;
147 GHashTable *native_wrapper_cache;
148 GHashTable *remoting_invoke_cache;
149 GHashTable *synchronized_cache;
150 GHashTable *unbox_wrapper_cache;
152 void *reflection_info;
155 * user_info is a public field and is not touched by the
160 /* dll map entries */
174 guint32 alloc_size; /* malloced bytes */
176 guint32 offset; /* from start of metadata */
182 guint8 row_size; /* calculated later with column_sizes */
185 guint32 *values; /* rows * columns */
188 struct _MonoDynamicAssembly {
189 MonoAssembly assembly;
191 guint32 strong_name_size;
196 struct _MonoDynamicImage {
200 guint32 metadata_rva;
202 guint32 cli_header_offset;
206 guint32 imp_names_offset;
212 } sections [MONO_SECTION_MAX];
213 GHashTable *typespec;
215 GHashTable *handleref;
216 MonoGHashTable *tokens;
217 GHashTable *blob_cache;
218 GList *array_methods;
219 GPtrArray *gen_params;
220 MonoGHashTable *token_fixups;
221 GHashTable *method_to_table_idx;
222 GHashTable *field_to_table_idx;
223 GHashTable *method_aux_hash;
226 gboolean initial_image;
227 guint32 pe_kind, machine;
229 guint32 strong_name_size;
231 guint32 win32_res_size;
232 MonoDynamicStream sheap;
233 MonoDynamicStream code; /* used to store method headers and bytecode */
234 MonoDynamicStream resources; /* managed embedded resources */
235 MonoDynamicStream us;
236 MonoDynamicStream blob;
237 MonoDynamicStream tstream;
238 MonoDynamicStream guid;
239 MonoDynamicTable tables [MONO_TABLE_NUM];
242 /* Contains information about assembly binding */
243 typedef struct _MonoAssemblyBindingInfo {
246 guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
249 AssemblyVersionSet old_version_bottom;
250 AssemblyVersionSet old_version_top;
251 AssemblyVersionSet new_version;
252 guint has_old_version_bottom : 1;
253 guint has_old_version_top : 1;
254 guint has_new_version : 1;
256 } MonoAssemblyBindingInfo;
258 struct _MonoMethodHeader {
260 const unsigned char *code;
262 unsigned int num_clauses : 15;
263 /* if num_locals != 0, then the following apply: */
264 unsigned int init_locals : 1;
266 MonoExceptionClause *clauses;
267 MonoType *locals [MONO_ZERO_LEN_ARRAY];
270 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
271 guint mono_aligned_addr_hash (gconstpointer ptr) MONO_INTERNAL;
273 const char * mono_meta_table_name (int table) MONO_INTERNAL;
274 void mono_metadata_compute_table_bases (MonoImage *meta) MONO_INTERNAL;
277 mono_metadata_interfaces_from_typedef_full (MonoImage *image,
279 MonoClass ***interfaces,
281 MonoGenericContext *context) MONO_INTERNAL;
284 mono_metadata_parse_array_full (MonoImage *image,
285 MonoGenericContainer *container,
287 const char **rptr) MONO_INTERNAL;
290 mono_metadata_parse_type_full (MonoImage *image,
291 MonoGenericContainer *container,
292 MonoParseTypeMode mode,
297 MonoMethodSignature *
298 mono_metadata_parse_signature_full (MonoImage *image,
299 MonoGenericContainer *generic_container,
300 guint32 token) MONO_INTERNAL;
302 MonoMethodSignature *
303 mono_metadata_parse_method_signature_full (MonoImage *image,
304 MonoGenericContainer *generic_container,
310 mono_metadata_parse_mh_full (MonoImage *image,
311 MonoGenericContainer *container,
315 mono_metadata_generic_method_hash (MonoGenericMethod *gmethod) MONO_INTERNAL;
318 mono_metadata_generic_method_equal (MonoGenericMethod *g1,
319 MonoGenericMethod *g2) MONO_INTERNAL;
322 mono_metadata_parse_generic_inst (MonoImage *image,
323 MonoGenericContainer *container,
326 const char **rptr) MONO_INTERNAL;
329 mono_metadata_lookup_generic_inst (MonoGenericInst *ginst) MONO_INTERNAL;
332 mono_metadata_lookup_generic_class (MonoGenericClass *gclass) MONO_INTERNAL;
335 mono_metadata_inflate_generic_inst (MonoGenericInst *ginst,
336 MonoGenericContext *context) MONO_INTERNAL;
338 void mono_dynamic_stream_reset (MonoDynamicStream* stream) MONO_INTERNAL;
339 void mono_assembly_addref (MonoAssembly *assembly) MONO_INTERNAL;
341 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info) MONO_INTERNAL;
344 mono_assembly_name_parse_full (const char *name,
345 MonoAssemblyName *aname,
346 gboolean save_public_key,
347 gboolean *is_version_defined) MONO_INTERNAL;
349 guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
351 #endif /* __MONO_METADATA_INTERNALS_H__ */