Rizin
unix-like reverse engineering framework and cli tools
test_skipdata Namespace Reference

Functions

def testcb (buffer, size, offset, userdata)
 
def test_class ()
 

Variables

string X86_CODE32 = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x00\x91\x92"
 
string RANDOM_CODE = b"\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78"
 
tuple all_tests
 

Function Documentation

◆ test_class()

def test_skipdata.test_class ( )

Definition at line 27 of file test_skipdata.py.

27 def test_class():
28  for (arch, mode, code, comment, syntax) in all_tests:
29  print('*' * 16)
30  print("Platform: %s" %comment)
31  print("Code: %s" % to_hex(code))
32  print("Disasm:")
33 
34  try:
35  md = Cs(arch, mode)
36 
37  if syntax is not None:
38  md.syntax = syntax
39 
40  md.skipdata = True
41 
42  # Default "data" instruction's name is ".byte". To rename it to "db", just use
43  # the code below.
44  md.skipdata_setup = ("db", None, None)
45 
46  # NOTE: This example ignores SKIPDATA's callback (first None) & user_data (second None)
47  # Can also use dedicated setter
48  #md.skipdata_mnem = 'db'
49 
50  # To customize the SKIPDATA callback, use the line below.
51  #md.skipdata_setup = (".db", testcb, None)
52 
53  # Or use dedicated setter with custom parameter
54  #md.skipdata_callback = (testcb, 42)
55 
56  # Or provide just a function
57  #md.skipdata_callback = testcb
58  # Note that reading this property will always return a tuple
59  #assert md.skipdata_callback == (testcb, None)
60 
61  for insn in md.disasm(code, 0x1000):
62  #bytes = binascii.hexlify(insn.bytes)
63  #print("0x%x:\t%s\t%s\t// hex-code: %s" %(insn.address, insn.mnemonic, insn.op_str, bytes))
64  print("0x%x:\t%s\t%s" % (insn.address, insn.mnemonic, insn.op_str))
65 
66  print("0x%x:" % (insn.address + insn.size))
67  print
68  except CsError as e:
69  print("ERROR: %s" % e)
70 
71 
def to_hex(s, prefix_0x=True)
Definition: xprint.py:9

References xprint.to_hex().

◆ testcb()

def test_skipdata.testcb (   buffer,
  size,
  offset,
  userdata 
)

Definition at line 21 of file test_skipdata.py.

21 def testcb(buffer, size, offset, userdata):
22  # always skip 2 bytes of data
23  return 2
24 
25 
26 # ## Test class Cs
def testcb(buffer, size, offset, userdata)

Variable Documentation

◆ all_tests

tuple test_skipdata.all_tests
Initial value:
1 = (
2  (CS_ARCH_X86, CS_MODE_32, X86_CODE32, "X86 32 (Intel syntax)", None),
3  (CS_ARCH_ARM, CS_MODE_ARM, RANDOM_CODE, "Arm", None),
4 )

Definition at line 14 of file test_skipdata.py.

◆ RANDOM_CODE

string test_skipdata.RANDOM_CODE = b"\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78"

Definition at line 12 of file test_skipdata.py.

◆ X86_CODE32

string test_skipdata.X86_CODE32 = b"\x8d\x4c\x32\x08\x01\xd8\x81\xc6\x34\x12\x00\x00\x00\x91\x92"

Definition at line 11 of file test_skipdata.py.