static GHashTable *loaded_images_guid_hash;
static GHashTable *loaded_images_refonly_hash;
static GHashTable *loaded_images_refonly_guid_hash;
-
+#define mono_images_lock() EnterCriticalSection (&images_mutex)
+#define mono_images_unlock() LeaveCriticalSection (&images_mutex)
static CRITICAL_SECTION images_mutex;
guint32
if (strncmp (ptr, "BSJB", 4) == 0){
guint32 version_string_len;
- ptr += 12;
+ ptr += 4;
+ image->md_version_major = read16 (ptr);
+ ptr += 4;
+ image->md_version_minor = read16 (ptr);
+ ptr += 4;
+
version_string_len = read32 (ptr);
ptr += 4;
image->version = g_strndup (ptr, version_string_len);
MonoImage *res;
GHashTable *loaded_images = refonly ? loaded_images_refonly_hash : loaded_images_hash;
- EnterCriticalSection (&images_mutex);
+ mono_images_lock ();
res = g_hash_table_lookup (loaded_images, name);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
return res;
}
MonoImage *res;
GHashTable *loaded_images = refonly ? loaded_images_refonly_guid_hash : loaded_images_guid_hash;
- EnterCriticalSection (&images_mutex);
+ mono_images_lock ();
res = g_hash_table_lookup (loaded_images, guid);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
return res;
}
MonoImage *image2;
GHashTable *loaded_images = image->ref_only ? loaded_images_refonly_hash : loaded_images_hash;
- EnterCriticalSection (&images_mutex);
+ mono_images_lock ();
image2 = g_hash_table_lookup (loaded_images, image->name);
if (image2) {
/* Somebody else beat us to it */
mono_image_addref (image2);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
mono_image_close (image);
return image2;
}
if (image->assembly_name && (g_hash_table_lookup (loaded_images, image->assembly_name) == NULL))
g_hash_table_insert (loaded_images, (char *) image->assembly_name, image);
g_hash_table_insert (image->ref_only ? loaded_images_refonly_guid_hash : loaded_images_guid_hash, image->guid, image);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
return image;
}
* happen outside the mutex, and if multiple threads happen to load
* the same image, we discard all but the first copy.
*/
- EnterCriticalSection (&images_mutex);
+ mono_images_lock ();
loaded_images = refonly ? loaded_images_refonly_hash : loaded_images_hash;
image = g_hash_table_lookup (loaded_images, absfname);
g_free (absfname);
if (image){
mono_image_addref (image);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
return image;
}
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
image = do_mono_image_open (fname, status, TRUE, refonly);
if (image == NULL)
if (InterlockedDecrement (&image->ref_count))
return;
- EnterCriticalSection (&images_mutex);
+ mono_images_lock ();
loaded_images = image->ref_only ? loaded_images_refonly_hash : loaded_images_hash;
loaded_images_guid = image->ref_only ? loaded_images_refonly_guid_hash : loaded_images_guid_hash;
image2 = g_hash_table_lookup (loaded_images, image->name);
}
if (image->assembly_name && (g_hash_table_lookup (loaded_images, image->assembly_name) == image))
g_hash_table_remove (loaded_images, (char *) image->assembly_name);
- LeaveCriticalSection (&images_mutex);
+ mono_images_unlock ();
if (image->file_descr) {
fclose (image->file_descr);
}
}
+/**
+ * mono_image_lookup_resource:
+ * @image: the image to look up the resource in
+ * @res_id: A MONO_PE_RESOURCE_ID_ that represents the resource ID to lookup.
+ * @lang_id: The language id.
+ * @name: the resource name to lookup.
+ *
+ * Returns: NULL if not found, otherwise a pointer to the in-memory representation
+ * of the given resource.
+ */
gpointer
mono_image_lookup_resource (MonoImage *image, guint32 res_id, guint32 lang_id, gunichar2 *name)
{
return(NULL);
}
+/**
+ * mono_image_get_entry_point:
+ * @image: the image where the entry point will be looked up.
+ *
+ * Use this routine to determine the metadata token for method that
+ * has been flagged as the entry point.
+ *
+ * Returns: the token for the entry point method in the image
+ */
guint32
mono_image_get_entry_point (MonoImage *image)
{
return ((MonoCLIImageInfo*)image->image_info)->cli_cli_header.ch_entry_point;
}
+/**
+ * mono_image_get_resource:
+ * @image: the image where the resource will be looked up.
+ * @offset: The offset to add to the resource
+ * @size: a pointer to an int where the size of the resource will be stored
+ *
+ * This is a low-level routine that fetches a resource from the
+ * metadata that starts at a given @offset. The @size parameter is
+ * filled with the data field as encoded in the metadata.
+ *
+ * Returns: the pointer to the resource whose offset is @offset.
+ */
const char*
mono_image_get_resource (MonoImage *image, guint32 offset, guint32 *size)
{