def my_syscall_write(ql, write_fd, write_buf, write_count, *rest):
    if write_fd is 2 and ql.file_des[2].__class__.__name__ == 'ql_pipe':
        ql.nprint("ql_custom: custom syscall_write return -1")
        ql_definesyscall_return(ql, -1)
    else:
        ql.nprint("ql_custom: custom syscall_write")
        syscall.ql_syscall_write(ql, write_fd, write_buf, write_count, *rest)
예제 #2
0
파일: test_elf.py 프로젝트: ty60/qiling
        def test_syscall_write(ql, write_fd, write_buf, write_count, *args):
            target = False
            pathname = ql.file_des[write_fd].name.split('/')[-1]

            if pathname == "test_syscall_write.txt":
                print("test => write(%d, %s, %d)" % (write_fd, pathname, write_count))
                target = True

            syscall.ql_syscall_write(ql, write_fd, write_buf, write_count, *args)

            if target:
                real_path = ql.file_des[write_fd].name
                with open(real_path) as fd:
                    assert fd.read() == 'Hello testing\x00'
                os.remove(real_path)
예제 #3
0
파일: message.py 프로젝트: xwings/qiling
def ql_qnx_msg_io_write(ql:Qiling, coid, smsg, sparts, rmsg, rparts, *args, **kw):
    # struct _io_write in lib/c/public/sys/iomsg.h
    (type, combine_len, nbytes, xtype, zero) = unpack("<HHiII", get_message_body(ql, smsg, sparts))

    if combine_len & _IO_COMBINE_FLAG != 0 or xtype != 0:
        raise NotImplementedError("IO combine and XTYPE support not implemented")

    return ql_syscall_write(ql, ql.os.connections[coid].fd, ql.unpack32(ql.mem.read(smsg + 8, 4)), nbytes)
예제 #4
0
def ql_qnx_msg_io_write(ql, coid, smsg, sparts, rmsg, rparts, *args, **kw):
    (type_, combine_len, nbytes, xtype,
     zero) = unpack("<HHIII", get_message_body(ql, smsg, sparts))

    if combine_len & _IO_COMBINE_FLAG != 0 or xtype != 0:
        raise NotImplementedError(
            "IO combine and XTYPE support not implemented")

    return ql_syscall_write(ql, coid, ql.unpack32(ql.mem.read(smsg + 8, 4)),
                            nbytes)
예제 #5
0
파일: test_elf.py 프로젝트: yzz127/qiling
        def test_syscall_write(ql, write_fd, write_buf, write_count, *args):
            target = False
            pathname = ql.os.fd[write_fd].name.split('/')[-1]

            if pathname == "test_syscall_write.txt":
                print("test => write(%d, %s, %d)" %
                      (write_fd, pathname, write_count))
                target = True

            syscall.ql_syscall_write(ql, write_fd, write_buf, write_count,
                                     *args)

            if target:
                real_path = ql.os.fd[write_fd].name
                with open(real_path) as fd:
                    assert fd.read() == 'Hello testing\x00'
                if ql.platform == QL_OS.WINDOWS:
                    return
                else:
                    os.remove(real_path)
예제 #6
0
def my_syscall_write(ql, write_fd, write_buf, write_count, *rest):
    if write_fd == 2 and ql.os.fd[2].__class__.__name__ == 'ql_pipe':
        return -1
    else:
        return syscall.ql_syscall_write(ql, write_fd, write_buf, write_count,
                                        *rest)
예제 #7
0
def my_syscall_write(ql, write_fd, write_buf, write_count, *rest):
    if write_fd == 2 and ql.os.file_des[2].__class__.__name__ == 'ql_pipe':
        ql.os.definesyscall_return(-1)
    else:
        syscall.ql_syscall_write(ql, write_fd, write_buf, write_count, *rest)
예제 #8
0
def hook_write(ql: Qiling, fd: int, buf, count: int) -> None:
    name = ql.os.file_des[fd].__class__.__name__
    log.info("Write to file: {}".format(name))
    syscall.ql_syscall_write(ql, fd, buf, count)