-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add missing PRINTER_INFO_X structs #1429
Draft
tresf
wants to merge
22
commits into
java-native-access:master
Choose a base branch
from
tresf:printer-info
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,310
−103
Draft
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e842ac9
Add missing PRINTER_INFO_X structs; Consolidate WinspoolUtil to use a…
tresf 7880ff3
Fix compilation
tresf a816862
Fix byte arrays
tresf 399136d
Switch DEVMODE to use Pointer
tresf 820eb7f
Add helper for byte[] to String
tresf eefe7de
Improve comments, javadocs
tresf b8caf8b
Favor int, short over DWORD, WORD
tresf 8e87b13
Update changelog
tresf ac29f71
Add JavaDocs for DEVMODE struct
tresf 9ed81f6
Add a few missing JavaDocs and const's for DEVMODE struct
tresf 5e2551d
typo fix and xp check removal
Vzor- f68bb7b
Bind Winspool#DocumentProperties (only signature, no documentation)
matthiasblaesing 9c126f0
Remove invalid WinGDI#DEVMODE members
matthiasblaesing 0477646
Move child structure definitions to the end of the structure definition
matthiasblaesing eeda6e0
Prevent out-of-bounds read if strings are not \0 terminated
matthiasblaesing f58508a
Bind missing members of DEVMODE.DUMMYUNIONNAME
matthiasblaesing 9581b69
Add constants for values of DEVMODE#dmFields
matthiasblaesing f84d022
Interactive Test (not for final commit!)
matthiasblaesing 77c9711
substruct read
Vzor- f50ca82
EnumDisplaySettings
Vzor- 7d6879f
typo
Vzor- 05c8f92
getName cleanup
Vzor- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve comments, javadocs
commit eefe7de53677e6d8e6c1ac3906b158b32dda8784
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although
WinNT
provides a struct namedSECURITY_DESCRIPTOR
, the struct is malformed for use withPRINTER_INFO_3
despite having an identical name. UsingWinNT.SECURITY_DESCRIPTOR
will throw a runtime errorjava.lang.IllegalStateException: Array fields must be initialized
.Fortunately
SECURITY_DESCRIPTOR_RELATIVE
matches the struct design exactly that's returned byPRINTER_INFO_3
, fixing this runtime exception. This is just an FYI and can be acknowledged by a project maintainer if there are no objections. :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pointer to
SECURITY_DESCRIPTOR
and I believe the_RELATIVE
version is the correct "by reference" mapping.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reopening... so going back on the
DWORD
vsint
conversation, I'm looking for examples and found thatPRINTER_INFO_2
usespublic INT_PTR pSecurityDescriptor;
however this PR uses theWinNT.SECURITY_DESCRIPTOR_RELATIVE
. Should I switchPRINTER_INFO_3
to match? It seems less useful, but I'd like to be consistent. If so, how would I go about getting the data, construct aPointer
from the int and manually cast it? If that's the case, is this better than just using the correct struct to begin with?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue occurs for
PRINTER_INFO_2
, which returns aINT_PTR
in place of thepDevMode
, whereas the newly writtenPRINTER_INFO_8
,PRINTER_INFO_9
both use this PR's struct.pDevMode
appears again inL_PRINTER_DEFAULTS
, but this time as aPointer
object.I can update
PRINTER_INFO_2
, but those using the API in its current form will break.Alternately I can switch
PRINTER_INFO_9
andPRINTER_INFO_8
to use Pointers and then allowDEVMODE
to be constructed manually, but I think this will be less intuitive.I tried to convert the
INT_PTR
to a Pointer and then to a struct, but I got an errorjava.lang.UnsupportedOperationException: This pointer is opaque: const@0x1a31bba904c
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies, I answered the first one thinking about a completely different recent change. Ultimately you need to map a pointer of some sort, and then use that pointer to map to the structure it points to. Using the
ByReference
tag on the structure accomplishes this transparently and should probably be your first choice. So I'd suggestWinNT.SECURITY_DESCRIPTOR_RELATIVE.ByReference
. Check the commit dates on the other structure, it's entirely possible it was committed first.Don't change old ones to break compatibility. If you want consistency, feel free to match them, but
INT_PTR
is a pointer-sized integer so you'd need to usetoPointer()
to convert it and then use that pointer to pass to a constructor.I think the structure (by reference) is the easiest. So you get
INT_PTR ip
, you doPointer p = ip.toPointer()
and then passp
to the pointer constructor of the structure, essentially this (FooStructure extends Structure
):