fltdefs.h source, used by Russell (rllibby)

systan
systan used Ask the Experts™
on
http://www.ndis.com/papers/winpktfilter.htm#W2KPktFilterInterface
The source was remove in ndis papers link;
Where could I find it?  The link.

And I'm also asking;
What <header> shall I convert to run a firewall in vista or 7 from delphi7/9?
Where is the source <?.h>  The link.

Thanks.
//This was the delphi convertion of fltdefs.h, but where is the source?

unit fltdefs;
////////////////////////////////////////////////////////////////////////////////
//
//   Delphi conversion of fltdefs.h for use with the IPHLPAPI.DLL
//
////////////////////////////////////////////////////////////////////////////////
interface

uses
  Windows;

const
  IPHLPAPI          =  'IPHLPAPI.DLL';

// Byte array
type
  TByteArray        =  Array [0..Pred(MaxInt)] of Byte;
  PByteArray        =  ^TByteArray;

// Data types
type
  FILTER_HANDLE     =  Pointer;
  PFILTER_HANDLE    =  ^FILTER_HANDLE;
  INTERFACE_HANDLE  =  Pointer;
  PINTERFACE_HANDLE =  ^INTERFACE_HANDLE;

// GlobalFilter enumeration
const
  GF_FRAGMENTS      =  2;
  GF_STRONGHOST     =  8;
  GF_FRAGCACHE      =  9;

type
  GLOBAL_FILTER     =  Integer;
  PGLOBAL_FILTER    =  ^GLOBAL_FILTER;

// PFAddressType enumeration
const
  PF_IPV4           =  0;
  PF_IPV6           =  1;

type
  PFADDRESSTYPE     =  Integer;
  PPFADDRESSTYPE    =  ^PFADDRESSTYPE;

// PFForwardAction enumeration
const
  PF_ACTION_FORWARD =  0;
  PF_ACTION_DROP    =  1;

type
  PFFORWARD_ACTION  =  Integer;
  PPFFORWARD_ACTION =  ^PPFFORWARD_ACTION;

// PFFrameType enumeration
const
  PFFT_FILTER       =  1;
  PFFT_FRAG         =  2;
  PFFT_SPOOF        =  3;

type
  PFFRAMETYPE       =  Integer;
  PPFFRAMETYPE      =  ^PFFRAMETYPE;

type
  _PF_FILTER_DESCRIPTOR   =  packed record
     dwFilterFlags:       DWORD;
     dwRule:              DWORD;
     pfatType:            PFADDRESSTYPE;
     SrcAddr:             PByteArray;
     SrcMask:             PByteArray;
     DstAddr:             PByteArray;
     DstMask:             PByteArray;
     dwProtocol:          DWORD;
     fLateBound:          DWORD;
     wSrcPort:            Word;
     wDstPort:            Word;
     wSrcPortHighRange:   Word;
     wDstPortHighRange:   Word;
  end;
  PF_FILTER_DESCRIPTOR    =  _PF_FILTER_DESCRIPTOR;
  PPF_FILTER_DESCRIPTOR   =  ^PF_FILTER_DESCRIPTOR;

type
  _PF_FILTER_STATS        =  packed record
     dwNumPacketsFiltered:DWORD;
     info:                PF_FILTER_DESCRIPTOR;
  end;
  PF_FILTER_STATS         =  _PF_FILTER_STATS;
  PPF_FILTER_STATS        =  ^PF_FILTER_STATS;

type
  _PF_INTERFACE_STATS     =  packed record
     pvDriverContext:     Pointer;
     dwFlags:             DWORD;
     dwInDrops:           DWORD;
     dwOutDrops:          DWORD;
     eaInAction:          PFFORWARD_ACTION;
     eaOutAction:         PFFORWARD_ACTION;
     dwNumInFilters:      DWORD;
     dwNumOutFilters:     DWORD;
     dwFrag:              DWORD;
     dwSpoof:             DWORD;
     dwReserved1:         DWORD;
     dwReserved2:         DWORD;
     liSyn:               LARGE_INTEGER;
     liTotalLogged:       LARGE_INTEGER;
     dwLostLogEntries:    DWORD;
     FilterInfo:          Array [0..0] of PF_FILTER_STATS;
  end;
  PF_INTERFACE_STATS      =  _PF_INTERFACE_STATS;
  PPF_INTERFACE_STATS     =  ^PF_INTERFACE_STATS;

