]> sigrok.org Git - sigrok-util.git/commitdiff
sigrok-fwextract-kingst-la2016: handle compressed Qt resources
authorDave Platt <redacted>
Sun, 29 Jan 2023 04:38:39 +0000 (20:38 -0800)
committerGerhard Sittig <redacted>
Sun, 29 Jan 2023 08:05:55 +0000 (09:05 +0100)
Qt resources in executable images support optional compression. Recent
vendor software uses this feature. Uncompress firmware images during
extraction of their blobs.

This handles the Qt resource compression part of bug #1825.

firmware/kingst-la/sigrok-fwextract-kingst-la2016

index 3575b04928a7989523ac69da288aa8e543cae7a2..0bcf9bf9d501edf8b7bf4a3743894a9087931898 100755 (executable)
@@ -99,24 +99,31 @@ class qt_resources(object):
             child_count, first_child = which[2:]
             for i in range(child_count):
                 child = table[first_child + i]
-                if child[1] & RCCFileInfo_Directory:
+                flags = child[1]
+                if flags & RCCFileInfo_Directory:
                     read_dir_entries(table, child, parents + [child[0]])
                 else:
                     country, language, data_offset = child[2:]
                     full_name = "/".join(parents + [child[0]])
                     self._resources[full_name] = data_offset
+                    self._resource_flags[full_name] = flags
 
         self._res_datas = self._get_elf_sym_value("_ZL16qt_resource_data")
         self._res_names = self._get_elf_sym_value("_ZL16qt_resource_name")
         self._res_struct = self._get_elf_sym_value("_ZL18qt_resource_struct")
 
         self._resources = {} # res_fn -> res_offset
+        self._resource_flags = {} # res_fn -> RCC_flags
         table = read_table()
         read_dir_entries(table, table[0])
 
     def get_resource(self, res_fn):
+        RCCFileInfo_Compressed = 1
         offset = self._resources[res_fn]
+        flags = self._resource_flags[res_fn]
         data = self._get_resource_data(offset)
+        if flags & RCCFileInfo_Compressed:
+            data = zlib.decompress(data[4:])
         return data
 
     def find_resource_names(self, res_fn_re):