ffalcinelli / jdivert

A Java binding for WinDivert driver
GNU Lesser General Public License v3.0
22 stars 10 forks source link

Every time get error WinDivertException{code=3, message='null'} #7

Open nimminimminot opened 9 months ago

nimminimminot commented 9 months ago

Hello! Every time packet match program throws exception. For example, filter all icmp: `public static void main(String[] args) { WinDivert w = new WinDivert("icmp");

    try {
        w.open(); // packets will be captured from now on

        int i = 0;
        while (i<10) {
            Packet packet = w.recv();  // read a single packet
            System.out.println(packet);
            w.send(packet);  // re-inject the packet into the network stack
            i++;
        }
        w.close();  // stop capturing packets
    } catch (WinDivertException e) {
        e.printStackTrace();
    }
}`

First packet printed: Packet {IPv4 {version=4, srcAddr=127.0.0.1, dstAddr=127.0.0.1, IHL=5, DSCP=0, ECN=0, length=60, ID=b7d3 RESERVED=false, DF=false, MF=false, fragOff=0 TTL=128 proto=ICMP, cksum=84eb}, ICMPv4 {type=8, code=0, cksum=4d4a, restOfHdr=00010011}, direction=OUTBOUND, iface=[0, 0], raw=4500003CB7D30000800184EB7F0000017F00000108004D4A000100116162636465666768696A6B6C6D6E6F7071727374757677616263646566676869}

And on w.send(packet) get an exception:

WinDivertException{code=3, message='null'}
        at com.github.ffalcinelli.jdivert.exceptions.WinDivertException.throwExceptionOnGetLastError(WinDivertException.java:57)
        at com.github.ffalcinelli.jdivert.Packet.recalculateChecksum(Packet.java:359)
        at com.github.ffalcinelli.jdivert.WinDivert.send(WinDivert.java:271)
        at com.github.ffalcinelli.jdivert.WinDivert.send(WinDivert.java:234)

Always. Run as admin.

Why I receive error on recalculateChecksum every time?

S0PEX commented 6 months ago

Hey, I am encountering the same Problem with JDK 11 and Windows 11. Did you manage to get it working by any chance?

Regards Artur

nimminimminot commented 6 months ago

Unfortunately not