From 98e5ffca868da36e752146f579e085aca4dd7387 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 6 Aug 2022 18:50:34 -0300 Subject: [PATCH] PhoenixAnalyzer: Load language tables separately on 4.0R6 --- biostools/analyzers.py | 44 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/biostools/analyzers.py b/biostools/analyzers.py index 3721687..93c2888 100644 --- a/biostools/analyzers.py +++ b/biostools/analyzers.py @@ -2221,22 +2221,32 @@ class PhoenixAnalyzer(Analyzer): # SecureCore may have 4 bytes before the STRPACK header. offset = data.find(b'STRPACK-BIOS') if offset > -1: - strings_files.append(data[offset:]) - self.debug_print('Loaded strings file:', file_in_dir) - else: - # Try to ascertain the string table location from the language code - # and next 2 bytes if no STRPACK header is present. (HP B013300I) - offset = data.find(b'us\x14\x00') - if offset > -1: - header = data[offset - 0x20:offset] - if len(header) < 0x20: - header = (b'\x00' * (0x20 - len(header))) + header - strings_files.append(header + data[offset:]) - else: - self.debug_print('Bad strings file:', file_in_dir) + # Load each string table. + offset += 0x1c + languages = [] + while True: + # Parse string table header. + lang_header = data[offset:offset + 6] + if len(lang_header) != 6: # end reached + break + lang_size, _, lang_code = struct.unpack('', languages) + else: + self.debug_print('Bad strings file:', file_in_dir) # Read sign-on string pointer. signon_segment = code_segment @@ -2246,7 +2256,6 @@ class PhoenixAnalyzer(Analyzer): signon = None if bios_maj >= 6 or (bios_maj == 4 and bios_min >= 6): # 4.0R6+: string table pointer is relative to string table file minus header. - signon_offset += 0x1c self.debug_print('BCPOST sign-on points to string table file offset', hex(signon_offset)) # Make sure we have a strings file first. @@ -2254,12 +2263,11 @@ class PhoenixAnalyzer(Analyzer): string_table_offset = strings_files[0][signon_offset:signon_offset + 2] if len(string_table_offset) == 2: signon_offset, = struct.unpack('