Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python bindings after changes to cs_detail #2041

Merged
merged 3 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]))