From 8d1578aa146bb8c2b386b0edf826549bf1ee7ec1 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Sat, 26 Sep 2009 05:25:52 +0000 Subject: [PATCH] - Alexandre Julliard : kernel32: Cope with an empty resource section in UpdateResource. - Wine Bug 19783 : http://bugs.winehq.org/show_bug.cgi?id=19783 svn path=/trunk/; revision=43157 --- reactos/dll/win32/kernel32/misc/res.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/reactos/dll/win32/kernel32/misc/res.c b/reactos/dll/win32/kernel32/misc/res.c index 285f1d3d0ae..7a6e3dcfd36 100644 --- a/reactos/dll/win32/kernel32/misc/res.c +++ b/reactos/dll/win32/kernel32/misc/res.c @@ -405,13 +405,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) - { - DPRINT("FIXME: .rsrc isn't the last section\n"); - return NULL; - } - return &sec[i]; } @@ -566,6 +559,9 @@ static BOOL read_mapped_resources( QUEUEDUPDATES *updates, void *base, DWORD map DPRINT("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 ); @@ -962,10 +958,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) { - DPRINT("FIXME: .rsrc isn't at the end of the image %08x + %08x != %08x\n", - sec->SizeOfRawData, sec->PointerToRawData, write_map->size); + DPRINT(".rsrc isn't at the end of the image %08x + %08x != %08x for %s\n", + sec->SizeOfRawData, sec->PointerToRawData, write_map->size, updates->pFileName); goto done; } -- 2.17.1