23 lines
788 B
Python
23 lines
788 B
Python
"""
|
|
This script is used to attach zero bytes to img file
|
|
REMENBER TO CHECK 0x01FF AND 0x1400
|
|
"""
|
|
|
|
def append_zeros_to_bin_file(file_path, target_size_hex):
|
|
target_size = int(target_size_hex, 16) # Convert hex size to decimal
|
|
with open(file_path, "ab") as file: # Open the file in append binary mode
|
|
file.seek(0, 2) # Go to the end of the file
|
|
current_size = file.tell() # Get the current size of the file
|
|
zeros_to_add = (
|
|
target_size - current_size
|
|
) # Calculate the number of zeros to add
|
|
|
|
if zeros_to_add > 0:
|
|
file.write(b"\x00" * zeros_to_add) # Append the zeros
|
|
else:
|
|
print("File is already at or exceeds the target size.")
|
|
|
|
|
|
# Usage
|
|
append_zeros_to_bin_file("helloos.img", "0x168000")
|