type
  _PF_LATEBIND_INFO       =  packed record
     SrcAddr:             PByteArray;
     DstAddr:             PByteArray;
     Mask:                PByteArray;
  end;
  PF_LATEBIND_INFO        =  _PF_LATEBIND_INFO;
  PPF_LATEBIND_INFO       =  ^PF_LATEBIND_INFO;

type
  _PFLOGFRAME             =  packed record
     Timestamp:           LARGE_INTEGER;
     pfeTypeOfFrame:      PFFRAMETYPE;
     dwTotalSizeUsed:     DWORD;
     dwFilterRule:        DWORD;
     wSizeOfAdditionalData:Word;
     wSizeOfIpHeader:     Word;
     dwInterfaceName:     DWORD;
     dwIPIndex:           DWORD;
     bPacketData:         Array [0..0] of Byte;
  end;
  PFLOGFRAME              =  _PFLOGFRAME;
  PPFLOGFRAME             =  ^PFLOGFRAME;

const
  FILTER_PROTO_ANY        =  $00;
  FILTER_PROTO_ICMP       =  $01;
  FILTER_PROTO_TCP        =  $06;
  FILTER_PROTO_UDP        =  $11;
  FILTER_TCPUDP_PORT_ANY  =  $00;

const
  FILTER_ICMP_TYPE_ANY    =  $FF;
  FILTER_ICMP_CODE_ANY    =  $FF;

const
  FD_FLAGS_NOSYN          =  $01;
  FD_FLAGS_ALLFLAGS       =  FD_FLAGS_NOSYN;

const
  LB_SRC_ADDR_USE_SRCADDR_FLAG  =  $00000001;
  LB_SRC_ADDR_USE_DSTADDR_FLAG  =  $00000002;
  LB_DST_ADDR_USE_SRCADDR_FLAG  =  $00000004;
  LB_DST_ADDR_USE_DSTADDR_FLAG  =  $00000008;
  LB_SRC_MASK_LATE_FLAG         =  $00000010;
  LB_DST_MASK_LATE_FLAG         =  $00000020;

const
  ERROR_BASE                    =  23000;
  PFERROR_NO_PF_INTERFACE       =  (ERROR_BASE + 0); // never returned.
  PFERROR_NO_FILTERS_GIVEN      =  (ERROR_BASE + 1);
  PFERROR_BUFFER_TOO_SMALL      =  (ERROR_BASE + 2);
  ERROR_IPV6_NOT_IMPLEMENTED    =  (ERROR_BASE + 3);

