/* * Copyright 2002-2019 Intel Corporation. * * This software is provided to you as Sample Source Code as defined in the accompanying * End User License Agreement for the Intel(R) Software Development Products ("Agreement") * section 1.L. * * This software and the related documents are provided as is, with no express or implied * warranties, other than those that are expressly stated in the License. */ #include "pin.H" #include #include #include using std::cout; using std::ios; using std::hex; using std::cerr; using std::endl; using std::string; /* ===================================================================== */ /* Global Variables */ /* ===================================================================== */ std::ofstream TraceFile; /* ===================================================================== */ /* Commandline Switches */ /* ===================================================================== */ KNOB KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool", "o", "", "specify trace file name"); /* ===================================================================== */ /* ===================================================================== */ /* Analysis routines */ /* ===================================================================== */ VOID MemcpyBefore(CHAR * name, ADDRINT dst, ADDRINT src, ADDRINT size) { TraceFile << name << "(" << dst << "," << src << "," << size << ")" << endl; } // Capture the return address of the ifunc which is the address of the actual memcpy VOID * IfuncMemcpyWrapper( CONTEXT * context, AFUNPTR orgFuncptr) { VOID * ret; PIN_CallApplicationFunction( context, PIN_ThreadId(), CALLINGSTD_DEFAULT, orgFuncptr, NULL, PIN_PARG(void *), &ret, PIN_PARG_END() ); TraceFile << "memcpy (ifunc)" <