ffalcinelli / jdivert

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

Fix read/write of WinDivertAddress fields from/to native memory #2

Open marvinlehmann opened 7 years ago

marvinlehmann commented 7 years ago

I noticed that the WinDivertAddress fields weren't set properly because the native memory of the JNA structure didn't get updated.

Note that if you use the structure's pointer as a function argument, you are responsible for calling write() prior to the call and read() after the call.

- https://java-native-access.github.io/jna/4.2.1/com/sun/jna/Structure.html#getPointer--

Unrelated: I also noticed that WinDef.USHORT is used for the direction which has a size of 2 bytes but it originally is defined as UINT8 (uint8_t) with a size of 1 byte. Could this generally be a problem? I'm just interested because I don't know much about JNA.

ffalcinelli commented 7 years ago

Thank you for this PR. Well the direction is just outbound/inbound so a byte is more than enough. Mapping as USHORT it's maybe an error, but should not be a problem as long as the value is below the byte size.

I'll merge this soon and update on maven too. May I add you to contributors?

marvinlehmann commented 7 years ago

OK! Yea, that's fine =)