Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- file_path = 'rom.bin'
- # Get the length of the file
- with open(file_path, 'rb') as file:
- file_length = len(file.read())
- # Subtract 1 from the file length
- file_length -= 1
- # Convert the file length to a 32-bit binary representation
- binary_length = struct.pack('<I', file_length)
- # Open the file in write mode and seek to the desired location (0x1A4)
- with open(file_path, 'r+b') as file:
- file.seek(0x1A4)
- # Write the binary length to the file
- file.write(binary_length)
Advertisement
Add Comment
Please, Sign In to add comment