Exemple #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);
}
Exemple #2
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);
}
Exemple #3
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);
}
Exemple #4
0
Fichier : fd.c Projet : 111X/radare
// XXX: fill buffer with 0xff ?
int debug_fd_read_at(pid_t pid, u8 *buf, int length, ut64 addr)
{
	int len;
	fdio_enabled = 0;
	if (bufaddr == 0)
		bufaddr = alloc_page(1024*32); // 32K
	if (bufaddr == 0) {
		eprintf("null addr\n");
		fdio_enabled = 1;
		return -1;
	}
	debug_fd_seek(pid, fdio_fd, addr, SEEK_SET);
	len = debug_fd_read(pid, fdio_fd, bufaddr, length);
	debug_os_read_at(pid, buf, len, bufaddr);
	fdio_enabled = 1;
	return len;
}
Exemple #5
0
static int __system(RIO *io, RIODesc *fd, const char *cmd) {
	RIOPtrace *iop = (RIOPtrace*)fd->data;
	//printf("ptrace io command (%s)\n", cmd);
	/* XXX ugly hack for testing purposes */
	if (!strcmp (cmd, "mem")) {
		char b[128];
		int ret = debug_os_read_at (iop->pid, (ut32*)b, 128, 0x8048500);
		printf ("ret = %d , pid = %d\n", ret, iop->pid);
		printf ("%x %x %x %x\n", b[0], b[1], b[2], b[3]);
	} else
	if (!strcmp (cmd, "pid")) {
		int pid = atoi (cmd+4);
		if (pid != 0)
			iop->pid = iop->tid = pid;
		io->printf ("%d\n", iop->pid);
		return pid;
	} else eprintf ("Try: '=!pid'\n");
	return R_TRUE;
}
Exemple #6
0
static int __read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int len) {
	ut64 addr = io->off;
	memset (buf, '\xff', len); // TODO: only memset the non-readed bytes
	return debug_os_read_at (RIOPROCPID_FD (fd), buf, len, addr);
}
Exemple #7
0
static int __read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int len) {
	memset (buf, '\xff', len); // TODO: only memset the non-readed bytes
	return debug_os_read_at (fd->data, buf, len, io->off);
}