mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-30 23:15:16 -04:00
Apple EFI File Renamer v1.2
Added official Intel $IBIOSI$ parsing Added $IBIOSI$ output information
This commit is contained in:
parent
bdcb70c2c8
commit
b70424e005
1 changed files with 30 additions and 17 deletions
|
@ -4,9 +4,10 @@
|
||||||
Apple EFI Rename
|
Apple EFI Rename
|
||||||
Apple EFI File Renamer
|
Apple EFI File Renamer
|
||||||
Copyright (C) 2018 Plato Mavropoulos
|
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 os
|
||||||
import re
|
import re
|
||||||
|
@ -15,7 +16,7 @@ import zlib
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
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 :
|
if len(sys.argv) >= 2 :
|
||||||
# Drag & Drop or CLI
|
# Drag & Drop or CLI
|
||||||
|
@ -24,7 +25,7 @@ else :
|
||||||
# Folder path
|
# Folder path
|
||||||
apple_efi = []
|
apple_efi = []
|
||||||
in_path = input('\nEnter the full folder path: ')
|
in_path = input('\nEnter the full folder path: ')
|
||||||
print('\nWorking...')
|
print('\nWorking...\n')
|
||||||
for root, dirs, files in os.walk(in_path):
|
for root, dirs, files in os.walk(in_path):
|
||||||
for name in files :
|
for name in files :
|
||||||
apple_efi.append(os.path.join(root, name))
|
apple_efi.append(os.path.join(root, name))
|
||||||
|
@ -59,27 +60,39 @@ for input_file in apple_efi :
|
||||||
|
|
||||||
if not error :
|
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()
|
BoardID = bios_info[:7].strip()
|
||||||
tag = bios_info[1].decode('utf-16').strip() # 88Z
|
BoardRev = bios_info[7]
|
||||||
version = bios_info[2].decode('utf-16').strip()
|
OEMID = bios_info[9:12] # 88Z
|
||||||
build = bios_info[3].decode('utf-16').strip() # Bxx
|
MajorVer = bios_info[13:17]
|
||||||
datetime = bios_info[4].decode('utf-16').strip() # Year Month Day Hour Minute
|
BuildType = bios_info[18] # B
|
||||||
year = datetime[0:2]
|
MinorVer = bios_info[19:21]
|
||||||
month = datetime[2:4]
|
Year = bios_info[22:24]
|
||||||
day = datetime[4:6]
|
Month = bios_info[24:26]
|
||||||
hour = datetime[6:8]
|
Day = bios_info[26:28]
|
||||||
minute = datetime[8:10]
|
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
|
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 :
|
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')
|
print(' Make sure that "UEFIFind" and "UEFIExtract" executables exist!\n')
|
||||||
|
|
||||||
input('Done!')
|
input('Done!')
|
Loading…
Add table
Add a link
Reference in a new issue