成功提取oem数据并解析
This commit is contained in:
@@ -233,6 +233,7 @@ def bin_to_hex(bin:bytearray,f,oem_file=None):
|
||||
turned+=pack_size
|
||||
else:
|
||||
data=bin[turned:]
|
||||
turned_old=turned
|
||||
turned=all_size
|
||||
if(all_size-turned_old>=64):
|
||||
hdr_data=bin[turned_old:turned_old+64]
|
||||
@@ -253,7 +254,7 @@ def bin_to_hex(bin:bytearray,f,oem_file=None):
|
||||
if(oem_file is not None):
|
||||
if(_ImgType[hdr_data[1]]=="imgV1OEM"):
|
||||
size=int(ret["imgSize"])
|
||||
oem_bin=bin[turned_old+32:turned_old+32+size]
|
||||
oem_bin=bin[turned_old+64:turned_old+64+size]
|
||||
oem_file.write(oem_bin)
|
||||
out_text=f"[{hex(turned_old)}] {data.hex(' ')}\n"
|
||||
f.write(out_text)
|
||||
@@ -272,17 +273,19 @@ def bin_to_hex_file(bin_file_name:str,hex_file_name:str,enc=0):
|
||||
with open(hex_file_name,mode='w+',encoding="utf-8") as f:
|
||||
# oem_bin 去除原始后缀 .bin.txt 添加新后缀 -oem.bin
|
||||
oem_name=hex_file_name[0:-8]+'-oem.bin'
|
||||
oem_name=os.path.normpath(oem_name)
|
||||
with open(oem_name,mode='wb+') as oem_f:
|
||||
kl=bin_to_hex(bin,f,oem_f)
|
||||
# 调用oem_tool 打印oem信息
|
||||
myprint(bin_path())
|
||||
oem_tool=os.path.join(bin_path(),f"{kl}_oem.exe")
|
||||
if(os.path.exists(oem_tool)):
|
||||
cmd_str=f"{oem_tool} --parse={oem_name}"
|
||||
myprint(cmd_str)
|
||||
os.system(cmd_str)
|
||||
else:
|
||||
myprint(f"oem_tool not found: {oem_tool}")
|
||||
# 调用oem_tool 打印oem信息
|
||||
oem_tool=os.path.join(bin_path(),f"{kl}_oem.exe")
|
||||
if(os.path.exists(oem_tool)):
|
||||
cmd_str=f"{oem_tool} --parse={oem_name}"
|
||||
with os.popen(cmd_str) as f:
|
||||
for line in f.readlines():
|
||||
myprint(line.strip())
|
||||
# os.system(cmd_str)
|
||||
else:
|
||||
myprint(f"oem_tool not found: {oem_tool}")
|
||||
|
||||
def bin_file_decrypt(bin_file:str):
|
||||
with open(bin_file,mode='rb') as f:
|
||||
|
Reference in New Issue
Block a user