Commit ea640e1a authored by David Collett's avatar David Collett Committed by Alexandre Julliard

kernel32: Adjust data directories in UpdateResource API.

When adding resources to a PE file using the UpdateResource API and the resource section is not the last section (i.e. we had to move existing sections), ensure any data directory entries pointing into moved sections is adjusted. Signed-off-by: 's avatarDavid Collett <david.collett@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 05925378
......@@ -1435,7 +1435,7 @@ static BOOL write_raw_resources( QUEUEDUPDATES *updates )
{
static const WCHAR prefix[] = { 'r','e','s','u',0 };
WCHAR tempdir[MAX_PATH], tempfile[MAX_PATH];
DWORD section_size;
DWORD i, section_size;
BOOL ret = FALSE;
IMAGE_SECTION_HEADER *sec;
IMAGE_NT_HEADERS32 *nt;
......@@ -1619,11 +1619,19 @@ static BOOL write_raw_resources( QUEUEDUPDATES *updates )
nt64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = sec->VirtualAddress;
nt64->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = res_size.total_size;
nt64->OptionalHeader.SizeOfInitializedData = get_init_data_size( write_map->base, mapping_size );
for (i=0; i<nt64->OptionalHeader.NumberOfRvaAndSizes; i++)
if (nt64->OptionalHeader.DataDirectory[i].VirtualAddress > sec->VirtualAddress)
nt64->OptionalHeader.DataDirectory[i].VirtualAddress += rva_delta;
} else {
nt->OptionalHeader.SizeOfImage += rva_delta;
nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = sec->VirtualAddress;
nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = res_size.total_size;
nt->OptionalHeader.SizeOfInitializedData = get_init_data_size( write_map->base, mapping_size );
for (i=0; i<nt->OptionalHeader.NumberOfRvaAndSizes; i++)
if (nt->OptionalHeader.DataDirectory[i].VirtualAddress > sec->VirtualAddress)
nt->OptionalHeader.DataDirectory[i].VirtualAddress += rva_delta;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment