R: NDIS driver problem

yeeeees! it works!! for the first time i have not seen the blue screen with
critical error!!! i m the happiest man on the woooorld!!!
:))
thanks!!!


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: gioved? 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and
dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:

Hi to all! i have a problem: i must create a driver (starting from
passthruex part 2 sample from ndis.com

)
that adds a delay to some packets (in function of their src and dst port).
i know only these two functions to add delay:

KeWaitForSingleObject
KeDelayExecutionThread

that run only at irq level = passive_level…
So functions in passthruex run at dispatch_level so i can use them because s
ystem crash.
My idea is to buffer packets that i must delay in a some kind of structur an

d give anyway the succes response, like the packet was sent…then i deliver
packets in the buffer after the delay wanted…
can it works? the problem is that i don t know how to call a passive_level f
unction from a driver function…

thanks!

p.s. if i add these function in working sample passthruex part 2 there is an
error like: attempt from a DPC routine to a waiting operation
… stop 0…B8
the error with dpc is connected to irq level or is an other problem?
thanks
francesco


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com

No. Put the packets to the queue, and then consume this queue by the timer
which will fire later.

You cannot delay threads at DISPATCH_LEVEL.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Infinito”
To: “Windows System Software Devs Interest List”
Sent: Thursday, February 02, 2006 6:44 PM
Subject: [ntdev] NDIS driver problem

> Hi to all! i have a problem: i must create a driver (starting from
> passthruex part 2 sample from ndis.com)
> that adds a delay to some packets (in function of their src and dst port).
>
> i know only these two functions to add delay:
>
>
>
> KeWaitForSingleObject
>
> KeDelayExecutionThread
>
>
>
> that run only at irq level = passive_level…
>
> So functions in passthruex run at dispatch_level so i can use them because s
>
> ystem crash.
>
> My idea is to buffer packets that i must delay in a some kind of structur an
>
> d give anyway the succes response, like the packet was sent…then i deliver
>
> packets in the buffer after the delay wanted…
>
> can it works? the problem is that i don t know how to call a passive_level f
>
> unction from a driver function…
>
> thanks!
>
> p.s. if i add these function in working sample passthruex part 2 there is an
> error like: attempt from a DPC routine to a waiting operation
> … stop 0…B8
> the error with dpc is connected to irq level or is an other problem?
> thanks
> francesco
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

hi!
i must create a function that works before MPSendPackets…so i set as
packethandler a new function, called newfunct…in this i create a NDIS
timer…so when the timer expires it calls the function
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

in this function i want to call the original MPSendPackets, but this needs
as parameters :

MPSendPackets(

IN NDIS_HANDLE MiniportAdapterContext,

IN PPNDIS_PACKET PacketArray,

IN UINT NumberOfPackets

)

How can i pass to pippo these parameters? they are in newfunct…

thanks!


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: gioved? 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and
dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:

Hi to all! i have a problem: i must create a driver (starting from
passthruex part 2 sample from ndis.com

)
that adds a delay to some packets (in function of their src and dst port).
i know only these two functions to add delay:

KeWaitForSingleObject
KeDelayExecutionThread

that run only at irq level = passive_level…
So functions in passthruex run at dispatch_level so i can use them because s
ystem crash.
My idea is to buffer packets that i must delay in a some kind of structur an

d give anyway the succes response, like the packet was sent…then i deliver
packets in the buffer after the delay wanted…
can it works? the problem is that i don t know how to call a passive_level f
unction from a driver function…

thanks!

p.s. if i add these function in working sample passthruex part 2 there is an
error like: attempt from a DPC routine to a waiting operation
… stop 0…B8
the error with dpc is connected to irq level or is an other problem?
thanks
francesco


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com

Pack the parameters to some structure of your own, and pass it to the timer
routine as FunctionContext.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Francesco Tabbita (IT)”
To: “Windows System Software Devs Interest List”
Sent: Friday, February 03, 2006 1:47 PM
Subject: R: [ntdev] NDIS driver problem

