# Path: shellcodes/thumb/syscall.py
# def get(no):
# 
# Path: shellcodes/arm/syscall.py
# def get(no):
# 
# Path: shellcodes/arm64/syscall.py
# def get(no):


from optparse import OptionParser
from unicorn import *
from unicorn.arm_const import *
from unicorn.arm64_const import *
from capstone import *
from capstone.arm import *
from struct import unpack
from ARMSCGen import *
from shellcodes.thumb import syscall as th_syscall
from shellcodes.arm   import syscall as arm_syscall
from shellcodes.arm64 import syscall as arm64_syscall
    from pygments import highlight
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters import TerminalFormatter
import os, sys
    if val == 0: 
        return ""
    if isinstance(val, bytearray):
        val = str(val)

    _hex = []
    _val = ''
    for v in val:
        _hex.append( v.encode('hex') )
        if v in printable:
            _val += v
        else:
            _val += '.'
    return (' '.join(_hex), _val)

# callback for tracing instructions
def hook_code(uc, address, size, user_data):
    # end of shellcode
    if address > g_code_base + g_sc_len:
        uc.emu_stop()

# callback for interrupt
def hook_intr(uc, intno, user_data):
    global g_before_pc

    reg_dump(uc, True)
    _print_reg = ''
    if g_uc_arch == UC_ARCH_ARM64:
        _print_reg = 'X'
        syscall_no =  get_reg( uc, UC_ARM64_REG_X8 ) 

# Path: shellcodes/thumb/syscall.py
# def get(no):
# 
# Path: shellcodes/arm/syscall.py
# def get(no):
# 
# Path: shellcodes/arm64/syscall.py
# def get(no):


# Path: sctest/sctest.py
from optparse import OptionParser
from unicorn import *
from unicorn.arm_const import *
from unicorn.arm64_const import *
from capstone import *
from capstone.arm import *
from struct import unpack
from ARMSCGen import *
from shellcodes.thumb import syscall as th_syscall
from shellcodes.arm   import syscall as arm_syscall
from shellcodes.arm64 import syscall as arm64_syscall
    from pygments import highlight
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters import TerminalFormatter
import os, sys

    if val == 0: 
        return ""
    if isinstance(val, bytearray):
        val = str(val)

    _hex = []
    _val = ''
    for v in val:
        _hex.append( v.encode('hex') )
        if v in printable:
            _val += v
        else:
            _val += '.'
    return (' '.join(_hex), _val)

# callback for tracing instructions
def hook_code(uc, address, size, user_data):
    # end of shellcode
    if address > g_code_base + g_sc_len:
        uc.emu_stop()

# callback for interrupt
def hook_intr(uc, intno, user_data):
    global g_before_pc

    reg_dump(uc, True)
    _print_reg = ''
    if g_uc_arch == UC_ARCH_ARM64:
        _print_reg = 'X'
        syscall_no =  get_reg( uc, UC_ARM64_REG_X8 ) 

        syscall_name = arm64_syscall.get( syscall_no )