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

preparations for python3, added pythonic critiques, added python idioms. #1

Closed
wants to merge 1 commit into from

Conversation

grugq
Copy link

@grugq grugq commented Nov 27, 2013

these are untested, but I believe still valid.

@danghvu
Copy link
Collaborator

danghvu commented Nov 27, 2013

python/capstone.py is moved to python/capstone/capstone.py so the merge is now broken.

Another note on python3, the import is broken

Python 3.3.2 (default, Sep  6 2013, 09:30:10)
[GCC 4.8.1 20130725 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import capstone
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
File "<snip>/lib/python3.3/site-packages/capstone/__init__.py", line 1, in <module>
from capstone import cs, cs_disasm_quick, cs_version, CS_ARCH_ARM, CS_ARCH_ARM64, CS_ARCH_MIPS, CS_ARCH_X86, CS_MODE_LITTLE_ENDIAN, CS_MODE_ARM, CS_MODE_THUMB, CS_MODE_SYNTAX_INTEL, CS_MODE_16, CS_MODE_32, CS_MODE_64, CS_MODE_SYNTAX_ATT, CS_MODE_BIG_ENDIAN, CS_MODE_MICRO, CS_MODE_N64
ImportError: cannot import name cs

@aquynh
Copy link
Collaborator

aquynh commented Nov 28, 2013

Grugq, this file was actually orphan file, and got deleted. but i will
manually pickup some of your fixes, and port it over to the right one
(python/capstone/capstone.py)

however, you have this:

  • pythonic would be: len(insn.operands)

def op_count(self, op_type):

this is not what it means: op_count() doesn't return the length of
insn.operands, but return the number of operands having the same type
@op_type.

<--- pay attention to the 2nd param.

for example, to count the number of register operands in current arm
insn, we would have:

count = insn.op_count(ARM_OP_REG)

otherwise, of course you want len(insn.operands) to get the number of
operands.

cheers,
Quynh

On Wed, Nov 27, 2013 at 4:13 PM, thaddeus t. grugq <[email protected]

wrote:

these are untested, but I believe still valid.

You can merge this Pull Request by running

git pull https://github.com/grugq/capstone master

Or view, comment on, or merge it at:

#1
Commit Summary

  • preparations for python3, added pythonic critiques, added python
    idioms.

File Changes

Patch Links:

@aquynh aquynh closed this Nov 30, 2013
aquynh pushed a commit that referenced this pull request Oct 11, 2014
sephiroth99 referenced this pull request in sephiroth99/capstone Sep 22, 2015
Also fixed compact parsing of colors without quotes.
sephiroth99 referenced this pull request in sephiroth99/capstone Sep 22, 2015
sephiroth99 referenced this pull request in sephiroth99/capstone Sep 22, 2015
Merging fungos changes into fork.
aquynh pushed a commit that referenced this pull request Nov 11, 2015
x86 encoding information
aquynh pushed a commit that referenced this pull request Apr 12, 2016
disconnect3d added a commit to disconnect3d/capstone that referenced this pull request Jan 1, 2019
For a more detailed description, see issue capstone-engine#1317.

Release 4.0.0 introduced a new field for ARM operands:
`operand.mem.lshift`. This field was supposed to be a bug fix for capstone-engine#246.
The capstone-engine#246 issue has been fixed in the meantime and the proper shift value
was stored in `operand.shift.value`.

The 4.0.0 changes created a regression in which `operand.shift.value`
was not set for a `tbh [r0, r1, lsl capstone-engine#1]` instruction on ARM and the
value was set in a `operand.mem.lshift` field instead.

As the regression broke some of users codebase (e.g. in
[manticore](trailofbits/manticore#1312) project), we fix it by setting
`operand.shift.value` back again.

As a result, the shift value is set in two fields: `operand.shift.value`
and `operand.mem.lshift`. As the `operand.shift` also stores a `.type`
field, we might want to deprecate `operand.mem.lshift` in the future.
aquynh pushed a commit that referenced this pull request Jan 2, 2019
* Fixes #1317 - arm thb operand.shift.value

For a more detailed description, see issue #1317.

Release 4.0.0 introduced a new field for ARM operands:
`operand.mem.lshift`. This field was supposed to be a bug fix for #246.
The #246 issue has been fixed in the meantime and the proper shift value
was stored in `operand.shift.value`.

The 4.0.0 changes created a regression in which `operand.shift.value`
was not set for a `tbh [r0, r1, lsl #1]` instruction on ARM and the
value was set in a `operand.mem.lshift` field instead.

As the regression broke some of users codebase (e.g. in
[manticore](trailofbits/manticore#1312) project), we fix it by setting
`operand.shift.value` back again.

As a result, the shift value is set in two fields: `operand.shift.value`
and `operand.mem.lshift`. As the `operand.shift` also stores a `.type`
field, we might want to deprecate `operand.mem.lshift` in the future.

* Add changelog stub
kabeor added a commit that referenced this pull request Jan 9, 2022
aeflores added a commit to aeflores/capstone that referenced this pull request Feb 11, 2022
kabeor pushed a commit that referenced this pull request Apr 22, 2023
Add handling of prefix `NOTRACK`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants