jdivert icon indicating copy to clipboard operation
jdivert copied to clipboard

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

Open marvinlehmann opened this issue 7 years ago • 2 comments

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.

marvinlehmann avatar Sep 19 '17 15:09 marvinlehmann

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?

ffalcinelli avatar Sep 20 '17 14:09 ffalcinelli

OK! Yea, that's fine =)

marvinlehmann avatar Sep 20 '17 16:09 marvinlehmann