<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PIN: Tools using WinInet? in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/PIN-Tools-using-WinInet/m-p/1113936#M73352</link>
    <description>&lt;P&gt;Good morning,&lt;/P&gt;

&lt;P&gt;I'm relatively new to PIN, but I have a few working tools that I made all tracing functions from Kernel32. &amp;nbsp;I wanted to try identifying and tracing functions in WinInet, particularly InternetOpenUrlA, but as soon as I start adding the includes and linking off the lib file I start getting some errors that I'm unsure of. &amp;nbsp;They all seem to be syntax errors in pinsync-windows.hpp, I don't know enough about this file to really dig in so I was hoping someone could help me understand what is wrong and what I might be able to do to fix this issue?&lt;/P&gt;

&lt;P&gt;Errors start like this:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;1&amp;gt;------ Build started: Project: MyPinTool, Configuration: Debug Win32 ------
1&amp;gt;  Source_InternetOpen.cpp
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(41): warning C4091: 'extern ' : ignored on left of 'void' when no variable is declared
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(73): error C2059: syntax error : '{'
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(73): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(11): error C2059: syntax error : '('
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(11): error C3805: '(': unexpected token, expected either '}' or a ','
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(868): error C2143: syntax error : missing ')' before '}'&lt;/PRE&gt;

&lt;P&gt;Just to get it out of the way, my includes look like this:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;#include&amp;lt;Windows.h&amp;gt;
#include &amp;lt;WinInet.h&amp;gt;
#include "pin.H"
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#pragma comment(lib, "wininet.lib")&lt;/PRE&gt;

&lt;P&gt;My code is all listed below, I didn't want to put it up top in order to prevent clutter.&lt;/P&gt;

&lt;P&gt;Thanks for any help, I really appreciate it.&lt;/P&gt;

&lt;P&gt;-Brandon&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;Windows.h&amp;gt;
#include &amp;lt;WinInet.h&amp;gt;
#include "pin.H"
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#pragma comment(lib, "wininet.lib")


/* ===================================================================== */
/* Global Variables */
/* ===================================================================== */

std::ofstream TraceFile;

/* ===================================================================== */
/* Commandline Switches */
/* ===================================================================== */

KNOB&amp;lt;string&amp;gt; KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool",
    "o", "w_InternetOpenUrlA.out.txt", "specify trace file name");

/* ===================================================================== */
/* Print Help Message                                                    */
/* ===================================================================== */

INT32 Usage()
{
    cerr &amp;lt;&amp;lt; "This tool produces a trace of calls to InternetOpenUrlA.";
    cerr &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;
    cerr &amp;lt;&amp;lt; KNOB_BASE::StringKnobSummary();
    cerr &amp;lt;&amp;lt; endl;
    return -1;
}

/* ===================================================================== */
/* Analysis routines                                                     */
/* ===================================================================== */
 
VOID Before(HINTERNET hInternet, LPCTSTR lpszUrl,
            LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwflags, DWORD_PTR dwContext) 
{
    TraceFile &amp;lt;&amp;lt; "Before: " &amp;lt;&amp;lt; hInternet &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; lpszUrl &amp;lt;&amp;lt; lpszHeaders &amp;lt;&amp;lt; ", "
              &amp;lt;&amp;lt; dwHeadersLength &amp;lt;&amp;lt; ", " &amp;lt;&amp;lt; dwflags &amp;lt;&amp;lt;", "&amp;lt;&amp;lt; dwContext &amp;lt;&amp;lt; ")" &amp;lt;&amp;lt; endl;
}

VOID After(HINTERNET hInternet, LPCTSTR lpszUrl,
            LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwflags, DWORD_PTR dwContext, ADDRINT ret)
{
    TraceFile &amp;lt;&amp;lt; "After: " &amp;lt;&amp;lt; hInternet &amp;lt;&amp;lt; ", "&amp;lt;&amp;lt; lpszUrl &amp;lt;&amp;lt;", "&amp;lt;&amp;lt; lpszHeaders&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwHeadersLength&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwflags&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwflags&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwContext&amp;lt;&amp;lt;", "&amp;lt;&amp;lt; ret &amp;lt;&amp;lt; dec &amp;lt;&amp;lt; endl;
}


/* ===================================================================== */
/* Instrumentation routines                                              */
/* ===================================================================== */
   
VOID Image(IMG img, VOID *v)
{
    // Walk through the symbols in the symbol table.
    //
    for (SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym))
    {
        string undFuncName = PIN_UndecorateSymbolName(SYM_Name(sym), UNDECORATION_NAME_ONLY);

        //  Find the RtlAllocHeap() function.
        if (undFuncName == "InternetOpenUrl")
        {
            RTN urlRtn = RTN_FindByAddress(IMG_LowAddress(img) + SYM_Value(sym));
            
            if (RTN_Valid(urlRtn))
            {
                // Instrument to print the input argument value and the return value.
                RTN_Open(urlRtn);
                
                RTN_InsertCall(urlRtn, IPOINT_BEFORE, (AFUNPTR)Before,
                               IARG_ADDRINT, "InternetOpenUrlA",
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 1,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 2,
							   IARG_FUNCARG_ENTRYPOINT_VALUE, 3,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 4,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 5,
                               IARG_END);
                RTN_InsertCall(urlRtn, IPOINT_AFTER, (AFUNPTR)After,
                               IARG_ADDRINT, "VoidTheRetValue",
                               IARG_FUNCRET_EXITPOINT_VALUE,
                               IARG_END);
                
                RTN_Close(urlRtn);
            }
        }
    }
}

/* ===================================================================== */

VOID Fini(INT32 code, VOID *v)
{
    TraceFile.close();
}

/* ===================================================================== */
/* Main                                                                  */
/* ===================================================================== */

int main(int argc, char *argv[])
{
    // Initialize pin &amp;amp; symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    // Write to a file since cout and cerr maybe closed by the application
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile &amp;lt;&amp;lt; hex;
    TraceFile.setf(ios::showbase);
    
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(Image, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}

/* ===================================================================== */
/* eof */
/* ===================================================================== */
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jun 2016 13:11:01 GMT</pubDate>
    <dc:creator>Brandon_Y_1</dc:creator>
    <dc:date>2016-06-30T13:11:01Z</dc:date>
    <item>
      <title>PIN: Tools using WinInet?</title>
      <link>https://community.intel.com/t5/Software-Archive/PIN-Tools-using-WinInet/m-p/1113936#M73352</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;

&lt;P&gt;I'm relatively new to PIN, but I have a few working tools that I made all tracing functions from Kernel32. &amp;nbsp;I wanted to try identifying and tracing functions in WinInet, particularly InternetOpenUrlA, but as soon as I start adding the includes and linking off the lib file I start getting some errors that I'm unsure of. &amp;nbsp;They all seem to be syntax errors in pinsync-windows.hpp, I don't know enough about this file to really dig in so I was hoping someone could help me understand what is wrong and what I might be able to do to fix this issue?&lt;/P&gt;

&lt;P&gt;Errors start like this:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;1&amp;gt;------ Build started: Project: MyPinTool, Configuration: Debug Win32 ------
1&amp;gt;  Source_InternetOpen.cpp
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(41): warning C4091: 'extern ' : ignored on left of 'void' when no variable is declared
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(73): error C2059: syntax error : '{'
1&amp;gt;c:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\pinsync-windows.hpp(73): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(11): error C2059: syntax error : '('
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(11): error C3805: '(': unexpected token, expected either '}' or a ','
1&amp;gt;C:\pin-2.14-71313-msvc11-windows\source\include\pin\gen\reg_ia32.PH(868): error C2143: syntax error : missing ')' before '}'&lt;/PRE&gt;

&lt;P&gt;Just to get it out of the way, my includes look like this:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;#include&amp;lt;Windows.h&amp;gt;
#include &amp;lt;WinInet.h&amp;gt;
#include "pin.H"
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#pragma comment(lib, "wininet.lib")&lt;/PRE&gt;

&lt;P&gt;My code is all listed below, I didn't want to put it up top in order to prevent clutter.&lt;/P&gt;

&lt;P&gt;Thanks for any help, I really appreciate it.&lt;/P&gt;

&lt;P&gt;-Brandon&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;Windows.h&amp;gt;
#include &amp;lt;WinInet.h&amp;gt;
#include "pin.H"
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#pragma comment(lib, "wininet.lib")


/* ===================================================================== */
/* Global Variables */
/* ===================================================================== */

std::ofstream TraceFile;

/* ===================================================================== */
/* Commandline Switches */
/* ===================================================================== */

KNOB&amp;lt;string&amp;gt; KnobOutputFile(KNOB_MODE_WRITEONCE, "pintool",
    "o", "w_InternetOpenUrlA.out.txt", "specify trace file name");

/* ===================================================================== */
/* Print Help Message                                                    */
/* ===================================================================== */

INT32 Usage()
{
    cerr &amp;lt;&amp;lt; "This tool produces a trace of calls to InternetOpenUrlA.";
    cerr &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;
    cerr &amp;lt;&amp;lt; KNOB_BASE::StringKnobSummary();
    cerr &amp;lt;&amp;lt; endl;
    return -1;
}

/* ===================================================================== */
/* Analysis routines                                                     */
/* ===================================================================== */
 
VOID Before(HINTERNET hInternet, LPCTSTR lpszUrl,
            LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwflags, DWORD_PTR dwContext) 
{
    TraceFile &amp;lt;&amp;lt; "Before: " &amp;lt;&amp;lt; hInternet &amp;lt;&amp;lt; "(" &amp;lt;&amp;lt; lpszUrl &amp;lt;&amp;lt; lpszHeaders &amp;lt;&amp;lt; ", "
              &amp;lt;&amp;lt; dwHeadersLength &amp;lt;&amp;lt; ", " &amp;lt;&amp;lt; dwflags &amp;lt;&amp;lt;", "&amp;lt;&amp;lt; dwContext &amp;lt;&amp;lt; ")" &amp;lt;&amp;lt; endl;
}

VOID After(HINTERNET hInternet, LPCTSTR lpszUrl,
            LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwflags, DWORD_PTR dwContext, ADDRINT ret)
{
    TraceFile &amp;lt;&amp;lt; "After: " &amp;lt;&amp;lt; hInternet &amp;lt;&amp;lt; ", "&amp;lt;&amp;lt; lpszUrl &amp;lt;&amp;lt;", "&amp;lt;&amp;lt; lpszHeaders&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwHeadersLength&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwflags&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwflags&amp;lt;&amp;lt;", "&amp;lt;&amp;lt;dwContext&amp;lt;&amp;lt;", "&amp;lt;&amp;lt; ret &amp;lt;&amp;lt; dec &amp;lt;&amp;lt; endl;
}


/* ===================================================================== */
/* Instrumentation routines                                              */
/* ===================================================================== */
   
VOID Image(IMG img, VOID *v)
{
    // Walk through the symbols in the symbol table.
    //
    for (SYM sym = IMG_RegsymHead(img); SYM_Valid(sym); sym = SYM_Next(sym))
    {
        string undFuncName = PIN_UndecorateSymbolName(SYM_Name(sym), UNDECORATION_NAME_ONLY);

        //  Find the RtlAllocHeap() function.
        if (undFuncName == "InternetOpenUrl")
        {
            RTN urlRtn = RTN_FindByAddress(IMG_LowAddress(img) + SYM_Value(sym));
            
            if (RTN_Valid(urlRtn))
            {
                // Instrument to print the input argument value and the return value.
                RTN_Open(urlRtn);
                
                RTN_InsertCall(urlRtn, IPOINT_BEFORE, (AFUNPTR)Before,
                               IARG_ADDRINT, "InternetOpenUrlA",
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 0,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 1,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 2,
							   IARG_FUNCARG_ENTRYPOINT_VALUE, 3,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 4,
                               IARG_FUNCARG_ENTRYPOINT_VALUE, 5,
                               IARG_END);
                RTN_InsertCall(urlRtn, IPOINT_AFTER, (AFUNPTR)After,
                               IARG_ADDRINT, "VoidTheRetValue",
                               IARG_FUNCRET_EXITPOINT_VALUE,
                               IARG_END);
                
                RTN_Close(urlRtn);
            }
        }
    }
}

/* ===================================================================== */

VOID Fini(INT32 code, VOID *v)
{
    TraceFile.close();
}

/* ===================================================================== */
/* Main                                                                  */
/* ===================================================================== */

int main(int argc, char *argv[])
{
    // Initialize pin &amp;amp; symbol manager
    PIN_InitSymbols();
    if( PIN_Init(argc,argv) )
    {
        return Usage();
    }
    
    // Write to a file since cout and cerr maybe closed by the application
    TraceFile.open(KnobOutputFile.Value().c_str());
    TraceFile &amp;lt;&amp;lt; hex;
    TraceFile.setf(ios::showbase);
    
    // Register Image to be called to instrument functions.
    IMG_AddInstrumentFunction(Image, 0);
    PIN_AddFiniFunction(Fini, 0);

    // Never returns
    PIN_StartProgram();
    
    return 0;
}

/* ===================================================================== */
/* eof */
/* ===================================================================== */
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 13:11:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/PIN-Tools-using-WinInet/m-p/1113936#M73352</guid>
      <dc:creator>Brandon_Y_1</dc:creator>
      <dc:date>2016-06-30T13:11:01Z</dc:date>
    </item>
    <item>
      <title>Support for PIN is all</title>
      <link>https://community.intel.com/t5/Software-Archive/PIN-Tools-using-WinInet/m-p/1113937#M73353</link>
      <description>&lt;P&gt;Support for PIN is all provided in the PINHeads Yahoo group:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://groups.yahoo.com/neo/groups/pinheads/info" target="_blank"&gt;https://groups.yahoo.com/neo/groups/pinheads/info&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 19:42:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/PIN-Tools-using-WinInet/m-p/1113937#M73353</guid>
      <dc:creator>LexiS_Intel</dc:creator>
      <dc:date>2016-07-18T19:42:36Z</dc:date>
    </item>
  </channel>
</rss>

