You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

  1. import sys
  2. import os
  3. #import pefile
  4. import io
  5. import string
  6. def main():
  7. path = os.path.dirname(os.path.realpath(sys.argv[0]))
  8. file = sys.argv[1]
  9. proxies = io.StringIO()
  10. proxy_add = io.StringIO()
  11. proxy_def = io.StringIO()
  12. proxy_def_file = io.StringIO()
  13. count = 0
  14. """ for dll in dlls:
  15. pe = pefile.PE(dll, fast_load=True)
  16. pe.parse_data_directories()
  17. for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
  18. name = exp.name.decode()
  19. proxies.write("%s\n" % name)
  20. proxy_add.write("ADD_ORIGINAL(%d, %s);\n" % (count, name))
  21. proxy_def.write("PROXY(%d, %s);\n" % (count, name))
  22. count = count + 1 """
  23. with open(file, "r") as includes:
  24. names = includes.readlines()
  25. for name in names:
  26. name = name.strip()
  27. proxies.write(f"{name}\n")
  28. proxy_add.write(f"ADD_ORIGINAL({count}, {name});\n")
  29. proxy_def.write(f"PROXY({count}, {name});\n")
  30. proxy_def_file.write(f" {name} @{count+1}\n")
  31. count = count + 1
  32. with open(f"{path}\\templates\\proxy_template.c", "r") as proxy_file:
  33. new_proxy = string.Template(proxy_file.read()).safe_substitute(proxy_count=count, proxy_add=proxy_add.getvalue(), proxy_def=proxy_def.getvalue())
  34. with open(f"{path}\\..\\Proxy\\proxy.c", "w") as proxy_c_file:
  35. proxy_c_file.write(new_proxy)
  36. with open(f"{path}\\templates\\proxy_template.def", "r") as proxy_file:
  37. new_proxy_def = string.Template(proxy_file.read()).safe_substitute(proxy_exports=proxy_def_file.getvalue())
  38. with open(f"{path}\\..\\Proxy\\proxy.def", "w") as proxy_def_file:
  39. proxy_def_file.write(new_proxy_def)
  40. if __name__ == "__main__":
  41. main()