Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (35 sloc) 0.756 kb
void run_elf(char *elf_filename) {
struct vxproc *p = vxproc_alloc();
vxproc_loadelffile(p, elf_filename, ...);
for (;;) {
int rc = vxproc_run(p); // run the binary!
switch(rc) {
case VXTRAP_SYSCALL:
switch(p->cpu->reg[EAX]) {
case VXSYSWRITE:
... handle the syscall ...
break;
...
}
break;
default:
// handle other traps - like segv
printf("vxproc_run trap %#x\n", rc);
result = -1;
goto out;
}
}
out:
vxproc_free(p);
}
uint32_t addr = p->cpu->reg[ECX];
uint32_t len = p->cpu->reg[EBX];
int r = 0;
if (!vxmem_checkperm(p->mem, addr, len,
VXPERM_READ, NULL)) {
r = -EINVAL;
} else {
vxmmap *m = vxmem_map(p->mem, 0);
r = printf("%s", (char*)m->base + addr);
}
p->cpu->reg[EAX] = r;
Jump to Line
Something went wrong with that request. Please try again.