Hi to all!! in my delay-packets project i managed, with your help, to delay
packets handled by SendPacketHandler…
Now i’m tryng to delay packets handled by ReceivePAcketHandler too…
With my first solution, the same of sendpacket, system dosn t crash but
connection go closed, with no packet going in only one direction.
I think that s because i sent to timer only i pointer to the original
packet, as i ve done in sendPacket, without making a clone of it .
the aim is to make a clone of the packet, create a timer, pass to his
function the pointer to cloned packet, return 0 value to the handler…
so the problem is that i m not sure how to clone the packet:
i hve done in this way and system crash in NDis.sys:
this is the receivepackethandler function that i created and that will call
original function after a delay:
INT
PtReceivePacketEx(IN NDIS_HANDLE ProtocolBindingContext,IN PNDIS_PACKET
Packet){
PNDIS_TIMER timerRec = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));
struct strutturaRec *strutRec = NULL;
UINT delayRec = 80;
PNDIS_STATUS Status=NULL;
PNDIS_BUFFER *Buffer=NULL;
NDIS_PACKET cloned = *Packet;
PNDIS_PACKET *pacc=NULL;
PADAPT pAdapt =(PADAPT)ProtocolBindingContext;
NDIS_PACKET *pcloned =ExAllocatePool(NonPagedPool, sizeof(NDIS_PACKET));
*pcloned=cloned;
NdisAllocateBuffer(Status, Buffer, pAdapt->handle,pcloned,
sizeof(NDIS_PACKET));
NdisAllocatePacket(Status, pacc, pAdapt->handle);
NdisChainBufferAtFront(*pacc,*Buffer);
if (timerRec == NULL){
ExFreePool(pcloned);
return 0;}
if (pcloned == NULL){
ExFreePool(timerRec);
return 0;}
strutRec = ExAllocatePool(NonPagedPool, sizeof(struct strutturaRec));
if (strutRec == NULL){
ExFreePool(pcloned);
ExFreePool(timerRec);
return 0;}
strutRec->pack=*pacc;
strutRec->pad=ProtocolBindingContext;
strutRec->timer = timerRec;
strutRec->Buf=*Buffer;
NdisInitializeTimer(timerRec,pippoRec,strutRec);
DbgPrint(“inizioritardoRec”);
NdisSetTimer(timerRec,delayRec);
DbgPrint(“DoporitardoRec”);
return 0;
}
this is the function that is called when timer expires:
VOID pippoRec(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)
{
struct strutturaRec *punt= FunctionContext;
PtReceivePacketEx(punt->pad,punt->pack);
ExFreePool(punt->timer);
ExFreePool(punt->pack);
ExFreePool(punt->Buf);
ExFreePool(punt);
DbgPrint(“ritardo avvenutoRec”);
}
this is structure i created:
struct strutturaRec{
PNDIS_PACKET pack;
PNDIS_BUFFER Buf;
NDIS_HANDLE pad;
PVOID timer;
};
I added to ADAPT structure a NDIS_HANDLE variable, named handle, and
initialized it in PtBindAdapter after the initialization of
&pAdapt->RecvPacketPoolHandle
in this way:
NdisAllocatePacketPoolEx(Status,
&pAdapt->handle,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
PROTOCOL_RESERVED_SIZE_IN_PACKET);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
any suggestions??
thanks anyway…
Francesco