Hi,

I was going through the code of Passthru sample IM driver. I am not
sure why the following has been done.

(e.g., in MPSendPackets. And Similarly for PRECV_RSVD)
-----------------------------
.
.
.
PSEND_RSVD SendRsvd;

SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);
SendRsvd->OriginalPkt = Packet;
.
.
.
-----------------------------

They are trying to store a pointer value "Packet" (4 bytes) in an
array of UCHAR[1] "MyPacket->ProtocolReserved". This would work as
long as the size of NDIS_PACKET is 3 bytes short of a 4-byte boundary
(NDIS_PACKET comes out to be 57 bytes!).

I am wondering why it is being done this way at all?

Thanks,
Sav

Re: A question on Passthru IM driver by Thomas

Thomas
Fri Dec 12 00:38:48 CST 2003

This works because the amount of memory actually allocated for each NDIS
packet descriptor is actually larger then sizeof( NDIS_PACKET). The actual
size of ProtocolReserved is specified when the call to
NdisAllocatePacketPool(Ex) is made. There you will see that the
ProtocolReserved size when allocating the send packet pool is
sizeof(SEND_RSVD).

Similar when allocating the separate packet pool for receiving.

Hope this helps.

Thomas F. Divine
www.pcausa.com


"Anubhav" <hyperarian@indiatimes.com> wrote in message
news:a94ef909.0312111603.5f9c7353@posting.google.com...
> Hi,
>
> I was going through the code of Passthru sample IM driver. I am not
> sure why the following has been done.
>
> (e.g., in MPSendPackets. And Similarly for PRECV_RSVD)
> -----------------------------
> .
> .
> .
> PSEND_RSVD SendRsvd;
>
> SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);
> SendRsvd->OriginalPkt = Packet;
> .
> .
> .
> -----------------------------
>
> They are trying to store a pointer value "Packet" (4 bytes) in an
> array of UCHAR[1] "MyPacket->ProtocolReserved". This would work as
> long as the size of NDIS_PACKET is 3 bytes short of a 4-byte boundary
> (NDIS_PACKET comes out to be 57 bytes!).
>
> I am wondering why it is being done this way at all?
>
> Thanks,
> Sav



Re: A question on Passthru IM driver by Stephan

Stephan
Mon Dec 15 06:23:22 CST 2003

Actually, the 'ProtocolReserved' field should be (at least)
PROTOCOL_RESERVED_SIZE_IN_PACKET bytes in length, which is defined in
<ndis.h>

See also

http://www.ndis.com/papers/ndispacket/ndispacket2.htm

Stephan
---
On Fri, 12 Dec 2003 01:38:48 -0500, "Thomas F. Divine"
<pcausa@hotmail.com> wrote:

>This works because the amount of memory actually allocated for each NDIS
>packet descriptor is actually larger then sizeof( NDIS_PACKET). The actual
>size of ProtocolReserved is specified when the call to
>NdisAllocatePacketPool(Ex) is made. There you will see that the
>ProtocolReserved size when allocating the send packet pool is
>sizeof(SEND_RSVD).
>
>Similar when allocating the separate packet pool for receiving.
>
>Hope this helps.
>
>Thomas F. Divine
>www.pcausa.com
>
>
>"Anubhav" <hyperarian@indiatimes.com> wrote in message
>news:a94ef909.0312111603.5f9c7353@posting.google.com...
>> Hi,
>>
>> I was going through the code of Passthru sample IM driver. I am not
>> sure why the following has been done.
>>
>> (e.g., in MPSendPackets. And Similarly for PRECV_RSVD)
>> -----------------------------
>> .
>> .
>> .
>> PSEND_RSVD SendRsvd;
>>
>> SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved);
>> SendRsvd->OriginalPkt = Packet;
>> .
>> .
>> .
>> -----------------------------
>>
>> They are trying to store a pointer value "Packet" (4 bytes) in an
>> array of UCHAR[1] "MyPacket->ProtocolReserved". This would work as
>> long as the size of NDIS_PACKET is 3 bytes short of a 4-byte boundary
>> (NDIS_PACKET comes out to be 57 bytes!).
>>
>> I am wondering why it is being done this way at all?
>>
>> Thanks,
>> Sav