From 224d90eff6c03c3be7af037fec7eba10cb55b433 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 13 Apr 2022 18:43:47 -0300 Subject: [PATCH] Move entrypoint pattern back to BIOSExtractor --- biostools/extractors.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/biostools/extractors.py b/biostools/extractors.py index 1feab71..a810ac5 100644 --- a/biostools/extractors.py +++ b/biostools/extractors.py @@ -23,13 +23,6 @@ except ImportError: PIL.Image = None from . import util -# Pattern for common BIOS entrypoints, declared globally here as multiple extractors use it. -_entrypoint_pattern = re.compile( - b'''\\xEA[\\x00-\\xFF]{2}\\x00\\xF0|''' # typical AMI/Award/Phoenix - b'''\\x0F\\x09\\xE9|''' # Intel AMIBIOS 6 - b'''\\xE9[\\x00-\\xFF]{2}\\x00{5}''' # weird Intel (observed in SRSH4) -) - class Extractor: def extract(self, file_path, file_header, dest_dir, dest_dir_0): """Extract the given file into one of the destination directories: @@ -258,6 +251,13 @@ class BIOSExtractor(Extractor): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + # BIOS entrypoint signatures (faster search) + self._entrypoint_pattern = re.compile( + b'''\\xEA[\\x00-\\xFF]{2}\\x00\\xF0|''' # typical AMI/Award/Phoenix + b'''\\x0F\\x09\\xE9|''' # Intel AMIBIOS 6 + b'''\\xE9[\\x00-\\xFF]{2}\\x00{5}''' # weird Intel (observed in SRSH4) + ) + # Fallback BIOS signatures (slower search), based on bios_extract.c self._signature_pattern = re.compile( b'''AMI(?:BIOS(?: \\(C\\)1993 American Megatrends Inc.,| W 0[45]|C0[6789])|BOOT ROM|EBBLK| Flash Utility for DOS Command mode\\.)|''' @@ -307,7 +307,7 @@ class BIOSExtractor(Extractor): file_header += util.read_complement(file_path, file_header) # Stop if no BIOS signatures are found. - if not _entrypoint_pattern.match(file_header[-16:]) and not self._signature_pattern.search(file_header): + if not self._entrypoint_pattern.match(file_header[-16:]) and not self._signature_pattern.search(file_header): return False # Create destination directory and stop if it couldn't be created.