Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # >> IMPORTS
- # =============================================================================
- # Python
- from __future__ import with_statement
- import pprint
- import os
- import time
- from path import path
- # EventScripts
- import es
- # binutils
- import binutils
- # =============================================================================
- # >> FUNCTIONS
- # =============================================================================
- def get_interface_register(dump_file, allowed_ext=('.dll', '.so')):
- if not dump_file.endswith(allowed_ext):
- return None
- try:
- binary = binutils.find_binary(dump_file, False)
- except:
- return None
- if os.name == 'posix':
- ref = binary['_ZN12InterfaceReg16s_pInterfaceRegsE']
- else:
- ref = binary.find_pointer('\x55\x8B\xEC\x56\x8B\x35\x2A\x2A\x2A\x2A\x57\x85\xF6\x74\x2A\x8B\x7D\x08\x8B\x46\x04', 6)
- if not ref:
- return None
- return ref.get_ptr()
- def dump_interface(dump_file):
- register = get_interface_register(dump_file)
- if not register:
- return None
- interfaces = set()
- # Loop through all interface versions and add them to the set
- while register:
- interfaces.add(register.get_string(4))
- register = register.get_ptr(8)
- return sorted(interfaces)
- def dump_interfaces(output_file):
- with open(output_file, 'w') as f:
- f.write('# Created at: %s\n\n'% time.ctime())
- for dump_file in path(os.getcwd()).joinpath('bin').files() + path(es.getString('eventscripts_gamedir')).joinpath('bin').files():
- dump = dump_interface(str(dump_file))
- if not dump:
- continue
- f.write('# %s\n'% dump_file.relpath().replace('\\', '/'))
- f.write(pprint.pformat(dump))
- f.write('\n\n')
- # =============================================================================
- # >> START DUMP
- # =============================================================================
- dump_interfaces(path(__file__).parent.joinpath('output.txt'))
Add Comment
Please, Sign In to add comment