MonoTableInfo *t;
int i;
char *base_dir;
- MonoImage **modules;
if (image->modules)
return;
t = &image->tables [MONO_TABLE_MODULEREF];
image->modules = g_new0 (MonoImage *, t->rows);
- image->module_count = 0;
+ image->module_count = t->rows;
base_dir = g_path_get_dirname (image->name);
for (i = 0; i < t->rows; i++){
char *module_ref;
mono_metadata_decode_row (t, i, cols, MONO_MODULEREF_SIZE);
name = mono_metadata_string_heap (image, cols [MONO_MODULEREF_NAME]);
module_ref = g_build_filename (base_dir, name, NULL);
- image->modules [image->module_count] = mono_image_open (module_ref, status);
- if (image->modules [image->module_count]) {
- image->module_count ++;
+ image->modules [i] = mono_image_open (module_ref, status);
+ if (image->modules [i]) {
/* g_print ("loaded module %s from %s (%p)\n", module_ref, image->name, image->assembly); */
}
/*
image->native_wrapper_cache = g_hash_table_new (NULL, NULL);
image->remoting_invoke_cache = g_hash_table_new (NULL, NULL);
image->synchronized_cache = g_hash_table_new (NULL, NULL);
+ image->unbox_wrapper_cache = g_hash_table_new (NULL, NULL);
image->typespec_cache = g_hash_table_new (NULL, NULL);
image->memberref_signatures = g_hash_table_new (NULL, NULL);
image->helper_signatures = g_hash_table_new (g_str_hash, g_str_equal);
-
- image->generic_inst_cache =
- g_hash_table_new ((GHashFunc)mono_metadata_generic_inst_hash,
- (GCompareFunc)mono_metadata_generic_inst_equal);
}
static MonoImage *
return image2;
}
g_hash_table_insert (loaded_images_hash, image->name, image);
- if (image->assembly_name)
+ if (image->assembly_name && (g_hash_table_lookup (loaded_images_hash, image->assembly_name) == NULL))
g_hash_table_insert (loaded_images_hash, (char *) image->assembly_name, image);
g_hash_table_insert (loaded_images_guid_hash, image->guid, image);
LeaveCriticalSection (&images_mutex);
mono_metadata_free_method_signature ((MonoMethodSignature*)val);
}
+static void
+free_remoting_wrappers (gpointer key, gpointer val, gpointer user_data)
+{
+ g_free (val);
+}
+
/**
* mono_image_addref:
* @image: The image file we wish to add a reference to
if (image == image2) {
/* This is not true if we are called from mono_image_open () */
g_hash_table_remove (loaded_images_hash, image->name);
- if (image->assembly_name)
- g_hash_table_remove (loaded_images_hash, (char *) image->assembly_name);
g_hash_table_remove (loaded_images_guid_hash, image->guid);
/* Multiple images might have the same guid */
build_guid_table ();
- }
+ }
+ if (image->assembly_name && (g_hash_table_lookup (loaded_images_hash, image->assembly_name) == image))
+ g_hash_table_remove (loaded_images_hash, (char *) image->assembly_name);
LeaveCriticalSection (&images_mutex);
if (image->f)
g_free (image->raw_data);
}
g_free (image->name);
+ g_free (image->guid);
g_free (image->files);
g_hash_table_destroy (image->method_cache);
g_hash_table_destroy (image->delegate_begin_invoke_cache);
g_hash_table_destroy (image->delegate_end_invoke_cache);
g_hash_table_destroy (image->delegate_invoke_cache);
+ g_hash_table_foreach (image->remoting_invoke_cache, free_remoting_wrappers, NULL);
g_hash_table_destroy (image->remoting_invoke_cache);
g_hash_table_destroy (image->runtime_invoke_cache);
+ g_hash_table_destroy (image->synchronized_cache);
+ g_hash_table_destroy (image->unbox_wrapper_cache);
g_hash_table_destroy (image->typespec_cache);
- g_hash_table_destroy (image->generic_inst_cache);
g_hash_table_foreach (image->memberref_signatures, free_mr_signatures, NULL);
g_hash_table_destroy (image->memberref_signatures);
g_hash_table_foreach (image->helper_signatures, free_mr_signatures, NULL);
}
int
-mono_table_info_get_rows (MonoTableInfo *table)
+mono_table_info_get_rows (const MonoTableInfo *table)
{
return table->rows;
}
return image->dynamic;
}
-
+gboolean
+mono_image_has_authenticode_entry (MonoImage *image)
+{
+ MonoCLIImageInfo *iinfo = image->image_info;
+ MonoDotNetHeader *header = &iinfo->cli_header;
+ MonoPEDirEntry *de = &header->datadir.pe_certificate_table;
+ // the Authenticode "pre" (non ASN.1) header is 8 bytes long
+ return ((de->rva != 0) && (de->size > 8));
+}