Added Dell PFS Update Extractor v6.0_a1

Adjusted dependencies
This commit is contained in:
platomav 2022-04-07 01:13:07 +03:00
parent 46172a218b
commit f2be701423
12 changed files with 1242 additions and 211 deletions

View file

@ -4,9 +4,9 @@
import os
import subprocess
from common.script_get import get_script_dir
from common.path_ops import get_script_dir
from common.system import get_os_ver
from common.text_ops import padder
from common.system import printer
# Get 7z path
def get_7z_path(static=False):
@ -36,10 +36,10 @@ def a7z_decompress(in_path, out_path, in_name, padding, static=False):
if not os.path.isdir(out_path): raise Exception('EXTRACT_DIR_MISSING')
except:
print('\n%sError: 7-Zip could not extract %s file %s!' % (padder(padding), in_name, in_path))
printer('Error: 7-Zip could not extract %s file %s!' % (in_name, in_path), padding)
return 1
print('\n%sSuccesfull %s decompression via 7-Zip!' % (padder(padding), in_name))
printer('Succesfull %s decompression via 7-Zip!' % in_name, padding)
return 0

View file

@ -2,12 +2,20 @@
#coding=utf-8
# Get Checksum 16-bit
def checksum16(data):
chk16 = 0
def get_chk_16(data, value=0, order='little'):
for idx in range(0, len(data), 2):
chk16 += int.from_bytes(data[idx:idx + 2], 'little')
# noinspection PyTypeChecker
value += int.from_bytes(data[idx:idx + 2], order)
chk16 &= 0xFFFF
value &= 0xFFFF
return chk16
return value
# Get Checksum 8-bit XOR
def get_chk_8_xor(data, value=0):
for byte in data:
value ^= byte
value ^= 0x0
return value

View file

@ -4,9 +4,9 @@
import os
import subprocess
from common.script_get import get_script_dir
from common.path_ops import get_script_dir
from common.system import get_os_ver
from common.text_ops import padder
from common.system import printer
def get_compress_sizes(data):
size_compress = int.from_bytes(data[0x0:0x4], 'little')
@ -42,10 +42,10 @@ def efi_decompress(in_path, out_path, padding, comp_type='--uefi'):
if os.path.getsize(out_path) != size_orig: raise Exception('EFI_DECOMPRESS_ERROR')
except:
print('\n%sError: TianoCompress could not extract file %s!' % (padder(padding), in_path))
printer('Error: TianoCompress could not extract file %s!' % in_path, padding)
return 1
print('\n%sSuccesfull EFI/Tiano decompression via TianoCompress!' % padder(padding))
printer('Succesfull EFI/Tiano decompression via TianoCompress!', padding)
return 0

View file

@ -3,11 +3,11 @@
import os
import re
import sys
import inspect
import argparse
from pathlib import Path
from common.script_get import get_script_dir
# Fix illegal/reserved Windows characters
def safe_name(in_name):
raw_name = repr(in_name).strip("'")
@ -76,4 +76,16 @@ def process_input_files(argparse_args, sys_argv=None):
output_path = get_absolute_path(input('\nEnter output directory path: '))
return input_files, output_path
return input_files, output_path
# https://stackoverflow.com/a/22881871 by jfs
def get_script_dir(follow_symlinks=True):
if getattr(sys, 'frozen', False):
path = os.path.abspath(sys.executable)
else:
path = inspect.getabsfile(get_script_dir)
if follow_symlinks:
path = os.path.realpath(path)
return os.path.dirname(path)

View file

