diff --git a/ciso.py b/ciso.py index bced6c3..52ef4aa 100755 --- a/ciso.py +++ b/ciso.py @@ -6,6 +6,8 @@ import os import struct import sys +import shutil +import math import lz4.frame CISO_MAGIC = 0x4F534943 # CISO @@ -221,9 +223,423 @@ def compress_iso(infile): pad_file_size(fout_2) fout_2.close() + +def is_xbe_file(xbe, offset = 0): + if not os.path.isfile(xbe): + return False + + with open(xbe, 'rb') as xbe_file: + xbe_file.seek(offset) + magic = xbe_file.read(4) + + if magic != b'XBEH': + return False + + return True + +def get_iso_root_dir_offset_and_size(iso_file): + global image_offset + + iso_header_offset = 0x10000 + root_dir_sect_offset = 0x14 + sector_size = 0x800 + + with open(iso_file, 'rb') as f: + detect_iso_type(f) + + f.seek(image_offset + iso_header_offset + root_dir_sect_offset) + root_dir_sect = struct.unpack('