Sample Code

Windows Driver Samples/ Windows Filtering Platform Sample/ C++/ syslib/ HelperFunctions_Headers.h/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//   Copyright (c) 2012 Microsoft Corporation.  All Rights Reserved.
//
//   Module Name:
//      HelperFunctions_Headers.h
//
//   Abstract:
//      This module contains definitions and prototypes of kernel helper functions that assist with 
//         MAC, IP, and Transport header operations.
//
//   Author:
//      Dusty Harper      (DHarper)
//
//   Revision History:
//
//      [ Month ][Day] [Year] - [Revision]-[ Comments ]
//      May       01,   2010  -     1.0   -  Creation
//
////////////////////////////////////////////////////////////////////////////////////////////////////
 
#ifndef HELPERFUNCTIONS_HEADERS_H
#define HELPERFUNCTIONS_HEADERS_H
 
#pragma warning(push)
#pragma warning(disable: 4201) /// NAMELESS_STRUCT_UNION
 
#define ETHERNET_ADDRESS_SIZE 6
 
#define IPV4_ADDRESS_SIZE  4
#define IPV6_ADDRESS_SIZE 16
 
#define IPV4 4
#define IPV6 6
 
#define IPV4_HEADER_MIN_SIZE 20
#define IPV6_HEADER_MIN_SIZE 40
#define ICMP_HEADER_MIN_SIZE  8
#define TCP_HEADER_MIN_SIZE  20
#define UDP_HEADER_MIN_SIZE   8
 
#define ICMPV4  1
#define TCP     6
#define UDP    17
#define ICMPV6 58
 
static const UINT8 IPV4_LOOPBACK_ADDRESS[] = {0x01,
                                              0x00,
                                              0x00,
                                              0x7F}; /// 127.0.0.1 ( in network byte order)
static const UINT8 IPV6_LOOPBACK_ADDRESS[] = {0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x00,
                                              0x01}; /// ::1
 
 
 
/*
    RFC 894 - A Standard for the Transmission of     <br>
              IP Datagrams over Ethernet Networks    <br>
                                                     <br>
    0                   1                   2        <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                               | <br>
   +            Destination MAC Address            + <br>
   |                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                               | <br>
   +               Source MAC Address              + <br>
   |                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |              Type             |    Data...    | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                     <br>
*/
typedef struct _ETHERNET_II_HEADER_
{
   BYTE   pDestinationAddress[6];
   BYTE   pSourceAddress[6];
   UINT16 type;
}ETHERNET_II_HEADER;
 
/*
    RFC 1042 - A Standard for the Transmission of    <br>
               IP Datagrams over IEEE 802 Networks   <br>
                                                     <br>
    0                   1                   2        <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                               | <br>
   +            Destination MAC Address            + <br>
   |                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                               | <br>
   +               Source MAC Address              + <br>
   |                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |            Length             |      DSAP     | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |      SSAP     | Control Byte  |    OUI ...    > <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   <           OUI (cont.)         |    Type ...   > <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   < Type (cont.)  |            Data ...           | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                     <br>
*/
typedef struct _ETHERNET_SNAP_HEADER_
{
   BYTE   pDestinationAddress[6];
   BYTE   pSourceAddress[6];
   UINT16 length;
   UINT8  destinationSAP; /// Destination Subnetwork Access Protocol
   UINT8  sourceSAP;      /// Source  Subnetwork Access Protocol
   UINT8  controlByte;
   UINT8  pOUI[3];        /// Organizationally Unique Identifier
   UINT16 type;
}ETHERNET_SNAP_HEADER;
 
/*
                     RFC 791 - Internet Protocol                     <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |Version|  IHL  |Type of Service|         Total Length          | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |        Identification         |Flags|     Fragment Offset     | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |  Time to Live |     Protocol  |        Header Checksum        | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                        Source Address                         | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                      Destination Address                      | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                    Options                    |    Padding    | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                                     <br>
*/
typedef struct _IP_HEADER_V4_
{
   union
   {
      UINT8 versionAndHeaderLength;
      struct
      {
         UINT8 headerLength : 4;
         UINT8 version : 4;
      };
   };
   union
   {
      UINT8  typeOfService;
      UINT8  differentiatedServicesCodePoint;
      struct
      {
         UINT8 explicitCongestionNotification : 2;
         UINT8 typeOfService : 6;
      };
   };
   UINT16 totalLength;
   UINT16 identification;
   union
   {
      UINT16 flagsAndFragmentOffset;
      struct
      {
         UINT16 fragmentOffset : 13;
         UINT16 flags : 3;
      };
   };
   UINT8  timeToLive;
   UINT8  protocol;
   UINT16 checksum;
   BYTE   pSourceAddress[sizeof(UINT32)];
   BYTE   pDestinationAddress[sizeof(UINT32)];
   UINT8  pOptions[1];                           /// pointer to the first byte of the variable length Options
}IP_HEADER_V4, *PIP_HEADER_V4;
 
