Skip to content

Commit

Permalink
Merge pull request #2041 from peace-maker/fix_python_bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeor authored Jun 9, 2023
2 parents a026fc4 + 1da1cbf commit ec48262
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,13 @@ class _cs_arch(ctypes.Union):

class _cs_detail(ctypes.Structure):
_fields_ = (
('regs_read', ctypes.c_uint16 * 16),
('regs_read', ctypes.c_uint16 * 20),
('regs_read_count', ctypes.c_ubyte),
('regs_write', ctypes.c_uint16 * 20),
('regs_write_count', ctypes.c_ubyte),
('groups', ctypes.c_ubyte * 8),
('groups_count', ctypes.c_ubyte),
('writeback', ctypes.c_bool),
('arch', _cs_arch),
)

Expand Down Expand Up @@ -725,9 +726,9 @@ def __gen_detail(self):
elif arch == CS_ARCH_BPF:
(self.operands) = bpf.get_arch_info(self._raw.detail.contents.arch.bpf)
elif arch == CS_ARCH_RISCV:
(self.operands) = riscv.get_arch_info(self._raw.detail.contents.arch.riscv)
(self.need_effective_addr, self.operands) = riscv.get_arch_info(self._raw.detail.contents.arch.riscv)
elif arch == CS_ARCH_TRICORE:
(self.operands) = riscv.get_arch_info(self._raw.detail.contents.arch.tricore)
(self.update_flags, self.operands) = tricore.get_arch_info(self._raw.detail.contents.arch.tricore)


def __getattr__(self, name):
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/capstone/riscv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# define the API
class RISCVOpMem(ctypes.Structure):
_fields_ = (
('base', ctypes.c_uint8),
('base', ctypes.c_uint),
('disp', ctypes.c_int64),
)

Expand Down Expand Up @@ -39,11 +39,11 @@ def mem(self):

class CsRISCV(ctypes.Structure):
_fields_ = (
('need_effective_addr', ctypes.c_bool),
('need_effective_addr', ctypes.c_bool),
('op_count', ctypes.c_uint8),
('operands', RISCVOp * 8),
)

def get_arch_info(a):
return (copy_ctypes_list(a.operands[:a.op_count]))
return (a.need_effective_addr, copy_ctypes_list(a.operands[:a.op_count]))

8 changes: 7 additions & 1 deletion bindings/python/capstone/tricore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Capstone Python bindings, by billow <billow.fun@gmail.com>

import ctypes, copy
import ctypes
from . import copy_ctypes_list
from .tricore_const import *

class TriCoreOpMem(ctypes.Structure):
Expand All @@ -22,6 +23,7 @@ class TriCoreOp(ctypes.Structure):
_fields_ = (
('type', ctypes.c_uint),
('value', TriCoreOpValue),
('access', ctypes.c_uint8)
)

@property
Expand All @@ -42,4 +44,8 @@ class CsTriCore(ctypes.Structure):
_fields_ = (
('op_count', ctypes.c_uint8),
('operands', TriCoreOp * 8),
('update_flags', ctypes.c_bool),
)

def get_arch_info(a):
return (a.update_flags, copy_ctypes_list(a.operands[:a.op_count]))

0 comments on commit ec48262

Please sign in to comment.