hi!
i must create a function that works before MPSendPackets…so i set as
packethandler a new function, called newfunct…in this i create a NDIS
timer…so when the timer expires it calls the function
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

in this function i want to call the original MPSendPackets, but this needs
as parameters :

MPSendPackets(

IN NDIS_HANDLE MiniportAdapterContext,

IN PPNDIS_PACKET PacketArray,

IN UINT NumberOfPackets

)

How can i pass to pippo these parameters? they are in newfunct…

thanks!

_____

Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: giovedì 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and
dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:

Hi to all! i have a problem: i must create a driver (starting from
passthruex part 2 sample from ndis.com

)
that adds a delay to some packets (in function of their src and dst port).
i know only these two functions to add delay:

KeWaitForSingleObject
KeDelayExecutionThread

that run only at irq level = passive_level…
So functions in passthruex run at dispatch_level so i can use them because s
ystem crash.
My idea is to buffer packets that i must delay in a some kind of structur an

d give anyway the succes response, like the packet was sent…then i deliver
packets in the buffer after the delay wanted…
can it works? the problem is that i don t know how to call a passive_level f
unction from a driver function…

thanks!

p.s. if i add these function in working sample passthruex part 2 there is an
error like: attempt from a DPC routine to a waiting operation
… stop 0…B8
the error with dpc is connected to irq level or is an other problem?
thanks
francesco


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

ok i did…but now i have another problem:

i set as packethandler my function newfunction
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = ExAllocatePool(NonPagedPool, sizeof(struct
struttura));

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS);
// Lying Send…

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

){

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,punt->pad); —>the third parameter
is different from the original numberofpackets

DbgPrint(“ritardo avvenuto”);

}

in the MPSendPacketsEx i deleted every call to NdisMSendComplete and the
for cycle that i added in newfunction…when i install the driver there is
an error IRQL NOT LESS OR EQUAL…with stop 00000A
maybe there is a memory reference wrong or i can t call MPSendPackets in
that way?? You told me to add to my queue all packets and then delivery
them…but where i must create that queue structure?
thanks!!!
francesco


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Francesco Tabbita
(IT)
Inviato: venerd? 3 febbraio 2006 11.47
A: Windows System Software Devs Interest List
Oggetto: R: [ntdev] NDIS driver problem

hi!
i must create a function that works before MPSendPackets…so i set as
packethandler a new function, called newfunct…in this i create a NDIS
timer…so when the timer expires it calls the function
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

in this function i want to call the original MPSendPackets, but this needs
as parameters :

MPSendPackets(

IN NDIS_HANDLE MiniportAdapterContext,

IN PPNDIS_PACKET PacketArray,

IN UINT NumberOfPackets

)

How can i pass to pippo these parameters? they are in newfunct…

thanks!


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: gioved? 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and
dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:

Hi to all! i have a problem: i must create a driver (starting from
passthruex part 2 sample from ndis.com

)
that adds a delay to some packets (in function of their src and dst port).
i know only these two functions to add delay:

KeWaitForSingleObject
KeDelayExecutionThread

that run only at irq level = passive_level…
So functions in passthruex run at dispatch_level so i can use them because s
ystem crash.
My idea is to buffer packets that i must delay in a some kind of structur an

d give anyway the succes response, like the packet was sent…then i deliver
packets in the buffer after the delay wanted…
can it works? the problem is that i don t know how to call a passive_level f
unction from a driver function…

thanks!

p.s. if i add these function in working sample passthruex part 2 there is an
error like: attempt from a DPC routine to a waiting operation
… stop 0…B8
the error with dpc is connected to irq level or is an other problem?
thanks
francesco


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?

What does the function MPSendPacketsEx do? Does it send the packet using NdisSend? If yes, then you are accessing the packets that you might have already completed. You can’t access a packet once you complete it. You need to throughly understand the packet lifetime before you implement the desired functionality or you will hit random bugchecks.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
ok i did…but now i have another problem:

i set as packethandler my function newfunction
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool, sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = ExAllocatePool(NonPagedPool, sizeof(struct struttura));

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS); // Lying Send…

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

){

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,punt->pad); —>the third parameter is different from the original numberofpackets

DbgPrint(“ritardo avvenuto”);

}

in the MPSendPacketsEx i deleted every call to NdisMSendComplete and the for cycle that i added in newfunction…when i install the driver there is an error IRQL NOT LESS OR EQUAL…with stop 00000A
maybe there is a memory reference wrong or i can t call MPSendPackets in that way?? You told me to add to my queue all packets and then delivery them…but where i must create that queue structure?
thanks!!!
francesco

------------------------------------------------------------------------------
Da: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] Per conto di Francesco Tabbita (IT)
Inviato: venerd? 3 febbraio 2006 11.47
A: Windows System Software Devs Interest List
Oggetto: R: [ntdev] NDIS driver problem

hi!
i must create a function that works before MPSendPackets…so i set as packethandler a new function, called newfunct…in this i create a NDIS timer…so when the timer expires it calls the function
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

in this function i want to call the original MPSendPackets, but this needs as parameters :

MPSendPackets(

IN NDIS_HANDLE MiniportAdapterContext,

IN PPNDIS_PACKET PacketArray,

IN UINT NumberOfPackets

)

How can i pass to pippo these parameters? they are in newfunct…

thanks!

------------------------------------------------------------------------------
Da: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: gioved? 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:
Hi to all! i have a problem: i must create a driver (starting from passthruex part 2 sample from ndis.com
) that adds a delay to some packets (in function of their src and dst port).i know only these two functions to add delay:KeWaitForSingleObject KeDelayExecutionThread
that run only at irq level = passive_level…So functions in passthruex run at dispatch_level so i can use them because system crash. My idea is to buffer packets that i must delay in a some kind of structur an
d give anyway the succes response, like the packet was sent…then i deliver packets in the buffer after the delay wanted…can it works? the problem is that i don t know how to call a passive_level function from a driver function…
thanks! p.s. if i add these function in working sample passthruex part 2 there is an error like: attempt from a DPC routine to a waiting operation … stop 0…B8
the error with dpc is connected to irq level or is an other problem?thanksfrancesco

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

How familiar are you with C? This is one of the basic C question. I would assume proficiency in C before writing kernel mode code on windows. Anyways, you declare a global pointer, allocate memory in it using ExAllocatePoolWithTag. In other files that need to access this, declare the same variable as extern or you can declare it as extern in a .h file and include that .h file in other .c files.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver functions can access it…where i must create it? in the driverentry call i suppose…but how can i call it (the buffer) from other functions implemented (some of them are in other files .c too) ?

yes it use ndissend…
MPSendPacketsEx is MPsendpackets without for-cycle and without
MPsendcomplete calls…i thought that not sending immediatly MPsendComplete
would make driver wait it…so MPsendpacket doesn t wait a MPsendcomplete
response to go on the next packet? i have found nothing about how the call
to MPSendPackets from DriverEntry is done…there is only a setting…
MChars.SendPacketsHandler = MPSendPackets;

thanks
Francesco


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.24
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

What does the function MPSendPacketsEx do? Does it send the packet using
NdisSend? If yes, then you are accessing the packets that you might have
already completed. You can’t access a packet once you complete it. You need
to throughly understand the packet lifetime before you implement the desired
functionality or you will hit random bugchecks.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
ok i did…but now i have another problem:

i set as packethandler my function newfunction
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = ExAllocatePool(NonPagedPool, sizeof(struct
struttura));

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS);
// Lying Send…

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

){

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,punt->pad); —>the third parameter
is different from the original numberofpackets

DbgPrint(“ritardo avvenuto”);

}

in the MPSendPacketsEx i deleted every call to NdisMSendComplete and the
for cycle that i added in newfunction…when i install the driver there is
an error IRQL NOT LESS OR EQUAL…with stop 00000A
maybe there is a memory reference wrong or i can t call MPSendPackets in
that way?? You told me to add to my queue all packets and then delivery
them…but where i must create that queue structure?
thanks!!!
francesco



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Francesco Tabbita
(IT)
Inviato: venerd? 3 febbraio 2006 11.47
A: Windows System Software Devs Interest List
Oggetto: R: [ntdev] NDIS driver problem

