mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-15 23:54:45 -04:00
Dell HDR Module Extractor v2.0
Fixed issue which caused some HDR executables to extract less modules than expected
This commit is contained in:
parent
dcb2aad30e
commit
09c02caa9a
2 changed files with 26 additions and 34 deletions
|
@ -7,7 +7,7 @@ Copyright (C) 2018 Plato Mavropoulos
|
|||
Inspired from https://forums.mydigitallife.net/threads/i-present-you-a-tool-to-decompress-dell-uefi-bios.44785/ by JimboBobB
|
||||
"""
|
||||
|
||||
print('Dell HDR Module Extractor v1.1\n')
|
||||
print('Dell HDR Module Extractor v2.0\n')
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -35,45 +35,35 @@ for input_file in hdr_exec :
|
|||
with open(input_file, 'rb') as in_file : bios_data = in_file.read()
|
||||
|
||||
# Compressed Dell HDR pattern followed by the zlib header of 0x789C
|
||||
pat_hdr = re.compile(br'\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL)
|
||||
match_hdr = pat_hdr.search(bios_data)
|
||||
match_hdr = re.compile(br'\xAA\xEE\xAA\x76\x1B\xEC\xBB\x20\xF1\xE6\x51.\x78\x9C', re.DOTALL).search(bios_data)
|
||||
|
||||
# Check if Compressed Dell HDR pattern was found
|
||||
# Check if compressed Dell HDR pattern was found
|
||||
if not match_hdr :
|
||||
print('\n Error: No Dell HDR found at %s%s!' % (input_name, input_extension))
|
||||
|
||||
continue # Next input file
|
||||
|
||||
# Detected Compressed Dell HDR pattern
|
||||
while match_hdr :
|
||||
# Store the compressed zlib data size from the proceeding 4 bytes of the Dell HDR pattern
|
||||
compressed_size = int.from_bytes(bios_data[match_hdr.start() - 0x4:match_hdr.start()], 'little')
|
||||
# Store the compressed zlib data size from the proceeding 4 bytes of the Dell HDR pattern
|
||||
compressed_size = int.from_bytes(bios_data[match_hdr.start() - 0x4:match_hdr.start()], 'little')
|
||||
|
||||
# Decompress zlib payload from 0x789C via Python
|
||||
decomp_data = zlib.decompress(bios_data[match_hdr.start() + 0xC:match_hdr.start() + 0xC + compressed_size])
|
||||
|
||||
output_name = input_name + '.hdr'
|
||||
|
||||
with open(output_name, 'wb') as hdr_file : hdr_file.write(decomp_data)
|
||||
|
||||
print('\n Decompressed %s%s via Python' % (input_name, input_extension))
|
||||
|
||||
# Extract the Dell HDR image via LongSoft's PFSExtractor-RS
|
||||
try :
|
||||
subprocess.run(['PFSExtractor', output_name], check = True, stdout = subprocess.DEVNULL)
|
||||
|
||||
# Store compressed zlib data
|
||||
compressed_data = bios_data[match_hdr.start() + 0xC:match_hdr.start() + 0xC + compressed_size]
|
||||
if os.path.isfile(output_name) : os.remove(output_name)
|
||||
|
||||
# Decompress zlib payload
|
||||
bios_data = zlib.decompress(compressed_data)
|
||||
|
||||
# Scan for nested zlib data streams
|
||||
match_hdr = pat_hdr.search(bios_data)
|
||||
else :
|
||||
output_name = input_name + '.hdr'
|
||||
|
||||
with open(output_name, 'wb') as hdr_file : hdr_file.write(bios_data)
|
||||
|
||||
print('\n Decompressed %s%s via Python' % (input_name, input_extension))
|
||||
|
||||
# Call LongSoft's PFSExtractor-RS to extract the Dell HDR container
|
||||
try :
|
||||
subprocess.run(['PFSExtractor', output_name], check = True, stdout = subprocess.DEVNULL)
|
||||
|
||||
if os.path.isfile(output_name) : os.remove(output_name)
|
||||
|
||||
print(' Extracted %s via PFSExtractor-RS' % output_name)
|
||||
except :
|
||||
print(' Error: Could not extract %s via PFSExtractor-RS!' % output_name)
|
||||
print(' Make sure that "PFSExtractor" executable exists!')
|
||||
print(' Extracted %s via PFSExtractor-RS' % output_name)
|
||||
except :
|
||||
print(' Error: Could not extract %s via PFSExtractor-RS!' % output_name)
|
||||
print(' Make sure that "PFSExtractor" executable exists!')
|
||||
|
||||
else :
|
||||
input('\nDone!')
|
Loading…
Add table
Add a link
Reference in a new issue