#include <stdio.h>
#include <packet32.h>
#include "wanpacket/wanpacket.h"
#include <windows.h>
#include <windowsx.h>
#include <Iphlpapi.h>
#include <IPIfCons.h>
#include <ntddndis.h>
Go to the source code of this file.
Defines | |
#define | UNICODE 1 |
Typedefs | |
typedef VOID(* | GAAHandler )(ULONG, DWORD, PVOID, PIP_ADAPTER_ADDRESSES, PULONG) |
Functions | |
BOOLEAN | PacketAddAdapterDag (PCHAR name, PCHAR description, BOOLEAN IsAFile) |
BOOL APIENTRY | DllMain (HANDLE DllHandle, DWORD Reason, LPVOID lpReserved) |
The main dll function. | |
ULONG | inet_addrU (const WCHAR *cp) |
Convert a Unicode dotted-quad to a 32-bit IP address. | |
PWCHAR | SChar2WChar (PCHAR string) |
Converts an ASCII string to UNICODE. Uses the MultiByteToWideChar() system function. | |
PCHAR | WChar2SChar (PWCHAR string) |
Converts an UNICODE string to ASCII. Uses the WideCharToMultiByte() system function. | |
BOOLEAN | PacketSetMaxLookaheadsize (LPADAPTER AdapterObject) |
Sets the maximum possible lookahead buffer for the driver's Packet_tap() function. | |
BOOLEAN | PacketSetReadEvt (LPADAPTER AdapterObject) |
Retrieves the event associated in the driver with a capture instance and stores it in an _ADAPTER structure. | |
BOOL | PacketInstallDriver (SC_HANDLE ascmHandle, SC_HANDLE *srvHandle) |
Installs the NPF device driver. | |
LONG | PacketDumpRegistryKey (PCHAR KeyName, PCHAR FileName) |
Dumps a registry key to disk in text format. Uses regedit. | |
BOOL | PacketGetFileVersion (LPTSTR FileName, PCHAR VersionBuff, UINT VersionBuffLen) |
Returns the version of a dll or exe file. | |
LPADAPTER | PacketOpenAdapterNPF (PCHAR AdapterName) |
Opens an adapter using the NPF device driver. | |
PCHAR | PacketGetVersion () |
Return a string with the dll version. | |
PCHAR | PacketGetDriverVersion () |
Return a string with the version of the NPF.sys device driver. | |
BOOL | PacketStopDriver () |
Stops and unloads the WinPcap device driver. | |
LPADAPTER | PacketOpenAdapter (PCHAR AdapterName) |
Opens an adapter. | |
VOID | PacketCloseAdapter (LPADAPTER lpAdapter) |
Closes an adapter. | |
LPPACKET | PacketAllocatePacket (void) |
Allocates a _PACKET structure. | |
VOID | PacketFreePacket (LPPACKET lpPacket) |
Frees a _PACKET structure. | |
VOID | PacketInitPacket (LPPACKET lpPacket, PVOID Buffer, UINT Length) |
Initializes a _PACKET structure. | |
BOOLEAN | PacketReceivePacket (LPADAPTER AdapterObject, LPPACKET lpPacket, BOOLEAN Sync) |
Read data (packets or statistics) from the NPF driver. | |
BOOLEAN | PacketSendPacket (LPADAPTER AdapterObject, LPPACKET lpPacket, BOOLEAN Sync) |
Sends one (or more) copies of a packet to the network. | |
INT | PacketSendPackets (LPADAPTER AdapterObject, PVOID PacketBuff, ULONG Size, BOOLEAN Sync) |
Sends a buffer of packets to the network. | |
BOOLEAN | PacketSetMinToCopy (LPADAPTER AdapterObject, int nbytes) |
Defines the minimum amount of data that will be received in a read. | |
BOOLEAN | PacketSetMode (LPADAPTER AdapterObject, int mode) |
Sets the working mode of an adapter. | |
BOOLEAN | PacketSetDumpName (LPADAPTER AdapterObject, void *name, int len) |
Sets the name of the file that will receive the packet when the adapter is in dump mode. | |
BOOLEAN | PacketSetDumpLimits (LPADAPTER AdapterObject, UINT maxfilesize, UINT maxnpacks) |
Set the dump mode limits. | |
BOOLEAN | PacketIsDumpEnded (LPADAPTER AdapterObject, BOOLEAN sync) |
Returns the status of the kernel dump process, i.e. tells if one of the limits defined with PacketSetDumpLimits() was reached. | |
HANDLE | PacketGetReadEvent (LPADAPTER AdapterObject) |
Returns the notification event associated with the read calls on an adapter. | |
BOOLEAN | PacketSetNumWrites (LPADAPTER AdapterObject, int nwrites) |
Sets the number of times a single packet written with PacketSendPacket() will be repeated on the network. | |
BOOLEAN | PacketSetReadTimeout (LPADAPTER AdapterObject, int timeout) |
Sets the timeout after which a read on an adapter returns. | |
BOOLEAN | PacketSetBuff (LPADAPTER AdapterObject, int dim) |
Sets the size of the kernel-level buffer associated with a capture. | |
BOOLEAN | PacketSetBpf (LPADAPTER AdapterObject, struct bpf_program *fp) |
Sets a kernel-level packet filter. | |
INT | PacketSetSnapLen (LPADAPTER AdapterObject, int snaplen) |
Sets the snap len on the adapters that allow it. | |
BOOLEAN | PacketGetStats (LPADAPTER AdapterObject, struct bpf_stat *s) |
Returns a couple of statistic values about the current capture session. | |
BOOLEAN | PacketGetStatsEx (LPADAPTER AdapterObject, struct bpf_stat *s) |
Returns statistic values about the current capture session. Enhanced version of PacketGetStats(). | |
BOOLEAN | PacketRequest (LPADAPTER AdapterObject, BOOLEAN Set, PPACKET_OID_DATA OidData) |
Performs a query/set operation on an internal variable of the network card driver. | |
BOOLEAN | PacketSetHwFilter (LPADAPTER AdapterObject, ULONG Filter) |
Sets a hardware filter on the incoming packets. | |
BOOLEAN | PacketGetAdapterNames (PTSTR pStr, PULONG BufferSize) |
Retrieve the list of available network adapters and their description. | |
BOOLEAN | PacketGetNetInfoEx (PCHAR AdapterName, npf_if_addr *buffer, PLONG NEntries) |
Returns comprehensive information the addresses of an adapter. | |
BOOLEAN | PacketGetNetType (LPADAPTER AdapterObject, NetType *type) |
Returns information about the MAC type of an adapter. | |
Variables | |
char | PacketLibraryVersion [64] |
Current packet.dll Version. It can be retrieved directly or through the PacketGetVersion() function. | |
char | PacketDriverVersion [64] |
Current NPF.sys Version. It can be retrieved directly or through the PacketGetVersion() function. | |
SC_HANDLE | scmHandle = NULL |
SC_HANDLE | srvHandle = NULL |
LPCTSTR | NPFServiceName = TEXT("NPF") |
LPCTSTR | NPFServiceDesc = TEXT("Netgroup Packet Filter") |
LPCTSTR | NPFRegistryLocation = TEXT("SYSTEM\\CurrentControlSet\\Services\\NPF") |
LPCTSTR | NPFDriverPath = TEXT("system32\\drivers\\npf.sys") |
PADAPTER_INFO | AdaptersInfoList |
HANDLE | AdaptersInfoMutex |
GAAHandler | GetAdaptersAddressesPointer = NULL |
|
Definition at line 22 of file Packet32.c. |
|
Definition at line 53 of file Packet32.c. Referenced by DllMain(). |
|
The main dll function.
Definition at line 85 of file Packet32.c. References AdaptersInfoList, AdaptersInfoMutex, GAAHandler, GetAdaptersAddressesPointer, _ADAPTER_INFO::NetworkAddresses, _ADAPTER_INFO::Next, ODS, PacketDriverVersion, PacketDumpRegistryKey(), PacketGetFileVersion(), and PacketLibraryVersion. |
|
Convert a Unicode dotted-quad to a 32-bit IP address.
Definition at line 194 of file Packet32.c. |
|
|
|
Returns the version of a dll or exe file.
Definition at line 433 of file Packet32.c. References ODS, ODSEx, and WChar2SChar(). Referenced by DllMain(). |
|
Installs the NPF device driver.
Definition at line 353 of file Packet32.c. References NPFDriverPath, NPFServiceDesc, NPFServiceName, ODS, ODSEx, and srvHandle. Referenced by PacketOpenAdapterNPF(). |
|
Opens an adapter using the NPF device driver.
Definition at line 526 of file Packet32.c. References ADAPTER, ADAPTER_NAME_LENGTH, _ADAPTER::hFile, MAX_LINK_NAME_LENGTH, _ADAPTER::Name, NPFRegistryLocation, NPFServiceName, _ADAPTER::NumWrites, ODS, ODSEx, PacketInstallDriver(), PacketSetMaxLookaheadsize(), PacketSetReadEvt(), scmHandle, srvHandle, and _ADAPTER::SymbolicLink. Referenced by PacketOpenAdapter(). |
|
Sets the maximum possible lookahead buffer for the driver's Packet_tap() function.
Definition at line 272 of file Packet32.c. References ODS, PacketRequest(), and PPACKET_OID_DATA. Referenced by PacketOpenAdapterNPF(). |
|
Retrieves the event associated in the driver with a capture instance and stores it in an _ADAPTER structure.
Definition at line 304 of file Packet32.c. References _ADAPTER::hFile, ODS, pBIOCEVNAME, _ADAPTER::ReadEvent, and _ADAPTER::ReadTimeOut. Referenced by PacketOpenAdapterNPF(). |
|
Converts an ASCII string to UNICODE. Uses the MultiByteToWideChar() system function.
Definition at line 228 of file Packet32.c. Referenced by PacketOpenAdapter(), and PacketSetDumpName(). |
|
Converts an UNICODE string to ASCII. Uses the WideCharToMultiByte() system function.
Definition at line 244 of file Packet32.c. Referenced by PacketGetFileVersion(), PacketGetNetInfoEx(), and PacketOpenAdapter(). |
|
Definition at line 50 of file Packet32.c. Referenced by DllMain(), and PacketGetAdapterNames(). |
|
Definition at line 51 of file Packet32.c. Referenced by DllMain(), PacketGetAdapterNames(), PacketGetNetInfoEx(), PacketGetNetType(), and PacketOpenAdapter(). |
|
Definition at line 59 of file Packet32.c. Referenced by DllMain(). |
|
Definition at line 48 of file Packet32.c. Referenced by PacketInstallDriver(). |
|
Definition at line 47 of file Packet32.c. Referenced by PacketOpenAdapterNPF(). |
|
Definition at line 46 of file Packet32.c. Referenced by PacketInstallDriver(). |
|
Definition at line 45 of file Packet32.c. Referenced by PacketInstallDriver(), PacketOpenAdapterNPF(), and PacketStopDriver(). |
|
Current NPF.sys Version. It can be retrieved directly or through the PacketGetVersion() function.
Definition at line 40 of file Packet32.c. Referenced by DllMain(), and PacketGetDriverVersion(). |
|
Current packet.dll Version. It can be retrieved directly or through the PacketGetVersion() function.
Definition at line 38 of file Packet32.c. Referenced by DllMain(), and PacketGetVersion(). |
|
Definition at line 43 of file Packet32.c. Referenced by PacketOpenAdapterNPF(), and PacketStopDriver(). |
|
Definition at line 44 of file Packet32.c. Referenced by PacketInstallDriver(), and PacketOpenAdapterNPF(). |
documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.