/*
      RFC 2460 - Internet Protocol, Version 6 (IPv6) Specification   <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |Version| Traffic Class |              Flow Label               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |        Payload Length         |  Next Header  |   Hop Limit   | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                                               | <br>
   +                                                               + <br>
   |                                                               | <br>
   +                        Source Address                         + <br>
   |                                                               | <br>
   +                                                               + <br>
   |                                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                                                               | <br>
   +                                                               + <br>
   |                                                               | <br>
   +                      Destination Address                      + <br>
   |                                                               | <br>
   +                                                               + <br>
   |                                                               | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                                     <br>
*/
typedef struct _IP_HEADER_V6_
{
   union
   {
      UINT8 pVersionTrafficClassAndFlowLabel[4];
      struct
      {
       UINT8 r1 : 4;
       UINT8 value : 4;
       UINT8 r2;
       UINT8 r3;
       UINT8 r4;
      }version;
   };
   UINT16 payloadLength;
   UINT8  nextHeader;
   UINT8  hopLimit;
   BYTE   pSourceAddress[16];
   BYTE   pDestinationAddress[16];
}IP_HEADER_V6, *PIP_HEADER_V6;
 
/*
             RFC 792 - Internet Control Message Protocol             <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |     Type      |     Code      |           Checksum            | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |              Variable (Dependent on Type / Code)              | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
*/
typedef struct _ICMP_HEADER_V4_
{
   UINT8  type;
   UINT8  code;
   UINT16 checksum;
   union
   {
      ECHO_MESSAGE                    echo;
      DESTINATION_UNREACHABLE_MESSAGE destinationUnreachable;
      SOURCE_QUENCH_MESSAGE           sourceQuench;
      REDIRECT_MESSAGE                redirect;
      TIME_EXCEEDED_MESSAGE           timeExceeded;
      PARAMETER_PROBLEM_MESSAGE       parameterProblem;
      TIMESTAMP_MESSAGE               timestamp;
      INFORMATION_MESSAGE             information;
   };
}ICMP_HEADER_V4, *PICMP_HEADER_V4;
 
/*
        RFC 2463 - Internet Control Message Protocol for IPv6        <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |     Type      |     Code      |           Checksum            | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |              Variable (Dependent on Type / Code)              | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
*/
typedef struct _ICMP_HEADER_V6_
{
   UINT8  type;
   UINT8  code;
   UINT16 checksum;
/*   union
   {
      ECHO_MESSAGE                    echo;
      DESTINATION_UNREACHABLE_MESSAGE destinationUnreachable;
      SOURCE_QUENCH_MESSAGE           sourceQuench;
      REDIRECT_MESSAGE                redirect;
      TIME_EXCEEDED_MESSAGE           timeExceeded;
      PARAMETER_PROBLEM_MESSAGE       parameterProblem;
      TIMESTAMP_MESSAGE               timestamp;
      INFORMATION_MESSAGE             information;
   };*/
}ICMP_HEADER_V6, *PICMP_HEADER_V6;
 
/*
               RFC 793 - Transmission Control Protocol               <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |          Source Port          |       Destination Port        | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                        Sequence Number                        | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                     Acknowledgment Number                     | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |Offset |Rsvd |N|C|E|U|A|P|R|S|F|            Window             | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |           Checksum            |        Urgent Pointer         | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |                    Options                    |    Padding    | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                                     <br>
*/
typedef struct _TCP_HEADER_
{
   UINT16 sourcePort;
   UINT16 destinationPort;
   UINT32 sequenceNumber;
   UINT32 acknowledgementNumber;
   union
   {
      UINT8 dataOffsetReservedAndNS;
      struct
      {
         UINT8 nonceSum : 1;
         UINT8 reserved : 3;
         UINT8 dataOffset : 4;
      }dORNS;
   };
   union
   {
      UINT8 controlBits;
      struct
      {
         UINT8 FIN : 1;
         UINT8 SYN : 1;
         UINT8 RST : 1;
         UINT8 PSH : 1;
         UINT8 ACK : 1;
         UINT8 URG : 1;
         UINT8 ECE : 1;
         UINT8 CWR : 1;
      };
   };
   UINT16 window;
   UINT16 checksum;
   UINT16 urgentPointer;
   UINT8  pOptions[1];                           /// pointer to the first byte of the variable length Options
}TCP_HEADER, *PTCP_HEADER;
 
