Upload files to "/"

This commit is contained in:
2024-10-18 17:42:24 +08:00
parent 9327c44117
commit fa2930a8ec

View File

@@ -70,21 +70,23 @@ def export_local_types_for_struct():
except Exception as msg: except Exception as msg:
mylog("export_local_types_for_struct",msg) mylog("export_local_types_for_struct",msg)
def export_local_types(save_file): def export_local_types(save_file,flags):
struct_list=export_local_types_for_struct()#返回字典列表 struct_list=export_local_types_for_struct()#返回字典列表
if(struct_list is None):return if(struct_list is None):return
if flags==0:
# # 将结构体信息转换为 JSON 格式 # # 将结构体信息转换为 JSON 格式
json_output = json.dumps(struct_list, indent=4) json_output = json.dumps(struct_list, indent=4)
#print(json_output) #print(json_output)
save_file=save_file+"_Estruct.json" filepath=save_file+"_Estruct.json"
with open(save_file,"w") as f: with open(filepath,"w") as f:
f.write(json_output) f.write(json_output)
else :
# 字符串存储 # 字符串存储
# save_file=save_file+"_Estruct.txt" filepath=save_file+"_Estruct.txt"
# with open(save_file,"w") as f: with open(filepath,"w") as f:
# for i in struct_list: for i in struct_list:
# f.write(f"[{i['name']}:struct_size {i['size']} -> {i['info']}]\n") f.write(f"[{i['name']}:struct_size {i['size']} -> {i['info']}]\n")
#函数黑名单 #函数黑名单
BLACK_LIST={ BLACK_LIST={
@@ -97,9 +99,11 @@ STRUCT_BACKLIST={
"Elf64_Sym","Elf64_Rela","Elf64_Dyn","Elf64_Verneed","Elf64_Vernaux" "Elf64_Sym","Elf64_Rela","Elf64_Dyn","Elf64_Verneed","Elf64_Vernaux"
} }
def main(): def main():
save_dir="result" save_dir="../input"
extractfile="extract.c" extractfile="extractelf"
filepath="tmp.txt" filepath="tmp.txt"
try:
if(not os.path.exists(save_dir)):os.makedirs(save_dir)
if (os.path.exists(filepath) and os.path.isfile(filepath) ): if (os.path.exists(filepath) and os.path.isfile(filepath) ):
with open(filepath,"r") as f: with open(filepath,"r") as f:
extractfile=f.read() extractfile=f.read()
@@ -107,7 +111,9 @@ def main():
extractfile=os.path.join(save_dir,extractfile) extractfile=os.path.join(save_dir,extractfile)
export_func(extractfile) export_func(extractfile)
export_local_types(extractfile) export_local_types(extractfile,0)
except Exception as msg:
mylog("main",msg)
if __name__ == "__main__": if __name__ == "__main__":
try : try :