mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-09 13:52:00 -04:00
BIOSUtilities v24.10.29
Added graceful exception hanlding during "main" flow Improved and cleaned 7-Zip and EFI compression logic Improved too aggressive extraction directory handling Fixed input name detection at VAIO Package Extractor Fixed Intel IBIOSI detection at Apple EFI Identifier
This commit is contained in:
parent
d8e23f9ef3
commit
f895fc208c
24 changed files with 327 additions and 380 deletions
|
@ -11,11 +11,10 @@ import os
|
|||
import re
|
||||
|
||||
from biosutilities.common.compression import is_szip_supported, szip_decompress
|
||||
from biosutilities.common.paths import make_dirs
|
||||
from biosutilities.common.paths import delete_file, make_dirs
|
||||
from biosutilities.common.patterns import PAT_FUJITSU_SFX
|
||||
from biosutilities.common.system import printer
|
||||
from biosutilities.common.templates import BIOSUtility
|
||||
from biosutilities.common.texts import file_to_bytes
|
||||
|
||||
|
||||
class FujitsuSfxExtract(BIOSUtility):
|
||||
|
@ -26,17 +25,13 @@ class FujitsuSfxExtract(BIOSUtility):
|
|||
def check_format(self) -> bool:
|
||||
""" Check if input is Fujitsu SFX image """
|
||||
|
||||
input_buffer: bytes = file_to_bytes(in_object=self.input_object)
|
||||
|
||||
return bool(PAT_FUJITSU_SFX.search(input_buffer))
|
||||
return bool(PAT_FUJITSU_SFX.search(self.input_buffer))
|
||||
|
||||
def parse_format(self) -> bool:
|
||||
""" Parse & Extract Fujitsu SFX image """
|
||||
|
||||
input_buffer: bytes = file_to_bytes(in_object=self.input_object)
|
||||
|
||||
# Microsoft CAB Header XOR 0xFF
|
||||
match_cab: re.Match[bytes] | None = PAT_FUJITSU_SFX.search(input_buffer)
|
||||
match_cab: re.Match[bytes] | None = PAT_FUJITSU_SFX.search(self.input_buffer)
|
||||
|
||||
if not match_cab:
|
||||
return False
|
||||
|
@ -47,7 +42,7 @@ class FujitsuSfxExtract(BIOSUtility):
|
|||
cab_start: int = match_cab.start() + 0xA
|
||||
|
||||
# Get LE XOR-ed CAB size
|
||||
cab_size: int = int.from_bytes(input_buffer[cab_start + 0x8:cab_start + 0xC], byteorder='little')
|
||||
cab_size: int = int.from_bytes(self.input_buffer[cab_start + 0x8:cab_start + 0xC], byteorder='little')
|
||||
|
||||
# Create CAB size XOR value
|
||||
xor_size: int = int.from_bytes(b'\xFF' * 0x4, byteorder='little')
|
||||
|
@ -58,7 +53,7 @@ class FujitsuSfxExtract(BIOSUtility):
|
|||
printer(message='Removing obfuscation...', padding=self.padding + 4)
|
||||
|
||||
# Get BE XOR-ed CAB data
|
||||
cab_data: int = int.from_bytes(input_buffer[cab_start:cab_start + cab_size], byteorder='big')
|
||||
cab_data: int = int.from_bytes(self.input_buffer[cab_start:cab_start + cab_size], byteorder='big')
|
||||
|
||||
# Create CAB data XOR value
|
||||
xor_data: int = int.from_bytes(b'\xFF' * cab_size, byteorder='big')
|
||||
|
@ -68,7 +63,7 @@ class FujitsuSfxExtract(BIOSUtility):
|
|||
|
||||
printer(message='Extracting archive...', padding=self.padding + 4)
|
||||
|
||||
make_dirs(in_path=self.extract_path, delete=True)
|
||||
make_dirs(in_path=self.extract_path)
|
||||
|
||||
cab_path: str = os.path.join(self.extract_path, 'FjSfxBinay.cab')
|
||||
|
||||
|
@ -76,10 +71,10 @@ class FujitsuSfxExtract(BIOSUtility):
|
|||
with open(cab_path, 'wb') as cab_file_object:
|
||||
cab_file_object.write(raw_data)
|
||||
|
||||
if is_szip_supported(in_path=cab_path, padding=self.padding + 8, silent=False):
|
||||
if is_szip_supported(in_path=cab_path):
|
||||
if szip_decompress(in_path=cab_path, out_path=self.extract_path, in_name='FjSfxBinay CAB',
|
||||
padding=self.padding + 8, check=True):
|
||||
os.remove(cab_path)
|
||||
delete_file(in_path=cab_path)
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue