From 4c009c7e64a0349967478946afbc21ec271ad8de Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Fri, 10 Jan 2014 11:23:51 +0800 Subject: [PATCH 1/3] python: instructions on installing Cython as dependency --- bindings/python/README | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bindings/python/README b/bindings/python/README index 7bd0762c..0d54b590 100644 --- a/bindings/python/README +++ b/bindings/python/README @@ -3,10 +3,16 @@ $ sudo make install For better performance, install Cython-based binding with: - (NOTE: you must have Cython installed in your machine first) $ sudo make install_cython + NOTE: to install Cython, depending on if you already have pip or + easy_install installed, simply do either: + + $ sudo pip install cython + or: + $ sudo pip install cython + This directory contains some test code to show how to use Capstone API. From 92f829645861692bb6588d420ff9993b50bb91b3 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sat, 11 Jan 2014 09:50:16 +0800 Subject: [PATCH 2/3] python: turn off detail by default, and raise CS_ERR_DETAIL when detail is OFF --- bindings/python/capstone/capstone.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bindings/python/capstone/capstone.py b/bindings/python/capstone/capstone.py index 5c89304c..c659f5c3 100644 --- a/bindings/python/capstone/capstone.py +++ b/bindings/python/capstone/capstone.py @@ -291,21 +291,24 @@ class CsInsn(object): if self._cs._detail: detail = self._raw.detail.contents return detail.regs_read[:detail.regs_read_count] - return None + + raise CsError(CS_ERR_DETAIL) @property def regs_write(self): if self._cs._detail: detail = self._raw.detail.contents return detail.regs_write[:detail.regs_write_count] - return None + + raise CsError(CS_ERR_DETAIL) @property def groups(self): if self._cs._detail: detail = self._raw.detail.contents return detail.groups[:detail.groups_count] - return None + + raise CsError(CS_ERR_DETAIL) def __gen_detail(self): arch = self._cs.arch @@ -327,6 +330,9 @@ class CsInsn(object): ppc.get_arch_info(detail.arch.ppc) def __getattr__(self, name): + if not self._cs._detail: + raise CsError(CS_ERR_DETAIL) + attr = object.__getattribute__ if not attr(self, '_cs')._detail: return None @@ -394,7 +400,7 @@ class Cs(object): else: self._syntax = None - self._detail = True # by default, get instruction details + self._detail = False # by default, get instruction details def __del__(self): if self.csh: From 377bced8c44c555ca099c9d81a75f19b97c6420f Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sat, 11 Jan 2014 09:51:48 +0800 Subject: [PATCH 3/3] python: correct comment on default value of @detail --- bindings/python/capstone/capstone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/capstone/capstone.py b/bindings/python/capstone/capstone.py index c659f5c3..29d41f69 100644 --- a/bindings/python/capstone/capstone.py +++ b/bindings/python/capstone/capstone.py @@ -400,7 +400,7 @@ class Cs(object): else: self._syntax = None - self._detail = False # by default, get instruction details + self._detail = False # by default, do not produce instruction details def __del__(self): if self.csh: