ec
eiveHandler和ReceivePacketHandler
PVOID
HookProtoFunc(
PNDIS_PROTOCOL_CHARACTERISTICS pCharacteristics,
DWORD dwFunctionCode,
PVOID pfuncNew,
DWORD dwNdisVersion)
{
PVOID pOldFunc = NULL;
//Check parameters
if( (!pCharacteristics ) || (!pfuncNew) )
return NULL;
switch(dwFunctionCode)
{
case PROTO_RECEIVE_HANDLER:
//Just hook once!
if(pCharacteristics->ReceiveHandler != pfuncNew )
{
pOldFunc = pCharacteristics->ReceiveHandler;
if( pOldFunc )
pCharacteristics->ReceiveHandler = pfuncNew;
}
break;
case PROTO_RECEIVE_PACKET_HANDLER:
if(pCharacteristics->ReceivePacketHandler != pfuncNew)
{
//if pOpenBlock is NULL or pOpenBlock->ReceivePacketHandl
er is NULL,
//just hook Characteristics;
pOldFunc = pCharacteristics->ReceivePacketHandler;
if(pOldFunc)
pCharacteristics->ReceivePacketHandler = pfuncNew
;
}
break;
default:
break;
}
return pOldFunc;
}
下