Alexandre Julliard : kernel32: Cope with an empty resource section in UpdateResource.

Alexandre Julliard julliard at winehq.org
Thu Sep 24 10:54:04 CDT 2009


Module: wine
Branch: master
Commit: 9f28d9a171c34552ba9040d5b499190af4225af8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9f28d9a171c34552ba9040d5b499190af4225af8

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Sep 24 13:10:39 2009 +0200

kernel32: Cope with an empty resource section in UpdateResource.

---

 dlls/kernel32/resource.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/dlls/kernel32/resource.c b/dlls/kernel32/resource.c
index f49ea24..9feb672 100644
--- a/dlls/kernel32/resource.c
+++ b/dlls/kernel32/resource.c
@@ -1078,6 +1078,9 @@ static BOOL read_mapped_resources( QUEUEDUPDATES *updates, void *base, DWORD map
 
     TRACE("found .rsrc at %08x, size %08x\n", sec[i].PointerToRawData, sec[i].SizeOfRawData);
 
+    if (!sec[i].PointerToRawData || sec[i].SizeOfRawData < sizeof(IMAGE_RESOURCE_DIRECTORY))
+        return TRUE;
+
     root = (void*) ((BYTE*)base + sec[i].PointerToRawData);
     enumerate_mapped_resources( updates, base, mapping_size, root );
 
@@ -1404,13 +1407,6 @@ static IMAGE_SECTION_HEADER *get_resource_section( void *base, DWORD mapping_siz
         return NULL;
     }
 
-    /* check that the resources section is last */
-    if (i != num_sections - 1)
-    {
-        FIXME(".rsrc isn't the last section\n");
-        return NULL;
-    }
-
     return &sec[i];
 }
 
@@ -1487,10 +1483,15 @@ static BOOL write_raw_resources( QUEUEDUPDATES *updates )
     if (!sec)
         goto done;
 
-    if ((sec->SizeOfRawData + sec->PointerToRawData) != write_map->size)
+    if (!sec->PointerToRawData)  /* empty section */
+    {
+        sec->PointerToRawData = write_map->size;
+        sec->SizeOfRawData = 0;
+    }
+    else if ((sec->SizeOfRawData + sec->PointerToRawData) != write_map->size)
     {
-        FIXME(".rsrc isn't at the end of the image %08x + %08x != %08x\n",
-            sec->SizeOfRawData, sec->PointerToRawData, write_map->size);
+        FIXME(".rsrc isn't at the end of the image %08x + %08x != %08x for %s\n",
+              sec->SizeOfRawData, sec->PointerToRawData, write_map->size, debugstr_w(updates->pFileName));
         goto done;
     }
 




More information about the wine-cvs mailing list