示例#1
0
文件: loaded.cpp 项目: giomasce/panda
void linux_mmap_pgoff_return(CPUState *cpu,target_ulong pc,uint32_t addr,uint32_t len,uint32_t prot,uint32_t flags,uint32_t fd,uint32_t pgoff) {
    CPUArchState *env = (CPUArchState*)cpu->env_ptr;
    target_ulong asid = panda_current_asid(cpu);
    if (running_procs.count(asid) == 0) {
        //printf ("linux_mmap_pgoff_enter for asid=0x%x fd=%d -- dont know about that asid.  discarding \n", (unsigned int) asid, (int) fd);
        return;
    }
    if ((int32_t) fd == -1){
        //printf ("linux_mmap_pgoff_enter for asid=0x%x fd=%d flags=%x -- not valid fd . . . \n", (unsigned int) asid, (int) fd, flags);
        return;
    }
    OsiProc proc = running_procs[asid];
    char *filename = osi_linux_fd_to_filename(cpu, &proc, fd);
    // gets us offset into the file.  could be useful
    //uint64_t pos = osi_linux_fd_to_pos(env, &proc, fd);
    // if a filename exists and permission is executable
    // TODO: fix this magic constant of 0x04 for PROT_EXEC
    if (filename != NULL && ((prot & 0x04) == 0x04)) {
        if (debug) {
            printf ("[loaded] linux_mmap_pgoff(fd=%d filename=[%s] "
                    "len=%d prot=%x flags=%x "
                    "pgoff=%d)=" TARGET_FMT_lx "\n", (int) fd,
                    filename, len, prot, flags, pgoff, env->regs[R_EAX]);
        }
        PPP_RUN_CB(on_library_load, cpu, pc, filename, env->regs[R_EAX], len)
    } else if ((prot & 0x04) == 0x04) {
示例#2
0
void linux_pread_enter(CPUState *cpu, target_ulong pc,
        uint32_t fd, uint32_t buf, uint32_t count, uint64_t pos) {
    target_ulong asid = panda_current_asid(cpu);
    if (running_procs.count(asid) == 0) {
        if (debug) printf ("linux_read_enter for asid=0x%x fd=%d -- dont know about that asid.  discarding \n", (unsigned int) asid, (int) fd);
        return;
    }
    char *filename;
    if (taint_stdin) {
        filename = stdin_filename;
        pos = 0;
    }
    else {
        OsiProc& proc = running_procs[asid];
        filename = osi_linux_fd_to_filename(cpu, &proc, fd);
        if (pos == (uint64_t)-1) {
            pos = osi_linux_fd_to_pos(cpu, &proc, fd);
        }
        if (filename==NULL) {
            if (debug)
                printf ("linux_read_enter for asid=0x%x pid=%d cmd=[%s] fd=%d -- that asid is known but resolving fd failed.  discarding\n",
                        (unsigned int) asid, (int) proc.pid, proc.name, (int) fd);
            return;
        }
        if (debug) printf ("linux_read_enter for asid==0x%x fd=%d filename=[%s] count=%d pos=%u\n", (unsigned int) asid, (int) fd, filename, count, (unsigned int) pos);
    }
    read_enter(cpu, pc, filename, pos, buf, count);
}