I am using Intel Pin in order trace memory activity of an executable on Windows. What I have found, that most of the memory operands (Read or Write) operates with 2 or 4 bytes. So I decided to modify original Pin's pinatrace example, in order to see which Assembly opcodes produces which memory activity.
VOID Instruction(INS ins, VOID *v)
{
UINT32 memOperands = INS_MemoryOperandCount(ins);
fprintf(trace,"\n[%s]\n",(INS_Disassemble(ins)).c_str());
for (UINT32 memOp = 0; memOp < memOperands; memOp++)
{
.....
What it basically does (I hope), is just writes disassembled opcode BEFORE the memory operands it produces. But then I looked in the file (W is for write, R is for read):
[test edx, 0x800000]
[jnz 0x77708557]
[mov dword ptr [ebp-0x4], edi]
[test dl, 0x1]
[jnz 0x77703136] RWWRWW
[lea edi, ptr [ebx+0xcc]]
[push dword ptr [edi]]
[call 0x77702520] RWW
[mov edi, edi]
[push ebp]
[mov ebp, esp]
[mov eax, dword ptr [ebp+0x8]]
[mov ecx, dword ptr fs:[0x18]]
[lea edx, ptr [eax+0x4]]
[lock btr dword ptr [edx], 0x0]
[jnb 0x777041dc]
[mov ecx, dword ptr [ecx+0x24]]
[mov dword ptr [eax+0xc], ecx]
[mov dword ptr [eax+0x8], 0x1]
[mov eax, 0x1]
[pop ebp]
[ret 0x4] WRRRWRWWRR
As we can see, opcodes that are supposed to work with memory (e.g. mov) do not produce memory operands. While memory traces are connected as blocks after ret/call/jnz etc.
Question: What kind of memory operands does Intel Pin trace? Is it about calls to virtual memory/RAM/CPU registers? Could it be possible, that memory activity goes in blocks due to CPU's pipeline?