Use main script's path to locate the database directory.

This is required when running the tool from another
project or IDE.
This commit is contained in:
Maxim Poliakovski 2021-10-22 13:00:17 +02:00
parent 85e4c919bc
commit e3616ecc59
1 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from ruamel.yaml import YAML
from capstone import *
from capstone.m68k import *
import os
import struct
def bit_not(n, numbits=32):
@ -317,9 +318,11 @@ if __name__ == "__main__":
check_sum = struct.unpack('>I', rom_data[0:4])[0]
print("ROM Checksum: %X" % check_sum)
my_path = os.path.dirname(os.path.realpath(__file__))
db_name = 'ROMDB_' + '{:x}'.format(int(check_sum)).upper() + '.yaml'
with open('database/' + db_name, 'rb') as db_file:
with open(my_path + '/database/' + db_name, 'rb') as db_file:
yaml = YAML()
annot_db = yaml.load(db_file)