2025-04-10 17:31:33 +08:00

50 lines
1.4 KiB
Python

import os
import sys
import shutil
import struct
def update_file(path, list_value):
content = bytes()
for value in list_value:
content = content + value
if os.path.exists(path):
file = open(path, mode='rb')
content = content + file.read()
file.close()
file = open(os.path.dirname(path) + '/pack.app', mode='wb')
file.write(content)
file.close()
else:
print('Error: ' + path + ' is not exists.')
if __name__ == '__main__':
root = os.path.dirname(os.path.realpath(__file__)) + '/../../../'
path = root + 'PLAT/appsdk_dyn/main.bin'
name = b'app0' + bytes(4)
size = struct.pack('I', os.path.getsize(path))
reserved_0 = bytes(4)
reserved_1 = bytes(16)
list_value = [name, size, reserved_0, reserved_1]
textOffset = bytes(4)
textSize = bytes(4)
textRelocation = bytes(4)
dataOffset = bytes(4)
dataSize = bytes(4)
dataRelocation = bytes(4)
resourceOffset = bytes(4)
resourceSize = bytes(4)
resourceRelocation = bytes(4)
reserved3 = bytes(12)
list_value = [name, size, reserved_0, reserved_1, textOffset, textSize, textRelocation, dataOffset, dataSize, dataRelocation, resourceOffset, resourceSize, resourceRelocation, reserved3]
update_file(path, list_value)
print('End')