Lyxica

Intel Pin Memory Types

Aug 31st, 2020
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. VOID InsertMemoryRecorder(INS ins, int operand)
  2. {
  3.     //assert(INS_OperandIsMemory(ins, operand));
  4.  
  5.     auto base = INS_OperandMemoryBaseReg(ins, operand);
  6.  
  7.     auto disp = INS_OperandMemoryDisplacement(ins, operand);
  8.  
  9.     auto index = INS_OperandMemoryIndexReg(ins, operand);
  10.     auto scale = INS_OperandMemoryScale(ins, operand);
  11.  
  12.     if (!REG_valid(base)) // [0xf000]
  13.     {
  14.         INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess,
  15.             IARG_INST_PTR,
  16.             IARG_ADDRINT, -1,
  17.             IARG_ADDRINT, disp,
  18.             IARG_ADDRINT, -1,
  19.             IARG_ADDRINT, 0,
  20.             IARG_END);
  21.     }
  22.     else if (REG_valid(index)) // [rax+rcx*8+disp]
  23.     {
  24.         INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess,
  25.             IARG_INST_PTR,
  26.             IARG_REG_VALUE, base,
  27.             IARG_ADDRINT, disp,
  28.             IARG_REG_VALUE, index,
  29.             IARG_ADDRINT, scale,
  30.             IARG_END);
  31.     }
  32.     else // [rax+(disp/0)]
  33.     {
  34.         INS_InsertThenCall(ins, IPOINT_BEFORE, (AFUNPTR)recordAccess,
  35.             IARG_INST_PTR,
  36.             IARG_REG_VALUE, base,
  37.             IARG_ADDRINT, disp,
  38.             IARG_ADDRINT, -1,
  39.             IARG_ADDRINT, 0,
  40.             IARG_END);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment