//-------------------------------------------------------------------------- VOID check_unpacked_cb(VOID * ip, const CONTEXT *ctxt, THREADID tid) { ADDRINT ea = (ADDRINT)ip; addrdeq_t::iterator it = std::find(write_address.begin(), write_address.end(), ea); if ( it != write_address.end() ) write_address.erase(it); fprintf(stderr, "Layer unpacked: %p\n", ip); PIN_ApplicationBreakpoint(ctxt, tid, false, "Layer unpacked!"); }
VOID check_unpacked_cb(VOID * ip, const CONTEXT *ctxt, THREADID tid) { // we clear the current instruction map write_address.clear(); cerr << "Layer unpacked: " << ip << endl; PIN_ApplicationBreakpoint(ctxt, tid, false, "Layer unpacked!"); }
//-------------------------------------------------------------------------- // Handle memory write records VOID record_mem_write_cb(VOID * ip, VOID * addr) { ADDRINT ea = (ADDRINT)addr; segmap_t::iterator p; for ( p = seg_bytes.begin(); p != seg_bytes.end() && !p->second.written; ++p ) { ADDRINT start_ea = p->first; if ( ea >= start_ea ) { segdata_t *seg = &p->second; if ( ea <= start_ea+seg->size ) { fprintf(stderr, "%p: W %p\n", ip, addr); write_address.push_back((ADDRINT)addr); seg->written = true; break; } } } }
//-------------------------------------------------------------------------- inline ADDRINT was_writen(ADDRINT ea) { return std::find(write_address.begin(), write_address.end(), ea) != write_address.end(); }
// Print a memory write record VOID RecordMemWrite(VOID * ip, VOID * addr) { write_address.push_back((ADDRINT)addr); }