WSPUPCALLTABLE upcallTable = { /* initialize upcallTable with function pointers */ };// 声明一个栈变量来代替堆变量 WSPPROC_TABLE ProcTable;wVersionRequested = MAKEWORD( 2, 2 );err = WSPStartup( wVersionRequested, &WSPData, lpProtocolBuffer, upcallTable, &ProcTable ); if ( err != 0 ) { /* Tell the user that we could not find a useable */ /* Windows Sockets service provider. */ return; } ..........
WSPDATA WSPData;
int err;
WSPUPCALLTABLE upcallTable =
{
/* initialize upcallTable with function pointers */
};// 声明一个栈变量来代替堆变量
WSPPROC_TABLE ProcTable;wVersionRequested = MAKEWORD( 2, 2 );err = WSPStartup( wVersionRequested, &WSPData, lpProtocolBuffer, upcallTable, &ProcTable );
if ( err != 0 ) {
/* Tell the user that we could not find a useable */
/* Windows Sockets service provider. */
return;
}
..........
WORD wVersionRequested,
LPWSPDATAW lpWSPData,
LPWSAPROTOCOL_INFOW lpProtocolInfo,
WSPUPCALLTABLE UpcallTable,
LPWSPPROC_TABLE lpProcTable
)
{
LPWSPSTARUP WSPStarProc=GetProcAddress(LbHandle,"WSPStartup");//得到下一层服务提供者的WSPStatrup函数指针,记得要先LoadLibrary下一层服务提供者的DLL
WSPStarProc(wVersionRequested,lpWSPData,lpProtocolInfo,UpcallTable,lpProcTable )
//记得要保留下一层原来的函数指针,有过HOOK API经验的朋友应该知道,就像要保存你HOOK 的API原来的地址一样
WSPPROC_TABLE SystemProc=*lpProcTable;
//然后就可以设置自己的处理函数了,和HOOK API也差不多,比如
lpProcTable->lpWSPSend=WSPSend; return 1;
}
http://www.csdn.net/Develop/article/15/15919.shtm