hi!
i must create a function that works before MPSendPackets…so i set as
packethandler a new function, called newfunct…in this i create a NDIS
timer…so when the timer expires it calls the function
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

in this function i want to call the original MPSendPackets, but this needs
as parameters :

MPSendPackets(

IN NDIS_HANDLE MiniportAdapterContext,

IN PPNDIS_PACKET PacketArray,

IN UINT NumberOfPackets

)

How can i pass to pippo these parameters? they are in newfunct…

thanks!



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Beyers Cronje
Inviato: gioved? 2 febbraio 2006 16.58
A: Windows System Software Devs Interest List
Oggetto: Re: [ntdev] NDIS driver problem

Francesco,

Try using an ndis timer, copy incoming packets to your own queue, and
dequeue when timer expires.

Beyers

On 2/2/06, Infinito < xxxxx@infinito.it> wrote:

Hi to all! i have a problem: i must create a driver (starting from
passthruex part 2 sample from ndis.com

)
that adds a delay to some packets (in function of their src and dst port).
i know only these two functions to add delay:

KeWaitForSingleObject
KeDelayExecutionThread

that run only at irq level = passive_level…
So functions in passthruex run at dispatch_level so i can use them because s
ystem crash.
My idea is to buffer packets that i must delay in a some kind of structur an

d give anyway the succes response, like the packet was sent…then i deliver
packets in the buffer after the delay wanted…
can it works? the problem is that i don t know how to call a passive_level f
unction from a driver function…

thanks!

p.s. if i add these function in working sample passthruex part 2 there is an
error like: attempt from a DPC routine to a waiting operation
… stop 0…B8
the error with dpc is connected to irq level or is an other problem?
thanks
francesco


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 You are currently subscribed to
ntdev as: unknown lmsubst tag argument: ‘’ To unsubscribe send a blank email
to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

yes i know that i have many problem with c…i have joined a project bigger
than my skills…but i m in now and i must go on…sorry for my newbe
questions…

thanks a lot
Francesco


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Francesco,

Here is how you can do it correctly:

  1. In your newFunction, don’t complete the packet, just set the timer one by one for each packet and return.
  2. When the timer expire call MpSendPacket for each packet
  3. Your MpSendPacket will call NdisSend (or NdisSendPacket)
  4. After calling MpSendPacket, Free the allocations made for timer
  5. When the packet is actually sent, NDIS will call your ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and 4.

Hope this helps.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer initialized in DriverEntry…if i use NDIS timer only to write a dbg message it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks

------------------------------------------------------------------------------
Da: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would assume proficiency in C before writing kernel mode code on windows. Anyways, you declare a global pointer, allocate memory in it using ExAllocatePoolWithTag. In other files that need to access this, declare the same variable as extern or you can declare it as extern in a .h file and include that .h file in other .c files.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver functions can access it…where i must create it? in the driverentry call i suppose…but how can i call it (the buffer) from other functions implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

  1. In your newFunction, don’t complete the packet, just set the timer one by
    one for each packet and return.
    VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
    PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

  1. When the timer expire call MpSendPacket for each packet

  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)

  3. After calling MpSendPacket, Free the allocations made for timer

  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniz
iobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe
newfunction must return such a values?


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

  1. When the timer expire call MpSendPacket for each packet
  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)
  3. After calling MpSendPacket, Free the allocations made for timer
  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and
ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and
4.

Hope this helps.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks

_____

Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

now i ve used NdisAllocateMemoryWithTag instead of ExAllocatedPool…and
other changes…but i ve error …00007E…that’s mean some exceptions not
intercepted…this mean that there are no more memory error or that can be
some memory error too?
my screen is always blue with fatal error page…argh!! :slight_smile: stressss
help!
Francesco


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Francesco Tabbita
(IT)
Inviato: mercoled? 8 febbraio 2006 11.58
A: Windows System Software Devs Interest List
Oggetto: R: [ntdev] NDIS driver problem

  1. In your newFunction, don’t complete the packet, just set the timer one by
    one for each packet and return.
    VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
    PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

  1. When the timer expire call MpSendPacket for each packet

  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)

  3. After calling MpSendPacket, Free the allocations made for timer

  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniz
iobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe
newfunction must return such a values?


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

  1. When the timer expire call MpSendPacket for each packet
  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)
  3. After calling MpSendPacket, Free the allocations made for timer
  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and
ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and
4.

Hope this helps.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks

_____

Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

and error is in Ndis.sys…


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Francesco Tabbita
(IT)
Inviato: mercoled? 8 febbraio 2006 11.58
A: Windows System Software Devs Interest List
Oggetto: R: [ntdev] NDIS driver problem

  1. In your newFunction, don’t complete the packet, just set the timer one by
    one for each packet and return.
    VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
    PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

  1. When the timer expire call MpSendPacket for each packet

  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)

  3. After calling MpSendPacket, Free the allocations made for timer

  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniz
iobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe
newfunction must return such a values?


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

  1. When the timer expire call MpSendPacket for each packet
  2. Your MpSendPacket will call NdisSend (or NdisSendPacket)
  3. After calling MpSendPacket, Free the allocations made for timer
  4. When the packet is actually sent, NDIS will call your
    ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and
ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and
4.

Hope this helps.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks

_____

Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Francesco, i don’t mean to discourage you but i think either you should really spend some good time learning C and then windows kernel mode programming or let your managers know that they should hire someone with more experience in driver development. Anyways beside that advice, here is what you need to do:

First, don’t use the global struct without proper synchronization. In fact you don’t need to use global struct (strut) at all. Your earlier implementation was better without using global data.

Also NdisInitializeTimer is documented to run at PASSIVE_LEVEL only but i think it can run on <= DISPATCH_LEVEL since it uses KeInitializeTimer only.

Here is what you need to do with changes shown in red color.

VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool, sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = NULL;

if (timer == NULL)

{

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_RESOURCES);

continue;

}

strut = ExAllocatePool(NonPagedPool, sizeof(struct struttura));

if (strut == NULL)

{

ExFreePool(timer);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_RESOURCES);

continue;

}

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

struct->timer = timer;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS); // Lying Send… Remove this line

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

{

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,1); —>the third parameter is different from the original numberofpackets

ExFreePool(punt->timer);

ExFreePool(punt);

DbgPrint(“ritardo avvenuto”);

}

“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
1. In your newFunction, don’t complete the packet, just set the timer one by one for each packet and return.
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool, sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

2. When the timer expire call MpSendPacket for each packet

3. Your MpSendPacket will call NdisSend (or NdisSendPacket)

4. After calling MpSendPacket, Free the allocations made for timer

5. When the packet is actually sent, NDIS will call your ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniziobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe newfunction must return such a values?

------------------------------------------------------------------------------
Da: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

2. When the timer expire call MpSendPacket for each packet
3. Your MpSendPacket will call NdisSend (or NdisSendPacket)
4. After calling MpSendPacket, Free the allocations made for timer
5. When the packet is actually sent, NDIS will call your ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and 4.

Hope this helps.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer initialized in DriverEntry…if i use NDIS timer only to write a dbg message it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks

----------------------------------------------------------------------------
Da: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would assume proficiency in C before writing kernel mode code on windows. Anyways, you declare a global pointer, allocate memory in it using ExAllocatePoolWithTag. In other files that need to access this, declare the same variable as extern or you can declare it as extern in a .h file and include that .h file in other .c files.

Pankaj
“Francesco Tabbita (IT)” wrote in message news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver functions can access it…where i must create it? in the driverentry call i suppose…but how can i call it (the buffer) from other functions implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

