Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Jan 2, 2019
2 parents 9955a2c + ebd176e commit 90b90f9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 9 deletions.
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
This file details the changelog of Capstone.

---------------------------------
Version 4.x: **SETDATE**


[ Arm ]

- Fix 4.0 regression: the `tbh [r0, r1, lsl #1]` instruction sets the operand.shift.value back again (see #1317)


[ X86 ]

- Fix: endbr32 and endbr64 instructions are now properly decoded in both CS_MODE_32 and CS_MODE_64 (#1129)


---------------------------------
Version 4.0: December 18th, 2018

Expand Down
2 changes: 2 additions & 0 deletions arch/ARM/ARMInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ static void printAddrModeTBH(MCInst *MI, unsigned Op, SStream *O)
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].mem.index = MCOperand_getReg(MO2);
SStream_concat0(O, ", lsl #1]");
if (MI->csh->detail) {
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].shift.type = ARM_SFT_LSL;
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].shift.value = 1;
MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].mem.lshift = 1;
}
set_mem_access(MI, false);
Expand Down
31 changes: 28 additions & 3 deletions bindings/python/capstone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ def __init__(self, arch, mode):

# default mnemonic for SKIPDATA
self._skipdata_mnem = ".byte"
self._skipdata_cb = (None, None)
self._skipdata = False


Expand Down Expand Up @@ -902,21 +903,45 @@ def skipdata(self, opt):

@property
def skipdata_setup(self):
return
return (self._skipdata_mnem,) + self._skipdata_cb


@skipdata_setup.setter
def skipdata_setup(self, opt):
_skipdata_opt = _cs_opt_skipdata()
_mnem, _cb, _ud = opt
_skipdata_opt.mnemonic = _mnem.encode()
_skipdata_opt.callback = CS_SKIPDATA_CALLBACK(_cb)
_skipdata_opt.callback = CS_SKIPDATA_CALLBACK(_cb or 0)
_skipdata_opt.user_data = ctypes.cast(_ud, ctypes.c_void_p)
status = _cs.cs_option(self.csh, CS_OPT_SKIPDATA_SETUP, ctypes.cast(ctypes.byref(_skipdata_opt), ctypes.c_void_p))
if status != CS_ERR_OK:
raise CsError(status)

self._skipdata_opt = _skipdata_opt
self._skipdata_mnem = _mnem
self._skipdata_cb = (_cb, _ud)


@property
def skipdata_mnem(self):
return self._skipdata_mnem


@skipdata_mnem.setter
def skipdata_mnem(self, mnem):
self.skipdata_setup = (mnem,) + self._skipdata_cb


@property
def skipdata_callback(self):
return self._skipdata_cb


@skipdata_callback.setter
def skipdata_callback(self, val):
if not isinstance(val, tuple):
val = (val, None)
func, data = val
self.skipdata_setup = (self._skipdata_mnem, func, data)


# customize instruction mnemonic
Expand Down
18 changes: 13 additions & 5 deletions bindings/python/test_skipdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@ def test_class():

md.skipdata = True

# Default "data" instruction's name is ".byte". To rename it to "db", just uncomment
# Default "data" instruction's name is ".byte". To rename it to "db", just use
# the code below.
# md.skipdata_setup = ("db", None, None)
md.skipdata_setup = ("db", None, None)
# NOTE: This example ignores SKIPDATA's callback (first None) & user_data (second None)

# To customize the SKIPDATA callback, uncomment the line below.
# md.skipdata_setup = (".db", testcb, None)
# Can also use dedicated setter
md.skipdata_mnem = 'db'

# To customize the SKIPDATA callback, use the line below.
md.skipdata_setup = (".db", testcb, None)
# Or use dedicated setter with custom parameter
md.skipdata_callback = (testcb, 42)
# Or provide just a function
md.skipdata_callback = testcb
# Note that reading this property will always return a tuple
assert md.skipdata_callback == (testcb, None)

for insn in md.disasm(code, 0x1000):
#bytes = binascii.hexlify(insn.bytes)
Expand Down
Binary file added docs/capstone-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion include/capstone/arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ typedef struct arm_op_mem {
arm_reg index; ///< index register
int scale; ///< scale for index register (can be 1, or -1)
int disp; ///< displacement/offset value
int lshift; ///< left-shift on index register, or 0 if irrelevant.
/// left-shift on index register, or 0 if irrelevant
/// NOTE: this value can also be fetched via operand.shift.value
int lshift;
} arm_op_mem;

/// Instruction operand
Expand Down

0 comments on commit 90b90f9

Please sign in to comment.