ReactOS  0.4.13-dev-66-gc714b7f
routines.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DISPLAY_IP_PACKET(x)
 
#define DISPLAY_TCP_PACKET(x)
 

Functions

UINT Random (VOID)
 
UINT CopyBufferToBufferChain (PNDIS_BUFFER DstBuffer, UINT DstOffset, PCHAR SrcData, UINT Length)
 
UINT CopyBufferChainToBuffer (PCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
 
UINT CopyPacketToBuffer (PCHAR DstData, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
 
UINT CopyPacketToBufferChain (PNDIS_BUFFER DstBuffer, UINT DstOffset, PNDIS_PACKET SrcPacket, UINT SrcOffset, UINT Length)
 
VOID FreeNdisPacketX (PNDIS_PACKET Packet, PCHAR File, UINT Line)
 
PVOID AdjustPacket (PNDIS_PACKET Packet, UINT Available, UINT Needed)
 
UINT ResizePacket (PNDIS_PACKET Packet, UINT Size)
 
NDIS_STATUS AllocatePacketWithBuffer (PNDIS_PACKET *NdisPacket, PCHAR Data, UINT Len)
 
VOID FreeNdisPacket (PNDIS_PACKET Packet)
 
void GetDataPtr (PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
 

Macro Definition Documentation

◆ DISPLAY_IP_PACKET

#define DISPLAY_IP_PACKET (   x)

Definition at line 69 of file routines.h.

◆ DISPLAY_TCP_PACKET

#define DISPLAY_TCP_PACKET (   x)

Definition at line 70 of file routines.h.

Function Documentation

◆ AdjustPacket()

PVOID AdjustPacket ( PNDIS_PACKET  Packet,
UINT  Available,
UINT  Needed 
)

Definition at line 334 of file mockbuffer.c.

347 {
348  PNDIS_BUFFER NdisBuffer;
349  INT Adjust;
350 
351  TI_DbgPrint(DEBUG_PBUFFER, ("Available = %d, Needed = %d.\n", Available, Needed));
352 
353  Adjust = Available - Needed;
354 
355  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
356 
357  /* If Adjust is zero there is no need to adjust this packet as
358  there is no additional space at start the of first buffer */
359  if (Adjust != 0) {
360  NdisBuffer->MappedSystemVa = (PVOID) ((ULONG_PTR)(NdisBuffer->MappedSystemVa) + Adjust);
361  NdisBuffer->ByteOffset += Adjust;
362  NdisBuffer->ByteCount -= Adjust;
363  }
364 
365  return NdisBuffer->MappedSystemVa;
366 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
static LONGLONG Adjust(LONGLONG value, const LONGLONG *pModifier, DWORD dwFlags)
Definition: seeking.c:201
int32_t INT
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define DEBUG_PBUFFER
Definition: debug.h:20
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575

◆ AllocatePacketWithBuffer()

NDIS_STATUS AllocatePacketWithBuffer ( PNDIS_PACKET NdisPacket,
PCHAR  Data,
UINT  Len 
)

Definition at line 325 of file buffer.c.

326  {
330  PCHAR NewData;
331 
333  if( !NewData ) return NDIS_STATUS_RESOURCES;
334 
335  if( Data ) RtlCopyMemory(NewData, Data, Len);
336 
338  if( Status != NDIS_STATUS_SUCCESS ) {
340  return Status;
341  }
342 
344  if( Status != NDIS_STATUS_SUCCESS ) {
347  return Status;
348  }
349 
351  *NdisPacket = Packet;
352 
353  return NDIS_STATUS_SUCCESS;
354 }
signed char * PCHAR
Definition: retypes.h:7
VOID EXPORT NdisAllocatePacket(OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:392
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define NdisChainBufferAtFront(Packet, Buffer)
Definition: ndis.h:3088
int NDIS_STATUS
Definition: ntddndis.h:380
Definition: bufpool.h:45
VOID EXPORT NdisAllocateBuffer(OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, IN NDIS_HANDLE PoolHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: buffer.c:334
VOID FreeNdisPacket(PNDIS_PACKET Packet)
Definition: buffer.c:358
#define Len
Definition: deflate.h:82
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
NDIS_HANDLE GlobalBufferPool
Definition: routines.c:4
Status
Definition: gdiplustypes.h:24
NDIS_HANDLE GlobalPacketPool
Definition: routines.c:3
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define PACKET_BUFFER_TAG
Definition: tags.h:27

◆ CopyBufferChainToBuffer()

UINT CopyBufferChainToBuffer ( PCHAR  DstData,
PNDIS_BUFFER  SrcBuffer,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 112 of file buffer.c.

130 {
131  UINT BytesCopied, BytesToCopy, SrcSize;
132  PCHAR SrcData;
133 
134  TI_DbgPrint(DEBUG_PBUFFER, ("DstData 0x%X SrcBuffer 0x%X SrcOffset 0x%X Length %d\n",DstData,SrcBuffer, SrcOffset, Length));
135 
136  /* Skip SrcOffset bytes in the source buffer chain */
137  if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == -1)
138  return 0;
139 
140  /* Start copying the data */
141  BytesCopied = 0;
142  for (;;) {
143  BytesToCopy = MIN(SrcSize, Length);
144 
145  TI_DbgPrint(DEBUG_PBUFFER, ("Copying (%d) bytes from 0x%X to 0x%X\n", BytesToCopy, SrcData, DstData));
146 
147  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
149  DstData = (PCHAR)((ULONG_PTR)DstData + BytesToCopy);
150 
151  Length -= BytesToCopy;
152  if (Length == 0)
153  break;
154 
155  SrcSize -= BytesToCopy;
156  if (SrcSize == 0) {
157  /* No more bytes in source buffer. Proceed to
158  the next buffer in the source buffer chain */
159  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
160  if (!SrcBuffer)
161  break;
162 
163  NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
164  }
165  }
166 
167  return BytesCopied;
168 }
signed char * PCHAR
Definition: retypes.h:7
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3149
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3368
uint32_t ULONG_PTR
Definition: typedefs.h:63
T MIN(T a, T b)
Definition: polytest.cpp:79
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3149
#define PCHAR
Definition: match.c:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PBUFFER
Definition: debug.h:20
__inline ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:13
unsigned int UINT
Definition: ndis.h:50
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953

Referenced by CopyPacketToBuffer().

◆ CopyBufferToBufferChain()

UINT CopyBufferToBufferChain ( PNDIS_BUFFER  DstBuffer,
UINT  DstOffset,
PCHAR  SrcData,
UINT  Length 
)

Definition at line 55 of file buffer.c.

73 {
74  UINT BytesCopied, BytesToCopy, DstSize;
75  PCHAR DstData;
76 
77  TI_DbgPrint(DEBUG_PBUFFER, ("DstBuffer (0x%X) DstOffset (0x%X) SrcData (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcData, Length));
78 
79  /* Skip DstOffset bytes in the destination buffer chain */
80  if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == -1)
81  return 0;
82 
83  /* Start copying the data */
84  BytesCopied = 0;
85  for (;;) {
86  BytesToCopy = MIN(DstSize, Length);
87 
88  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
90  SrcData = (PCHAR)((ULONG_PTR)SrcData + BytesToCopy);
91 
93  if (Length == 0)
94  break;
95 
96  DstSize -= BytesToCopy;
97  if (DstSize == 0) {
98  /* No more bytes in destination buffer. Proceed to
99  the next buffer in the destination buffer chain */
100  NdisGetNextBuffer(DstBuffer, &DstBuffer);
101  if (!DstBuffer)
102  break;
103 
104  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
105  }
106  }
107 
108  return BytesCopied;
109 }
signed char * PCHAR
Definition: retypes.h:7
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3149
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3368
uint32_t ULONG_PTR
Definition: typedefs.h:63
T MIN(T a, T b)
Definition: polytest.cpp:79
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3149
#define PCHAR
Definition: match.c:90
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PBUFFER
Definition: debug.h:20
__inline ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:13
unsigned int UINT
Definition: ndis.h:50
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953

◆ CopyPacketToBuffer()

UINT CopyPacketToBuffer ( PCHAR  DstData,
PNDIS_PACKET  SrcPacket,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 171 of file buffer.c.

189 {
190  PNDIS_BUFFER FirstBuffer;
191  PVOID Address;
192  UINT FirstLength;
194 
195  TI_DbgPrint(DEBUG_PBUFFER, ("DstData (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstData, SrcPacket, SrcOffset, Length));
196 
198  &FirstBuffer,
199  &Address,
200  &FirstLength,
201  &TotalLength);
202 
203  return CopyBufferChainToBuffer(DstData, FirstBuffer, SrcOffset, Length);
204 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_In_ ULONG TotalLength
Definition: usbdlib.h:145
static WCHAR Address[46]
Definition: ping.c:68
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:871
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PBUFFER
Definition: debug.h:20
unsigned int UINT
Definition: ndis.h:50
UINT CopyBufferChainToBuffer(PUCHAR DstData, PNDIS_BUFFER SrcBuffer, UINT SrcOffset, UINT Length)
Definition: buffer.c:111

◆ CopyPacketToBufferChain()

UINT CopyPacketToBufferChain ( PNDIS_BUFFER  DstBuffer,
UINT  DstOffset,
PNDIS_PACKET  SrcPacket,
UINT  SrcOffset,
UINT  Length 
)

Definition at line 206 of file buffer.c.

226 {
227  PNDIS_BUFFER SrcBuffer;
228  PUCHAR DstData, SrcData;
229  UINT DstSize, SrcSize;
230  UINT Count, Total;
231 
232  NDIS_DbgPrint(MAX_TRACE, ("DstBuffer (0x%X) DstOffset (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcPacket, SrcOffset, Length));
233 
234  /* Skip DstOffset bytes in the destination buffer chain */
235  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
236  if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == 0xFFFFFFFF)
237  return 0;
238  /* Skip SrcOffset bytes in the source packet */
239  NdisGetFirstBufferFromPacket(SrcPacket, &SrcBuffer, (PVOID*)&SrcData, &SrcSize, &Total);
240  if (SkipToOffset(SrcBuffer, SrcOffset, &SrcData, &SrcSize) == 0xFFFFFFFF)
241  return 0;
242  /* Copy the data */
243  for (Total = 0;;) {
244  /* Find out how many bytes we can copy at one time */
245  if (Length < SrcSize)
246  Count = Length;
247  else
248  Count = SrcSize;
249  if (DstSize < Count)
250  Count = DstSize;
251 
252  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, Count);
253 
254  Total += Count;
255  Length -= Count;
256  if (Length == 0)
257  break;
258 
259  DstSize -= Count;
260  if (DstSize == 0) {
261  /* No more bytes in destination buffer. Proceed to
262  the next buffer in the destination buffer chain */
263  NdisGetNextBuffer(DstBuffer, &DstBuffer);
264  if (!DstBuffer)
265  break;
266 
267  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
268  }
269 
270  SrcSize -= Count;
271  if (SrcSize == 0) {
272  /* No more bytes in source buffer. Proceed to
273  the next buffer in the source buffer chain */
274  NdisGetNextBuffer(SrcBuffer, &SrcBuffer);
275  if (!SrcBuffer)
276  break;
277 
278  NdisQueryBuffer(SrcBuffer, (PVOID)&SrcData, &SrcSize);
279  }
280  }
281 
282  return Total;
283 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
MDL * PNDIS_BUFFER
Definition: ndis.h:343
unsigned char * PUCHAR
Definition: retypes.h:3
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3368
VOID EXPORT NdisGetFirstBufferFromPacket(IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, OUT PVOID *_FirstBufferVA, OUT PUINT _FirstBufferLength, OUT PUINT _TotalBufferLength)
Definition: buffer.c:871
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
__inline ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:13
#define MAX_TRACE
Definition: debug.h:16
unsigned int UINT
Definition: ndis.h:50
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953

◆ FreeNdisPacket()

VOID FreeNdisPacket ( PNDIS_PACKET  Packet)

Definition at line 358 of file buffer.c.

364 {
365  PNDIS_BUFFER Buffer, NextBuffer;
366 
367  TI_DbgPrint(DEBUG_PBUFFER, ("Packet (0x%X)\n", Packet));
368 
369  /* Free all the buffers in the packet first */
371  for (; Buffer != NULL; Buffer = NextBuffer) {
372  PVOID Data;
373  UINT Length;
374 
375  NdisGetNextBuffer(Buffer, &NextBuffer);
377  TI_DbgPrint(DEBUG_PBUFFER, ("Freeing ndis buffer (0x%X)\n", Buffer));
379  TI_DbgPrint(DEBUG_PBUFFER, ("Freeing exal buffer (0x%X)\n", Data));
381  }
382 
383  /* Finally free the NDIS packet descriptor */
385 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:809
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3368
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: bufpool.h:45
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:826
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PBUFFER
Definition: debug.h:20
unsigned int UINT
Definition: ndis.h:50
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define PACKET_BUFFER_TAG
Definition: tags.h:27

Referenced by AllocatePacketWithBuffer().

◆ FreeNdisPacketX()

VOID FreeNdisPacketX ( PNDIS_PACKET  Packet,
PCHAR  File,
UINT  Line 
)

Definition at line 118 of file routines.c.

126 {
127  PNDIS_BUFFER Buffer, NextBuffer;
128 
129  LA_DbgPrint(DEBUG_PBUFFER, ("Packet (0x%X)\n", Packet));
130 
131  /* Free all the buffers in the packet first */
133  for (; Buffer != NULL; Buffer = NextBuffer) {
134  PVOID Data;
135  UINT Length;
136 
137  NdisGetNextBuffer(Buffer, &NextBuffer);
141  exFreePool(Data);
142  }
143 
144  /* Finally free the NDIS packet descriptor */
147 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:809
#define exFreePool(x)
Definition: memtrack.h:18
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3368
#define UntrackFL(x, y, z)
Definition: memtrack.h:20
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: bufpool.h:45
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:826
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define DEBUG_PBUFFER
Definition: debug.h:20
Definition: ncftp.h:79
unsigned int UINT
Definition: ndis.h:50
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
Definition: File.h:15
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ GetDataPtr()

void GetDataPtr ( PNDIS_PACKET  Packet,
UINT  Offset,
PCHAR DataOut,
PUINT  Size 
)

Definition at line 65 of file routines.c.

68  {
70 
72  if( !Buffer ) return;
73  SkipToOffset( Buffer, Offset, DataOut, Size );
74 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__inline INT SkipToOffset(PNDIS_BUFFER Buffer, UINT Offset, PCHAR *Data, PUINT Size)
Definition: routines.c:24
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ Random()

UINT Random ( VOID  )

Definition at line 16 of file routines.c.

23 {
24  RandomNumber ^= 0x78563412;
25 
26  return RandomNumber;
27 }
static UINT RandomNumber
Definition: routines.c:13

Referenced by AddGenericHeaderIPv4(), and PrepareICMPPacket().

◆ ResizePacket()

UINT ResizePacket ( PNDIS_PACKET  Packet,
UINT  Size 
)

Definition at line 289 of file buffer.c.

300 {
301  PNDIS_BUFFER NdisBuffer;
302  UINT OldSize;
303 
304  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
305 
306  OldSize = NdisBuffer->ByteCount;
307 
308  if (Size != OldSize)
309  NdisBuffer->ByteCount = Size;
310 
311  return OldSize;
312 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1530
MDL * PNDIS_BUFFER
Definition: ndis.h:343
smooth NULL
Definition: ftsmooth.c:416
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned int UINT
Definition: ndis.h:50
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3575