pankai i love u!! i thanks all u people that help other guys with nothing in
change…now it works and i think i can go on with my project…
thanks a lot again…without u i would not end my work!!!
Francesco
(the next time i hope that i ll be more expert than now… :slight_smile: )


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: venerd? 10 febbraio 2006 4.48
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco, i don’t mean to discourage you but i think either you should
really spend some good time learning C and then windows kernel mode
programming or let your managers know that they should hire someone with
more experience in driver development. Anyways beside that advice, here is
what you need to do:

First, don’t use the global struct without proper synchronization. In fact
you don’t need to use global struct (strut) at all. Your earlier
implementation was better without using global data.

Also NdisInitializeTimer is documented to run at PASSIVE_LEVEL only but i
think it can run on <= DISPATCH_LEVEL since it uses KeInitializeTimer only.

Here is what you need to do with changes shown in red color.

VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = NULL;

if (timer == NULL)

{

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_R
ESOURCES);

continue;

}

strut = ExAllocatePool(NonPagedPool, sizeof(struct struttura));

if (strut == NULL)

{

ExFreePool(timer);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_R
ESOURCES);

continue;

}

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

struct->timer = timer;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS);
// Lying Send… Remove this line

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

{

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,1); —>the third parameter is
different from the original numberofpackets

ExFreePool(punt->timer);

ExFreePool(punt);

DbgPrint(“ritardo avvenuto”);

}

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
1. In your newFunction, don’t complete the packet, just set the timer one by
one for each packet and return.
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

2. When the timer expire call MpSendPacket for each packet

3. Your MpSendPacket will call NdisSend (or NdisSendPacket)

4. After calling MpSendPacket, Free the allocations made for timer

5. When the packet is actually sent, NDIS will call your
ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniz
iobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe
newfunction must return such a values?



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

2. When the timer expire call MpSendPacket for each packet
3. Your MpSendPacket will call NdisSend (or NdisSendPacket)
4. After calling MpSendPacket, Free the allocations made for timer
5. When the packet is actually sent, NDIS will call your
ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and
ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and
4.

Hope this helps.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: venerd? 10 febbraio 2006 4.48
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco, i don’t mean to discourage you but i think either you should
really spend some good time learning C and then windows kernel mode
programming or let your managers know that they should hire someone with
more experience in driver development. Anyways beside that advice, here is
what you need to do:

First, don’t use the global struct without proper synchronization. In fact
you don’t need to use global struct (strut) at all. Your earlier
implementation was better without using global data.

Also NdisInitializeTimer is documented to run at PASSIVE_LEVEL only but i
think it can run on <= DISPATCH_LEVEL since it uses KeInitializeTimer only.

Here is what you need to do with changes shown in red color.

VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets

){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

for (i = 0; i < NumberOfPackets; i++){

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

PNDIS_PACKET Packet = PacketArray[i];

UINT delay = 80;

struct struttura *strut = NULL;

if (timer == NULL)

{

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_R
ESOURCES);

continue;

}

strut = ExAllocatePool(NonPagedPool, sizeof(struct struttura));

if (strut == NULL)

{

ExFreePool(timer);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,STATUS_INSUFFICIENT_R
ESOURCES);

continue;

}

strut->hand=MiniportAdapterContext;

strut->pack=Packet;

strut->pad=pAdapt;

struct->timer = timer;

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS);
// Lying Send… Remove this line

}

}

and pippo function is
VOID pippo(

IN PVOID SystemSpecific1,

IN PVOID FunctionContext,

IN PVOID SystemSpecific2,

IN PVOID SystemSpecific3

)

