public class WinDivert
extends java.lang.Object
The main methods are open()
, recv()
, send(Packet)
and close()
.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PACKET_BUFFER_SIZE |
Constructor and Description |
---|
WinDivert(java.lang.String filter)
|
WinDivert(java.lang.String filter,
Enums.Layer layer,
int priority,
Enums.Flag... flags)
Create a new WinDivert instance based upon the given parameters
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the handle opened by
open . |
java.lang.String |
getMode()
Returns the operational mode as a String
|
long |
getParam(Enums.Param param)
Get a WinDivert parameter.
|
boolean |
is(Enums.Flag flag)
Checks if the given flag is set
|
boolean |
isOpen()
Indicates if there is currently an open handle.
|
WinDivert |
open()
Opens a WinDivert handle for the given filter.
|
Packet |
recv()
Receives a diverted packet that matched the filter.
|
Packet |
recv(int bufsize)
Receives a diverted packet that matched the filter.
|
int |
send(Packet packet)
Injects a packet into the headers stack.
|
int |
send(Packet packet,
boolean recalculateChecksum,
Enums.CalcChecksumsOption... options)
Injects a packet into the headers stack.
|
void |
setParam(Enums.Param param,
long value)
Set a WinDivert parameter.
|
java.lang.String |
toString()
|
public WinDivert(java.lang.String filter)
NETWORK
layer with priority set to 0 and in
DEFAULT
mode (Drop and divert packet).filter
- The filter string expressed using WinDivert filter language.public WinDivert(java.lang.String filter, Enums.Layer layer, int priority, Enums.Flag... flags)
filter
- The filter string expressed using WinDivert filter language.layer
- The layer
priority
- The priority of the handleflags
- Additional flags
public WinDivert open() throws WinDivertException
recv
.
The remapped function is WinDivertOpen
:
HANDLE WinDivertOpen(
__in const char *filter,
__in WINDIVERT_LAYER layer,
__in INT16 priority,
__in UINT64 flags
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_open
Windivert w = new WinDivert("true").open()
)WinDivertException
- Whenever the DLL call sets a LastError different by 0 (Success) or 997 (Overlapped I/O
is in progress)public boolean isOpen()
public void close()
open
.
The remapped function is WinDivertClose
:
BOOL WinDivertClose(
__in HANDLE handle
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_close """
public Packet recv() throws WinDivertException
packet
.
The remapped function is WinDivertRecv
:
BOOL WinDivertRecv(
__in HANDLE handle,
__out PVOID pPacket,
__in UINT packetLen,
__out_opt PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *recvLen
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_recv
Packet
instanceWinDivertException
- Whenever the DLL call sets a LastError different by 0 (Success) or 997 (Overlapped I/O
is in progress)public Packet recv(int bufsize) throws WinDivertException
packet
.
The remapped function is WinDivertRecv
:
BOOL WinDivertRecv(
__in HANDLE handle,
__out PVOID pPacket,
__in UINT packetLen,
__out_opt PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *recvLen
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_recv
bufsize
- The size for the buffer to allocatePacket
instanceWinDivertException
- Whenever the DLL call sets a LastError different by 0 (Success) or 997 (Overlapped I/O
is in progress)public int send(Packet packet) throws WinDivertException
The injected packet may be one received from recv
, or a modified version, or a completely new packet.
Injected packets can be captured and diverted again by other WinDivert handles with lower priorities.
The remapped function is WinDivertSend
:
BOOL WinDivertSend(
__in HANDLE handle,
__in PVOID pPacket,
__in UINT packetLen,
__in PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *sendLen
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_send
packet
- The Packet
to sendWinDivertException
- Whenever the DLL call sets a LastError different by 0 (Success) or 997 (Overlapped I/O
is in progress)public int send(Packet packet, boolean recalculateChecksum, Enums.CalcChecksumsOption... options) throws WinDivertException
recalculateChecksum=false
is passed:recalculateChecksum=true
then checksums are calculated using the given options
.recalculateChecksum=false
then options
are ignored.
The injected packet may be one received from recv
, or a modified version, or a completely new packet.
Injected packets can be captured and diverted again by other WinDivert handles with lower priorities.
The remapped function is WinDivertSend
:
BOOL WinDivertSend(
__in HANDLE handle,
__in PVOID pPacket,
__in UINT packetLen,
__in PWINDIVERT_ADDRESS pAddr,
__out_opt UINT *sendLen
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_send
packet
- The Packet
to sendrecalculateChecksum
- Whether to recalculate the checksums or pass the packet
as is.options
- A set of options
to use when recalculating checksums.WinDivertException
- Whenever the DLL call sets a LastError different by 0 (Success) or 997 (Overlapped I/O
is in progress)public long getParam(Enums.Param param)
Param
for the list of parameters.
The remapped function is WinDivertGetParam
:
BOOL WinDivertGetParam(
__in HANDLE handle,
__in WINDIVERT_PARAM param,
__out UINT64 *pValue
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_get_param
param
- The param
to setpublic void setParam(Enums.Param param, long value)
Param
for the list of parameters.
The remapped function is DivertSetParam
:
BOOL WinDivertSetParam(
__in HANDLE handle,
__in WINDIVERT_PARAM param,
__in UINT64 value
);
For more info on the C call visit: http://reqrypt.org/windivert-doc.html#divert_set_param
param
- The param
to setvalue
- The value for the parameterpublic boolean is(Enums.Flag flag)
flag
- The mode flag to setpublic java.lang.String getMode()
public java.lang.String toString()
toString
in class java.lang.Object