A typical PIN code snippet looks like this (taken from the official manual):
// This function is called before every instruction is executed
// and prints the IP
VOID printip(VOID *ip) { fprintf(trace, "%p\n", ip); }
// Pin calls this function every time a new instruction is encountered
VOID Instruction(INS ins, VOID *v)
{
// Insert a call to printip before every instruction, and pass it the IP
INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)printip, IARG_INST_PTR, IARG_END);
}
I just can't figure out how to access the ins
object from within printip(VOID *p)
. The other way round seems easy, i.e. getting the IP from from the ins
object:
INS_Address (INS ins)
(see here)
I tried passing a INS *ins
pointer to printip(VOID *ip, INS *ins)
ins via IARG_PTR, &ins
but this ended in either casting errors or Segmentation faults.
How can I access the ins
object (type INS
) from inside an analysis function?
Side note: I got to this problem when trying to call INS_Disassemble (INS ins)
for every executed instruction.