Merge branch 'master' into next

This commit is contained in:
Nguyen Anh Quynh 2019-01-02 10:01:28 +08:00
commit d4ce009086
6 changed files with 59 additions and 8 deletions

View File

@ -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

View File

@ -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);

View File

@ -833,6 +833,7 @@ class Cs(object):
# default mnemonic for SKIPDATA
self._skipdata_mnem = ".byte"
self._skipdata_cb = (None, None)
self._skipdata = False
@ -902,7 +903,7 @@ class Cs(object):
@property
def skipdata_setup(self):
return
return (self._skipdata_mnem,) + self._skipdata_cb
@skipdata_setup.setter
@ -910,13 +911,37 @@ class Cs(object):
_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

View File

@ -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)
# Can also use dedicated setter
md.skipdata_mnem = 'db'
# To customize the SKIPDATA callback, uncomment the line below.
# md.skipdata_setup = (".db", testcb, None)
# 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)

BIN
docs/capstone-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -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