mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-13 06:34:42 -04:00
Added AMI PFAT RSA 3K signed blocks support
Added AMI PFAT nested detection at each file Added Award BIOS payload naming at each file Switched Panasonic BIOS LZNT1 external library Improved Panasonic LZNT1 detection and length Improved Dell PFS code structure and fixed bugs Improved code exception handling (raise, catch) Improved code definitions (PEP8, docs, types) Fixed some arguments missing from help screens
This commit is contained in:
parent
03ae0cf070
commit
d85a7f82dc
37 changed files with 2897 additions and 2174 deletions
|
@ -1,33 +1,48 @@
|
|||
#!/usr/bin/env python3
|
||||
#coding=utf-8
|
||||
#!/usr/bin/env python3 -B
|
||||
# coding=utf-8
|
||||
|
||||
"""
|
||||
Copyright (C) 2022 Plato Mavropoulos
|
||||
Copyright (C) 2022-2024 Plato Mavropoulos
|
||||
"""
|
||||
|
||||
# Generate padding (spaces or tabs)
|
||||
|
||||
def padder(padd_count, tab=False):
|
||||
""" Generate padding (spaces or tabs) """
|
||||
|
||||
return ('\t' if tab else ' ') * padd_count
|
||||
|
||||
# Get String from given input object
|
||||
|
||||
def to_string(in_object, sep_char=''):
|
||||
if type(in_object).__name__ in ('list','tuple'):
|
||||
""" Get String from given input object """
|
||||
|
||||
if type(in_object).__name__ in ('list', 'tuple'):
|
||||
out_string = sep_char.join(map(str, in_object))
|
||||
else:
|
||||
out_string = str(in_object)
|
||||
|
||||
|
||||
return out_string
|
||||
|
||||
# Get Bytes from given buffer or file path
|
||||
|
||||
def file_to_bytes(in_object):
|
||||
""" Get Bytes from given buffer or file path """
|
||||
|
||||
object_bytes = in_object
|
||||
|
||||
if type(in_object).__name__ not in ('bytes','bytearray'):
|
||||
|
||||
if type(in_object).__name__ not in ('bytes', 'bytearray'):
|
||||
with open(to_string(in_object), 'rb') as object_data:
|
||||
object_bytes = object_data.read()
|
||||
|
||||
|
||||
return object_bytes
|
||||
|
||||
# Check if string starts and ends with given character(s)
|
||||
|
||||
def bytes_to_hex(buffer: bytes, order: str, data_len: int, slice_len: int | None = None) -> str:
|
||||
""" Converts bytes to hex string, controlling endianess, data size and string slicing """
|
||||
|
||||
# noinspection PyTypeChecker
|
||||
return f'{int.from_bytes(buffer, order):0{data_len * 2}X}'[:slice_len]
|
||||
|
||||
|
||||
def is_encased(in_string, chars):
|
||||
""" Check if string starts and ends with given character(s) """
|
||||
|
||||
return in_string.startswith(chars) and in_string.endswith(chars)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue