Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Pavel_R_
Beginner
242 Views

pin-2.14-71313 and WinSock library

Hi,
I have a problem trying to start my pintool built with WinSock library (ws2_32.lib) - it immediately exits with message "Failure to open DLL file WS2_32.dll".
I've prepared a simple pintool to illistrate the problem:

//----------------------------------------------------------
#include "pin.H"

namespace WINDOWS
{
#include <Ws2tcpip.h>
void *p = WSAStartup;
};

int main(int argc, char *argv[])
{
if (PIN_Init(argc, argv)) return 1;
PIN_StartProgram();
return 0;
}

I've placed this file to a subdirectory of source\tools, added to makefile.rules the following line
TOOL_LIBS := ${TOOL_LIBS} ws2_32.lib

built the pintool
make -B TARGET=ia32

then tried to run with the following command:
..\..\..\pin.exe -t obj-ia32\sock_tool.dll -- c:\windows\System32\cmd /c echo ****** started Ok ******

and have got the following message:
E: Failure to open DLL file Z:\pin-2.14-71313\source\tools\sock_tool\obj-ia32\WS2_32.dll
E: System error 2 : The system cannot find the file specified.
E: Failure to initialize DLL Z:\pin-2.14-71313\source\tools\sock_tool\obj-ia32\sock_tool.dll
E: See preceding message to find out the reason

Could you please explain me what I'm doing wrong?
With the previous versions of PIN this pintool works Ok.
When I remove the line "void *p = WSAStartup;" from the source and rebuild the pintool works Ok with pin-2.14-71313 too.

Any help would be greatly appreciated.
Thanks in advance,
Pavel

OS: Windows 7
compiler: Visual Studio 2010

0 Kudos
7 Replies
Bernard
Black Belt
242 Views

It seems that you have aproblem with  path related to winsock dll location, 

Can you create test project which uses Ws2tcpip.h?

I have also seen that call to WSAStartup returns void pointer, but in documentation return type is address of WSADATA structure which is passed as a function parameter. Maybe this is the reason for the failure.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms742213%28v=vs.85%29.aspx

 

MarkC_Intel
Moderator
242 Views

Hi Guys,

Pin support stuff is handled on the pinheads yahoo group: 

    https://groups.yahoo.com/neo/groups/pinheads/info

It is monitored by the pin developers and many users.

Pavel_R_
Beginner
242 Views

iliyapolak wrote:

It seems that you have aproblem with  path related to winsock dll location, 

No problem with path - the same pintool built with the previous version of PIN works Ok

iliyapolak wrote:

Can you create test project which uses Ws2tcpip.h?

I have also seen that call to WSAStartup returns void pointer, but in documentation return type is address of WSADATA structure which is passed as a function parameter. Maybe this is the reason for the failure.

WSAStartup is not called there, I just assigned its address to a void pointer to have a reference to w2_3.dll

 

Bernard
Black Belt
242 Views

You may try to run pintools under windbg with loader snaps enabled.  You may get more comprehensive error description.

http://blogs.msdn.com/b/junfeng/archive/2006/11/20/debugging-loadlibrary-failures.aspx

Pavel_R_
Beginner
242 Views

Thank you, I'll try. In any case this is a useful link for me

Bernard
Black Belt
242 Views

Btw, you can put breakpoint on address assignment to void pointer and observe in windbg if address of WSAStartup was resolved properly.

Pavel_R_
Beginner
242 Views

Hi Mark,

Mark Charney (Intel) wrote:

Pin support stuff is handled on the pinheads yahoo group: 

    https://groups.yahoo.com/neo/groups/pinheads/info

It is monitored by the pin developers and many users.

I've asked them before but have no answer. Strange, because this looks like a bug in PIN toolkit, as for me. 

Reply