////////////////////////////////////////////////////////////////////////////////
//
// Filter functions exported by IPHLPAPI
//
////////////////////////////////////////////////////////////////////////////////
function   PfCreateInterface(
           dwName:           DWORD;
           inAction:         PFFORWARD_ACTION;
           outAction:        PFFORWARD_ACTION;
           bUseLog:          BOOL;
           bMustBeUnique:    BOOL;
           var ppInterface:  INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfCreateInterface@24';

function   PfDeleteInterface(
           pInterface:       INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfDeleteInterface@4';

function   PfAddFiltersToInterface(
           ih:               INTERFACE_HANDLE;
           cInFilters:       DWORD;
           pfiltIn:          PPF_FILTER_DESCRIPTOR;
           cOutFilters:      DWORD;
           pfiltOut:         PPF_FILTER_DESCRIPTOR;
           pfHandle:         PFILTER_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';

function   PfRemoveFiltersFromInterface(
           ih:               INTERFACE_HANDLE;
           cInFilters:       DWORD;
           pfiltIn:          PPF_FILTER_DESCRIPTOR;
           cOutFilters:      DWORD;
           pfiltOut:         PPF_FILTER_DESCRIPTOR): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';

function   PfRemoveFilterHandles(
           pInterface:       INTERFACE_HANDLE;
           cFilters:         DWORD;
           pvHandles:        PFILTER_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';

function   PfUnBindInterface(
           pInterface:       INTERFACE_HANDLE): DWORD;
           stdcall; external IPHLPAPI name '_PfUnBindInterface@4';

function   PfBindInterfaceToIndex(
           pInterface:       INTERFACE_HANDLE;
           dwIndex:          DWORD;
           pfatLinkType:     PFADDRESSTYPE;
           LinkIPAddress:    PByteArray): DWORD;
           stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';

function   PfBindInterfaceToIPAddress(
           pInterface:       INTERFACE_HANDLE;
           pfatLinkType:     PFADDRESSTYPE;
           IPAddress:        PByteArray): DWORD;
           stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';

function   PfRebindFilters(
           pInterface:       INTERFACE_HANDLE;
           pLateBindInfo:    PPF_LATEBIND_INFO): DWORD;
           stdcall; external IPHLPAPI name '_PfRebindFilters@8';

function   PfAddGlobalFilterToInterface(
           pInterface:       INTERFACE_HANDLE;
           gfFilter:         GLOBAL_FILTER): DWORD;
           stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';

function   PfRemoveGlobalFilterFromInterface(
           pInterface:       INTERFACE_HANDLE;
           gfFilter:         GLOBAL_FILTER): DWORD;
           stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';

////////////////////////////////////////////////////////////////////////////////
//
// Log APIs. Note that there is at most one log and it must be created
// before any interface needing it is created. There is no way to set a
// log onto an existing interface. The log can be applied to any or all of
// the interfaces.
//
///////////////////////////////////////////////////////////////////////
function   PfMakeLog(
           hEvent:           THandle): DWORD;
           stdcall; external IPHLPAPI name '_PfMakeLog@4';

function   PfSetLogBuffer(
           pbBuffer:         PByteArray;
           dwSize:           DWORD;
           dwThreshold:      DWORD;
           dwEntries:        DWORD;
           pdwLoggedEntries: PDWORD;
           pdwLostEntries:   PDWORD;
           pdwSizeUsed:      PDWORD): DWORD;
           stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';

function   PfDeleteLog(
           ): DWORD;
           stdcall; external IPHLPAPI name '_PfDeleteLog@0';

////////////////////////////////////////////////////////////////////////////////
//
// Get statistics. Note pdwBufferSize in an IN/OUT parameter. If
// ERROR_INSUFFICIENT_BUFFER is returned, the common statistics are
// available and the correct byte count is in *pdwBufferSize. If only the
// interface statistics are needed, provide a buffer of size
// PF_INTERFACE_STATS only. If the filter descriptions are also needed,
// then supply a large buffer, or use the returned count from the first call
// to allocate a buffer of sufficient size. Note that for a shared interface,
// this second call may fail with ERROR_INSUFFICIENT_BUFFER. This can happen
// if the other sharers add filters in the interim. This should not happen for
// a UNIQUE interface.
//
////////////////////////////////////////////////////////////////////////////////
function   PfGetInterfaceStatistics(
           pInterface:       INTERFACE_HANDLE;
           ppfStats:         PPF_INTERFACE_STATS;
           pdwBufferSize:    PDWORD;
           fResetCounters:   BOOL): DWORD;
           stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';

////////////////////////////////////////////////////////////////////////////////
//
// Test a packet. This call will evaluate the packet against the given
// interfaces and return the filtering action.
//
////////////////////////////////////////////////////////////////////////////////
function   PfTestPacket(
           pInInterface:     INTERFACE_HANDLE;
           pOutInterface:    INTERFACE_HANDLE;
           cBytes:           DWORD;
           pbPacket:         PByteArray;
           ppAction:         PPFFORWARD_ACTION): DWORD;
           stdcall; external IPHLPAPI name '_PfTestPacket@20';

implementation

end.

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
The original 'fltdefs.h' comes with the DDK/WDK, which you can download from http://www.microsoft.com/whdc/DevTools/WDK/WDKpkg.mspx ("How to Get the WDK") or directly from http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff

Author

Commented:
jkr;
The link does not show's the source of fltdefs.h as rllibby converted it.
Please submit a direct link.


Thanks
jkr
Top Expert 2012

Commented:
Well, a direct link to a file that is contained inside a MSI installer is not possible, and poting the content would infringe MS' copyright. You'll ned to install the DDK/WDK and get that file from there.
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Author

Commented:
This is the previous link that Russell (rllibby) used to convert from c to delphi
http://www.ndis.com/papers/winpktfilter.htm#W2KPktFilterInterface
So, I need only the link, not a big installion just only for a single file source fltdefs.h

Author

Commented:
I found it,
http://www.gamedev.net/community/forums/topic.asp?topic_id=185815

Ok, if windows xp and windows 2003 uses <fltdefs.h>, Whats for vista and 7?
I just need the header<?.h> file for vista and 7 to convert it from c to delphi.


Thanks.
Top Expert 2014

Commented:

Author

Commented:
ton plooy? Yes that was the author of <fltdefs.h source>, converted by Russell (rllibby)

Thanks Aikimark

Regarding to the firewall AddinBound? How did you RemoveinBound?  Russel's code onjly point blocking an ip and port, but what about Unblocking the blocked ip and port?   Did you ever made or continue a task that really removes the blocked a specific ip and port?   DeleteinBound just delete the index of the blocked,  but what about when you many ip and port and being block and randomly unblock, I think the deleteinBound procedure is good only in a sequencial order of blocking.   What can you say about that Aikimark?
Top Expert 2014

Commented:
I handed the results to another developer, so I can't expound on it.

Author

Commented:
Ok;
How about this;

if windows xp and windows 2003 uses <fltdefs.h> for convertion to delphi which was  used by Russell (rllibby).    Whats for vista and 7?

I just need the header<?.h> file for vista and 7 to convert it from c to delphi.


Thanks
Top Expert 2014

Commented:
Do you know if the interface has changed?

Author

Commented:
>>Do you know if the interface has changed?
Sorry, I can't get what your asking,  Oh, please elaborate.

Ok;
I got it again, the source for vista 7 is <Fwpmu.h>

Please, someone could attached the source code of that <Fwpmu.h>, so I can try to convert it from c to delphi.


Thanks.
Top Expert 2014
Commented:
Have you visited the links posted in http:#33130394 ?

Author

Commented:
The links posted? your pointing to this direction.
And yes, I've visited your links and its not the answer of the question.

The question is this:
if windows xp and windows 2003 uses <fltdefs.h> for convertion to delphi which was  used by Russell (rllibby).    Whats for vista and 7?

I just need the header<?.h> file for vista and 7 to convert it from c to delphi.


Thanks
Top Expert 2014

Commented:
Does that mean that you downloaded the Windows Driver Kit from the linked page and it did NOT contain the header files on the ISO image?

Author

Commented:
Aikimark;
I did not download the link
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff

Because the file is to large for me to download it,  I just need the header file <Fwpmu.h>

This is my previous post:
Ok;
I got it again, the source for vista 7 is <Fwpmu.h>

Please, someone could attached the source code of that <Fwpmu.h>, so I can try to convert it from c to delphi.
Top Expert 2014

Commented:
@systan

Does this mean that you do not have access to a broadband Internet connection?

Author

Commented:
I have an access to a broadband connection, but my internet is very slow, thats why I only ask the source code of Fwpmu.h

Anyway I'll try to download it now, since no one could produce a direct code or link.
Top Expert 2014

Commented:
since the download is an ISO image, you might ask a friend/colleague to download it and burn a CD, if they have a fast Internet connection.

Author

Commented:
I've seen it.

Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial