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"
11 #include "mono/utils/monobitset.h"
13 struct _MonoAssembly {
14 /* The number of appdomains which have this assembly loaded. Initially 0 */
15 int ref_count; /* use atomic operations only */
17 MonoAssemblyName aname;
20 GSList *friend_assembly_names;
23 guint8 corlib_internal;
25 /* security manager flags (one bit is for lazy initialization) */
26 guint32 ecma:2; /* Has the ECMA key */
27 guint32 aptc:2; /* Has the [AllowPartiallyTrustedCallers] attributes */
28 guint32 fulltrust:2; /* Has FullTrust permission */
29 guint32 unmanaged:2; /* Has SecurityPermissionFlag.UnmanagedCode permission */
37 struct _MonoTableInfo {
43 * Tables contain up to 9 columns and the possible sizes of the
44 * fields in the documentation are 1, 2 and 4 bytes. So we
45 * can encode in 2 bits the size.
47 * A 32 bit value can encode the resulting size
49 * The top eight bits encode the number of columns in the table.
50 * we only need 4, but 8 is aligned no shift required.
52 guint32 size_bitfield;
57 * The number of assemblies which reference this MonoImage though their 'image'
62 /* if file_descr is NULL the image was loaded from raw data */
65 guint8 raw_data_allocated;
67 /* Whenever this is a dynamically emitted module */
70 /* Whenever this is a reflection only image */
74 const char *assembly_name;
75 const char *module_name;
77 gint16 md_version_major, md_version_minor;
84 guint8 idx_string_wide, idx_guid_wide, idx_blob_wide;
86 MonoStreamHeader heap_strings;
87 MonoStreamHeader heap_us;
88 MonoStreamHeader heap_blob;
89 MonoStreamHeader heap_guid;
90 MonoStreamHeader heap_tables;
92 const char *tables_base;
95 MonoTableInfo tables [MONO_TABLE_NUM];
98 * references is initialized only by using the mono_assembly_open
99 * function, and not by using the lowlevel mono_image_open.
101 * It is NULL terminated.
103 MonoAssembly **references;
106 guint32 module_count;
111 * The Assembly this image was loaded from.
113 MonoAssembly *assembly;
116 * Indexed by method tokens and typedef tokens.
118 GHashTable *method_cache;
119 GHashTable *class_cache;
121 * Indexed by fielddef and memberref tokens
123 GHashTable *field_cache;
125 /* indexed by typespec tokens. */
126 GHashTable *typespec_cache;
127 /* indexed by token */
128 GHashTable *memberref_signatures;
129 GHashTable *helper_signatures;
132 * Indexes namespaces to hash tables that map class name to typedef token.
134 GHashTable *name_cache;
137 * Indexed by ((rank << 24) | (typedef & 0xffffff)), which limits us to a
138 * maximal rank of 255
140 GHashTable *array_cache;
143 * indexed by MonoMethodSignature
145 GHashTable *delegate_begin_invoke_cache;
146 GHashTable *delegate_end_invoke_cache;
147 GHashTable *delegate_invoke_cache;
150 * indexed by MonoMethod pointers
152 GHashTable *runtime_invoke_cache;
153 GHashTable *managed_wrapper_cache;
154 GHashTable *native_wrapper_cache;
155 GHashTable *remoting_invoke_cache;
156 GHashTable *synchronized_cache;
157 GHashTable *unbox_wrapper_cache;
159 void *reflection_info;
162 * user_info is a public field and is not touched by the
167 /* dll map entries */
170 /* interfaces IDs from this image */
171 MonoBitSet *interface_bitset;
184 guint32 alloc_size; /* malloced bytes */
186 guint32 offset; /* from start of metadata */
192 guint8 row_size; /* calculated later with column_sizes */
195 guint32 *values; /* rows * columns */
198 struct _MonoDynamicAssembly {
199 MonoAssembly assembly;
201 guint32 strong_name_size;
206 struct _MonoDynamicImage {
210 guint32 metadata_rva;
212 guint32 cli_header_offset;
216 guint32 imp_names_offset;
222 } sections [MONO_SECTION_MAX];
223 GHashTable *typespec;
225 GHashTable *handleref;
226 MonoGHashTable *tokens;
227 GHashTable *blob_cache;
228 GList *array_methods;
229 GPtrArray *gen_params;
230 MonoGHashTable *token_fixups;
231 GHashTable *method_to_table_idx;
232 GHashTable *field_to_table_idx;
233 GHashTable *method_aux_hash;
236 gboolean initial_image;
237 guint32 pe_kind, machine;
239 guint32 strong_name_size;
241 guint32 win32_res_size;
242 MonoDynamicStream sheap;
243 MonoDynamicStream code; /* used to store method headers and bytecode */
244 MonoDynamicStream resources; /* managed embedded resources */
245 MonoDynamicStream us;
246 MonoDynamicStream blob;
247 MonoDynamicStream tstream;
248 MonoDynamicStream guid;
249 MonoDynamicTable tables [MONO_TABLE_NUM];
252 /* Contains information about assembly binding */
253 typedef struct _MonoAssemblyBindingInfo {
256 guchar public_key_token [MONO_PUBLIC_KEY_TOKEN_LENGTH];
259 AssemblyVersionSet old_version_bottom;
260 AssemblyVersionSet old_version_top;
261 AssemblyVersionSet new_version;
262 guint has_old_version_bottom : 1;
263 guint has_old_version_top : 1;
264 guint has_new_version : 1;
266 } MonoAssemblyBindingInfo;
268 struct _MonoMethodHeader {
270 const unsigned char *code;
272 unsigned int num_clauses : 15;
273 /* if num_locals != 0, then the following apply: */
274 unsigned int init_locals : 1;
276 MonoExceptionClause *clauses;
277 MonoType *locals [MONO_ZERO_LEN_ARRAY];
280 /* for use with allocated memory blocks (assumes alignment is to 8 bytes) */
281 guint mono_aligned_addr_hash (gconstpointer ptr) MONO_INTERNAL;
283 const char * mono_meta_table_name (int table) MONO_INTERNAL;
284 void mono_metadata_compute_table_bases (MonoImage *meta) MONO_INTERNAL;
287 mono_metadata_interfaces_from_typedef_full (MonoImage *image,
289 MonoClass ***interfaces,
291 MonoGenericContext *context) MONO_INTERNAL;
294 mono_metadata_parse_array_full (MonoImage *image,
295 MonoGenericContainer *container,
297 const char **rptr) MONO_INTERNAL;
300 mono_metadata_parse_type_full (MonoImage *image,
301 MonoGenericContainer *container,
302 MonoParseTypeMode mode,
307 MonoMethodSignature *
308 mono_metadata_parse_signature_full (MonoImage *image,
309 MonoGenericContainer *generic_container,
310 guint32 token) MONO_INTERNAL;
312 MonoMethodSignature *
313 mono_metadata_parse_method_signature_full (MonoImage *image,
314 MonoGenericContainer *generic_container,
320 mono_metadata_parse_mh_full (MonoImage *image,
321 MonoGenericContainer *container,
325 mono_metadata_generic_method_hash (MonoGenericMethod *gmethod) MONO_INTERNAL;
328 mono_metadata_generic_method_equal (MonoGenericMethod *g1,
329 MonoGenericMethod *g2) MONO_INTERNAL;
332 mono_metadata_parse_generic_inst (MonoImage *image,
333 MonoGenericContainer *container,
336 const char **rptr) MONO_INTERNAL;
339 mono_metadata_lookup_generic_inst (MonoGenericInst *ginst) MONO_INTERNAL;
342 mono_metadata_lookup_generic_class (MonoGenericClass *gclass) MONO_INTERNAL;
345 mono_metadata_inflate_generic_inst (MonoGenericInst *ginst,
346 MonoGenericContext *context) MONO_INTERNAL;
348 void mono_dynamic_stream_reset (MonoDynamicStream* stream) MONO_INTERNAL;
349 void mono_assembly_addref (MonoAssembly *assembly) MONO_INTERNAL;
351 void mono_config_parse_publisher_policy (const char *filename, MonoAssemblyBindingInfo *binding_info) MONO_INTERNAL;
354 mono_assembly_name_parse_full (const char *name,
355 MonoAssemblyName *aname,
356 gboolean save_public_key,
357 gboolean *is_version_defined) MONO_INTERNAL;
359 guint32 mono_metadata_get_generic_param_row (MonoImage *image, guint32 token, guint32 *owner);
361 void mono_unload_interface_ids (MonoBitSet *bitset) MONO_INTERNAL;
363 #endif /* __MONO_METADATA_INTERNALS_H__ */