//[reg id, reg value, taint]* [REG_INVALID_, 0, 0] void EmitRegisters(FILE *f, const CONTEXT *ctx, context &delta){ ADDRINT v, taint; int i, sz; //XXX: if you change order of these ids, you also need to change numbering //in motriage.ml, function: rid2reg REG regs[] = {LEVEL_BASE::REG_EAX, LEVEL_BASE::REG_EBX, LEVEL_BASE::REG_ECX, LEVEL_BASE::REG_EDX, LEVEL_BASE::REG_ESI, LEVEL_BASE::REG_EDI, LEVEL_BASE::REG_EBP, LEVEL_BASE::REG_ESP, LEVEL_BASE::REG_EFLAGS, LEVEL_BASE::REG_EIP}; context::iterator it; sz = sizeof(regs)/sizeof(regs[0]); write_u32(f, TAG_REGS); write_u32(f, sz); for(i=0;i<sz;i++){ REG r = regs[i]; v = PIN_GetContextReg(ctx, r); write_u32(f, i); //we don't use PIN's ids write_u32(f, v); it = delta.find(r); if(it != delta.end()){ taint = it->second; } else{ taint = 0; } write_u32(f, taint); fprintf(stderr, "%s v=0x%08x, t=0x%08x\n", REG_StringShort(r).c_str(), v, taint); } }
uint32_t TaintTracker::exists(context &ctx, uint32_t elem) { return (ctx.find(elem) != ctx.end()); }