Keep the original resources if !bDeleteExistingResources in

BeginUpdateResourceW.
Pass the correct handle to callback functions in
BeginUpdateResourceW.
Fix a bug while saving data in memory in UpdateResourceW.
This commit is contained in:
Vincent Béron 2004-09-29 21:10:44 +00:00 committed by Alexandre Julliard
parent 336d84583c
commit 9fc774eb49
1 changed files with 32 additions and 2 deletions

View File

@ -656,6 +656,30 @@ static BOOL CALLBACK enum_resources_types_delete_all(HMODULE hModule, LPWSTR lpT
return EnumResourceNamesW(hModule, lpType, enum_resources_names_delete_all, lParam); return EnumResourceNamesW(hModule, lpType, enum_resources_names_delete_all, lParam);
} }
static BOOL CALLBACK enum_resources_languages_add_all(HMODULE hModule, LPCWSTR lpType, LPCWSTR lpName, WORD wLang, LONG_PTR lParam)
{
DWORD size;
HRSRC hResource = FindResourceExW(hModule, lpType, lpName, wLang);
HGLOBAL hGlobal;
LPVOID lpData;
if(hResource == NULL) return FALSE;
if(!(hGlobal = LoadResource(hModule, hResource))) return FALSE;
if(!(lpData = LockResource(hGlobal))) return FALSE;
if(!(size = SizeofResource(hModule, hResource))) return FALSE;
return UpdateResourceW((HANDLE)lParam, lpType, lpName, wLang, lpData, size);
}
static BOOL CALLBACK enum_resources_names_add_all(HMODULE hModule, LPCWSTR lpType, LPWSTR lpName, LONG_PTR lParam)
{
return EnumResourceLanguagesW(hModule, lpType, lpName, enum_resources_languages_add_all, lParam);
}
static BOOL CALLBACK enum_resources_types_add_all(HMODULE hModule, LPWSTR lpType, LONG_PTR lParam)
{
return EnumResourceNamesW(hModule, lpType, enum_resources_names_add_all, lParam);
}
/*********************************************************************** /***********************************************************************
* BeginUpdateResourceW (KERNEL32.@) * BeginUpdateResourceW (KERNEL32.@)
*/ */
@ -709,8 +733,15 @@ HANDLE WINAPI BeginUpdateResourceW( LPCWSTR pFileName, BOOL bDeleteExistingResou
list_init(&current_updates->resources_list); list_init(&current_updates->resources_list);
if(bDeleteExistingResources) if(bDeleteExistingResources)
if(!EnumResourceTypesW(hModule, enum_resources_types_delete_all, (LONG_PTR)&current_updates)) {
if(!EnumResourceTypesW(hModule, enum_resources_types_delete_all, (LONG_PTR)hUpdate))
goto done; goto done;
}
else
{
if(!EnumResourceTypesW(hModule, enum_resources_types_add_all, (LONG_PTR)hUpdate))
goto done;
}
ret = hUpdate; ret = hUpdate;
done: done:
@ -850,7 +881,6 @@ BOOL WINAPI UpdateResourceW( HANDLE hUpdate, LPCWSTR lpType, LPCWSTR lpName,
} }
current_resource->wLanguage = wLanguage; current_resource->wLanguage = wLanguage;
memcpy(current_resource->lpData, lpData, cbData); memcpy(current_resource->lpData, lpData, cbData);
current_resource->lpData = lpData;
current_resource->cbData = cbData; current_resource->cbData = cbData;
list_add_tail(&current_updates->resources_list, &current_resource->entry); list_add_tail(&current_updates->resources_list, &current_resource->entry);
ret = TRUE; ret = TRUE;