diff --git a/CHANGES.md b/CHANGES.md index 29adc496c0..b4ab49df4f 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ Features Bug Fixes --------- -* Ensure platform w32 classes use unsigned where appropriate (ULONG_PTR, UINT_PTR, ULONGLONG, WORD, DWORDLONG) [@twall](https://github.com/twall). +* Ensure platform w32 classes use unsigned where appropriate (`ULONG_PTR`, `UINT_PTR`, `ULONGLONG`, `WORD`, `DWORDLONG`) - [@twall](https://github.com/twall). * [#71](https://github.com/twall/jna/issues/71), [#73](https://github.com/twall/jna/issues/73): Fix OSGI entries in manifest - [@twall](https://github.com/twall). * [#78](https://github.com/twall/jna/issues/78): Fix NPE in `platform.win32.Netapi32Util.getDomainTrusts` - [@dblock](https://github.com/dblock). * Fix: auto-sync memory for `struct**` arguments (array of struct pointers) - [@twall](https://github.com/twall). diff --git a/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java b/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java index 611d34c69c..0e325342ae 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java @@ -65,7 +65,7 @@ public ULONG_PTR() { public ULONG_PTR(long value) { super(Pointer.SIZE, value, true); } - + public Pointer toPointer() { return Pointer.createConstant(longValue()); } @@ -75,13 +75,16 @@ public Pointer toPointer() { * PULONG_PTR */ public static class ULONG_PTRByReference extends ByReference { - public ULONG_PTRByReference() { + + public ULONG_PTRByReference() { this(new ULONG_PTR(0)); } + public ULONG_PTRByReference(ULONG_PTR value) { super(Pointer.SIZE); setValue(value); } + public void setValue(ULONG_PTR value) { if (Pointer.SIZE == 4) { getPointer().setInt(0, value.intValue()); @@ -90,6 +93,7 @@ public void setValue(ULONG_PTR value) { getPointer().setLong(0, value.longValue()); } } + public ULONG_PTR getValue() { return new ULONG_PTR(Pointer.SIZE == 4 ? getPointer().getInt(0) @@ -109,6 +113,10 @@ public DWORD_PTR() { public DWORD_PTR(long value) { super(Pointer.SIZE, value); } + + public Pointer toPointer() { + return Pointer.createConstant(longValue()); + } } /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/W32FileMonitor.java b/contrib/platform/src/com/sun/jna/platform/win32/W32FileMonitor.java index 6757fa76e5..cebdc247dd 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/W32FileMonitor.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/W32FileMonitor.java @@ -109,15 +109,15 @@ private void handleChanges(FileInfo finfo) throws IOException { } private FileInfo waitForChange() { - Kernel32 klib = Kernel32.INSTANCE; IntByReference rcount = new IntByReference(); ULONG_PTRByReference rkey = new ULONG_PTRByReference(); PointerByReference roverlap = new PointerByReference(); - klib.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE); + if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) + return null; synchronized (this) { - return handleMap.get(rkey.getValue()); - } + return handleMap.get(new HANDLE(rkey.getValue().toPointer())); + } } private int convertMask(int mask) {