From: Dave Platt Date: Sun, 29 Jan 2023 04:38:39 +0000 (-0800) Subject: sigrok-fwextract-kingst-la2016: handle compressed Qt resources X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=64859badb1221edccb103b6eadfbda9e760ed9a9;p=sigrok-util.git sigrok-fwextract-kingst-la2016: handle compressed Qt resources 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. --- diff --git a/firmware/kingst-la/sigrok-fwextract-kingst-la2016 b/firmware/kingst-la/sigrok-fwextract-kingst-la2016 index 3575b04..0bcf9bf 100755 --- a/firmware/kingst-la/sigrok-fwextract-kingst-la2016 +++ b/firmware/kingst-la/sigrok-fwextract-kingst-la2016 @@ -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):