Example #1
0
def ptrace(command, pid=0, arg1=0, arg2=0, check_errno=False):
    if HAS_CPTRACE:
        try:
            result = _ptrace(command, pid, arg1, arg2)
        except ValueError, errobj:
            message = str(errobj)
            errno = get_errno()
            raise PtraceError(message, errno=errno, pid=pid)
Example #2
0
def ptrace(command, pid=0, arg1=0, arg2=0, check_errno=False):
    if HAS_CPTRACE:
        try:
            result = _ptrace(command, pid, arg1, arg2, check_errno)
        except ValueError as errobj:
            message = str(errobj)
            errno = get_errno()
            raise PtraceError(message, errno=errno, pid=pid)
    else:
        result = _ptrace(command, pid, arg1, arg2)
        result_signed = c_long(result).value
        if result_signed == -1:
            errno = get_errno()
            # peek operations may returns -1 with errno=0:
            # it's not an error. For other operations, -1
            # is always an error
            if not (check_errno) or errno:
                message = "ptrace(cmd=%s, pid=%s, %r, %r) error #%s: %s" % (
                    command, pid, arg1, arg2, errno, strerror(errno))
                raise PtraceError(message, errno=errno, pid=pid)
    return result
Example #3
0
def ptrace(command, pid=0, arg1=0, arg2=0, check_errno=False):
    if HAS_CPTRACE:
        try:
            result = _ptrace(command, pid, arg1, arg2)
        except ValueError as errobj:
            message = str(errobj)
            errno = get_errno()
            raise PtraceError(message, errno=errno, pid=pid)
    else:
        result = _ptrace(command, pid, arg1, arg2)
        result_signed = c_long(result).value
        if result_signed == -1:
            errno = get_errno()
            # peek operations may returns -1 with errno=0:
            # it's not an error. For other operations, -1
            # is always an error
            if not(check_errno) or errno:
                message = "ptrace(cmd=%s, pid=%s, %r, %r) error #%s: %s" % (
                    command, pid, arg1, arg2,
                    errno, strerror(errno))
                raise PtraceError(message, errno=errno, pid=pid)
    return result
Example #4
0
    # Load ptrace() function from the system C library
    _ptrace = libc.ptrace
    _ptrace.argtypes = (c_ulong, c_ulong, c_ulong, c_ulong)
    _ptrace.restype = c_ulong


def ptrace(command, pid=0, arg1=0, arg2=0, check_errno=False):
    if HAS_CPTRACE:
        try:
            result = _ptrace(command, pid, arg1, arg2)
        except ValueError, errobj:
            message = str(errobj)
            errno = get_errno()
            raise PtraceError(message, errno=errno, pid=pid)
    else:
        result = _ptrace(command, pid, arg1, arg2)
        result_signed = c_long(result).value
        if result_signed == -1:
            errno = get_errno()
            # peek operations may returns -1 with errno=0:
            # it's not an error. For other operations, -1
            # is always an error
            if not (check_errno) or errno:
                message = "ptrace(cmd=%s, pid=%s, %r, %r) error #%s: %s" % (
                    command,
                    pid,
                    arg1,
                    arg2,
                    errno,
                    strerror(errno),
                )