Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Regression #668

Closed
amarcionek opened this issue Jun 1, 2016 · 4 comments
Closed

Possible Regression #668

amarcionek opened this issue Jun 1, 2016 · 4 comments

Comments

@amarcionek
Copy link
Contributor

Testing the latest tip of master and found some issues with a few of the platform related functions. Specifically, there were a number of functions I added back in November in #532. All of the MPR functions and some of the security functions aren't working. I noticed they were modified in #541. Likely the cause is the change to String from WString. So I changed a few of the structs back to WString and retested all of MPR with success.

Testing this on Windows 10 and Server 2012 R2.

@amarcionek
Copy link
Contributor Author

Further investigation reveals its just the structure members. I can keep the function signatures as String.

@twall
Copy link
Contributor

twall commented Jun 2, 2016

You should be able to have the default w32 type mapping handle those, maybe
it's because the struct is declared outside of the library mapping which
defines the type mapping options?

On Wednesday, June 1, 2016, Adam Marcionek notifications@github.com wrote:

Further investigation reveals its just the structure members. I can keep
the function signatures as String.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#668 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAuMrSUCQ588J51xm-5S3rvVvcn2zoU0ks5qHef0gaJpZM4Ir45k
.

@amarcionek
Copy link
Contributor Author

amarcionek commented Jun 2, 2016

Bingo. I moved the definition of NETRESOURCE out of Winnetwk.java and into Mpr.Java where the instance uses W32APIOptions.DEFAULT_OPTIONS, changed the structures back to String and it works now. There is no INSTANCE in Winnetwk becasue its not a DLL and so Native.loadLibrary wouldn't make sense.

Is this the fix or is there another way to keep those in Winnetwk since that is JNA best practice? I'm happy to move those structures into the relevant DLL files if so.

Update: Also, if I go ahead and make this change, should I only move the structures that are at issue or all of them? E.g. NETRESOURCE is the only one I would move. Same is true for SHARE_INFO_* structures in LMShare, I would move them to NetApi32.

matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Jul 26, 2016
Winnetwk definitions follow the typemapper set by the "w32.ascii"
property, following the convention demonstrated/used in 
W32APIOptions.DEFAULT.

The definitions in LMShare are defined as pure UNICODE.

Closes: java-native-access#668
@matthiasblaesing
Copy link
Member

My analysis: by default java string is mapped to char_, but the Win32 functions expect wchar_ (always or depending on calling style selected by w32.ascii). When a struct field is declared as WString the mapping is fixed to wchar* and it works (as long as the unicode variants of functions are invoced).

The PR is not yet complete - I'll have to look through the over files touched by #541, to adjust all structures, affected in the same way.

matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 2, 2016
Winnetwk definitions follow the typemapper set by the "w32.ascii"
property, following the convention demonstrated/used in
W32APIOptions.DEFAULT.

The definitions in LMShare are defined as pure UNICODE.

Closes: java-native-access#668
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 2, 2016
Winnetwk definitions follow the typemapper set by the "w32.ascii"
property, following the convention demonstrated/used in
W32APIOptions.DEFAULT.

The definitions in LMShare are defined as pure UNICODE.

Closes: java-native-access#668
matthiasblaesing added a commit to matthiasblaesing/jna that referenced this issue Aug 2, 2016
Winnetwk definitions follow the typemapper set by the "w32.ascii"
property, following the convention demonstrated/used in
W32APIOptions.DEFAULT.

The definitions in LMShare are defined as pure UNICODE.

Closes: java-native-access#668
lreimer added a commit to seu-as-code/seu-as-code.plugins that referenced this issue Aug 12, 2016
mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024
java-native-access#668)

… a queue to make debugging leaks easier

Motivation:

We should touch our messages when we take over ownership, this allows
easier debugging of buffer leaks.

Modifications:

Let's add touch call before enqueue into internal datastructure

Result:

Easier to debug buffer leaks
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

No branches or pull requests

3 participants