Apple EFI File Renamer v1.2

Added official Intel $IBIOSI$ parsing
Added $IBIOSI$ output information
This commit is contained in:
Plato Mavropoulos 2018-09-05 15:36:17 +03:00
parent bdcb70c2c8
commit b70424e005

View file

@ -4,9 +4,10 @@
Apple EFI Rename
Apple EFI File Renamer
Copyright (C) 2018 Plato Mavropoulos
https://github.com/tianocore/edk2/blob/master/Vlv2TbltDevicePkg/Include/Library/BiosIdLib.h
"""
print('Apple EFI File Renamer v1.1\n')
print('Apple EFI File Renamer v1.2\n')
import os
import re
@ -15,7 +16,7 @@ import zlib
import shutil
import subprocess
pattern = re.compile(br'\x24\x49\x42\x49\x4F\x53\x49\x24') # Apple $IBIOSI$
pattern = re.compile(br'\x24\x49\x42\x49\x4F\x53\x49\x24') # Intel $IBIOSI$
if len(sys.argv) >= 2 :
# Drag & Drop or CLI
@ -24,7 +25,7 @@ else :
# Folder path
apple_efi = []
in_path = input('\nEnter the full folder path: ')
print('\nWorking...')
print('\nWorking...\n')
for root, dirs, files in os.walk(in_path):
for name in files :
apple_efi.append(os.path.join(root, name))
@ -59,27 +60,39 @@ for input_file in apple_efi :
if not error :
bios_info = buffer[is_ibiosi.end():is_ibiosi.end() + 0x40].split(b'\x2E\x00') # Each $IBIOSI$ section ends with 0x2E00
bios_info = buffer[is_ibiosi.end():is_ibiosi.end() + 0x42].decode('utf-16')
model = bios_info[0].decode('utf-16').strip()
tag = bios_info[1].decode('utf-16').strip() # 88Z
version = bios_info[2].decode('utf-16').strip()
build = bios_info[3].decode('utf-16').strip() # Bxx
datetime = bios_info[4].decode('utf-16').strip() # Year Month Day Hour Minute
year = datetime[0:2]
month = datetime[2:4]
day = datetime[4:6]
hour = datetime[6:8]
minute = datetime[8:10]
BoardID = bios_info[:7].strip()
BoardRev = bios_info[7]
OEMID = bios_info[9:12] # 88Z
MajorVer = bios_info[13:17]
BuildType = bios_info[18] # B
MinorVer = bios_info[19:21]
Year = bios_info[22:24]
Month = bios_info[24:26]
Day = bios_info[26:28]
Hour = bios_info[28:30]
Minute = bios_info[30:32]
file_chk = zlib.adler32(buffer) & 0xFFFFFFFF # Checksum for EFI with same $IBIOSI$ but different PRD/PRE status
file_chk = zlib.adler32(buffer) # Checksum for EFI with same $IBIOSI$ but different PRD/PRE status
file_path_new = os.path.join(file_dir, '%s_%s_%s_20%s-%s-%s_%s-%s_%0.8X%s' % (model, version, build, year, month, day, hour, minute, file_chk, file_ext))
new_name = '%s%s_%s_%s%s_20%s-%s-%s_%s-%s_%0.8X%s' % (BoardID, BoardRev, MajorVer, BuildType, MinorVer, Year, Month, Day, Hour, Minute, file_chk, file_ext)
file_path_new = os.path.join(file_dir, new_name)
if not os.path.isfile(file_path_new) : os.replace(file_path, file_path_new) # Rename input EFI with proper name
print(new_name)
print('\nBoard Identity: %s%s' % (BoardID, BoardRev))
print('Apple Identity: %s' % OEMID)
print('Major Version: %s' % MajorVer)
print('Minor Version: %s' % MinorVer)
print('Build Type: %s' % BuildType)
print('Build Date: 20%s-%s-%s' % (Year, Month, Day))
print('Build Time: %s:%s\n' % (Hour, Minute))
else :
print('Error: Could not find $IBIOSI$ pattern at %s!' % file_name)
print('\nError: Could not find $IBIOSI$ pattern at %s!' % file_name)
print(' Make sure that "UEFIFind" and "UEFIExtract" executables exist!\n')
input('Done!')