/*
                    RFC 768 - User Datagram Protocol                 <br>
                                                                     <br>
    0                   1                   2                   3    <br>
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1  <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |          Source Port          |       Destination Port        | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
   |            Length             |           Checksum            | <br>
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <br>
                                                                     <br>
*/
typedef struct _UDP_HEADER_
{
   UINT16 sourcePort;
   UINT16 destinationPort;
   UINT16 length;
   UINT16 checksum;
}UDP_HEADER, *PUDP_HEADER;
 
#pragma warning(pop) /// NAMELESS_STRUCT_UNION
 
_At_(*ppMACHeader, _Pre_ _Notnull_)
_At_(*ppMACHeader, _Post_ _Null_)
_Success_(*ppMACHeader == 0)
inline VOID KrnlHlprMACHeaderDestroy(_Inout_ VOID** ppMACHeader);
 
_When_(return != STATUS_SUCCESS, _At_(*ppMACHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppMACHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprMACHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                              _Outptr_ VOID** ppMACHeader,
                              _Inout_ BOOLEAN* pNeedToFreeMemory,
                              _In_ UINT32 macHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprMACHeaderModifySourceAddress(_In_ const FWP_VALUE* pValue,
                                              _Inout_ NET_BUFFER_LIST* pNetBufferList);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprMACHeaderModifyDestinationAddress(_In_ const FWP_VALUE* pValue,
                                                   _Inout_ NET_BUFFER_LIST* pNetBufferList);
 
_At_(*ppIPHeader, _Pre_ _Notnull_)
_At_(*ppIPHeader, _Post_ _Null_)
_Success_(*ppIPHeader == 0)
inline VOID KrnlHlprIPHeaderDestroy(_Inout_ VOID** ppIPHeader);
 
_When_(return != STATUS_SUCCESS, _At_(*ppIPHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppIPHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprIPHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                             _In_ const FWPS_INCOMING_VALUES* pClassifyValues,
                             _In_ const FWPS_INCOMING_METADATA_VALUES* pMetadata,
                             _Outptr_ VOID** ppIPHeader,
                             _Inout_ BOOLEAN* pNeedToFreeMemory,
                             _Inout_opt_ FWP_DIRECTION* pDirection = 0,
                             _Inout_opt_ UINT32* pIPHeaderSize = 0);
_When_(return != STATUS_SUCCESS, _At_(*ppIPHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppIPHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprIPHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                             _Outptr_ VOID** ppIPHeader,
                             _Inout_ BOOLEAN* pNeedToFreeMemory,
                             _In_ UINT32 ipHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
IPPROTO KrnlHlprIPHeaderGetProtocolField(_In_ NET_BUFFER_LIST* pNetBufferList,
                                         _In_ ADDRESS_FAMILY addressFamily);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
inline VOID KrnlHlprIPHeaderCalculateV4Checksum(_Inout_ IP_HEADER_V4* pIPv4Header,
                                                _In_ UINT32 headerSize);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprIPHeaderModifySourceAddress(_In_ const FWP_VALUE* pValue,
                                             _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                             _In_ const BOOLEAN recalculateChecksum = TRUE,
                                             _In_ BOOLEAN convertByteOrder = FALSE);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprIPHeaderModifyDestinationAddress(_In_ const FWP_VALUE* pValue,
                                                  _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                                  _In_ const BOOLEAN recalculateChecksum = TRUE,
                                                  _In_ BOOLEAN convertByteOrder = FALSE);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprIPHeaderModifyLoopbackToLocal(_In_ const FWPS_INCOMING_METADATA_VALUES* pMetadata,
                                               _In_ const FWP_VALUE* pRemoteAddress,
                                               _In_ const UINT32 ipHeaderSize,
                                               _Inout_ NET_BUFFER_LIST* pNetBufferList);
 
_At_(*ppTransportHeader, _Pre_ _Notnull_)
_At_(*ppTransportHeader, _Post_ _Null_)
_Success_(*ppTransportHeader == 0)
inline VOID KrnlHlprTransportHeaderDestroy(_Inout_ VOID** ppTransportHeader);
 
_When_(return != STATUS_SUCCESS, _At_(*ppTransportHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppTransportHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprTransportHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                                    _In_ const FWPS_INCOMING_VALUES* pClassifyValues,
                                    _In_ const FWPS_INCOMING_METADATA_VALUES* pMetadata,
                                    _Outptr_ VOID** ppTransportHeader,
                                    _Inout_ BOOLEAN* pNeedToFreeMemory,
                                    _Inout_opt_ IPPROTO* pProtocol = 0,
                                    _Inout_opt_ FWP_DIRECTION* pDirection = 0,
                                    _Inout_opt_ UINT32* pTransportHeaderSize = 0);
_When_(return != STATUS_SUCCESS, _At_(*ppTransportHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppTransportHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprTransportHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                                    _Outptr_ VOID** ppTransportHeader,
                                    _Inout_ BOOLEAN* pNeedToFreeMemory,
                                    _In_ UINT32 transportHeaderSize = 0);
 
_When_(return != STATUS_SUCCESS, _At_(*ppICMPv4Header, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppICMPv4Header, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv4HeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                                 _Outptr_ VOID** ppICMPv4Header,
                                 _Inout_ BOOLEAN* pNeedToFreeMemory,
                                 _In_ UINT32 icmpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv4HeaderModifyType(_In_ const FWP_VALUE* pValue,
                                        _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                        _In_ UINT32 icmpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv4HeaderModifyCode(_In_ const FWP_VALUE* pValue,
                                        _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                        _In_ UINT32 icmpHeaderSize = 0);
 
_When_(return != STATUS_SUCCESS, _At_(*ppICMPv4Header, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppICMPv4Header, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv6HeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                                 _Outptr_ VOID** ppICMPv4Header,
                                 _Inout_ BOOLEAN* pNeedToFreeMemory,
                                 _In_ UINT32 icmpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv6HeaderModifyType(_In_ const FWP_VALUE* pValue,
                                        _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                        _In_ UINT32 icmpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprICMPv6HeaderModifyCode(_In_ const FWP_VALUE* pValue,
                                        _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                        _In_ UINT32 icmpHeaderSize = 0);
 
_When_(return != STATUS_SUCCESS, _At_(*ppTCPHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppTCPHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprTCPHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                             _Outptr_ VOID** ppTCPHeader,
                             _Inout_ BOOLEAN* pNeedToFreeMemory,
                             _In_ UINT32 tcpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprTCPHeaderModifySourcePort(_In_ const FWP_VALUE* pValue,
                                           _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                           _In_ UINT32 tcpHeaderSize = 0,
                                           _In_ BOOLEAN convertByteOrder = FALSE);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprTCPHeaderModifyDestinationPort(_In_ const FWP_VALUE* pValue,
                                                _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                                _In_ UINT32 tcpHeaderSize = 0,
                                                _In_ BOOLEAN convertByteOrder = FALSE);
 
_When_(return != STATUS_SUCCESS, _At_(*ppUDPHeader, _Post_ _Null_))
_When_(return == STATUS_SUCCESS, _At_(*ppUDPHeader, _Post_ _Notnull_))
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprUDPHeaderGet(_In_ NET_BUFFER_LIST* pNetBufferList,
                             _Outptr_ VOID** ppUDPHeader,
                             _Inout_ BOOLEAN* pNeedToFreeMemory,
                             _In_ UINT32 udpHeaderSize = 0);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprUDPHeaderModifySourcePort(_In_ const FWP_VALUE* pValue,
                                           _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                           _In_ UINT32 udpHeaderSize = 0,
                                           _In_ BOOLEAN convertByteOrder = FALSE);
 
_IRQL_requires_min_(PASSIVE_LEVEL)
_IRQL_requires_max_(DISPATCH_LEVEL)
_IRQL_requires_same_
_Check_return_
_Success_(return == STATUS_SUCCESS)
NTSTATUS KrnlHlprUDPHeaderModifyDestinationPort(_In_ const FWP_VALUE* pValue,
                                                _Inout_ NET_BUFFER_LIST* pNetBufferList,
                                                _In_ UINT32 udpheaderSize = 0,
                                                _In_ BOOLEAN convertByteOrder = FALSE);
 
#endif /// HELPERFUNCTIONS_HEADERS_H

Our Services

  • What our customers say about us?

© 2011-2025 All Rights Reserved. Joya Systems. 4425 South Mopac Building II Suite 101 Austin, TX 78735 Tel: 800-DEV-KERNEL

Privacy Policy. Terms of use. Valid XHTML & CSS