Insyde iFlash/iFdPacker Extractor v2.0_a8

Improved PFAT, UCP, PFS, TDK format check methods

Cleanup/improvements to all utilities
This commit is contained in:
platomav 2022-07-06 17:54:17 +03:00
parent cd2704f743
commit 4749414f81
21 changed files with 603 additions and 435 deletions

View file

@ -22,8 +22,10 @@ def is_efi_compressed(data, strict=True):
check_diff = size_comp < size_orig
if strict: check_size = size_comp + 0x8 == len(data)
else: check_size = size_comp + 0x8 <= len(data)
if strict:
check_size = size_comp + 0x8 == len(data)
else:
check_size = size_comp + 0x8 <= len(data)
return check_diff and check_size
@ -38,9 +40,11 @@ def efi_decompress(in_path, out_path, padding=0, silent=False, comp_type='--uefi
try:
subprocess.run([get_tiano_path(), '-d', in_path, '-o', out_path, '-q', comp_type], check=True, stdout=subprocess.DEVNULL)
with open(in_path, 'rb') as file: _,size_orig = get_compress_sizes(file.read())
with open(in_path, 'rb') as file:
_,size_orig = get_compress_sizes(file.read())
if os.path.getsize(out_path) != size_orig: raise Exception('EFI_DECOMPRESS_ERROR')
if os.path.getsize(out_path) != size_orig:
raise Exception('EFI_DECOMPRESS_ERROR')
except:
if not silent:
printer(f'Error: TianoCompress could not extract file {in_path}!', padding)

View file

@ -27,7 +27,8 @@ def is_szip_supported(in_path, padding=0, check=False, silent=False):
try:
szip_t = subprocess.run([get_szip_path(), 't', in_path, '-bso0', '-bse0', '-bsp0'], check=False)
if check: check_bad_exit_code(szip_t.returncode)
if check:
check_bad_exit_code(szip_t.returncode)
except:
if not silent:
printer(f'Error: 7-Zip could not check support for file {in_path}!', padding)
@ -38,14 +39,17 @@ def is_szip_supported(in_path, padding=0, check=False, silent=False):
# Archive decompression via 7-Zip
def szip_decompress(in_path, out_path, in_name, padding=0, check=False, silent=False):
if not in_name: in_name = 'archive'
if not in_name:
in_name = 'archive'
try:
szip_x = subprocess.run([get_szip_path(), 'x', '-aou', '-bso0', '-bse0', '-bsp0', '-o' + out_path, in_path], check=False)
if check: check_bad_exit_code(szip_x.returncode)
if check:
check_bad_exit_code(szip_x.returncode)
if not os.path.isdir(out_path): raise Exception('EXTRACT_DIR_MISSING')
if not os.path.isdir(out_path):
raise Exception('EXTRACT_DIR_MISSING')
except:
if not silent:
printer(f'Error: 7-Zip could not extract {in_name} file {in_path}!', padding)

View file

@ -6,6 +6,7 @@ Copyright (C) 2022 Plato Mavropoulos
"""
# https://github.com/allowitsme/big-tool by Dmitry Frolov
# https://github.com/platomav/BGScriptTool by Plato Mavropoulos
def get_bgs_tool():
try:
from external.big_script_tool import BigScript

View file

@ -84,7 +84,8 @@ def is_path_absolute(in_path):
# Create folder(s), controlling parents, existence and prior deletion
def make_dirs(in_path, parents=True, exist_ok=False, delete=False):
if delete: del_dirs(in_path)
if delete:
del_dirs(in_path)
Path.mkdir(Path(in_path), parents=parents, exist_ok=exist_ok)
@ -129,7 +130,8 @@ def get_argparse_path(argparse_path):
# Process input files (argparse object)
def process_input_files(argparse_args, sys_argv=None):
if sys_argv is None: sys_argv = []
if sys_argv is None:
sys_argv = []
if len(sys_argv) >= 2:
# Drag & Drop or CLI

View file

@ -14,6 +14,7 @@ PAT_DELL_FTR = re.compile(br'\xEE\xAA\xEE\x8F\x49\x1B\xE8\xAE\x14\x37\x90')
PAT_DELL_HDR = re.compile(br'\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL)
PAT_DELL_PKG = re.compile(br'\x72\x13\x55\x00.{45}7zXZ', re.DOTALL)
PAT_INSYDE_IFL = re.compile(br'\$_IFLASH_')
PAT_INSYDE_SFX = re.compile(br'\x0D\x0A;!@InstallEnd@!\x0D\x0A(7z\xBC\xAF\x27|\x6E\xF4\x79\x5F\x4E)')
PAT_INTEL_ENG = re.compile(br'\x04\x00{3}[\xA1\xE1]\x00{3}.{8}\x86\x80.{9}\x00\$((MN2)|(MAN))', re.DOTALL)
PAT_MICROSOFT_CAB = re.compile(br'MSCF\x00{4}')
PAT_MICROSOFT_MZ = re.compile(br'MZ')

View file

@ -15,7 +15,8 @@ uint64_t = ctypes.c_uint64
# https://github.com/skochinsky/me-tools/blob/master/me_unpack.py by Igor Skochinsky
def get_struct(buffer, start_offset, class_name, param_list=None):
if param_list is None: param_list = []
if param_list is None:
param_list = []
structure = class_name(*param_list) # Unpack parameter list
struct_len = ctypes.sizeof(structure)

View file

@ -56,7 +56,8 @@ def check_sys_os():
sys.exit(126)
# Fix Windows Unicode console redirection
if os_win: sys.stdout.reconfigure(encoding='utf-8')
if os_win:
sys.stdout.reconfigure(encoding='utf-8')
# Initialize common argparse arguments
def argparse_init():
@ -85,10 +86,12 @@ def script_init(title, arguments, padding=0):
printer(title, new_line=False)
# Show Utility Version on demand
if arguments.version: sys.exit(0)
if arguments.version:
sys.exit(0)
# Set console/terminal window title (Windows only)
if get_os_ver()[1]: ctypes.windll.kernel32.SetConsoleTitleW(title)
if get_os_ver()[1]:
ctypes.windll.kernel32.SetConsoleTitleW(title)
# Process input files and generate output path
input_files,output_path = process_input_files(arguments, sys.argv)