I have this NDIS Filter Driver. I try to start in my driver a thread, that will send packet every 10 seconds.
To do that, I use this code:
LARGE_INTEGER TimePrev, TimeNow;
void ThreadedAction()
{
while(1)
{
KeQuerySystemTime(&TimeNow);
if(NBLtoSend && (TimeNow.QuadPart - TimePrev.QuadPart)>100000000)
{
NdisFSendNetBufferLists(NBLtoSend->SourceHandle, NBLtoSend, 0, 0);
KeQuerySystemTime(&TimePrev);
}
}
}
The function started with PsCreateSystemThread
in DriverEntry
.
But this is not sends my packet.
I try to use this:
void ThreadedAction()
{
while(1)
{
if(NBLtoSend)
{
NdisFSendNetBufferLists(NBLtoSend->SourceHandle, NBLtoSend, 0, 0);
}
}
}
This code sends my packet non stop.
The following code creates new file with my packet every 10 seconds(CreateFileS is my function), but don't sends my packet:
LARGE_INTEGER TimePrev, TimeNow;
void ThreadedAction()
{
while(1)
{
KeQuerySystemTime(&TimeNow);
if(NBLtoSend && (TimeNow.QuadPart - TimePrev.QuadPart)>100000000)
{
PMDL pmdl = NET_BUFFER_CURRENT_MDL(NET_BUFFER_LIST_FIRST_NB(NBLtoSend));
CreateFileS(NULL,(char*)MmGetMdlVirtualAddress(pmdl),MmGetMdlByteCount(pmdl));
NdisFSendNetBufferLists(NBLtoSend->SourceHandle, NBLtoSend, 0, 0);
KeQuerySystemTime(&TimePrev);
}
}
}
Why it's happened, and what can I do to send packet every 10 seconds?