VOID InsertMemoryRecorder(INS ins, int operand) { //assert(INS_OperandIsMemory(ins, operand)); auto base = INS_OperandMemoryBaseReg(ins, operand); auto disp = INS_OperandMemoryDisplacement(ins, operand); auto index = INS_OperandMemoryIndexReg(ins, operand); auto scale = INS_OperandMemoryScale(ins, operand); if (!REG_valid(base)) // [0xf000] { INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess, IARG_INST_PTR, IARG_ADDRINT, -1, IARG_ADDRINT, disp, IARG_ADDRINT, -1, IARG_ADDRINT, 0, IARG_END); } else if (REG_valid(index)) // [rax+rcx*8+disp] { INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess, IARG_INST_PTR, IARG_REG_VALUE, base, IARG_ADDRINT, disp, IARG_REG_VALUE, index, IARG_ADDRINT, scale, IARG_END); } else // [rax+(disp/0)] { INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess, IARG_INST_PTR, IARG_REG_VALUE, base, IARG_ADDRINT, disp, IARG_ADDRINT, -1, IARG_ADDRINT, 0, IARG_END); } }