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

Functions

def to_hex (s, prefix_0x=True)
 
def to_hex2 (s)
 
def to_x (s)
 
def to_x_32 (s)
 

Variables

int _python3 = 3
 

Function Documentation

◆ to_hex()

def xprint.to_hex (   s,
  prefix_0x = True 
)

Definition at line 9 of file xprint.py.

9 def to_hex(s, prefix_0x = True):
10  if _python3:
11  if prefix_0x:
12  return " ".join("0x{0:02x}".format(c) for c in s) # <-- Python 3 is OK
13  else:
14  return " ".join("{0:02x}".format(c) for c in s) # <-- Python 3 is OK
15  else:
16  if prefix_0x:
17  return " ".join("0x{0:02x}".format(ord(c)) for c in s)
18  else:
19  return " ".join("{0:02x}".format(ord(c)) for c in s)
20 
def to_hex(s, prefix_0x=True)
Definition: xprint.py:9

Referenced by test_customized_mnem.print_insn(), test_arm.test_class(), test_arm64.test_class(), test_basic.test_class(), test_lite.test_class(), test_m68k.test_class(), test_mips.test_class(), test_ppc.test_class(), test_skipdata.test_class(), test_sparc.test_class(), test_systemz.test_class(), test_tms320c64x.test_class(), test_x86.test_class(), test_xcore.test_class(), test_basic.test_cs_disasm_quick(), and test_lite.test_cs_disasm_quick().

◆ to_hex2()

def xprint.to_hex2 (   s)

Definition at line 21 of file xprint.py.

21 def to_hex2(s):
22  if _python3:
23  r = "".join("{0:02x}".format(c) for c in s) # <-- Python 3 is OK
24  else:
25  r = "".join("{0:02x}".format(ord(c)) for c in s)
26  while r[0] == '0': r = r[1:]
27  return r
28 
def to_hex2(s)
Definition: xprint.py:21

Referenced by to_x(), and to_x_32().

◆ to_x()

def xprint.to_x (   s)

Definition at line 29 of file xprint.py.

29 def to_x(s):
30  from struct import pack
31  if not s: return '0'
32  x = pack(">q", s)
33  while x[0] in ('\0', 0): x = x[1:]
34  return to_hex2(x)
35 
def to_x(s)
Definition: xprint.py:29
int pack(libgdbr_t *g, const char *msg)
Definition: packet.c:206

References pack(), and to_hex2().

Referenced by test_arm64.print_insn_detail(), test_mips.print_insn_detail(), test_systemz.print_insn_detail(), test_tms320c64x.print_insn_detail(), test_xcore.print_insn_detail(), and test_x86.print_insn_detail().

◆ to_x_32()

def xprint.to_x_32 (   s)

Definition at line 36 of file xprint.py.

36 def to_x_32(s):
37  from struct import pack
38  if not s: return '0'
39  x = pack(">i", s)
40  while x[0] in ('\0', 0): x = x[1:]
41  return to_hex2(x)
def to_x_32(s)
Definition: xprint.py:36

References pack(), and to_hex2().

Referenced by test_arm.print_insn_detail(), test_ppc.print_insn_detail(), test_sparc.print_insn_detail(), and test_x86.print_insn_detail().

Variable Documentation

◆ _python3

int xprint._python3 = 3
private

Definition at line 6 of file xprint.py.