2 * image.c: Routines for manipulating an image stored in an
3 * extended PE/COFF file.
6 * Miguel de Icaza (miguel@ximian.com)
8 * (C) 2001 Ximian, Inc. http://www.ximian.com
11 * Implement big-endian versions of the reading routines.
21 #include "rawbuffer.h"
22 #include "mono-endian.h"
24 #include "tabledefs.h"
26 #define INVALID_ADDRESS 0xffffffff
29 * Keeps track of the various assemblies loaded
31 static GHashTable *loaded_images_hash;
34 mono_cli_rva_image_map (MonoCLIImageInfo *iinfo, guint32 addr)
36 const int top = iinfo->cli_section_count;
37 MonoSectionTable *tables = iinfo->cli_section_tables;
40 for (i = 0; i < top; i++){
41 if ((addr >= tables->st_virtual_address) &&
42 (addr < tables->st_virtual_address + tables->st_raw_data_size)){
43 return addr - tables->st_virtual_address + tables->st_raw_data_ptr;
47 return INVALID_ADDRESS;
51 mono_cli_rva_map (MonoCLIImageInfo *iinfo, guint32 addr)
53 const int top = iinfo->cli_section_count;
54 MonoSectionTable *tables = iinfo->cli_section_tables;
57 for (i = 0; i < top; i++){
58 if ((addr >= tables->st_virtual_address) &&
59 (addr < tables->st_virtual_address + tables->st_raw_data_size)){
60 return (char*)iinfo->cli_sections [i] +
61 (addr - tables->st_virtual_address);
69 * mono_image_ensure_section_idx:
70 * @image: The image we are operating on
71 * @section: section number that we will load/map into memory
73 * This routine makes sure that we have an in-memory copy of
74 * an image section (.text, .rsrc, .data).
76 * Returns: TRUE on success
79 mono_image_ensure_section_idx (MonoImage *image, int section)
81 MonoCLIImageInfo *iinfo = image->image_info;
82 MonoSectionTable *sect;
85 g_return_val_if_fail (section < iinfo->cli_section_count, FALSE);
87 if (iinfo->cli_sections [section] != NULL)
90 sect = &iinfo->cli_section_tables [section];
92 writable = sect->st_flags & SECT_FLAGS_MEM_WRITE;
94 iinfo->cli_sections [section] = mono_raw_buffer_load (
95 fileno (image->f), writable,
96 sect->st_raw_data_ptr, sect->st_raw_data_size);
98 if (iinfo->cli_sections [section] == NULL)
105 * mono_image_ensure_section:
106 * @image: The image we are operating on
107 * @section: section name that we will load/map into memory
109 * This routine makes sure that we have an in-memory copy of
110 * an image section (.text, .rsrc, .data).
112 * Returns: TRUE on success
115 mono_image_ensure_section (MonoImage *image, const char *section)
117 MonoCLIImageInfo *ii = image->image_info;
120 for (i = 0; i < ii->cli_section_count; i++){
121 if (strncmp (ii->cli_section_tables [i].st_name, section, 8) != 0)
124 return mono_image_ensure_section_idx (image, i);
130 load_section_tables (MonoImage *image, MonoCLIImageInfo *iinfo)
132 const int top = iinfo->cli_header.coff.coff_sections;
135 iinfo->cli_section_count = top;
136 iinfo->cli_section_tables = g_new0 (MonoSectionTable, top);
137 iinfo->cli_sections = g_new0 (void *, top);
139 for (i = 0; i < top; i++){
140 MonoSectionTable *t = &iinfo->cli_section_tables [i];
142 if (fread (t, sizeof (MonoSectionTable), 1, image->f) != 1)
145 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
146 t->st_virtual_size = GUINT32_FROM_LE (t->st_virtual_size);
147 t->st_virtual_address = GUINT32_FROM_LE (t->st_virtual_address);
148 t->st_raw_data_size = GUINT32_FROM_LE (t->st_raw_data_size);
149 t->st_raw_data_ptr = GUINT32_FROM_LE (t->st_raw_data_ptr);
150 t->st_reloc_ptr = GUINT32_FROM_LE (t->st_reloc_ptr);
151 t->st_lineno_ptr = GUINT32_FROM_LE (t->st_lineno_ptr);
152 t->st_reloc_count = GUINT16_FROM_LE (t->st_reloc_count);
153 t->st_line_count = GUINT16_FROM_LE (t->st_line_count);
154 t->st_flags = GUINT32_FROM_LE (t->st_flags);
156 /* consistency checks here */
159 for (i = 0; i < top; i++)
160 if (!mono_image_ensure_section_idx (image, i))
167 load_cli_header (MonoImage *image, MonoCLIImageInfo *iinfo)
172 offset = mono_cli_rva_image_map (iinfo, iinfo->cli_header.datadir.pe_cli_header.rva);
173 if (offset == INVALID_ADDRESS)
176 if (fseek (image->f, offset, SEEK_SET) != 0)
179 if ((n = fread (&iinfo->cli_cli_header, sizeof (MonoCLIHeader), 1, image->f)) != 1)
182 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
183 #define SWAP32(x) (x) = GUINT32_FROM_LE ((x))
184 #define SWAP16(x) (x) = GUINT16_FROM_LE ((x))
185 #define SWAPPDE(x) do { (x).rva = GUINT32_FROM_LE ((x).rva); (x).size = GUINT32_FROM_LE ((x).size);} while (0)
186 SWAP32 (iinfo->cli_cli_header.ch_size);
187 SWAP32 (iinfo->cli_cli_header.ch_flags);
188 SWAP32 (iinfo->cli_cli_header.ch_entry_point);
189 SWAP16 (iinfo->cli_cli_header.ch_runtime_major);
190 SWAP16 (iinfo->cli_cli_header.ch_runtime_minor);
191 SWAPPDE (iinfo->cli_cli_header.ch_metadata);
192 SWAPPDE (iinfo->cli_cli_header.ch_resources);
193 SWAPPDE (iinfo->cli_cli_header.ch_strong_name);
194 SWAPPDE (iinfo->cli_cli_header.ch_code_manager_table);
195 SWAPPDE (iinfo->cli_cli_header.ch_vtable_fixups);
196 SWAPPDE (iinfo->cli_cli_header.ch_export_address_table_jumps);
197 SWAPPDE (iinfo->cli_cli_header.ch_eeinfo_table);
198 SWAPPDE (iinfo->cli_cli_header.ch_helper_table);
199 SWAPPDE (iinfo->cli_cli_header.ch_dynamic_info);
200 SWAPPDE (iinfo->cli_cli_header.ch_delay_load_info);
201 SWAPPDE (iinfo->cli_cli_header.ch_module_image);
202 SWAPPDE (iinfo->cli_cli_header.ch_external_fixups);
203 SWAPPDE (iinfo->cli_cli_header.ch_ridmap);
204 SWAPPDE (iinfo->cli_cli_header.ch_debug_map);
205 SWAPPDE (iinfo->cli_cli_header.ch_ip_map);
210 /* Catch new uses of the fields that are supposed to be zero */
212 if ((iinfo->cli_cli_header.ch_eeinfo_table.rva != 0) ||
213 (iinfo->cli_cli_header.ch_helper_table.rva != 0) ||
214 (iinfo->cli_cli_header.ch_dynamic_info.rva != 0) ||
215 (iinfo->cli_cli_header.ch_delay_load_info.rva != 0) ||
216 (iinfo->cli_cli_header.ch_module_image.rva != 0) ||
217 (iinfo->cli_cli_header.ch_external_fixups.rva != 0) ||
218 (iinfo->cli_cli_header.ch_ridmap.rva != 0) ||
219 (iinfo->cli_cli_header.ch_debug_map.rva != 0) ||
220 (iinfo->cli_cli_header.ch_ip_map.rva != 0)){
223 * No need to scare people who are testing this, I am just
224 * labelling this as a LAMESPEC
226 /* g_warning ("Some fields in the CLI header which should have been zero are not zero"); */
234 load_metadata_ptrs (MonoImage *image, MonoCLIImageInfo *iinfo)
236 guint32 offset, size;
241 offset = mono_cli_rva_image_map (iinfo, iinfo->cli_cli_header.ch_metadata.rva);
242 size = iinfo->cli_cli_header.ch_metadata.size;
244 image->raw_metadata = mono_raw_buffer_load (fileno (image->f), FALSE, offset, size);
245 if (image->raw_metadata == NULL)
248 ptr = image->raw_metadata;
250 if (strncmp (ptr, "BSJB", 4) == 0){
251 guint32 version_string_len;
254 version_string_len = read32 (ptr);
256 ptr += version_string_len;
257 if (((guint32) ptr) % 4)
258 ptr += 4 - (((guint32) ptr) %4);
262 /* skip over flags */
265 streams = read16 (ptr);
268 for (i = 0; i < streams; i++){
269 if (strncmp (ptr + 8, "#~", 3) == 0){
270 image->heap_tables.data = image->raw_metadata + read32 (ptr);
271 image->heap_tables.size = read32 (ptr + 4);
273 } else if (strncmp (ptr + 8, "#Strings", 9) == 0){
274 image->heap_strings.data = image->raw_metadata + read32 (ptr);
275 image->heap_strings.size = read32 (ptr + 4);
277 } else if (strncmp (ptr + 8, "#US", 4) == 0){
278 image->heap_us.data = image->raw_metadata + read32 (ptr);
279 image->heap_us.size = read32 (ptr + 4);
281 } else if (strncmp (ptr + 8, "#Blob", 6) == 0){
282 image->heap_blob.data = image->raw_metadata + read32 (ptr);
283 image->heap_blob.size = read32 (ptr + 4);
285 } else if (strncmp (ptr + 8, "#GUID", 6) == 0){
286 image->heap_guid.data = image->raw_metadata + read32 (ptr);
287 image->heap_guid.size = read32 (ptr + 4);
290 g_message ("Unknown heap type: %s\n", ptr + 8);
291 ptr += 8 + strlen (ptr) + 1;
293 if (((guint32)ptr) % 4){
294 ptr += 4 - (((guint32)ptr) % 4);
301 * Load representation of logical metadata tables, from the "#~" stream
304 load_tables (MonoImage *image)
306 const char *heap_tables = image->heap_tables.data;
308 guint64 valid_mask, sorted_mask;
309 int valid = 0, table;
312 heap_sizes = heap_tables [6];
313 image->idx_string_wide = ((heap_sizes & 0x01) == 1);
314 image->idx_guid_wide = ((heap_sizes & 0x02) == 2);
315 image->idx_blob_wide = ((heap_sizes & 0x04) == 4);
317 valid_mask = read64 (heap_tables + 8);
318 sorted_mask = read64 (heap_tables + 16);
319 rows = (const guint32 *) (heap_tables + 24);
321 for (table = 0; table < 64; table++){
322 if ((valid_mask & ((guint64) 1 << table)) == 0){
323 image->tables [table].rows = 0;
327 g_warning("bits in valid must be zero above 0x2b (II - 23.1.6)");
329 /*if ((sorted_mask & ((guint64) 1 << table)) == 0){
330 g_print ("table %s (0x%02x) is sorted\n", mono_meta_table_name (table), table);
332 image->tables [table].rows = read32 (rows);
337 image->tables_base = (heap_tables + 24) + (4 * valid);
339 /* They must be the same */
340 g_assert ((const void *) image->tables_base == (const void *) rows);
342 mono_metadata_compute_table_bases (image);
347 load_metadata (MonoImage *image, MonoCLIImageInfo *iinfo)
349 if (!load_metadata_ptrs (image, iinfo))
352 return load_tables (image);
356 load_class_names (MonoImage *image)
358 MonoTableInfo *t = &image->tables [MONO_TABLE_TYPEDEF];
359 guint32 cols [MONO_TYPEDEF_SIZE];
362 GHashTable *nspace_table;
363 GHashTable *name_cache = image->name_cache;
366 for (i = 1; i <= t->rows; ++i) {
367 mono_metadata_decode_row (t, i - 1, cols, MONO_TYPEDEF_SIZE);
368 /* nested types are accessed from the nesting name */
369 visib = cols [MONO_TYPEDEF_FLAGS] & TYPE_ATTRIBUTE_VISIBILITY_MASK;
370 if (visib > TYPE_ATTRIBUTE_PUBLIC && visib <= TYPE_ATTRIBUTE_NESTED_ASSEMBLY)
372 name = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAME]);
373 nspace = mono_metadata_string_heap (image, cols [MONO_TYPEDEF_NAMESPACE]);
374 if (!(nspace_table = g_hash_table_lookup (name_cache, nspace))) {
375 nspace_table = g_hash_table_new (g_str_hash, g_str_equal);
376 g_hash_table_insert (name_cache, (char *)nspace, (char *)nspace_table);
378 g_hash_table_insert (nspace_table, (char *) name, GUINT_TO_POINTER (i));
383 do_mono_image_open (const char *fname, MonoImageOpenStatus *status)
385 MonoCLIImageInfo *iinfo;
386 MonoDotNetHeader *header;
387 MonoMSDOSHeader msdos;
391 image = g_new0 (MonoImage, 1);
392 image->ref_count = 1;
393 image->f = fopen (fname, "rb");
394 image->name = g_strdup (fname);
395 iinfo = g_new0 (MonoCLIImageInfo, 1);
396 image->image_info = iinfo;
398 image->method_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
399 image->class_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
400 image->name_cache = g_hash_table_new (g_str_hash, g_str_equal);
401 image->array_cache = g_hash_table_new ((GHashFunc)mono_metadata_type_hash, (GCompareFunc)mono_metadata_type_equal);
403 image->delegate_invoke_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
404 image->runtime_invoke_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
405 image->managed_wrapper_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
406 image->native_wrapper_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
408 header = &iinfo->cli_header;
410 if (image->f == NULL){
412 *status = MONO_IMAGE_ERROR_ERRNO;
413 mono_image_close (image);
418 *status = MONO_IMAGE_IMAGE_INVALID;
420 if (fread (&msdos, sizeof (msdos), 1, image->f) != 1)
423 if (!(msdos.msdos_sig [0] == 'M' && msdos.msdos_sig [1] == 'Z'))
426 msdos.pe_offset = GUINT32_FROM_LE (msdos.pe_offset);
428 if (msdos.pe_offset != sizeof (msdos))
429 fseek (image->f, msdos.pe_offset, SEEK_SET);
431 if ((n = fread (header, sizeof (MonoDotNetHeader), 1, image->f)) != 1)
434 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
435 #define SWAP32(x) (x) = GUINT32_FROM_LE ((x))
436 #define SWAP16(x) (x) = GUINT16_FROM_LE ((x))
437 #define SWAPPDE(x) do { (x).rva = GUINT32_FROM_LE ((x).rva); (x).size = GUINT32_FROM_LE ((x).size);} while (0)
438 SWAP32 (header->coff.coff_time);
439 SWAP32 (header->coff.coff_symptr);
440 SWAP32 (header->coff.coff_symcount);
441 SWAP16 (header->coff.coff_machine);
442 SWAP16 (header->coff.coff_sections);
443 SWAP16 (header->coff.coff_opt_header_size);
444 SWAP16 (header->coff.coff_attributes);
446 SWAP32 (header->pe.pe_code_size);
447 SWAP32 (header->pe.pe_data_size);
448 SWAP32 (header->pe.pe_uninit_data_size);
449 SWAP32 (header->pe.pe_rva_entry_point);
450 SWAP32 (header->pe.pe_rva_code_base);
451 SWAP32 (header->pe.pe_rva_data_base);
452 SWAP16 (header->pe.pe_magic);
454 /* MonoPEHeaderNT: not used yet */
455 SWAP32 (header->nt.pe_image_base); /* must be 0x400000 */
456 SWAP32 (header->nt.pe_section_align); /* must be 8192 */
457 SWAP32 (header->nt.pe_file_alignment); /* must be 512 or 4096 */
458 SWAP16 (header->nt.pe_os_major); /* must be 4 */
459 SWAP16 (header->nt.pe_os_minor); /* must be 0 */
460 SWAP16 (header->nt.pe_user_major);
461 SWAP16 (header->nt.pe_user_minor);
462 SWAP16 (header->nt.pe_subsys_major);
463 SWAP16 (header->nt.pe_subsys_minor);
464 SWAP32 (header->nt.pe_reserved_1);
465 SWAP32 (header->nt.pe_image_size);
466 SWAP32 (header->nt.pe_header_size);
467 SWAP32 (header->nt.pe_checksum);
468 SWAP16 (header->nt.pe_subsys_required);
469 SWAP16 (header->nt.pe_dll_flags);
470 SWAP32 (header->nt.pe_stack_reserve);
471 SWAP32 (header->nt.pe_stack_commit);
472 SWAP32 (header->nt.pe_heap_reserve);
473 SWAP32 (header->nt.pe_heap_commit);
474 SWAP32 (header->nt.pe_loader_flags);
475 SWAP32 (header->nt.pe_data_dir_count);
477 /* MonoDotNetHeader: mostly unused */
478 SWAPPDE (header->datadir.pe_export_table);
479 SWAPPDE (header->datadir.pe_import_table);
480 SWAPPDE (header->datadir.pe_resource_table);
481 SWAPPDE (header->datadir.pe_exception_table);
482 SWAPPDE (header->datadir.pe_certificate_table);
483 SWAPPDE (header->datadir.pe_reloc_table);
484 SWAPPDE (header->datadir.pe_debug);
485 SWAPPDE (header->datadir.pe_copyright);
486 SWAPPDE (header->datadir.pe_global_ptr);
487 SWAPPDE (header->datadir.pe_tls_table);
488 SWAPPDE (header->datadir.pe_load_config_table);
489 SWAPPDE (header->datadir.pe_bound_import);
490 SWAPPDE (header->datadir.pe_iat);
491 SWAPPDE (header->datadir.pe_delay_import_desc);
492 SWAPPDE (header->datadir.pe_cli_header);
493 SWAPPDE (header->datadir.pe_reserved);
500 if (header->coff.coff_machine != 0x14c)
503 if (header->coff.coff_opt_header_size != (sizeof (MonoDotNetHeader) - sizeof (MonoCOFFHeader) - 4))
506 if (header->pesig[0] != 'P' || header->pesig[1] != 'E' || header->pe.pe_magic != 0x10B)
509 if (header->pe.pe_major != 6 || header->pe.pe_minor != 0)
513 * FIXME: byte swap all addresses here for header.
516 if (!load_section_tables (image, iinfo))
519 /* Load the CLI header */
520 if (!load_cli_header (image, iinfo))
523 if (!load_metadata (image, iinfo))
526 load_class_names (image);
528 /* modules don't have an assembly table row */
529 if (image->tables [MONO_TABLE_ASSEMBLY].rows)
530 image->assembly_name = mono_metadata_string_heap (image,
531 mono_metadata_decode_row_col (&image->tables [MONO_TABLE_ASSEMBLY],
532 0, MONO_ASSEMBLY_NAME));
534 image->module_name = mono_metadata_string_heap (image,
535 mono_metadata_decode_row_col (&image->tables [MONO_TABLE_MODULE],
536 0, MONO_MODULE_NAME));
539 *status = MONO_IMAGE_OK;
546 mono_image_close (image);
551 mono_image_loaded (const char *name) {
552 if (strcmp (name, "mscorlib") == 0)
554 if (loaded_images_hash)
555 return g_hash_table_lookup (loaded_images_hash, name);
561 * @fname: filename that points to the module we want to open
562 * @status: An error condition is returned in this field
564 * Retuns: An open image of type %MonoImage or NULL on error.
565 * if NULL, then check the value of @status for details on the error
568 mono_image_open (const char *fname, MonoImageOpenStatus *status)
572 g_return_val_if_fail (fname != NULL, NULL);
574 if (loaded_images_hash){
575 image = g_hash_table_lookup (loaded_images_hash, fname);
582 image = do_mono_image_open (fname, status);
586 if (!loaded_images_hash)
587 loaded_images_hash = g_hash_table_new (g_str_hash, g_str_equal);
588 g_hash_table_insert (loaded_images_hash, image->name, image);
589 if (image->assembly_name)
590 g_hash_table_insert (loaded_images_hash, (char *) image->assembly_name, image);
596 free_hash_table(gpointer key, gpointer val, gpointer user_data)
598 g_hash_table_destroy ((GHashTable*)val);
603 * @image: The image file we wish to close
605 * Closes an image file, deallocates all memory consumed and
606 * unmaps all possible sections of the file
609 mono_image_close (MonoImage *image)
611 g_return_if_fail (image != NULL);
613 if (--image->ref_count)
616 g_hash_table_remove (loaded_images_hash, image->name);
621 g_free (image->name);
623 g_hash_table_destroy (image->method_cache);
624 g_hash_table_destroy (image->class_cache);
625 g_hash_table_destroy (image->array_cache);
626 g_hash_table_foreach (image->name_cache, free_hash_table, NULL);
627 g_hash_table_destroy (image->name_cache);
629 if (image->raw_metadata != NULL)
630 mono_raw_buffer_free (image->raw_metadata);
632 if (image->image_info){
633 MonoCLIImageInfo *ii = image->image_info;
636 for (i = 0; i < ii->cli_section_count; i++){
637 if (!ii->cli_sections [i])
639 mono_raw_buffer_free (ii->cli_sections [i]);
641 if (ii->cli_section_tables)
642 g_free (ii->cli_section_tables);
643 if (ii->cli_sections)
644 g_free (ii->cli_sections);
645 g_free (image->image_info);
652 * mono_image_strerror:
653 * @status: an code indicating the result from a recent operation
655 * Returns: a string describing the error
658 mono_image_strerror (MonoImageOpenStatus status)
663 case MONO_IMAGE_ERROR_ERRNO:
664 return strerror (errno);
665 case MONO_IMAGE_IMAGE_INVALID:
666 return "File does not contain a valid CIL image";
667 case MONO_IMAGE_MISSING_ASSEMBLYREF:
668 return "An assembly was referenced, but could not be found";
670 return "Internal error";
674 mono_image_walk_resource_tree (MonoCLIImageInfo *info, guint32 res_id,
675 guint32 lang_id, gunichar2 *name,
676 MonoPEResourceDirEntry *entry,
677 MonoPEResourceDir *root, guint32 level)
679 gboolean is_string=entry->name_is_string;
681 /* Level 0 holds a directory entry for each type of resource
682 * (identified by ID or name).
684 * Level 1 holds a directory entry for each named resource
685 * item, and each "anonymous" item of a particular type of
688 * Level 2 holds a directory entry for each language pointing to
693 if((is_string==FALSE && entry->name_offset!=res_id) ||
697 } else if (level==1) {
700 is_string==TRUE && name!=lookup (entry->name_offset)) {
704 } else if (level==2) {
705 if((is_string==FALSE && entry->name_offset!=lang_id) ||
710 g_assert_not_reached ();
713 if(entry->is_dir==TRUE) {
714 MonoPEResourceDir *res_dir=(MonoPEResourceDir *)(((char *)root)+entry->dir_offset);
715 MonoPEResourceDirEntry *sub_entries=(MonoPEResourceDirEntry *)(res_dir+1);
718 entries=res_dir->res_named_entries + res_dir->res_id_entries;
720 for(i=0; i<entries; i++) {
721 MonoPEResourceDirEntry *sub_entry=&sub_entries[i];
724 ret=mono_image_walk_resource_tree (info, res_id,
735 MonoPEResourceDataEntry *data_entry=(MonoPEResourceDataEntry *)((char *)(root)+entry->dir_offset);
742 mono_image_lookup_resource (MonoImage *image, guint32 res_id, guint32 lang_id, gunichar2 *name)
744 MonoCLIImageInfo *info;
745 MonoDotNetHeader *header;
746 MonoPEDatadir *datadir;
747 MonoPEDirEntry *rsrc;
748 MonoPEResourceDir *resource_dir;
749 MonoPEResourceDirEntry *res_entries;
756 info=image->image_info;
761 header=&info->cli_header;
766 datadir=&header->datadir;
771 rsrc=&datadir->pe_resource_table;
776 resource_dir=(MonoPEResourceDir *)mono_cli_rva_map (info, rsrc->rva);
777 if(resource_dir==NULL) {
781 entries=resource_dir->res_named_entries + resource_dir->res_id_entries;
782 res_entries=(MonoPEResourceDirEntry *)(resource_dir+1);
784 for(i=0; i<entries; i++) {
785 MonoPEResourceDirEntry *entry=&res_entries[i];
788 ret=mono_image_walk_resource_tree (info, res_id, lang_id,
789 name, entry, resource_dir,