Trouble with WS2_32.DLL
Posted: Wed Apr 21, 2004 1:28 am
I managed to get the program injected, and it appears to have attached fine, but any time I attempt to access namelen or *name in my hooked function, it causes a fault and crashes. it says buffer overrun.
Any help anyone could provide would be wonderful, here are the important bits:
[/quote]
Any help anyone could provide would be wonderful, here are the important bits:
Code: Select all
char CapturedData[0x10000];
typedef struct
{
char ID;
int Length;
SOCKET Socket;
char Name[14];
} CONNECT;
int (*connectNext)( SOCKET s, const struct sockaddr FAR *name, int namelen );
int connectHook( SOCKET s, const struct sockaddr FAR *name, int namelen )
{
CONNECT *cData = (CONNECT*)(&CapturedData[CaptureLength += sizeof(CONNECT)]);
int i;
cData->ID = SOCKET_CONNECT;
cData->Length = sizeof(CONNECT);
cData->Socket = s;
for(i=0;i<namelen;i++) ; // this crashes
return connectNext( s, name, namelen ) ;
}
HookAPI("ws2_32.dll", "connect", connectHook, (PVOID*) &connectNext);