Skip to content

Commit

Permalink
Make parameter the root directory in import script
Browse files Browse the repository at this point in the history
Instead of specifying the file name, the user just points to the
directory and the script will grab the necessary files.
  • Loading branch information
hainest committed Dec 27, 2023
1 parent 2059392 commit e25173d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions instructionAPI/capstone/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
"--capstone",
type=str,
required=True,
help="Capstone header (e.g., /capstone-engine/capstone/arch/X86/X86MappingInsnName.inc)"
help="Capstone directory (e.g., /capstone-engine/capstone/)"
)

parser.add_argument("--arch", type=str, choices=["x86"], default="x86")
args = parser.parse_args()

if args.arch == "x86":
translator = x86.x86()
translator = x86.x86(args.capstone)

with open("mnemonics", "w") as f:
for p in translator.pseudo:
f.write("{0:s}_{1:s}, /* pseudo mnemonic */\n".format(translator.dyninst_prefix, p))

mnemonics = capstone.read_mnemonics(args.capstone)
mnemonics = capstone.read_mnemonics(translator.mnemonics_file)
mnemonics.extend(translator.missing)
mnemonics.sort()

Expand Down
4 changes: 3 additions & 1 deletion instructionAPI/capstone/x86.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class x86:

def __init__(self):
def __init__(self, cap_dir):
self.capstone_prefix = "X86"
self.dyninst_prefix = "e"
self.dyninst_register_prefix = "x86_64"
self.mnemonics_file = cap_dir + "/arch/X86/X86MappingInsnName.inc"
self.registers_file = cap_dir + "/include/capstone/x86.h"

# Mnemonics missing in Capstone
self.missing = [ "faddp" ]
Expand Down

0 comments on commit e25173d

Please sign in to comment.