https://bugs.winehq.org/show_bug.cgi?id=52046
Bug ID: 52046 Summary: UpdateResource does not delete resources Product: Wine Version: unspecified Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: kernel32 Assignee: wine-bugs@winehq.org Reporter: info@daniel-marschall.de Distribution: ---
Hello,
I noticed that UpdateResourceA() does not delete resources if data=NULL and length=0.
Example code
HANDLE hUpdate = BeginUpdateResourceA("d:\test.dll", false); UpdateResourceA(hUpdate, "TEST", "X", 1033, NULL, 0); EndUpdateResourceA(hUpdate, false);
I analyzed the code https://github.com/wine-mirror/wine/blob/master/dlls/kernel32/resource.c and I have found the following:
`BeginUpdateResourceW` creates a list `list_init( &updates->root );` of type `QUEUEDUPDATES`.
The list is empty and stays empty!
`check_pe_exe( file, updates )` is called, but the argument `updates` is not used. The list will not be filled with the resources of the EXE file!
When `UpdateResource` wants to delete a resource, then `update_add_resource` will not find the existing resource: `find_resource_dir_entry` fails, because the list is empty. So there is nothing to delete.
Another side effect of this bug: If I add or modify a resource (it will get added to the queue) and then delete the resource (it will be deleted from the queue), then the resource will stay unchanged in the target file.
I think the fix would be that `check_pe_exe` loads all resources into the list (which is then not a "queue" anymore), then the add/delete/change operations are taking place, and in EndUpdateResource, the changes are written (or discarded).