{

struct struttura *punt= FunctionContext;

MPSendPacketsEx(punt->hand,punt->pack,1); —>the third parameter is
different from the original numberofpackets

ExFreePool(punt->timer);

ExFreePool(punt);

DbgPrint(“ritardo avvenuto”);

}

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
1. In your newFunction, don’t complete the packet, just set the timer one by
one for each packet and return.
VOID newfunction(IN NDIS_HANDLE MiniportAdapterContext,IN PPNDIS_PACKET
PacketArray,IN UINT NumberOfPackets){

PADAPT pAdapt = (PADAPT)MiniportAdapterContext;

NDIS_STATUS Status;

UINT i;

DbgPrint(“newfunction”);

for (i = 0; i < NumberOfPackets; i++){

ULONG NumberOfBytesRead;

PNDIS_TIMER timer = (PNDIS_TIMER)ExAllocatePool(NonPagedPool,
sizeof(NDIS_TIMER));

NDIS_PACKET Packe = *PacketArray[i];

PNDIS_PACKET Packet= &Packe;

UINT delay = 100;

strut->hand=MiniportAdapterContext;

strut->buffer[strut->finebuffer]=Packe;

strut->pad=pAdapt;

(strut->finebuffer)++;

if (strut->finebuffer==199)

{strut->finebuffer=0;}

NdisInitializeTimer(timer,pippo,strut);

DbgPrint(“inizioritardo”);

NdisSetTimer(timer,delay);

DbgPrint(“Doporitardo”);

}

}

2. When the timer expire call MpSendPacket for each packet

3. Your MpSendPacket will call NdisSend (or NdisSendPacket)

4. After calling MpSendPacket, Free the allocations made for timer

5. When the packet is actually sent, NDIS will call your
ProtocolSendComplete handler and you can Complete the packet then.

VOID pippo(IN PVOID SystemSpecific1,IN PVOID FunctionContext,IN PVOID
SystemSpecific2,IN PVOID SystemSpecific3)

{

struct struttura *punt= FunctionContext;

int unused=1;

MPSend(punt->pad, &(punt->buffer[punt->iniziobuffer]),unused); <2,3

NdisMSendComplete(ADAPT_MINIPORT_HANDLE(punt->pad),&(punt->buffer[punt->iniz
iobuffer]), NDIS_STATUS_SUCCESS); <5

ExFreePool(punt->tim); <4

(punt->iniziobuffer)++;

if(punt->iniziobuffer==199){

punt->iniziobuffer=0;

}

DbgPrint(“ritardo avvenuto”);

}

I see error IRQL_NOT_LESS_OR_EQUAL again, with stop at ndis.sys…maybe
newfunction must return such a values?



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: mercoled? 8 febbraio 2006 6.37
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

Francesco,

Here is how you can do it correctly:

2. When the timer expire call MpSendPacket for each packet
3. Your MpSendPacket will call NdisSend (or NdisSendPacket)
4. After calling MpSendPacket, Free the allocations made for timer
5. When the packet is actually sent, NDIS will call your
ProtocolSendComplete handler and you can Complete the packet then.

My guess is that passthru is already handling MpSendPacket and
ProtocolSendComplete correctly, so all you need to do is, do step 1, 2 and
4.

Hope this helps.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
thanks, now it compiles…
but there is the error that i saw many times with Hook driver
too…IRQL_NOT_LESS_OR_EQUAL…
I used the NDIS timer to delay the delivery of packets saved to a buffer
initialized in DriverEntry…if i use NDIS timer only to write a dbg message
it works, so maybe i can t call NDISSend in this way??
How could u resolve it?
thanks



Da: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] Per conto di Pankaj Garg
Inviato: marted? 7 febbraio 2006 10.27
A: Windows System Software Devs Interest List
Oggetto: Re:[ntdev] NDIS driver problem

How familiar are you with C? This is one of the basic C question. I would
assume proficiency in C before writing kernel mode code on windows. Anyways,
you declare a global pointer, allocate memory in it using
ExAllocatePoolWithTag. In other files that need to access this, declare the
same variable as extern or you can declare it as extern in a .h file and
include that .h file in other .c files.

Pankaj

“Francesco Tabbita (IT)” wrote in message
news:xxxxx@ntdev…
hi!
i m implementing a NDIS IM driver…i must create a buffer that all driver
functions can access it…where i must create it? in the driverentry call i
suppose…but how can i call it (the buffer) from other functions
implemented (some of them are in other files .c too) ?


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com