Squashed 'external/capstone/' content from commit 5430745e962

git-subtree-dir: external/capstone
git-subtree-split: 5430745e9623786f65c0d773a417f389ebb43395
This commit is contained in:
SimoneN64
2024-09-23 19:06:48 +02:00
commit 352a52804d
3915 changed files with 2927938 additions and 0 deletions

28
bindings/python/tests/xprint.py Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python
# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>
def to_hex(s, prefix_0x = True):
if prefix_0x:
return " ".join("0x{0:02x}".format(c) for c in s) # <-- Python 3 is OK
else:
return " ".join("{0:02x}".format(c) for c in s) # <-- Python 3 is OK
def to_hex2(s):
r = "".join("{0:02x}".format(c) for c in s) # <-- Python 3 is OK
while r[0] == '0': r = r[1:]
return r
def to_x(s):
from struct import pack
if not s: return '0'
x = pack(">q", s)
while x[0] in ('\0', 0): x = x[1:]
return to_hex2(x)
def to_x_32(s):
from struct import pack
if not s: return '0'
x = pack(">i", s)
while x[0] in ('\0', 0): x = x[1:]
return to_hex2(x)