Kirill Smelkov : kernel32: Support deleting resources in UpdateResource.

Alexandre Julliard julliard at winehq.org
Thu Apr 7 07:36:44 CDT 2011


Module: wine
Branch: stable
Commit: f7d9db83662c304bad680178038d70059f4b33d3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f7d9db83662c304bad680178038d70059f4b33d3

Author: Kirill Smelkov <kirr at landau.phys.spbu.ru>
Date:   Tue Dec 21 17:23:11 2010 +0300

kernel32: Support deleting resources in UpdateResource.
(cherry picked from commit d5cb11a45a3aab5ac372e571b55e1fc35709f13d)

---

 dlls/kernel32/resource.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/dlls/kernel32/resource.c b/dlls/kernel32/resource.c
index 0050cb9..8876b1a 100644
--- a/dlls/kernel32/resource.c
+++ b/dlls/kernel32/resource.c
@@ -706,7 +706,8 @@ static void res_free_str( LPWSTR str )
 }
 
 static BOOL update_add_resource( QUEUEDUPDATES *updates, LPCWSTR Type, LPCWSTR Name,
-                                 struct resource_data *resdata, BOOL overwrite_existing )
+                                 LANGID Lang, struct resource_data *resdata,
+                                 BOOL overwrite_existing )
 {
     struct resource_dir_entry *restype, *resname;
     struct resource_data *existing;
@@ -736,7 +737,7 @@ static BOOL update_add_resource( QUEUEDUPDATES *updates, LPCWSTR Type, LPCWSTR N
      * If there's an existing resource entry with matching (Type,Name,Language)
      *  it needs to be removed before adding the new data.
      */
-    existing = find_resource_data( &resname->children, resdata->lang );
+    existing = find_resource_data( &resname->children, Lang );
     if (existing)
     {
         if (!overwrite_existing)
@@ -745,7 +746,8 @@ static BOOL update_add_resource( QUEUEDUPDATES *updates, LPCWSTR Type, LPCWSTR N
         HeapFree( GetProcessHeap(), 0, existing );
     }
 
-    add_resource_data_entry( &resname->children, resdata );
+    if (resdata)
+        add_resource_data_entry( &resname->children, resdata );
 
     return TRUE;
 }
@@ -1007,7 +1009,7 @@ static BOOL enumerate_mapped_resources( QUEUEDUPDATES *updates,
                 resdata = allocate_resource_data( Lang, data->CodePage, p, data->Size, FALSE );
                 if (resdata)
                 {
-                    if (!update_add_resource( updates, Type, Name, resdata, FALSE ))
+                    if (!update_add_resource( updates, Type, Name, Lang, resdata, FALSE ))
                         HeapFree( GetProcessHeap(), 0, resdata );
                 }
             }
@@ -1639,10 +1641,17 @@ BOOL WINAPI UpdateResourceW( HANDLE hUpdate, LPCWSTR lpType, LPCWSTR lpName,
     updates = GlobalLock(hUpdate);
     if (updates)
     {
-        struct resource_data *data;
-        data = allocate_resource_data( wLanguage, 0, lpData, cbData, TRUE );
-        if (data)
-            ret = update_add_resource( updates, lpType, lpName, data, TRUE );
+        if (lpData == NULL && cbData == 0)  /* remove resource */
+        {
+            ret = update_add_resource( updates, lpType, lpName, wLanguage, NULL, TRUE );
+        }
+        else
+        {
+            struct resource_data *data;
+            data = allocate_resource_data( wLanguage, 0, lpData, cbData, TRUE );
+            if (data)
+                ret = update_add_resource( updates, lpType, lpName, wLanguage, data, TRUE );
+        }
         GlobalUnlock(hUpdate);
     }
     return ret;




More information about the wine-cvs mailing list