Skip to content

Commit

Permalink
Initialze mode and options separately
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Aug 19, 2024
1 parent ee31bc4 commit 92431cc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bindings/python/py_cstest/src/py_cstest/cstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,25 @@ def setup(self):
f"Couldn't init architecture as '{self.arch}' or '{cs_name}'.\n"
f"'{self.arch}' is not mapped to a capstone architecture."
)
self.handle = Cs(arch, 0)
new_mode = 0
for opt in self.options:
if "CS_MODE_" in opt:
mode = get_cs_int_attr(capstone, opt, "CS_OPT")
if mode is not None:
new_mode |= mode
continue
self.handle = Cs(arch, new_mode)

for opt in self.options:
if "CS_MODE_" in opt:
continue
if "CS_OPT_" in opt and opt in configs:
mtype = configs[opt]["type"]
val = configs[opt]["val"]
self.handle.option(mtype, val)
continue
log.warning(f"Option: '{opt}' not used")

self.handle.mode = new_mode
self.arch_bits = arch_bits(self.handle.arch, self.handle.mode)
log.debug("Init done")

Expand Down

0 comments on commit 92431cc

Please sign in to comment.