Exemplo n.º 1
0
static int __read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int len) {
	ut64 addr = io->off;
	if (!fd || !fd->data)
		return -1;
	memset (buf, '\xff', len); // TODO: only memset the non-readed bytes
	return debug_os_read_at (RIOPTRACE_PID (fd), (ut32*)buf, len, addr);
}
Exemplo n.º 2
0
static int __close(RIODesc *fd) {
	int pid;
	if (!fd || !fd->data)
		return -1;
	pid = RIOPTRACE_PID (fd);
	free (fd->data);
	fd->data = NULL;
	return ptrace (PTRACE_DETACH, pid, 0, 0);
}
Exemplo n.º 3
0
static int __close(RIODesc *desc) {
	int pid, fd;
	if (!desc || !desc->data)
		return -1;
	pid = RIOPTRACE_PID (desc);
	fd = RIOPTRACE_FD (desc);
	if (fd!=-1) close (fd);
	free (desc->data);
	desc->data = NULL;
	return ptrace (PTRACE_DETACH, pid, 0, 0);
}
Exemplo n.º 4
0
static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
	int fd;
	ut64 addr = io->off;
	if (!desc || !desc->data)
		return -1;
	memset (buf, '\xff', len); // TODO: only memset the non-readed bytes
	fd = RIOPTRACE_FD (desc);
	if (fd != -1) {
		lseek (fd, addr, SEEK_SET);
		return read (fd, buf, len);
	}
	return debug_os_read_at (RIOPTRACE_PID (desc), (ut32*)buf, len, addr);
}
Exemplo n.º 5
0
static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
	int ret, fd;
	ut64 addr = io->off;
	if (!desc || !desc->data)
		return -1;
	memset (buf, '\xff', len); // TODO: only memset the non-readed bytes
	fd = RIOPTRACE_FD (desc);
	if (fd != -1) {
		ret = lseek (fd, addr, SEEK_SET);
		if (ret < 0) return -1;
		ret = read (fd, buf, len);
		// Workaround for the buggy Debian Wheeze's /proc/pid/mem
		if (ret != -1) return ret;
	}
	return debug_os_read_at (RIOPTRACE_PID (desc), (ut32*)buf, len, addr);
}
Exemplo n.º 6
0
static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int len) {
	if (!fd || !fd->data)
		return -1;
	return ptrace_write_at (RIOPTRACE_PID (fd), buf, len, io->off);
}