Skip to content

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

Open
marvinlehmann wants to merge 1 commit intoffalcinelli:masterfrom
marvinlehmann:master
Open

Fix read/write of WinDivertAddress fields from/to native memory#2
marvinlehmann wants to merge 1 commit intoffalcinelli:masterfrom
marvinlehmann:master

Conversation

@marvinlehmann
Copy link
Copy Markdown

@marvinlehmann marvinlehmann commented Sep 19, 2017

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.

...from/to native memory

"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--
@ffalcinelli
Copy link
Copy Markdown
Owner

ffalcinelli commented Sep 20, 2017

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
Copy link
Copy Markdown
Author

OK!
Yea, that's fine =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants