def test_syscall_read(ql, read_fd, read_buf, read_count, *args): target = False pathname = ql.file_des[read_fd].name.split('/')[-1] if pathname == "test_syscall_read.txt": print("test => read(%d, %s, %d)" % (read_fd, pathname, read_count)) target = True syscall.ql_syscall_read(ql, read_fd, read_buf, read_count, *args) if target: real_path = ql.file_des[read_fd].name with open(real_path) as fd: assert fd.read() == ql.mem_read(read_buf, read_count).decode() os.remove(real_path)
def test_syscall_read(ql, read_fd, read_buf, read_count, *args): target = False pathname = ql.os.fd[read_fd].name.split('/')[-1] reg = ql.reg.read("v0") print("reg : 0x%x" % reg) ql.reg.v0 = reg if pathname == "test_syscall_read.txt": print("test => read(%d, %s, %d)" % (read_fd, pathname, read_count)) target = True regreturn = syscall.ql_syscall_read(ql, read_fd, read_buf, read_count, *args) if target: real_path = ql.os.fd[read_fd].name with open(real_path) as fd: assert fd.read() == ql.mem.read(read_buf, read_count).decode() if ql.platform != QL_OS.WINDOWS: os.remove(real_path) return regreturn
def ql_qnx_msg_io_read(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_read(ql, coid, rmsg, rparts)
def ql_qnx_msg_io_read(ql:Qiling, 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") rlen = c_int32(rparts).value assert nbytes == -rlen, "different sizes for io_read" return ql_syscall_read(ql, ql.os.connections[coid].fd, rmsg, nbytes)
def test_syscall_read(ql, read_fd, read_buf, read_count, *args): target = False pathname = ql.os.fd[read_fd].name.split('/')[-1] if pathname == "test_syscall_read.txt": print("test => read(%d, %s, %d)" % (read_fd, pathname, read_count)) target = True syscall.ql_syscall_read(ql, read_fd, read_buf, read_count, *args) if target: real_path = ql.os.fd[read_fd].name with open(real_path) as fd: assert fd.read() == ql.mem.read(read_buf, read_count).decode() if ql.platform == QL_OS.WINDOWS: return else: os.remove(real_path)
def hook_read(ql: Qiling, fd: int, buf, count: int) -> None: name = ql.os.file_des[fd].__class__.__name__ log.info("Read file: {}".format(name)) syscall.ql_syscall_read(ql, fd, buf, count)