@ -5,4 +5,7 @@ import re
PAT_AMI_PFAT = re.compile(b'_AMIPFAT.AMI_BIOS_GUARD_FLASH_CONFIGURATIONS', re.DOTALL)
PAT_AMI_UCP = re.compile(br'\x40\x55\x41\x46.{12}\x40', re.DOTALL)
PAT_DELL_PKG = re.compile(br'\x72\x13\x55\x00.{45}\x37\x7A\x58\x5A', re.DOTALL)
PAT_DELL_HDR = re.compile(br'\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL)
PAT_DELL_FTR = re.compile(br'\xEE\xAA\xEE\x8F\x49\x1B\xE8\xAE\x14\x37\x90')
PAT_INTEL_ENG = re.compile(br'\x04\x00{3}[\xA1\xE1]\x00{3}.{8}\x86\x80.{9}\x00\$((MN2)|(MAN))', re.DOTALL)

View file

@ -1,19 +0,0 @@
#!/usr/bin/env python3
#coding=utf-8
# https://stackoverflow.com/a/22881871 by jfs
import os
import sys
import inspect
def get_script_dir(follow_symlinks=True):
if getattr(sys, 'frozen', False):
path = os.path.abspath(sys.executable)
else:
path = inspect.getabsfile(get_script_dir)
if follow_symlinks:
path = os.path.realpath(path)
return os.path.dirname(path)

View file

@ -5,6 +5,9 @@ import sys
import ctypes
import traceback
from common.text_ops import padder
from common.path_ops import process_input_files
# Get Python Version (tuple)
def get_py_ver():
return sys.version_info
@ -20,7 +23,7 @@ def get_os_ver():
# Check for --auto-exit|-e
def is_auto_exit():
return '--auto-exit' in sys.argv or '-e' in sys.argv
return bool('--auto-exit' in sys.argv or '-e' in sys.argv)
# Check Python Version
def check_sys_py():
@ -40,7 +43,7 @@ def check_sys_os():
os_tag,os_win,os_sup = get_os_ver()
if not os_sup:
print('\nError: Unsupported platform "%s"!' % os_tag)
printer('Error: Unsupported platform "%s"!' % os_tag)
if not is_auto_exit():
input('\nPress enter to exit')
@ -51,8 +54,8 @@ def check_sys_os():
if os_win: sys.stdout.reconfigure(encoding='utf-8')
# Show Script Title
def show_title(title):
print('\n' + title)
def script_title(title):
printer(title)
_,os_win,_ = get_os_ver()
@ -60,12 +63,28 @@ def show_title(title):
if os_win: ctypes.windll.kernel32.SetConsoleTitleW(title)
else: sys.stdout.write('\x1b]2;' + title + '\x07')
# Initialize Script
def script_init(arguments, padding=0):
# Pretty Python exception handler (must be after argparse)
sys.excepthook = nice_exc_handler
# Check Python Version (must be after argparse)
check_sys_py()
# Check OS Platform (must be after argparse)
check_sys_os()
# Process input files and generate output path
input_files,output_path = process_input_files(arguments, sys.argv)
return input_files, output_path, padding
# https://stackoverflow.com/a/781074 by Torsten Marek
def nice_exc_handler(exc_type, exc_value, tb):
if exc_type is KeyboardInterrupt:
print('\n')
printer('')
else:
print('\nError: Script crashed, please report the following:\n')
printer('Error: Script crashed, please report the following:\n')
traceback.print_exception(exc_type, exc_value, tb)
@ -74,6 +93,17 @@ def nice_exc_handler(exc_type, exc_value, tb):
sys.exit(3)
# Print or Input Message based on --auto-exit|-e
def print_input(msg):
(print if is_auto_exit() else input)(msg)
# Show message(s) while controlling padding, newline, pausing & separator
def printer(in_message='', padd_count=0, new_line=True, pause=False, sep_char=' '):
if type(in_message).__name__ in ('list','tuple'):
message = sep_char.join(map(str, in_message))
else:
message = str(in_message)
padding = padder(padd_count)
newline = '\n' if new_line else ''
output = newline + padding + message
(input if pause and not is_auto_exit() else print)(output)

View file

@ -2,5 +2,5 @@
#coding=utf-8
# Generate padding (spaces or tabs)
def padder(count, tab=False):
return ('\t' if tab else ' ') * count
def padder(padd_count, tab=False):
return ('\t' if tab else ' ') * padd_count