ReactOS  0.4.15-dev-2343-ge044df8
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:1548
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:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
void * PVOID
Definition: retypes.h:9
#define DEBUG_PBUFFER
Definition: debug.h:20
#define NULL
Definition: types.h:112
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:3593

◆ AllocatePacketWithBuffer()

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

Definition at line 326 of file buffer.c.

327  {
331  PCHAR NewData;
332 
334  if( !NewData ) return NDIS_STATUS_RESOURCES;
335 
336  if( Data ) RtlCopyMemory(NewData, Data, Len);
337 
339  if( Status != NDIS_STATUS_SUCCESS ) {
341  return Status;
342  }
343 
345  if( Status != NDIS_STATUS_SUCCESS ) {
348  return Status;
349  }
350 
352  *NdisPacket = Packet;
353 
354  return NDIS_STATUS_SUCCESS;
355 }
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:394
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define NdisChainBufferAtFront(Packet, Buffer)
Definition: ndis.h:3106
int NDIS_STATUS
Definition: ntddndis.h:471
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:336
VOID FreeNdisPacket(PNDIS_PACKET Packet)
Definition: buffer.c:359
Status
Definition: gdiplustypes.h:24
#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
NDIS_HANDLE GlobalPacketPool
Definition: routines.c:3
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define PACKET_BUFFER_TAG
Definition: tags.h:27

◆ CopyBufferChainToBuffer()

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

Definition at line 113 of file buffer.c.

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

Referenced by CopyPacketToBuffer().

◆ CopyBufferToBufferChain()

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

Definition at line 56 of file buffer.c.

74 {
75  UINT BytesCopied, BytesToCopy, DstSize;
76  PCHAR DstData;
77 
78  TI_DbgPrint(DEBUG_PBUFFER, ("DstBuffer (0x%X) DstOffset (0x%X) SrcData (0x%X) Length (%d)\n", DstBuffer, DstOffset, SrcData, Length));
79 
80  /* Skip DstOffset bytes in the destination buffer chain */
81  if (SkipToOffset(DstBuffer, DstOffset, &DstData, &DstSize) == -1)
82  return 0;
83 
84  /* Start copying the data */
85  BytesCopied = 0;
86  for (;;) {
87  BytesToCopy = MIN(DstSize, Length);
88 
89  RtlCopyMemory((PVOID)DstData, (PVOID)SrcData, BytesToCopy);
91  SrcData = (PCHAR)((ULONG_PTR)SrcData + BytesToCopy);
92 
94  if (Length == 0)
95  break;
96 
97  DstSize -= BytesToCopy;
98  if (DstSize == 0) {
99  /* No more bytes in destination buffer. Proceed to
100  the next buffer in the destination buffer chain */
101  NdisGetNextBuffer(DstBuffer, &DstBuffer);
102  if (!DstBuffer)
103  break;
104 
105  NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
106  }
107  }
108 
109  return BytesCopied;
110 }
signed char * PCHAR
Definition: retypes.h:7
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3167
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
uint32_t ULONG_PTR
Definition: typedefs.h:65
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:3167
#define PCHAR
Definition: match.c:90
#define DEBUG_PBUFFER
Definition: debug.h:20
unsigned int UINT
Definition: ndis.h:50
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:955
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
FORCEINLINE ULONG SkipToOffset(IN PNDIS_BUFFER Buffer, IN UINT Offset, IN OUT PUCHAR *Data, IN OUT PUINT Size)
Definition: buffer.c:15

◆ CopyPacketToBuffer()

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

Definition at line 172 of file buffer.c.

190 {
191  PNDIS_BUFFER FirstBuffer;
192  PVOID Address;
193  UINT FirstLength;
195 
196  TI_DbgPrint(DEBUG_PBUFFER, ("DstData (0x%X) SrcPacket (0x%X) SrcOffset (0x%X) Length (%d)\n", DstData, SrcPacket, SrcOffset, Length));
197 
199  &FirstBuffer,
200  &Address,
201  &FirstLength,
202  &TotalLength);
203 
204  return CopyBufferChainToBuffer(DstData, FirstBuffer, SrcOffset, Length);
205 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_In_ ULONG TotalLength
Definition: usbdlib.h:158
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:873
#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:113

◆ CopyPacketToBufferChain()

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

Definition at line 208 of file buffer.c.

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

◆ FreeNdisPacket()

VOID FreeNdisPacket ( PNDIS_PACKET  Packet)

Definition at line 359 of file buffer.c.

365 {
366  PNDIS_BUFFER Buffer, NextBuffer;
367 
368  TI_DbgPrint(DEBUG_PBUFFER, ("Packet (0x%X)\n", Packet));
369 
370  /* Free all the buffers in the packet first */
372  for (; Buffer != NULL; Buffer = NextBuffer) {
373  PVOID Data;
374  UINT Length;
375 
376  NdisGetNextBuffer(Buffer, &NextBuffer);
378  TI_DbgPrint(DEBUG_PBUFFER, ("Freeing ndis buffer (0x%X)\n", Buffer));
380  TI_DbgPrint(DEBUG_PBUFFER, ("Freeing exal buffer (0x%X)\n", Data));
382  }
383 
384  /* Finally free the NDIS packet descriptor */
386 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:811
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
Definition: bufpool.h:45
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:828
#define DEBUG_PBUFFER
Definition: debug.h:20
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:3593
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:955
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#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_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:811
#define exFreePool(x)
Definition: memtrack.h:18
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
#define UntrackFL(x, y, z)
Definition: memtrack.h:20
Definition: bufpool.h:45
#define LA_DbgPrint(_t_, _x_)
Definition: debug.h:66
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:828
#define DEBUG_PBUFFER
Definition: debug.h:20
Definition: ncftp.h:79
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:3593
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:955
Definition: File.h:15

◆ 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:1548
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
MDL * PNDIS_BUFFER
Definition: ndis.h:343
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Definition: bufpool.h:45
__inline INT SkipToOffset(PNDIS_BUFFER Buffer, UINT Offset, PCHAR *Data, PUINT Size)
Definition: routines.c:24
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define NULL
Definition: types.h:112
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:3593

◆ 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().

◆ ResizePacket()

UINT ResizePacket ( PNDIS_PACKET  Packet,
UINT  Size 
)

Definition at line 290 of file buffer.c.

301 {
302  PNDIS_BUFFER NdisBuffer;
303  UINT OldSize;
304 
305  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, NULL);
306 
307  OldSize = NdisBuffer->ByteCount;
308 
309  if (Size != OldSize)
310  NdisBuffer->ByteCount = Size;
311 
312  return OldSize;
313 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
MDL * PNDIS_BUFFER
Definition: ndis.h:343
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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:3593