Author: zoltan
Date: 2008-01-30 13:51:03 -0500 (Wed, 30 Jan 2008)
New Revision: 94398

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/icall.c
Log:
2008-01-30  Zoltan Varga  <[EMAIL PROTECTED]>

        * icall.c (ves_icall_System_Reflection_Assembly_GetModulesInternal): 
        Handle properly modules which are not in the moduleref table. Fixes
        #356938.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2008-01-30 18:27:26 UTC (rev 94397)
+++ trunk/mono/mono/metadata/ChangeLog  2008-01-30 18:51:03 UTC (rev 94398)
@@ -1,3 +1,9 @@
+2008-01-30  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * icall.c (ves_icall_System_Reflection_Assembly_GetModulesInternal): 
+       Handle properly modules which are not in the moduleref table. Fixes
+       #356938.
+
 2008-01-29  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * icall.c (ves_icall_System_Reflection_Assembly_GetModulesInternal): 
Remove

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2008-01-30 18:27:26 UTC (rev 94397)
+++ trunk/mono/mono/metadata/icall.c    2008-01-30 18:51:03 UTC (rev 94398)
@@ -4560,15 +4560,17 @@
        MonoImage **modules;
        guint32 module_count, real_module_count;
        MonoTableInfo *table;
+       guint32 cols [MONO_FILE_SIZE];
+       MonoImage *image = assembly->assembly->image;
 
-       g_assert (assembly->assembly->image != NULL);
+       g_assert (image != NULL);
        g_assert (!assembly->assembly->dynamic);
 
-       table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
+       table = &image->tables [MONO_TABLE_FILE];
        file_count = table->rows;
 
-       modules = assembly->assembly->image->modules;
-       module_count = assembly->assembly->image->module_count;
+       modules = image->modules;
+       module_count = image->module_count;
 
        real_module_count = 0;
        for (i = 0; i < module_count; ++i)
@@ -4578,7 +4580,7 @@
        klass = mono_class_from_name (mono_defaults.corlib, 
"System.Reflection", "Module");
        res = mono_array_new (domain, klass, 1 + real_module_count + 
file_count);
 
-       mono_array_setref (res, 0, mono_module_get_object (domain, 
assembly->assembly->image));
+       mono_array_setref (res, 0, mono_module_get_object (domain, image));
        j = 1;
        for (i = 0; i < module_count; ++i)
                if (modules [i]) {
@@ -4586,12 +4588,20 @@
                        ++j;
                }
 
-       for (i = 0; i < file_count; ++i, ++j)
-               mono_array_setref (res, j, mono_module_file_get_object (domain, 
assembly->assembly->image, i));
+       for (i = 0; i < file_count; ++i, ++j) {
+               mono_metadata_decode_row (table, i, cols, MONO_FILE_SIZE);
+               if (cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA)
+                       mono_array_setref (res, j, mono_module_file_get_object 
(domain, image, i));
+               else {
+                       MonoImage *m = mono_image_load_file_for_image (image, i 
+ 1);
+                       if (!m) {
+                               MonoString *fname = mono_string_new 
(mono_domain_get (), mono_metadata_string_heap (image, cols [MONO_FILE_NAME]));
+                               mono_raise_exception 
(mono_get_exception_file_not_found2 (NULL, fname));
+                       }
+                       mono_array_setref (res, j, mono_module_get_object 
(domain, m));
+               }
+       }
 
-       if (assembly->assembly->dynamic)
-               g_free (modules);
-
        return res;
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to