截获WINSOCKET的源代码WSOCK32.CPP#includewindows.h#includestdio.hvoidabc(char*p){FILE*fp=fopen(c:\z.txt,a+);fprintf(fp,%s,p);fclose(fp);}//日志文件//必须输出与原WSOCK32.DLL库同样的函数。HMODULEi;charaa[1000];FARPROCa;DWORDd;int(__stdcall*getsockopt1)(SOCKET,int,int,char*,int*);u_short(__stdcall*ntohs1)(u_short);structhostent*(__stdcall*gethostbyname1)(constcharFAR*);int(__stdcall*getsockname1)(SOCKET,structsockaddr*,int*);int(__stdcall*bind1)(SOCKET,conststructsockaddr*,int);u_long(__stdcall*htonl1)(u_long);char*(__stdcall*inet_ntoa1)(structin_addr);int(__stdcall*WsControl1)(int,int,int,int,int,int);unsignedlong(__stdcall*inet_addr1)(constcharFAR*);int(__stdcall*__WSAFDIsSet1)(SOCKET,fd_setFAR*);int(__stdcall*WSAGetLastError1)();int(__stdcall*recv1)(SOCKET,charFAR*,int,int);int(__stdcall*send1)(SOCKET,constchar*,int,int);int(__stdcall*connect1)(SOCKET,conststructsockaddr*,int);int(__stdcall*closesockinfo1)(int);int(__stdcall*NPLoadNameSpaces1)(int,int,int);int(__stdcall*closesocket1)(SOCKET);int(__stdcall*select1)(int,fd_setFAR*,fd_setFAR*,fd_setFAR*,conststructtimevalFAR*);HANDLE(__stdcall*WSAAsyncGetHostByName1)(HWND,u_int,constcharFAR*,charFAR*,int);int(__stdcall*ioctlsocket1)(SOCKET,long,u_longFAR*);int(__stdcall*setsockopt1)(SOCKET,int,int,constchar*,int);int(__stdcall*WSAAsyncSelect1)(SOCKET,HWND,u_int,long);SOCKET(__stdcall*socket1)(int,int,int);u_short(__stdcall*htons1)(u_short);int(__stdcall*WSAStartup1)(WORD,LPWSADATA);int(__stdcall*WSACleanup1)();intPASCALFARWSAStartup(WORDwVersionRequired,LPWSADATAlpWSAData){abc(WSAStartup);//记日志,当然也可以是您的模块i=LoadLibrary(c:\windows\system\wsock32.aaa);//装载原动态库a=GetProcAddress(i,WSAStartup);WSAStartup1=(int(_stdcall*)(WORD,LPWSADATA))a;returnWSAStartup1(wVersionRequired,lpWSAData);//取得原同名函数地址//执行真正的处理}intPASCALFARWSACleanup(void){abc(WSACleanup);//记日志a=GetProcAddress(i,WSACleanup);//取得原同名函数地址WSACleanup1=(int(_stdcall*)())a;returnWSACleanup1();//执行真正的处理}u_shortPASCALFARhtons(u_shorthostshort){abc(htons);a=GetProcAddress(i,htons);htons1=(u_short(_stdcall*)(u_short))a;returnhtons1(hostshort);//取得原同名函数地址//执行真正的处理}SOCKETPASCALFARsocket(intaf,inttype,intprotocol){abc(socket);a=GetProcAddress(i,socket);socket1=(SOCKET(_stdcall*)(int,int,int))a;returnsocket1(af,type,protocol);//取得原同名函数地址//执行真正的处理}intPASCALFARWSAAsyncSelect(SOCKETs,HWNDhWnd,u_intwMsg,longlEvent){abc(WSAAsyncSelect);a=GetProcAddress(i,WSAAsyncSelect);WSAAsyncSelect1=(int(_stdcall*)(SOCKET,HWND,u_int,long))a;returnWSAAsyncSelect1(s,hWnd,wMsg,lEvent);//取得原同名函数地址//执行真正的处理}intPASCALFARsetsockopt(SOCKETs,intlevel,intoptname,constchar*optval,intoptlen){abc(setsockopt);a=GetProcAddress(i,setsockopt);setsockopt1=(int(_stdcall*)(SOCKET,int,int,constchar*,int))a;returnsetsockopt1(s,level,optname,optval,optlen);//取得原同名函数地址//执行真正的处理}intPASCALFARioctlsocket(SOCKETs,longcmd,u_longFAR*argp){abc(ioctlsocket);a=GetProcAddress(i,ioctlsocket);ioctlsocket1=(int(_stdcall*)(SOCKET,long,u_longFAR*))a;returnioctlsocket1(s,cmd,argp);//取得原同名函数地址//执行真正的处理}HANDLEPASCALFARWSAAsyncGetHostByName(HWNDhWnd,u_intwMsg,constcharFAR*name,charFAR*buf,intbuflen){abc(WSAAsyncGetHostByName);a=GetProcAddress(i,WSAAsyncGetHostByName);WSAAsyncGetHostByName1=(HANDLE(_stdcall*)(HWND,u_int,constcharFAR*,charFAR*,int))a;returnWSAAsyncGetHostByName1(hWnd,wMsg,name,buf,buflen);//取得原同名函数地址//执行真正的处理}intPASCALFARselect(intnfds,fd_setFAR*readfds,fd_setFAR*writefds,fd_setFAR*exceptfds,conststructtimevalFAR*timeout){abc(select);a=GetProcAddress(i,select);select1=(int(_stdcall*)(int,fd_setFAR*,fd_setFAR*,fd_setFAR*,conststructtimevalFAR*))a;returnselect1(nfds,readfds,writefds,exceptfds,timeout);//取得原同名函数地址//执行真正的处理}intPASCALFARclosesocket(SOCKETs){abc(closesocket);a=GetProcAddress(i,closesocket);closesocket1=(int(_stdcall*)(SOCKET))a;returnclosesocket1(s);//取得原同名函数地址//执行真正的处理}intPASCALFARNPLoadNameSpaces(intp,intq,intr){abc(NPLoadNameSpaces);a=GetProcAddress(i,NPLoadNameSpaces);NPLoadNameSpaces1=(int(_stdcall*)(int,int,int))a;returnNPLoadNameSpaces1(p,q,r);//取得原同名函数地址//执行真正的处理}intPASCALFARclosesockinfo(intp){abc(closesockinfo);a=GetProcAddress(i,closesockinfo);closesockinfo1=(int(_stdcall*)(int))a;returnclosesockinfo1(p);//取得原同名函数地址//执行真正的处理}intPASCALFARconnect(SOCKETs,conststructsockaddr*name,intnamelen){abc(connect);a=GetProcAddress(i,connect);connect1=(int(_stdcall*)(SOCKET,conststructsockaddr*,int))a;returnconnect1(s,name,namelen);//取得原同名函数地址//执行真正的处理}intPASCALFARWSAGetLastError(void){a=GetProcAddress(i,WSAGetLastError);WSAGetLastError1=(int(_stdcall*)())a;d=WSAGetLastError1();sprintf(aa,WSAGetLastError%d,d);abc(aa);returnd;//取得原同名函数地址//执行真正的处理}intPASCALFARsend(SOCKETs,constchar*buf,intlen,intflags){abc(send);a=GetProcAddress(i,send);send1=(int(_stdcall*)(SOCKET,constchar*,int,int))a;returnsend1(s,buf,len,flags);//取得原同名函数地址//执行真正的处理}intPASCALFARrecv(SOCKETs,charFAR*buf,intlen,intflags){abc(recv);a=GetProcAddress(i,recv);recv1=(int(_stdcall*)(SOCKET,charFAR*,int,int))a;returnrecv1(s,buf,len,flags);//取得原同名函数地址//执行真正的处理}intPASCALFAR__WSAFDIsSet(SOCKETp,fd_setFAR*q){abc(__WSAFDIsSet