diff --git a/build.xml b/build.xml index 07bf219196..7a42361062 100644 --- a/build.xml +++ b/build.xml @@ -307,6 +307,7 @@ + @@ -520,7 +521,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc - + @@ -543,7 +544,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc - + @@ -971,7 +972,10 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc - + + + + @@ -1025,7 +1029,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc - + diff --git a/contrib/platform/build.xml b/contrib/platform/build.xml index 1658e1b44a..5aa5ece8ba 100644 --- a/contrib/platform/build.xml +++ b/contrib/platform/build.xml @@ -111,13 +111,13 @@ com.sun.jna.platform.wince Saving test results in ${build.test.results.dir.abs} - + - + - + @@ -155,7 +155,7 @@ com.sun.jna.platform.wince - + diff --git a/contrib/platform/src/com/sun/jna/platform/WindowUtils.java b/contrib/platform/src/com/sun/jna/platform/WindowUtils.java index fc8894dc9f..798de335c6 100644 --- a/contrib/platform/src/com/sun/jna/platform/WindowUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/WindowUtils.java @@ -83,8 +83,11 @@ import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinDef.HRGN; import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; import com.sun.jna.platform.win32.WinDef.POINT; import com.sun.jna.platform.win32.WinDef.RECT; +import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinGDI; import com.sun.jna.platform.win32.WinGDI.BITMAP; import com.sun.jna.platform.win32.WinGDI.BITMAPINFO; @@ -1050,205 +1053,215 @@ public boolean outputRange(int x, int y, int w, int h) { setWindowRegion(w, region); } - @Override - public BufferedImage getWindowIcon(final HWND hwnd) { - // request different kind of icons if any solution fails - final DWORDByReference hIconNumber = new DWORDByReference(); - long result = User32.INSTANCE.SendMessageTimeout(hwnd, - WinUser.WM_GETICON, WinUser.ICON_BIG, 0, - WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); - if (result == 0) - result = User32.INSTANCE.SendMessageTimeout(hwnd, - WinUser.WM_GETICON, WinUser.ICON_SMALL, 0, - WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); - if (result == 0) - result = User32.INSTANCE.SendMessageTimeout(hwnd, - WinUser.WM_GETICON, WinUser.ICON_SMALL2, 0, - WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); - if (result == 0) { - result = User32.INSTANCE.GetClassLongPtr(hwnd, - WinUser.GCLP_HICON); - hIconNumber.getValue().setValue(result); - } - if (result == 0) { - result = User32.INSTANCE.GetClassLongPtr(hwnd, - WinUser.GCLP_HICONSM); - hIconNumber.getValue().setValue(result); - } - if (result == 0) - return null; - - // draw native icon into Java image - final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue() - .longValue())); - final Dimension iconSize = getIconSize(hIcon); - if (iconSize.width == 0 || iconSize.height == 0) - return null; - - final int width = iconSize.width; - final int height = iconSize.height; - final short depth = 24; - - final byte[] lpBitsColor = new byte[width * height * depth / 8]; - final Pointer lpBitsColorPtr = new Memory(lpBitsColor.length); - final byte[] lpBitsMask = new byte[width * height * depth / 8]; - final Pointer lpBitsMaskPtr = new Memory(lpBitsMask.length); - final BITMAPINFO bitmapInfo = new BITMAPINFO(); - final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER(); - - bitmapInfo.bmiHeader = hdr; - hdr.biWidth = width; - hdr.biHeight = height; - hdr.biPlanes = 1; - hdr.biBitCount = depth; - hdr.biCompression = 0; - hdr.write(); - bitmapInfo.write(); - - final HDC hDC = User32.INSTANCE.GetDC(null); - final ICONINFO iconInfo = new ICONINFO(); - User32.INSTANCE.GetIconInfo(hIcon, iconInfo); - iconInfo.read(); - GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmColor, 0, height, - lpBitsColorPtr, bitmapInfo, 0); - lpBitsColorPtr.read(0, lpBitsColor, 0, lpBitsColor.length); - GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmMask, 0, height, - lpBitsMaskPtr, bitmapInfo, 0); - lpBitsMaskPtr.read(0, lpBitsMask, 0, lpBitsMask.length); - final BufferedImage image = new BufferedImage(width, height, - BufferedImage.TYPE_INT_ARGB); - - int r, g, b, a, argb; - int x = 0, y = height - 1; - for (int i = 0; i < lpBitsColor.length; i = i + 3) { - b = lpBitsColor[i] & 0xFF; - g = lpBitsColor[i + 1] & 0xFF; - r = lpBitsColor[i + 2] & 0xFF; - a = 0xFF - lpBitsMask[i] & 0xFF; - argb = (a << 24) | (r << 16) | (g << 8) | b; - image.setRGB(x, y, argb); - x = (x + 1) % width; - if (x == 0) - y--; - } - - User32.INSTANCE.ReleaseDC(null, hDC); - - return image; - } - - @Override - public Dimension getIconSize(final HICON hIcon) { - final ICONINFO iconInfo = new ICONINFO(); - try { - if (!User32.INSTANCE.GetIconInfo(hIcon, iconInfo)) - return new Dimension(); - iconInfo.read(); - - final BITMAP bmp = new BITMAP(); - if (iconInfo.hbmColor != null - && iconInfo.hbmColor.getPointer() != Pointer.NULL) { - final int nWrittenBytes = GDI32.INSTANCE.GetObject( - iconInfo.hbmColor, bmp.size(), bmp.getPointer()); - bmp.read(); - if (nWrittenBytes > 0) - return new Dimension(bmp.bmWidth.intValue(), - bmp.bmHeight.intValue()); - } else if (iconInfo.hbmMask != null - && iconInfo.hbmMask.getPointer() != Pointer.NULL) { - final int nWrittenBytes = GDI32.INSTANCE.GetObject( - iconInfo.hbmMask, bmp.size(), bmp.getPointer()); - bmp.read(); - if (nWrittenBytes > 0) - return new Dimension(bmp.bmWidth.intValue(), bmp.bmHeight.intValue() / 2); - } - } finally { - if (iconInfo.hbmColor != null - && iconInfo.hbmColor.getPointer() != Pointer.NULL) - GDI32.INSTANCE.DeleteObject(iconInfo.hbmColor); - if (iconInfo.hbmMask != null - && iconInfo.hbmMask.getPointer() != Pointer.NULL) - GDI32.INSTANCE.DeleteObject(iconInfo.hbmMask); - } - - return new Dimension(); - } - - @Override - public List getAllWindows( - final boolean onlyVisibleWindows) { - final List result = new LinkedList(); - - final WNDENUMPROC lpEnumFunc = new WNDENUMPROC() { - @Override - public boolean callback(final HWND hwnd, final Pointer arg1) { - try { - final boolean visible = !onlyVisibleWindows - || User32.INSTANCE.IsWindowVisible(hwnd); - if (visible) { - final String title = getWindowTitle(hwnd); - final String filePath = getProcessFilePath(hwnd); - final Rectangle locAndSize = getWindowLocationAndSize(hwnd); - result.add(new DesktopWindow(hwnd, title, filePath, - locAndSize)); - } - } catch (final Exception e) { - e.printStackTrace(); - } - - return true; - } - }; - - if (!User32.INSTANCE.EnumWindows(lpEnumFunc, null)) - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - - return result; - } - - @Override - public String getWindowTitle(final HWND hwnd) { - final int requiredLength = User32.INSTANCE - .GetWindowTextLength(hwnd) + 1; - final char[] title = new char[requiredLength]; - final int length = User32.INSTANCE.GetWindowText(hwnd, title, - title.length); - - return Native.toString(Arrays.copyOfRange(title, 0, length)); - } - - @Override - public String getProcessFilePath(final HWND hwnd) { - final char[] filePath = new char[1025]; - final IntByReference pid = new IntByReference(); - User32.INSTANCE.GetWindowThreadProcessId(hwnd, pid); - - final HANDLE process = Kernel32.INSTANCE.OpenProcess( - WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ, - false, pid.getValue()); - if (process == null - && Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_ACCESS_DENIED) - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - - final int length = Psapi.INSTANCE.GetModuleFileNameExW(process, - null, filePath, filePath.length); - if (length == 0 - && Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_INVALID_HANDLE) - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - - return Native.toString(filePath).trim(); - } - - @Override - public Rectangle getWindowLocationAndSize(final HWND hwnd) { - final RECT lpRect = new RECT(); - if (!User32.INSTANCE.GetWindowRect(hwnd, lpRect)) - throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); - - return new Rectangle(lpRect.left, lpRect.top, Math.abs(lpRect.right - - lpRect.left), Math.abs(lpRect.bottom - lpRect.top)); - } - } + @Override + public BufferedImage getWindowIcon(final HWND hwnd) { + // request different kind of icons if any solution fails + final DWORDByReference hIconNumber = new DWORDByReference(); + LRESULT result = User32.INSTANCE + .SendMessageTimeout(hwnd, + WinUser.WM_GETICON, + new WPARAM(WinUser.ICON_BIG), + new LPARAM(0), + WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); + if (result.intValue() == 0) + result = User32.INSTANCE + .SendMessageTimeout(hwnd, + WinUser.WM_GETICON, + new WPARAM(WinUser.ICON_SMALL), + new LPARAM(0), + WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); + if (result.intValue() == 0) + result = User32.INSTANCE + .SendMessageTimeout(hwnd, + WinUser.WM_GETICON, + new WPARAM(WinUser.ICON_SMALL2), + new LPARAM(0), + WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); + if (result.intValue() == 0) { + result = new LRESULT(User32.INSTANCE + .GetClassLongPtr(hwnd, + WinUser.GCLP_HICON).intValue()); + hIconNumber.getValue().setValue(result.intValue()); + } + if (result.intValue() == 0) { + result = new LRESULT(User32.INSTANCE + .GetClassLongPtr(hwnd, + WinUser.GCLP_HICONSM).intValue()); + hIconNumber.getValue().setValue(result.intValue()); + } + if (result.intValue() == 0) + return null; + + // draw native icon into Java image + final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue() + .longValue())); + final Dimension iconSize = getIconSize(hIcon); + if (iconSize.width == 0 || iconSize.height == 0) + return null; + + final int width = iconSize.width; + final int height = iconSize.height; + final short depth = 24; + + final byte[] lpBitsColor = new byte[width * height * depth / 8]; + final Pointer lpBitsColorPtr = new Memory(lpBitsColor.length); + final byte[] lpBitsMask = new byte[width * height * depth / 8]; + final Pointer lpBitsMaskPtr = new Memory(lpBitsMask.length); + final BITMAPINFO bitmapInfo = new BITMAPINFO(); + final BITMAPINFOHEADER hdr = new BITMAPINFOHEADER(); + + bitmapInfo.bmiHeader = hdr; + hdr.biWidth = width; + hdr.biHeight = height; + hdr.biPlanes = 1; + hdr.biBitCount = depth; + hdr.biCompression = 0; + hdr.write(); + bitmapInfo.write(); + + final HDC hDC = User32.INSTANCE.GetDC(null); + final ICONINFO iconInfo = new ICONINFO(); + User32.INSTANCE.GetIconInfo(hIcon, iconInfo); + iconInfo.read(); + GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmColor, 0, height, + lpBitsColorPtr, bitmapInfo, 0); + lpBitsColorPtr.read(0, lpBitsColor, 0, lpBitsColor.length); + GDI32.INSTANCE.GetDIBits(hDC, iconInfo.hbmMask, 0, height, + lpBitsMaskPtr, bitmapInfo, 0); + lpBitsMaskPtr.read(0, lpBitsMask, 0, lpBitsMask.length); + final BufferedImage image = new BufferedImage(width, height, + BufferedImage.TYPE_INT_ARGB); + + int r, g, b, a, argb; + int x = 0, y = height - 1; + for (int i = 0; i < lpBitsColor.length; i = i + 3) { + b = lpBitsColor[i] & 0xFF; + g = lpBitsColor[i + 1] & 0xFF; + r = lpBitsColor[i + 2] & 0xFF; + a = 0xFF - lpBitsMask[i] & 0xFF; + argb = (a << 24) | (r << 16) | (g << 8) | b; + image.setRGB(x, y, argb); + x = (x + 1) % width; + if (x == 0) + y--; + } + + User32.INSTANCE.ReleaseDC(null, hDC); + + return image; + } + + @Override + public Dimension getIconSize(final HICON hIcon) { + final ICONINFO iconInfo = new ICONINFO(); + try { + if (!User32.INSTANCE.GetIconInfo(hIcon, iconInfo)) + return new Dimension(); + iconInfo.read(); + + final BITMAP bmp = new BITMAP(); + if (iconInfo.hbmColor != null + && iconInfo.hbmColor.getPointer() != Pointer.NULL) { + final int nWrittenBytes = GDI32.INSTANCE.GetObject( + iconInfo.hbmColor, bmp.size(), bmp.getPointer()); + bmp.read(); + if (nWrittenBytes > 0) + return new Dimension(bmp.bmWidth.intValue(), + bmp.bmHeight.intValue()); + } else if (iconInfo.hbmMask != null + && iconInfo.hbmMask.getPointer() != Pointer.NULL) { + final int nWrittenBytes = GDI32.INSTANCE.GetObject( + iconInfo.hbmMask, bmp.size(), bmp.getPointer()); + bmp.read(); + if (nWrittenBytes > 0) + return new Dimension(bmp.bmWidth.intValue(), bmp.bmHeight.intValue() / 2); + } + } finally { + if (iconInfo.hbmColor != null + && iconInfo.hbmColor.getPointer() != Pointer.NULL) + GDI32.INSTANCE.DeleteObject(iconInfo.hbmColor); + if (iconInfo.hbmMask != null + && iconInfo.hbmMask.getPointer() != Pointer.NULL) + GDI32.INSTANCE.DeleteObject(iconInfo.hbmMask); + } + + return new Dimension(); + } + + @Override + public List getAllWindows(final boolean onlyVisibleWindows) { + final List result = new LinkedList(); + + final WNDENUMPROC lpEnumFunc = new WNDENUMPROC() { + @Override + public boolean callback(final HWND hwnd, final Pointer arg1) { + try { + final boolean visible = !onlyVisibleWindows + || User32.INSTANCE.IsWindowVisible(hwnd); + if (visible) { + final String title = getWindowTitle(hwnd); + final String filePath = getProcessFilePath(hwnd); + final Rectangle locAndSize = getWindowLocationAndSize(hwnd); + result.add(new DesktopWindow(hwnd, title, filePath, + locAndSize)); + } + } catch (final Exception e) { + // FIXME properly handle whatever error is raised + e.printStackTrace(); + } + + return true; + } + }; + + if (!User32.INSTANCE.EnumWindows(lpEnumFunc, null)) + throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); + + return result; + } + + @Override + public String getWindowTitle(final HWND hwnd) { + final int requiredLength = User32.INSTANCE + .GetWindowTextLength(hwnd) + 1; + final char[] title = new char[requiredLength]; + final int length = User32.INSTANCE.GetWindowText(hwnd, title, + title.length); + + return Native.toString(Arrays.copyOfRange(title, 0, length)); + } + + @Override + public String getProcessFilePath(final HWND hwnd) { + final char[] filePath = new char[2048]; + final IntByReference pid = new IntByReference(); + User32.INSTANCE.GetWindowThreadProcessId(hwnd, pid); + + final HANDLE process = Kernel32.INSTANCE.OpenProcess(WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ, + false, pid.getValue()); + if (process == null + && Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_ACCESS_DENIED) { + throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); + } + final int length = Psapi.INSTANCE.GetModuleFileNameExW(process, + null, filePath, filePath.length); + if (length == 0 + && Kernel32.INSTANCE.GetLastError() != WinNT.ERROR_INVALID_HANDLE) { + throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); + } + return Native.toString(filePath).trim(); + } + + @Override + public Rectangle getWindowLocationAndSize(final HWND hwnd) { + final RECT lpRect = new RECT(); + if (!User32.INSTANCE.GetWindowRect(hwnd, lpRect)) + throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); + + return new Rectangle(lpRect.left, lpRect.top, Math.abs(lpRect.right + - lpRect.left), Math.abs(lpRect.bottom - lpRect.top)); + } + } private static class MacWindowUtils extends NativeWindowUtils { public boolean isWindowAlphaSupported() { @@ -1497,6 +1510,7 @@ private static long getVisualID(GraphicsConfiguration config) { return ((Number)o).longValue(); } catch (Exception e) { + // FIXME properly handle this error e.printStackTrace(); return -1; } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java index c32facfb02..5fc3979628 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32.java @@ -50,7 +50,7 @@ */ public interface Advapi32 extends StdCallLibrary { Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", - Advapi32.class, W32APIOptions.UNICODE_OPTIONS); + Advapi32.class, W32APIOptions.DEFAULT_OPTIONS); public static final int MAX_KEY_LENGTH = 255; public static final int MAX_VALUE_NAME = 16383; @@ -1581,6 +1581,10 @@ public boolean LookupPrivilegeValue(String lpSystemName, String lpName, * otherwise, none of the descriptor is returned. * @return whether the call succeeded */ + public boolean GetFileSecurity(String lpFileName, + int RequestedInformation, Pointer pointer, int nLength, + IntByReference lpnLengthNeeded); + /** @deprecated Use the String version */ public boolean GetFileSecurity(WString lpFileName, int RequestedInformation, Pointer pointer, int nLength, IntByReference lpnLengthNeeded); @@ -1796,6 +1800,8 @@ public boolean AccessCheck(Pointer pSecurityDescriptor, * function fails, the return value is zero. To get extended error * information, call GetLastError. */ + public boolean EncryptFile(String lpFileName); + /** @deprecated Use the String version */ public boolean EncryptFile(WString lpFileName); /** @@ -1809,6 +1815,8 @@ public boolean AccessCheck(Pointer pSecurityDescriptor, * function fails, the return value is zero. To get extended error * information, call GetLastError. */ + public boolean DecryptFile(String lpFileName, DWORD dwReserved); + /** @deprecated Use the String version */ public boolean DecryptFile(WString lpFileName, DWORD dwReserved); /** @@ -1823,6 +1831,8 @@ public boolean AccessCheck(Pointer pSecurityDescriptor, * function fails, the return value is zero. To get extended error * information, call GetLastError. */ + public boolean FileEncryptionStatus(String lpFileName, DWORDByReference lpStatus); + /** @deprecated Use the String version */ public boolean FileEncryptionStatus(WString lpFileName, DWORDByReference lpStatus); /** @@ -1840,6 +1850,8 @@ public boolean AccessCheck(Pointer pSecurityDescriptor, * function fails, the return value is zero. To get extended error * information, call GetLastError. */ + public boolean EncryptionDisable(String DirPath, boolean Disable); + /** @deprecated Use the String version */ public boolean EncryptionDisable(WString DirPath, boolean Disable); /** @@ -1862,8 +1874,11 @@ public boolean AccessCheck(Pointer pSecurityDescriptor, * FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic * text description of the error. */ + public int OpenEncryptedFileRaw(String lpFileName, ULONG ulFlags, + PointerByReference pvContext); + /** @deprecated Use the String version */ public int OpenEncryptedFileRaw(WString lpFileName, ULONG ulFlags, - PointerByReference pvContext); + PointerByReference pvContext); /** * Backs up (export) encrypted files. This is one of a group of Encrypted File diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java index 96065f65fa..871801746e 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java @@ -2032,8 +2032,8 @@ public static ACCESS_ACEStructure[] getFileSecurity(String fileName, repeat = false; memory = new Memory(nLength); IntByReference lpnSize = new IntByReference(); - boolean succeded = Advapi32.INSTANCE.GetFileSecurity(new WString( - fileName), infoType, memory, nLength, lpnSize); + boolean succeded = Advapi32.INSTANCE.GetFileSecurity( + fileName, infoType, memory, nLength, lpnSize); if (!succeded) { int lastError = Kernel32.INSTANCE.GetLastError(); @@ -2100,7 +2100,7 @@ private static Memory getSecurityDescriptorForFile(final String absoluteFilePath final IntByReference lpnSize = new IntByReference(); boolean succeeded = Advapi32.INSTANCE.GetFileSecurity( - new WString(absoluteFilePath), + absoluteFilePath, infoType, null, 0, lpnSize); @@ -2114,8 +2114,8 @@ private static Memory getSecurityDescriptorForFile(final String absoluteFilePath final int nLength = lpnSize.getValue(); final Memory securityDescriptorMemoryPointer = new Memory(nLength); - succeeded = Advapi32.INSTANCE.GetFileSecurity(new WString( - absoluteFilePath), infoType, securityDescriptorMemoryPointer, nLength, lpnSize); + succeeded = Advapi32.INSTANCE.GetFileSecurity( + absoluteFilePath, infoType, securityDescriptorMemoryPointer, nLength, lpnSize); if (!succeeded) { securityDescriptorMemoryPointer.clear(); @@ -2407,7 +2407,7 @@ public static void setFileSecurityDescriptor( * The file or directory to encrypt. */ public static void encryptFile(File file) { - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); if (!Advapi32.INSTANCE.EncryptFile(lpFileName)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } @@ -2420,7 +2420,7 @@ public static void encryptFile(File file) { * The file or directory to decrypt. */ public static void decryptFile(File file) { - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); if (!Advapi32.INSTANCE.DecryptFile(lpFileName, new DWORD(0))) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } @@ -2435,7 +2435,7 @@ public static void decryptFile(File file) { */ public static int fileEncryptionStatus(File file) { DWORDByReference status = new DWORDByReference(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); if (!Advapi32.INSTANCE.FileEncryptionStatus(lpFileName, status)) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } @@ -2452,7 +2452,7 @@ public static int fileEncryptionStatus(File file) { * TRUE to disable encryption. FALSE to enable it. */ public static void disableEncryption(File directory, boolean disable) { - WString dirPath = new WString(directory.getAbsolutePath()); + String dirPath = directory.getAbsolutePath(); if (!Advapi32.INSTANCE.EncryptionDisable(dirPath, disable)) { throw new Win32Exception(Native.getLastError()); } @@ -2484,7 +2484,7 @@ public static void backupEncryptedFile(File src, File destDir) { } // open encrypted file for export - WString srcFileName = new WString(src.getAbsolutePath()); + String srcFileName = src.getAbsolutePath(); PointerByReference pvContext = new PointerByReference(); if (Advapi32.INSTANCE.OpenEncryptedFileRaw(srcFileName, readFlag, pvContext) != W32Errors.ERROR_SUCCESS) { @@ -2495,9 +2495,9 @@ public static void backupEncryptedFile(File src, File destDir) { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); FE_EXPORT_FUNC pfExportCallback = new FE_EXPORT_FUNC() { @Override - public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONG ulLength) { - byte[] arr = pbData.getPointer().getByteArray(0, ulLength.intValue()); + byte[] arr = pbData.getByteArray(0, ulLength.intValue()); try { outputStream.write(arr); } catch (IOException e) { @@ -2521,8 +2521,8 @@ public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, Advapi32.INSTANCE.CloseEncryptedFileRaw(pvContext.getValue()); // open file for import - WString destFileName = new WString(destDir.getAbsolutePath() + File.separator - + src.getName()); + String destFileName = destDir.getAbsolutePath() + File.separator + + src.getName(); pvContext = new PointerByReference(); if (Advapi32.INSTANCE.OpenEncryptedFileRaw(destFileName, writeFlag, pvContext) != W32Errors.ERROR_SUCCESS) { @@ -2533,12 +2533,12 @@ public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, final IntByReference elementsReadWrapper = new IntByReference(0); FE_IMPORT_FUNC pfImportCallback = new FE_IMPORT_FUNC() { @Override - public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONGByReference ulLength) { int elementsRead = elementsReadWrapper.getValue(); int remainingElements = outputStream.size() - elementsRead; int length = Math.min(remainingElements, ulLength.getValue().intValue()); - pbData.getPointer().write(0, outputStream.toByteArray(), elementsRead, + pbData.write(0, outputStream.toByteArray(), elementsRead, length); elementsReadWrapper.setValue(elementsRead + length); ulLength.setValue(new ULONG(length)); 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 a2475f8d8b..e17f05cd58 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/BaseTSD.java @@ -15,18 +15,18 @@ import com.sun.jna.IntegerType; import com.sun.jna.Pointer; import com.sun.jna.ptr.ByReference; -import com.sun.jna.win32.StdCallLibrary; /** * Based on basetsd.h (various types) * @author dblock[at]dblock[dot]org */ @SuppressWarnings("serial") -public interface BaseTSD extends StdCallLibrary { +public interface BaseTSD { + /** -* Signed long type for pointer precision. -* Use when casting a pointer to a long to perform pointer arithmetic. -*/ + * Signed long type for pointer precision. + * Use when casting a pointer to a long to perform pointer arithmetic. + */ public static class LONG_PTR extends IntegerType { public LONG_PTR() { this(0); @@ -124,4 +124,4 @@ public SIZE_T(long value) { super(value); } } -} \ No newline at end of file +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/COM/TypeLibUtil.java b/contrib/platform/src/com/sun/jna/platform/win32/COM/TypeLibUtil.java index 4c3011411b..92c1adf960 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/COM/TypeLibUtil.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/COM/TypeLibUtil.java @@ -520,7 +520,7 @@ public String getDocString() { * * @return the help context */ - public long getHelpContext() { + public int getHelpContext() { return helpContext; } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java b/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java index e5b9035762..170029f5b1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java @@ -28,7 +28,7 @@ public interface Crypt32 extends StdCallLibrary { Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32", - Crypt32.class, W32APIOptions.UNICODE_OPTIONS); + Crypt32.class, W32APIOptions.DEFAULT_OPTIONS); /** * The CryptProtectData function performs encryption on the data in a DATA_BLOB diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java index b747810a74..5380efe27a 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java @@ -22,7 +22,6 @@ import com.sun.jna.platform.win32.WinDef.LONG; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY; -import com.sun.jna.win32.StdCallLibrary; /** * Based on dbt.h (various types) @@ -30,7 +29,7 @@ * @author Tobias Wolf, wolf.tobias@gmx.net */ @SuppressWarnings("serial") -public interface DBT extends StdCallLibrary { +public interface DBT { /** The dbt no disk space. */ int DBT_NO_DISK_SPACE = 0x0047; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java index 5e52093ff8..eb84634016 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DsGetDC.java @@ -17,7 +17,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.WinNT.PSID; import com.sun.jna.win32.StdCallLibrary; @@ -27,7 +26,7 @@ * * @author dblock[at]dblock.org */ -public interface DsGetDC extends StdCallLibrary { +public interface DsGetDC { /** * The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName @@ -48,7 +47,7 @@ public DOMAIN_CONTROLLER_INFO(Pointer memory) { } /** - * Pointer to a null-terminated WString that specifies the computer name + * Pointer to a null-terminated string that specifies the computer name * of the discovered domain controller. The returned computer name is * prefixed with "\\". The DNS-style name, for example, * "\\phoenix.fabrikam.com", is returned, if available. If the DNS-style @@ -57,16 +56,16 @@ public DOMAIN_CONTROLLER_INFO(Pointer memory) { * 4.0 domain or if the domain does not support the IP family of * protocols. */ - public WString DomainControllerName; + public String DomainControllerName; /** - * Pointer to a null-terminated WString that specifies the address of + * Pointer to a null-terminated string that specifies the address of * the discovered domain controller. The address is prefixed with "\\". - * This WString is one of the types defined by the + * This string is one of the types defined by the * DomainControllerAddressType member. */ - public WString DomainControllerAddress; + public String DomainControllerAddress; /** - * Indicates the type of WString that is contained in the + * Indicates the type of string that is contained in the * DomainControllerAddress member. */ public int DomainControllerAddressType; @@ -77,40 +76,40 @@ public DOMAIN_CONTROLLER_INFO(Pointer memory) { */ public GUID DomainGuid; /** - * Pointer to a null-terminated WString that specifies the name of the + * Pointer to a null-terminated string that specifies the name of the * domain. The DNS-style name, for example, "fabrikam.com", is returned * if available. Otherwise, the flat-style name, for example, * "fabrikam", is returned. This name may be different than the * requested domain name if the domain has been renamed. */ - public WString DomainName; + public String DomainName; /** - * Pointer to a null-terminated WString that specifies the name of the + * Pointer to a null-terminated string that specifies the name of the * domain at the root of the DS tree. The DNS-style name, for example, * "fabrikam.com", is returned if available. Otherwise, the flat-style * name, for example, "fabrikam" is returned. */ - public WString DnsForestName; + public String DnsForestName; /** * Contains a set of flags that describe the domain controller. */ public int Flags; /** - * Pointer to a null-terminated WString that specifies the name of the + * Pointer to a null-terminated string that specifies the name of the * site where the domain controller is located. This member may be NULL * if the domain controller is not in a site; for example, the domain * controller is a Windows NT 4.0 domain controller. */ - public WString DcSiteName; + public String DcSiteName; /** - * Pointer to a null-terminated WString that specifies the name of the + * Pointer to a null-terminated string that specifies the name of the * site that the computer belongs to. The computer is specified in the * ComputerName parameter passed to DsGetDcName. This member may be NULL * if the site that contains the computer cannot be found; for example, * if the DS administrator has not associated the subnet that the * computer is in with a valid site. */ - public WString ClientSiteName; + public String ClientSiteName; protected List getFieldOrder() { return Arrays.asList(new String[] { "DomainControllerName", @@ -182,12 +181,12 @@ public static class ByReference extends DS_DOMAIN_TRUSTS implements * Pointer to a null-terminated string that contains the NetBIOS name of * the domain. */ - public WString NetbiosDomainName; + public String NetbiosDomainName; /** * Pointer to a null-terminated string that contains the DNS name of the * domain. This member may be NULL. */ - public WString DnsDomainName; + public String DnsDomainName; /** * Contains a set of flags that specify more data about the domain * trust. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/GL.java b/contrib/platform/src/com/sun/jna/platform/win32/GL.java index 0638abe6e0..da808ace16 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/GL.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/GL.java @@ -12,12 +12,10 @@ */ package com.sun.jna.platform.win32; -import com.sun.jna.win32.StdCallLibrary; - /** * Definitions for WinOpenGL */ -public interface GL extends StdCallLibrary { +public interface GL { public final int GL_VENDOR = 0x1F00; public final int GL_RENDERER = 0x1F01; public final int GL_VERSION = 0x1F02; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java index 87af3296d5..5ee11bd2d5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java @@ -18,17 +18,18 @@ import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; import com.sun.jna.win32.W32APIOptions; +import com.sun.jna.win32.StdCallLibrary; /** * Interface definitions for kernel32.dll. Includes additional * alternate mappings from {@link WinNT} which make use of NIO buffers, * {@link Wincon} for console API. */ -public interface Kernel32 extends WinNT, Wincon { +public interface Kernel32 extends StdCallLibrary, WinNT, Wincon { /** The instance. */ Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", - Kernel32.class, W32APIOptions.UNICODE_OPTIONS); + Kernel32.class, W32APIOptions.DEFAULT_OPTIONS); /** * Reads data from the specified file or input/output (I/O) device. Reads diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java index 3e8c8153b7..badd31e365 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java @@ -17,16 +17,14 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinNT.PSID; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from LMAccess.h. * Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface LMAccess extends StdCallLibrary { +public interface LMAccess { public static class LOCALGROUP_INFO_0 extends Structure { public LOCALGROUP_INFO_0() { @@ -38,7 +36,7 @@ public LOCALGROUP_INFO_0(Pointer memory) { read(); } - public WString lgrui0_name; + public String lgrui0_name; protected List getFieldOrder() { return Arrays.asList(new String[] { "lgrui0_name" }); @@ -55,8 +53,8 @@ public LOCALGROUP_INFO_1(Pointer memory) { read(); } - public WString lgrui1_name; - public WString lgrui1_comment; + public String lgrui1_name; + public String lgrui1_comment; protected List getFieldOrder() { return Arrays.asList(new String[] { "lgrui1_name", "lgrui1_comment" }); } @@ -89,7 +87,7 @@ public USER_INFO_0(Pointer memory) { /** * Pointer to a Unicode string that specifies the name of the user account. */ - public WString usri0_name; + public String usri0_name; protected List getFieldOrder() { return Arrays.asList(new String[] { "usri0_name" }); } @@ -114,12 +112,12 @@ public USER_INFO_1(Pointer memory) { * Pointer to a Unicode string that specifies the name of the user * account. */ - public WString usri1_name; + public String usri1_name; /** * Pointer to a Unicode string that specifies the password of the user * indicated by the usri1_name member. */ - public WString usri1_password; + public String usri1_password; /** * Specifies a DWORD value that indicates the number of seconds that have * elapsed since the usri1_password member was last changed. @@ -134,12 +132,12 @@ public USER_INFO_1(Pointer memory) { * Pointer to a Unicode string specifying the path of the home directory * for the user specified in the usri1_name member. */ - public WString usri1_home_dir; + public String usri1_home_dir; /** * Pointer to a Unicode string that contains a comment to associate with * the user account. */ - public WString usri1_comment; + public String usri1_comment; /** * Specifies a DWORD value that determines several features. */ @@ -148,7 +146,7 @@ public USER_INFO_1(Pointer memory) { * Pointer to a Unicode string specifying the path for the user's * logon script file. */ - public WString usri1_script_path; + public String usri1_script_path; protected List getFieldOrder() { return Arrays.asList(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" }); @@ -178,17 +176,17 @@ public USER_INFO_23(Pointer memory) { * A pointer to a Unicode string that specifies the name of the user account. * Calls to the NetUserSetInfo function ignore this member. */ - public WString usri23_name; + public String usri23_name; /** * A pointer to a Unicode string that contains the full name of the user. * This string can be a null string, or it can have any number of characters before the terminating null character. */ - public WString usri23_full_name; + public String usri23_full_name; /** * A pointer to a Unicode string that contains a comment associated with the user account. * This string can be a null string, or it can have any number of characters before the terminating null character. */ - public WString usri23_comment; + public String usri23_comment; /** * This member can be one or more of the following values. * Note that setting user account control flags may require certain privileges and control access rights. @@ -246,7 +244,7 @@ public GROUP_USERS_INFO_0(Pointer memory) { /** * Pointer to a null-terminated Unicode character string that specifies a name. */ - public WString grui0_name; + public String grui0_name; protected List getFieldOrder() { return Arrays.asList(new String[] { "grui0_name" }); @@ -269,7 +267,7 @@ public LOCALGROUP_USERS_INFO_0(Pointer memory) { /** * Pointer to a Unicode string specifying the name of a local group to which the user belongs. */ - public WString lgrui0_name; + public String lgrui0_name; protected List getFieldOrder() { return Arrays.asList(new String[] { "lgrui0_name" }); @@ -295,7 +293,7 @@ public GROUP_INFO_0(Pointer memory) { * Pointer to a null-terminated Unicode character string that specifies * the name of the global group. */ - public WString grpi0_name; + public String grpi0_name; protected List getFieldOrder() { return Arrays.asList(new String[] { "grpi0_name" }); @@ -320,13 +318,13 @@ public GROUP_INFO_1(Pointer memory) { * Pointer to a null-terminated Unicode character string that specifies * the name of the global group. */ - public WString grpi1_name; + public String grpi1_name; /** * Pointer to a null-terminated Unicode character string that specifies * a remark associated with the global group. This member can be a null * string. The comment can contain MAXCOMMENTSZ characters. */ - public WString grpi1_comment; + public String grpi1_comment; protected List getFieldOrder() { return Arrays.asList(new String[] { "grpi1_name", "grpi1_comment" }); @@ -351,13 +349,13 @@ public GROUP_INFO_2(Pointer memory) { * Pointer to a null-terminated Unicode character string that * specifies the name of the global group. */ - public WString grpi2_name; + public String grpi2_name; /** * Pointer to a null-terminated Unicode character string that contains a * remark associated with the global group. This member can be a null string. * The comment can contain MAXCOMMENTSZ characters. */ - public WString grpi2_comment; + public String grpi2_comment; /** * Specifies a DWORD value that contains the relative identifier (RID) of * the global group. @@ -392,13 +390,13 @@ public GROUP_INFO_3(Pointer memory) { * Pointer to a null-terminated Unicode character string that * specifies the name of the global group. */ - public WString grpi3_name; + public String grpi3_name; /** * Pointer to a null-terminated Unicode character string that * contains a remark associated with the global group. This member can be * a null string. The comment can contain MAXCOMMENTSZ characters. */ - public WString grpi3_comment; + public String grpi3_comment; /** * Pointer to a SID structure that contains the security identifier (SID) that * uniquely identifies the global group. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMCons.java b/contrib/platform/src/com/sun/jna/platform/win32/LMCons.java index cbfd186efb..dbf8c82575 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMCons.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMCons.java @@ -12,14 +12,12 @@ */ package com.sun.jna.platform.win32; -import com.sun.jna.win32.StdCallLibrary; - /** * Ported from LMCons.h. * @author dblock[at]dblock.org * Windows SDK 6.0A */ -public interface LMCons extends StdCallLibrary { +public interface LMCons { int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes) /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMErr.java b/contrib/platform/src/com/sun/jna/platform/win32/LMErr.java index cfbd30f95d..4e595e348d 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMErr.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMErr.java @@ -12,14 +12,12 @@ */ package com.sun.jna.platform.win32; -import com.sun.jna.win32.StdCallLibrary; - /** * Ported from LMErr.h. * @author dblock[at]dblock.org * Windows SDK 6.0A */ -public interface LMErr extends StdCallLibrary { +public interface LMErr { int NERR_Success = 0; int NERR_BASE = 2100; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMJoin.java b/contrib/platform/src/com/sun/jna/platform/win32/LMJoin.java index 2eccc337f6..dab5cc5ddb 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMJoin.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMJoin.java @@ -12,14 +12,12 @@ */ package com.sun.jna.platform.win32; -import com.sun.jna.win32.StdCallLibrary; - /** * Ported from LMJoin.h. * Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface LMJoin extends StdCallLibrary { +public interface LMJoin { /** * Status of a workstation. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java b/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java index dabb8bc42b..bd6ce1a9d5 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMShare.java @@ -17,7 +17,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.win32.StdCallLibrary; /** @@ -25,7 +24,7 @@ * Windows SDK 7.1 * @author amarcionek[at]seven10storage.com */ -public interface LMShare extends StdCallLibrary { +public interface LMShare { // // Share types (shi1_type and shi2_type fields). @@ -78,7 +77,7 @@ public SHARE_INFO_2(Pointer memory) { /** * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. */ - public WString shi2_netname; + public String shi2_netname; /** * A combination of values that specify the type of share. Calls to the NetShareSetInfo function ignore this member. @@ -90,7 +89,7 @@ public SHARE_INFO_2(Pointer memory) { /** * Pointer to a Unicode string specifying an optional comment about the shared resource. */ - public WString shi2_remark; + public String shi2_remark; /** * Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security. @@ -116,14 +115,14 @@ public SHARE_INFO_2(Pointer memory) { * Pointer to a Unicode string that contains the local path for the shared resource. For disks, this member is the path being shared. * For print queues, this member is the name of the print queue being shared. Calls to the NetShareSetInfo function ignore this member. */ - public WString shi2_path; + public String shi2_path; /** * Pointer to a Unicode string that specifies the share's password (when the server is running with share-level security). If the server is * running with user-level security, this member is ignored. Note that Windows does not support share-level security. * This member can be no longer than SHPWLEN+1 bytes (including a terminating null character). Calls to the NetShareSetInfo function ignore this member. */ - public WString shi2_passwd; + public String shi2_passwd; protected List getFieldOrder() { return Arrays.asList(new String[] { "shi2_netname", @@ -153,7 +152,7 @@ public SHARE_INFO_502(Pointer memory) { /** * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. */ - public WString shi502_netname; + public String shi502_netname; /** * A combination of values that specify the type of share. Calls to the NetShareSetInfo function ignore this member. @@ -165,7 +164,7 @@ public SHARE_INFO_502(Pointer memory) { /** * Pointer to a Unicode string specifying an optional comment about the shared resource. */ - public WString shi502_remark; + public String shi502_remark; /** * Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security. @@ -191,14 +190,14 @@ public SHARE_INFO_502(Pointer memory) { * Pointer to a Unicode string that contains the local path for the shared resource. For disks, this member is the path being shared. * For print queues, this member is the name of the print queue being shared. Calls to the NetShareSetInfo function ignore this member. */ - public WString shi502_path; + public String shi502_path; /** * Pointer to a Unicode string that specifies the share's password (when the server is running with share-level security). If the server is * running with user-level security, this member is ignored. Note that Windows does not support share-level security. * This member can be no longer than SHPWLEN+1 bytes (including a terminating null character). Calls to the NetShareSetInfo function ignore this member. */ - public WString shi502_passwd; + public String shi502_passwd; /** * Reserved; must be zero. Calls to the NetShareSetInfo function ignore this member. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Mpr.java b/contrib/platform/src/com/sun/jna/platform/win32/Mpr.java index 0f6d99cbf8..7929d050d4 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Mpr.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Mpr.java @@ -16,7 +16,6 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; @@ -34,7 +33,7 @@ public interface Mpr extends StdCallLibrary { - Mpr INSTANCE = (Mpr) Native.loadLibrary("Mpr", Mpr.class, W32APIOptions.UNICODE_OPTIONS); + Mpr INSTANCE = (Mpr) Native.loadLibrary("Mpr", Mpr.class, W32APIOptions.DEFAULT_OPTIONS); /** * The WNetOpenEnum function starts an enumeration of network resources or @@ -182,7 +181,7 @@ public interface Mpr extends StdCallLibrary { * https://msdn.microsoft.com/en-us/library/windows/desktop/aa385474 * (v=vs.85).aspx */ - int WNetGetUniversalName(WString lpLocalPath, int dwInfoLevel, Pointer lpBuffer, IntByReference lpBufferSize); + int WNetGetUniversalName(String lpLocalPath, int dwInfoLevel, Pointer lpBuffer, IntByReference lpBufferSize); /** * The WNetUseConnection function makes a connection to a network resource. @@ -299,7 +298,7 @@ public interface Mpr extends StdCallLibrary { * https://msdn.microsoft.com/en-us/library/windows/desktop/aa385482 * (v=vs.85).aspx */ - public int WNetUseConnection(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, WString lpPassword, WString lpUserID, int dwFlags, + public int WNetUseConnection(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, String lpPassword, String lpUserID, int dwFlags, PointerByReference lpAccessName, IntByReference lpBufferSize, IntByReference lpResult); /** @@ -380,7 +379,7 @@ public int WNetUseConnection(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, WString * [in] Set of bit flags describing the connection. This * parameter can be any combination of the values in ConnectFlag. */ - public int WNetAddConnection3(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, WString lpPassword, WString lpUserID, int dwFlags); + public int WNetAddConnection3(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, String lpPassword, String lpUserID, int dwFlags); /** * The WNetCancelConnection2 function cancels an existing network @@ -417,5 +416,5 @@ public int WNetUseConnection(HWND hwndOwner, NETRESOURCE lpNETRESOURCE, WString * https://msdn.microsoft.com/en-us/library/windows/desktop/aa385482 * (v=vs.85).aspx */ - public int WNetCancelConnection2(WString lpName, int dwFlags, boolean fForce); + public int WNetCancelConnection2(String lpName, int dwFlags, boolean fForce); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Msi.java b/contrib/platform/src/com/sun/jna/platform/win32/Msi.java index 2874918569..7fc72b2937 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Msi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Msi.java @@ -21,7 +21,7 @@ public interface Msi extends StdCallLibrary { Msi INSTANCE = (Msi) - Native.loadLibrary("msi", Msi.class, W32APIOptions.UNICODE_OPTIONS); + Native.loadLibrary("msi", Msi.class, W32APIOptions.DEFAULT_OPTIONS); /** * The component being requested is disabled on the computer. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java index c76db51ae2..425f7ab6f1 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/NTSecApi.java @@ -21,14 +21,13 @@ import com.sun.jna.Union; import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER; import com.sun.jna.platform.win32.WinNT.PSID; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from NTSecApi.h * Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface NTSecApi extends StdCallLibrary { +public interface NTSecApi { /** * The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java b/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java index ec9ee45127..161edd1cc9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Netapi32.java @@ -15,7 +15,6 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; import com.sun.jna.platform.win32.Guid.GUID; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; @@ -31,7 +30,7 @@ public interface Netapi32 extends StdCallLibrary { Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32", - Netapi32.class, W32APIOptions.UNICODE_OPTIONS); + Netapi32.class, W32APIOptions.DEFAULT_OPTIONS); /** * Retrieves join status information for the specified computer. @@ -451,7 +450,7 @@ public int DsEnumerateDomainTrusts(String serverName, int Flags, * index is not returned on error. For more information, see the NetShareSetInfo function. * @return If the function succeeds, the return value is NERR_Success. If the function fails, the return value can be an error code as seen on MSDN. */ - public int NetShareAdd(WString servername, int level, Pointer buf, IntByReference parm_err); + public int NetShareAdd(String servername, int level, Pointer buf, IntByReference parm_err); /** * Deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource. @@ -466,5 +465,5 @@ public int DsEnumerateDomainTrusts(String serverName, int Flags, * @return If the function succeeds, the return value is LMErr.NERR_Success. * If the function fails, the return value can be an error code as seen on MSDN. */ - public int NetShareDel(WString servername, WString netname, int reserved); + public int NetShareDel(String servername, String netname, int reserved); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/NtDll.java b/contrib/platform/src/com/sun/jna/platform/win32/NtDll.java index bd69134ca6..e25e6e7adb 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/NtDll.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/NtDll.java @@ -26,7 +26,7 @@ public interface NtDll extends StdCallLibrary { NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll", - NtDll.class, W32APIOptions.UNICODE_OPTIONS); + NtDll.class, W32APIOptions.DEFAULT_OPTIONS); /** * The ZwQueryKey routine provides information about the class of a registry key, @@ -52,4 +52,4 @@ public interface NtDll extends StdCallLibrary { */ public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass, Structure KeyInformation, int Length, IntByReference ResultLength); -} \ No newline at end of file +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Ole32.java b/contrib/platform/src/com/sun/jna/platform/win32/Ole32.java index 90eb10f0ac..3df89c47af 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Ole32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Ole32.java @@ -34,7 +34,7 @@ public interface Ole32 extends StdCallLibrary { /** The instance. */ Ole32 INSTANCE = (Ole32) Native.loadLibrary("Ole32", Ole32.class, - W32APIOptions.UNICODE_OPTIONS); + W32APIOptions.DEFAULT_OPTIONS); /** * Creates a GUID, a unique 128-bit integer used for CLSIDs and interface @@ -217,6 +217,8 @@ HRESULT CoCreateInstance(GUID rclsid, Pointer pUnkOuter, int dwClsContext, * * REGDB_E_READREGDB The registry could not be opened for reading. */ + HRESULT CLSIDFromString(String lpsz, CLSID.ByReference pclsid); + /** @deprecated use the String version */ HRESULT CLSIDFromString(WString lpsz, CLSID.ByReference pclsid); /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java b/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java index 4a992ffb33..7cec6e09f7 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java @@ -100,7 +100,7 @@ public interface OleAuto extends StdCallLibrary { /** The instance. */ OleAuto INSTANCE = (OleAuto) Native.loadLibrary("OleAut32", OleAuto.class, - W32APIOptions.UNICODE_OPTIONS); + W32APIOptions.DEFAULT_OPTIONS); /** * This function allocates a new string and copies the passed string into @@ -473,6 +473,8 @@ public HRESULT LoadRegTypeLib(GUID rguid, int wVerMajor, int wVerMinor, * loaded. * @return status */ + public HRESULT LoadTypeLib(String szFile, PointerByReference pptlib); + /** @deprecated use the String version */ public HRESULT LoadTypeLib(WString szFile, PointerByReference pptlib); /** diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java b/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java index 1c28fb02e1..99af9441ae 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Pdh.java @@ -33,7 +33,7 @@ */ public interface Pdh extends StdCallLibrary { Pdh INSTANCE = (Pdh) Native.loadLibrary("Pdh", - Pdh.class, W32APIOptions.UNICODE_OPTIONS); + Pdh.class, W32APIOptions.DEFAULT_OPTIONS); /** Maximum counter name length. */ diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Rasapi32.java b/contrib/platform/src/com/sun/jna/platform/win32/Rasapi32.java index e8388789e6..a0ca394abe 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Rasapi32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Rasapi32.java @@ -33,7 +33,7 @@ * Rasapi32.dll Interface. */ public interface Rasapi32 extends StdCallLibrary { - Rasapi32 INSTANCE = (Rasapi32) Native.loadLibrary("Rasapi32", Rasapi32.class, W32APIOptions.UNICODE_OPTIONS); + Rasapi32 INSTANCE = (Rasapi32) Native.loadLibrary("Rasapi32", Rasapi32.class, W32APIOptions.DEFAULT_OPTIONS); /** * The RasDial function establishes a RAS connection between a RAS client and a RAS server. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Secur32.java b/contrib/platform/src/com/sun/jna/platform/win32/Secur32.java index 3444fcc857..c63c203033 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Secur32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Secur32.java @@ -30,7 +30,7 @@ * @author dblock[at]dblock.org */ public interface Secur32 extends StdCallLibrary { - Secur32 INSTANCE = (Secur32) Native.loadLibrary("Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS); + Secur32 INSTANCE = (Secur32) Native.loadLibrary("Secur32", Secur32.class, W32APIOptions.DEFAULT_OPTIONS); /** * Specifies a format for a directory service object name. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java b/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java index 38b5f00218..1f98925861 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Shell32.java @@ -30,7 +30,7 @@ public interface Shell32 extends ShellAPI, StdCallLibrary { Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, - W32APIOptions.UNICODE_OPTIONS); + W32APIOptions.DEFAULT_OPTIONS); /** * No dialog box confirming the deletion of the objects will be displayed. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java index 11079d0bc7..2495c97ee3 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/ShellAPI.java @@ -19,7 +19,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.TypeMapper; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinDef.DWORD; import com.sun.jna.platform.win32.WinDef.HINSTANCE; import com.sun.jna.platform.win32.WinDef.HWND; @@ -39,7 +38,7 @@ public interface ShellAPI extends StdCallLibrary { int STRUCTURE_ALIGNMENT = Platform.is64Bit() ? Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE; - TypeMapper TYPE_MAPPER = Boolean.getBoolean("w32.ascii") ? W32APITypeMapper.ASCII : W32APITypeMapper.UNICODE; + TypeMapper TYPE_MAPPER = Boolean.getBoolean("w32.ascii") ? W32APITypeMapper.ASCII : W32APITypeMapper.UNICODE; int FO_MOVE = 0x0001; int FO_COPY = 0x0002; @@ -85,11 +84,11 @@ public static class SHFILEOPSTRUCT extends Structure { /** * A pointer to one or more source file names, double null-terminated. */ - public WString pFrom; + public String pFrom; /** * A pointer to the destination file or directory name. */ - public WString pTo; + public String pTo; /** * Flags that control the file operation. */ @@ -110,7 +109,7 @@ public static class SHFILEOPSTRUCT extends Structure { /** * A pointer to the title of a progress dialog box. This is a null-terminated string. */ - public WString lpszProgressTitle; + public String lpszProgressTitle; protected List getFieldOrder() { return Arrays.asList(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" }); diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java index 42fde7b374..b249ce2f0c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Sspi.java @@ -18,15 +18,13 @@ import com.sun.jna.Memory; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from Sspi.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface Sspi extends StdCallLibrary { +public interface Sspi { /** * Maximum size in bytes of a security token. @@ -431,12 +429,12 @@ public static class ByReference extends SecPkgInfo implements Structure.ByRefere /** * Pointer to a null-terminated string that contains the name of the security package. */ - public WString Name; + public String Name; /** * Pointer to a null-terminated string. This can be any additional string passed * back by the package. */ - public WString Comment; + public String Comment; protected List getFieldOrder() { return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" }); diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java index 9c787ec769..32fac29565 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Tlhelp32.java @@ -15,12 +15,11 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.win32.StdCallLibrary; /** * Interface for the Tlhelp32.h header file. */ -public interface Tlhelp32 extends StdCallLibrary { +public interface Tlhelp32 { /** * Includes all heaps of the process specified in th32ProcessID in the snapshot. To enumerate the heaps, see diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32.java b/contrib/platform/src/com/sun/jna/platform/win32/User32.java index fe696ebbca..a1bec435de 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32.java @@ -1303,6 +1303,8 @@ boolean RedrawWindow(HWND hWnd, RECT lprcUpdate, * If the function fails, the return value is zero. To get extended * error information, call {@link Kernel32#GetLastError}. */ + public boolean UnregisterClass(String lpClassName, HINSTANCE hInstance); + /** @deprecated use the String version */ public boolean UnregisterClass(WString lpClassName, HINSTANCE hInstance); /** @@ -1471,6 +1473,11 @@ boolean RedrawWindow(HWND hWnd, RECT lprcUpdate, * WM_NCCREATE * */ + public HWND CreateWindowEx(int dwExStyle, String lpClassName, + String lpWindowName, int dwStyle, int x, int y, int nWidth, + int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, + LPVOID lpParam); + /** @deprecated use the String version */ public HWND CreateWindowEx(int dwExStyle, WString lpClassName, String lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, @@ -1537,7 +1544,7 @@ public HWND CreateWindowEx(int dwExStyle, WString lpClassName, * If the function fails, the return value is zero. To get extended * error information, call {@link Kernel32#GetLastError} . */ - public boolean GetClassInfoEx(HINSTANCE hinst, WString lpszClass, + public boolean GetClassInfoEx(HINSTANCE hinst, String lpszClass, WNDCLASSEX lpwcx); /** @@ -1973,7 +1980,7 @@ HDEVNOTIFY RegisterDeviceNotification(HANDLE hRecipient, * Windows 2000: If {@link Kernel32#GetLastError()} returns 0, then * the function timed out. */ - long SendMessageTimeout(HWND hWnd, int msg, long wParam, long lParam, + LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam, int fuFlags, int uTimeout, DWORDByReference lpdwResult); /** @@ -1999,7 +2006,7 @@ long SendMessageTimeout(HWND hWnd, int msg, long wParam, long lParam, * If the function fails, the return value is zero. To get extended * error information, call {@link Kernel32#GetLastError()}.

*/ - long GetClassLongPtr(HWND hWnd, int nIndex); + ULONG_PTR GetClassLongPtr(HWND hWnd, int nIndex); /** * @param pRawInputDeviceList diff --git a/contrib/platform/src/com/sun/jna/platform/win32/User32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/User32Util.java index 69b5223d64..ef43290a02 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/User32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/User32Util.java @@ -12,7 +12,6 @@ import java.util.Arrays; import java.util.List; -import com.sun.jna.WString; import com.sun.jna.platform.win32.WinDef.HINSTANCE; import com.sun.jna.platform.win32.WinDef.HMENU; import com.sun.jna.platform.win32.WinDef.HWND; @@ -43,7 +42,7 @@ public static final HWND createWindow(final String className, final String windo public static final HWND createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y, final int width, final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) { final HWND hWnd = User32.INSTANCE - .CreateWindowEx(exStyle, new WString(className), windowName, style, x, y, width, height, parent, menu, instance, param); + .CreateWindowEx(exStyle, className, windowName, style, x, y, width, height, parent, menu, instance, param); if (hWnd == null) throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); return hWnd; @@ -77,4 +76,4 @@ public static final List GetRawInputDeviceList() { return Arrays.asList(records); } -} \ No newline at end of file +} diff --git a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java index 52e7f39c2e..2b69e978a7 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/VerRsrc.java @@ -15,12 +15,11 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.win32.StdCallLibrary; /** * Interface for the VerRsrc.h header file. */ -public interface VerRsrc extends StdCallLibrary { +public interface VerRsrc { /** * Contains version information for a file. This information is language and code page independent. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java b/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java index d2a0d83e16..fa4dba8eea 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/W32FileUtils.java @@ -15,7 +15,6 @@ import java.io.File; import java.io.IOException; -import com.sun.jna.WString; import com.sun.jna.platform.FileUtils; public class W32FileUtils extends FileUtils { @@ -32,7 +31,7 @@ public void moveToTrash(File[] files) throws IOException { for (int i=0;i < paths.length;i++) { paths[i] = files[i].getAbsolutePath(); } - fileop.pFrom = new WString(fileop.encodePaths(paths)); + fileop.pFrom = fileop.encodePaths(paths); fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NO_UI; int ret = shell.SHFileOperation(fileop); if (ret != 0) { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java index 8dfcb03904..9693f94f5f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Wdm.java @@ -18,14 +18,13 @@ import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from Wdm.h. * Microsoft Windows DDK. * @author dblock[at]dblock.org */ -public interface Wdm extends StdCallLibrary { +public interface Wdm { /** * The KEY_BASIC_INFORMATION structure defines a subset of diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Win32Exception.java b/contrib/platform/src/com/sun/jna/platform/win32/Win32Exception.java index 5886f3f5a2..e87e44dfd0 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Win32Exception.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Win32Exception.java @@ -20,9 +20,9 @@ */ public class Win32Exception extends RuntimeException { - private static final long serialVersionUID = 1L; - - private HRESULT _hr; + private static final long serialVersionUID = 1L; + + private HRESULT _hr; /** * Returns the error code of the error. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java index 8623cfe39a..d8f30cae81 100755 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinBase.java @@ -26,13 +26,14 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByteByReference; import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.StdCallLibrary.StdCallCallback; /** * Ported from Winbase.h (kernel32.dll/kernel services). * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface WinBase extends StdCallLibrary, WinDef, BaseTSD { +public interface WinBase extends WinDef, BaseTSD { /** Constant value representing an invalid HANDLE. */ HANDLE INVALID_HANDLE_VALUE = @@ -992,7 +993,7 @@ public PROCESS_INFORMATION(Pointer memory) { /** * Represents a thread entry point local to this process, as a Callback. */ - public interface THREAD_START_ROUTINE extends Callback{ + public interface THREAD_START_ROUTINE extends StdCallCallback{ public DWORD apply( LPVOID lpParameter ); } @@ -1079,8 +1080,8 @@ public static interface COMPUTER_NAME_FORMAT { * ExportCallback writes the encrypted file's data to another storage media, * usually for purposes of backing up the file. */ - public interface FE_EXPORT_FUNC extends Callback { - public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, + public interface FE_EXPORT_FUNC extends StdCallCallback { + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONG ulLength); } @@ -1091,8 +1092,8 @@ public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, * backup file sequentially and restores the data, and the system continues * calling it until it has read all of the backup file data. */ - public interface FE_IMPORT_FUNC extends Callback { - public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, + public interface FE_IMPORT_FUNC extends StdCallCallback { + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONGByReference ulLength); } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java index 7bab7735b6..cc57161b1f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java @@ -20,14 +20,13 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinDef.HWND; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from WinCrypt.h. * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface WinCrypt extends StdCallLibrary { +public interface WinCrypt { /** * The CryptoAPI CRYPTOAPI_BLOB structure is used for an arbitrary array of bytes. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java index f2f99a2075..3c531fca88 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinDef.java @@ -25,7 +25,6 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.ptr.ByReference; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from Windef.h (various macros and types). Microsoft Windows SDK 6.0A. @@ -33,7 +32,7 @@ * @author dblock[at]dblock.org */ @SuppressWarnings("serial") -public interface WinDef extends StdCallLibrary { +public interface WinDef { /** The max path. */ int MAX_PATH = 260; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java index 92cd1a14d2..40e1f38a4c 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinGDI.java @@ -21,7 +21,6 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinDef.HBITMAP; import com.sun.jna.platform.win32.WinDef.RECT; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from WinGDI.h. @@ -29,7 +28,7 @@ * @author dblock[at]dblock.org * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de */ -public interface WinGDI extends StdCallLibrary { +public interface WinGDI { int RDH_RECTANGLES = 1; class RGNDATAHEADER extends Structure { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java index efbcd83318..b61585a829 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinNT.java @@ -26,6 +26,7 @@ import com.sun.jna.Structure; import com.sun.jna.Union; import com.sun.jna.ptr.ByReference; +import com.sun.jna.win32.StdCallLibrary.StdCallCallback; /** * This module defines the 32-Bit Windows types and constants that are defined diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java b/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java index 13d8142a03..331042abf0 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinRas.java @@ -26,12 +26,12 @@ import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinNT.LUID; -import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.StdCallLibrary.StdCallCallback; /** * Definitions for RASAPI32 */ -public interface WinRas extends StdCallLibrary { +public interface WinRas { public static final int ERROR_BUFFER_TOO_SMALL = 603; public static final int ERROR_CANNOT_FIND_PHONEBOOK_ENTRY = 623; diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinReg.java b/contrib/platform/src/com/sun/jna/platform/win32/WinReg.java index c3e7458739..3ef54c876f 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinReg.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinReg.java @@ -15,7 +15,6 @@ import com.sun.jna.Pointer; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.ptr.ByReference; -import com.sun.jna.win32.StdCallLibrary; /** * This module contains the function prototypes and constant, type and structure @@ -24,7 +23,7 @@ * Microsoft Windows SDK 6.0A. * @author dblock[at]dblock.org */ -public interface WinReg extends StdCallLibrary { +public interface WinReg { public static class HKEY extends HANDLE { public HKEY() { } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java index 3d5ab193ac..f85f5ba358 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/WinUser.java @@ -19,10 +19,9 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.Union; -import com.sun.jna.WString; import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.win32.StdCallLibrary; +import com.sun.jna.win32.StdCallLibrary.StdCallCallback; /** * Ported from WinUser.h Microsoft Windows SDK 6.0A. @@ -30,7 +29,7 @@ * @author dblock[at]dblock.org * @author Andreas "PAX" Lück, onkelpax-git[at]yahoo.de */ -public interface WinUser extends StdCallLibrary, WinDef { +public interface WinUser extends WinDef { HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF)); HWND HWND_MESSAGE = new HWND(Pointer.createConstant(-3)); @@ -1039,7 +1038,7 @@ public WNDCLASSEX(Pointer memory) { public String lpszMenuName; /** The lpsz class name. */ - public WString lpszClassName; + public String lpszClassName; /** The h icon sm. */ public HICON hIconSm; @@ -1059,7 +1058,7 @@ protected List getFieldOrder() { * * WindowProc is a placeholder for the application-defined function name. */ - public interface WindowProc extends Callback { + public interface WindowProc extends StdCallCallback { /** * @param hwnd @@ -1260,7 +1259,7 @@ protected List getFieldOrder() * display monitor. You can then paint into the device context in a manner that is optimal for the * display monitor. */ - public interface MONITORENUMPROC extends Callback + public interface MONITORENUMPROC extends StdCallCallback { /** * @param hMonitor A handle to the display monitor. This value will always be non-NULL. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java index 80ade8622d..c697f11a42 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winioctl.java @@ -15,12 +15,11 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.win32.StdCallLibrary; /** * Interface for the Winioctl.h header file. */ -public interface Winioctl extends StdCallLibrary { +public interface Winioctl { /** * Retrieves the device type, device number, and, for a partitionable device, the partition number of a device. diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java b/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java index 1f44d2e6a6..07933e60f6 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winnetwk.java @@ -19,8 +19,6 @@ import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.WString; -import com.sun.jna.win32.StdCallLibrary; /** * Ported from AccCtrl.h. Microsoft Windows SDK 7.1 @@ -28,7 +26,7 @@ * @author amarcionek[at]gmail.com */ -public abstract class Winnetwk implements StdCallLibrary { +public abstract class Winnetwk { /** * The scope of the enumeration. This member can be one of the following @@ -329,7 +327,7 @@ protected List getFieldOrder() { * character string that specifies the name of a local device. This * member is NULL if the connection does not use a device. */ - public WString lpLocalName; + public String lpLocalName; /** * If the entry is a network resource, this member is a pointer to a @@ -343,13 +341,13 @@ protected List getFieldOrder() { * The string can be MAX_PATH characters in length, and it must follow * the network provider's naming conventions */ - public WString lpRemoteName; + public String lpRemoteName; /** * A pointer to a NULL-terminated string that contains a comment * supplied by the network provider. */ - public WString lpComment; + public String lpComment; /** * A pointer to a NULL-terminated string that contains the name of the @@ -357,7 +355,7 @@ protected List getFieldOrder() { * provider name is unknown. To retrieve the provider name, you can call * the WNetGetProviderName function. */ - public WString lpProvider; + public String lpProvider; } // @@ -396,7 +394,7 @@ public UNIVERSAL_NAME_INFO(Pointer address) { * Pointer to the null-terminated UNC name string that identifies a * network resource. */ - public WString lpUniversalName; + public String lpUniversalName; @Override protected List getFieldOrder() { @@ -436,18 +434,18 @@ public REMOTE_NAME_INFO(Pointer address) { * Pointer to the null-terminated UNC name string that identifies a * network resource. */ - public WString lpUniversalName; + public String lpUniversalName; /** * Pointer to a null-terminated string that is the name of a network * connection. */ - public WString lpConnectionName; + public String lpConnectionName; /** * Pointer to a null-terminated name string. */ - public WString lpRemainingPath; + public String lpRemainingPath; @Override protected List getFieldOrder() { diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java index 4d3d16167b..822c00e7d9 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winspool.java @@ -93,7 +93,7 @@ public interface Winspool extends StdCallLibrary { int PRINTER_ENUM_HIDE = 0x01000000; Winspool INSTANCE = (Winspool) Native.loadLibrary("Winspool.drv", - Winspool.class, W32APIOptions.UNICODE_OPTIONS); + Winspool.class, W32APIOptions.DEFAULT_OPTIONS); /** * The EnumPrinters function enumerates available printers, print servers, diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java index b5e1916672..cc34077935 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Winsvc.java @@ -19,7 +19,6 @@ import com.sun.jna.Memory; import com.sun.jna.Structure; import com.sun.jna.platform.win32.WinNT.HANDLE; -import com.sun.jna.win32.StdCallLibrary; /** * This module defines the 32-Bit Windows types and constants that are defined @@ -28,7 +27,7 @@ * Microsoft Windows SDK 7.0A. * @author EugineLev */ -public interface Winsvc extends StdCallLibrary { +public interface Winsvc { /** * Contains status information for a service. The ControlService, EnumDependentServices, diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java index abe4e5d11f..e49a253875 100755 --- a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32Test.java @@ -44,7 +44,6 @@ import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.sun.jna.WString; import com.sun.jna.platform.win32.LMAccess.USER_INFO_1; import com.sun.jna.platform.win32.WinBase.FE_EXPORT_FUNC; import com.sun.jna.platform.win32.WinBase.FE_IMPORT_FUNC; @@ -73,7 +72,6 @@ import com.sun.jna.platform.win32.Winsvc.SC_HANDLE; import com.sun.jna.platform.win32.Winsvc.SC_STATUS_TYPE; import com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS; -import com.sun.jna.ptr.ByteByReference; import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.PointerByReference; @@ -387,8 +385,8 @@ public void testGetTokenGroupsInformation() { public void testImpersonateLoggedOnUser() { USER_INFO_1 userInfo = new USER_INFO_1(); - userInfo.usri1_name = new WString("JNAAdvapi32TestImp"); - userInfo.usri1_password = new WString("!JNAP$$Wrd0"); + userInfo.usri1_name = "JNAAdvapi32TestImp"; + userInfo.usri1_password = "!JNAP$$Wrd0"; userInfo.usri1_priv = LMAccess.USER_PRIV_USER; // ignore test if not able to add user (need to be administrator to do this). if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) { @@ -1306,7 +1304,7 @@ public void testAccessCheck() { public void testEncryptFile() throws Exception { // create a temp file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); // encrypt a read only file file.setWritable(false); @@ -1323,7 +1321,7 @@ public void testEncryptFile() throws Exception { public void testDecryptFile() throws Exception { // create an encrypted file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName)); // decrypt a read only file @@ -1343,7 +1341,7 @@ public void testFileEncryptionStatus() throws Exception { // create a temp file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); // unencrypted file assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(lpFileName, lpStatus)); @@ -1369,7 +1367,7 @@ public void testEncryptionDisable() throws Exception { // create a temp dir String filePath = System.getProperty("java.io.tmpdir") + File.separator + System.nanoTime(); - WString DirPath = new WString(filePath); + String DirPath = filePath; File dir = new File(filePath); dir.mkdir(); @@ -1397,7 +1395,7 @@ public void testEncryptionDisable() throws Exception { public void testOpenEncryptedFileRaw() throws Exception { // create an encrypted file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName)); // open file for export @@ -1413,7 +1411,7 @@ public void testOpenEncryptedFileRaw() throws Exception { public void testReadEncryptedFileRaw() throws Exception { // create an encrypted file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName)); // open file for export @@ -1426,9 +1424,12 @@ public void testReadEncryptedFileRaw() throws Exception { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); FE_EXPORT_FUNC pfExportCallback = new FE_EXPORT_FUNC() { @Override - public DWORD callback(ByteByReference pbData, Pointer + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONG ulLength) { - byte[] arr = pbData.getPointer().getByteArray(0, ulLength.intValue()); + if (pbData == null) { + throw new NullPointerException("Callback data unexpectedly missing"); + } + byte[] arr = pbData.getByteArray(0, ulLength.intValue()); try { outputStream.write(arr); } catch (IOException e) { @@ -1449,7 +1450,7 @@ public DWORD callback(ByteByReference pbData, Pointer public void testWriteEncryptedFileRaw() throws Exception { // create an encrypted file File file = createTempFile(); - WString lpFileName = new WString(file.getAbsolutePath()); + String lpFileName = file.getAbsolutePath(); assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName)); // open file for export @@ -1462,9 +1463,12 @@ public void testWriteEncryptedFileRaw() throws Exception { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); FE_EXPORT_FUNC pfExportCallback = new FE_EXPORT_FUNC() { @Override - public DWORD callback(ByteByReference pbData, Pointer + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONG ulLength) { - byte[] arr = pbData.getPointer().getByteArray(0, ulLength.intValue()); + if (pbData == null) { + throw new NullPointerException("Callback data unexpectedly null"); + } + byte[] arr = pbData.getByteArray(0, ulLength.intValue()); try { outputStream.write(arr); } catch (IOException e) { @@ -1480,8 +1484,8 @@ public DWORD callback(ByteByReference pbData, Pointer Advapi32.INSTANCE.CloseEncryptedFileRaw(pvContext.getValue()); // open file for import - WString lbFileName2 = new WString(System.getProperty("java.io.tmpdir") + - File.separator + "backup-" + file.getName()); + String lbFileName2 = System.getProperty("java.io.tmpdir") + + File.separator + "backup-" + file.getName(); ULONG ulFlags2 = new ULONG(CREATE_FOR_IMPORT); PointerByReference pvContext2 = new PointerByReference(); assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.OpenEncryptedFileRaw( @@ -1491,13 +1495,12 @@ public DWORD callback(ByteByReference pbData, Pointer final IntByReference elementsReadWrapper = new IntByReference(0); FE_IMPORT_FUNC pfImportCallback = new FE_IMPORT_FUNC() { @Override - public DWORD callback(ByteByReference pbData, Pointer pvCallbackContext, + public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONGByReference ulLength) { int elementsRead = elementsReadWrapper.getValue(); int remainingElements = outputStream.size() - elementsRead; int length = Math.min(remainingElements, ulLength.getValue().intValue()); - pbData.getPointer().write(0, outputStream.toByteArray(), elementsRead, - length); + pbData.write(0, outputStream.toByteArray(), elementsRead, length); elementsReadWrapper.setValue(elementsRead + length); ulLength.setValue(new ULONG(length)); return new DWORD(W32Errors.ERROR_SUCCESS); diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java index 5f0b38db79..0aa0aa6d3f 100755 --- a/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java @@ -19,7 +19,6 @@ import junit.framework.TestCase; -import com.sun.jna.WString; import com.sun.jna.platform.win32.Advapi32Util.Account; import com.sun.jna.platform.win32.Advapi32Util.EventLogIterator; import com.sun.jna.platform.win32.Advapi32Util.EventLogRecord; @@ -127,8 +126,8 @@ public void testGetCurrentUserGroups() { public void testGetUserGroups() { USER_INFO_1 userInfo = new USER_INFO_1(); - userInfo.usri1_name = new WString("JNANetapi32TestUser"); - userInfo.usri1_password = new WString("!JNAP$$Wrd0"); + userInfo.usri1_name = "JNANetapi32TestUser"; + userInfo.usri1_password = "!JNAP$$Wrd0"; userInfo.usri1_priv = LMAccess.USER_PRIV_USER; // ignore test if not able to add user (need to be administrator to do this). if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) { @@ -161,8 +160,8 @@ public void testGetUserGroups() { public void testGetUserAccount() { USER_INFO_1 userInfo = new USER_INFO_1(); - userInfo.usri1_name = new WString("JNANetapi32TestUser"); - userInfo.usri1_password = new WString("!JNAP$$Wrd0"); + userInfo.usri1_name = "JNANetapi32TestUser"; + userInfo.usri1_password = "!JNAP$$Wrd0"; userInfo.usri1_priv = LMAccess.USER_PRIV_USER; // ignore test if not able to add user (need to be administrator to do this). if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) { diff --git a/contrib/platform/test/com/sun/jna/platform/win32/COM/ShellApplicationWindowsTest.java b/contrib/platform/test/com/sun/jna/platform/win32/COM/ShellApplicationWindowsTest.java index 1d0bd8687f..9aa53769e8 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/COM/ShellApplicationWindowsTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/ShellApplicationWindowsTest.java @@ -29,7 +29,8 @@ public void testWindowsCount() // IE is open, so there should be at least one present. // More may exist if Windows Explorer windows are open. - assertTrue(sa.Windows().Count() > 0); + assertTrue("No shell application windows found", + sa.Windows().Count() > 0); boolean pageFound = false; for (InternetExplorer ie : sa.Windows()) @@ -43,7 +44,7 @@ public void testWindowsCount() } // Finally, did we find our page in the collection? - assertTrue(pageFound); + assertTrue("No IE page was found", pageFound); } @Override @@ -183,4 +184,7 @@ public String getURL() } } + public static void main(String[] args) { + junit.textui.TestRunner.run(ShellApplicationWindowsTest.class); + } } diff --git a/contrib/platform/test/com/sun/jna/platform/win32/MprTest.java b/contrib/platform/test/com/sun/jna/platform/win32/MprTest.java index 40bb22d45f..c174136911 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/MprTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/MprTest.java @@ -17,7 +17,6 @@ import java.io.File; import com.sun.jna.Memory; -import com.sun.jna.WString; import com.sun.jna.platform.win32.LMShare.SHARE_INFO_2; import com.sun.jna.platform.win32.WinNT.HANDLEByReference; import com.sun.jna.platform.win32.Winnetwk.ConnectFlag; @@ -43,14 +42,14 @@ public static void main(String[] args) throws Exception { public void testWNetUseConnection() throws Exception { // First create a share on the local machine File fileShareFolder = createTempFolder(); - WString share = createLocalShare(fileShareFolder); + String share = createLocalShare(fileShareFolder); NETRESOURCE resource = new NETRESOURCE(); resource.dwDisplayType = 0; resource.dwScope = 0; resource.dwType = RESOURCETYPE.RESOURCETYPE_DISK; - resource.lpRemoteName = new WString("\\\\" + getLocalComputerName() + "\\" + share); + resource.lpRemoteName = "\\\\" + getLocalComputerName() + "\\" + share; try { // Cancel any existing connections of the same name @@ -68,14 +67,14 @@ public void testWNetUseConnection() throws Exception { public void testWNetAddConnection3() throws Exception { // First create a share on the local machine File fileShareFolder = createTempFolder(); - WString share = createLocalShare(fileShareFolder); + String share = createLocalShare(fileShareFolder); NETRESOURCE resource = new NETRESOURCE(); resource.dwDisplayType = 0; resource.dwScope = 0; resource.dwType = RESOURCETYPE.RESOURCETYPE_DISK; - resource.lpRemoteName = new WString("\\\\" + getLocalComputerName() + "\\" + share); + resource.lpRemoteName = "\\\\" + getLocalComputerName() + "\\" + share; try { // Cancel any existing connections of the same name @@ -104,7 +103,7 @@ public void testWNetEnumConnection() throws Exception { // Create a local share and connect to it. This ensures the enum will // find at least one entry. File fileShareFolder = createTempFolder(); - WString share = createLocalShare(fileShareFolder); + String share = createLocalShare(fileShareFolder); // Connect to local share connectToLocalShare(share, null); @@ -155,7 +154,7 @@ public void testWNetEnumConnection() throws Exception { } finally { // Clean up resources Mpr.INSTANCE.WNetCloseEnum(lphEnum.getValue()); - disconnectFromLocalShare(new WString("\\\\" + getLocalComputerName() + "\\" + share)); + disconnectFromLocalShare("\\\\" + getLocalComputerName() + "\\" + share); deleteLocalShare(share); fileShareFolder.delete(); } @@ -166,7 +165,7 @@ public void testWNetGetUniversalName() throws Exception { Memory memory = new Memory(bufferSize); IntByReference lpBufferSize = new IntByReference(bufferSize); File file = null; - WString share = null; + String share = null; String driveLetter = new String("x:"); File fileShareFolder = createTempFolder(); @@ -174,7 +173,7 @@ public void testWNetGetUniversalName() throws Exception { // Create a local share and connect to it. share = createLocalShare(fileShareFolder); // Connect to share using a drive letter. - connectToLocalShare(share, new WString(driveLetter)); + connectToLocalShare(share, driveLetter); // Create a path on local device redirected to the share. String filePath = new String(driveLetter + "\\testfile.txt"); @@ -183,14 +182,14 @@ public void testWNetGetUniversalName() throws Exception { // Test WNetGetUniversalName using UNIVERSAL_NAME_INFO_LEVEL assertEquals(WinError.ERROR_SUCCESS, - Mpr.INSTANCE.WNetGetUniversalName(new WString(filePath), Winnetwk.UNIVERSAL_NAME_INFO_LEVEL, memory, lpBufferSize)); + Mpr.INSTANCE.WNetGetUniversalName(filePath, Winnetwk.UNIVERSAL_NAME_INFO_LEVEL, memory, lpBufferSize)); UNIVERSAL_NAME_INFO uinfo = new UNIVERSAL_NAME_INFO(memory); assertNotNull(uinfo.lpUniversalName); // Test WNetGetUniversalName using REMOTE_NAME_INFO_LEVEL assertEquals(WinError.ERROR_SUCCESS, - Mpr.INSTANCE.WNetGetUniversalName(new WString(filePath), Winnetwk.REMOTE_NAME_INFO_LEVEL, memory, lpBufferSize)); + Mpr.INSTANCE.WNetGetUniversalName(filePath, Winnetwk.REMOTE_NAME_INFO_LEVEL, memory, lpBufferSize)); REMOTE_NAME_INFO rinfo = new REMOTE_NAME_INFO(memory); assertNotNull(rinfo.lpUniversalName); @@ -201,7 +200,7 @@ public void testWNetGetUniversalName() throws Exception { if (file != null) file.delete(); if (share != null) { - disconnectFromLocalShare(new WString(driveLetter)); + disconnectFromLocalShare(driveLetter); deleteLocalShare(share); fileShareFolder.delete(); } @@ -242,22 +241,22 @@ private String getLocalComputerName() throws Exception { * * @param shareFolder * the full path local folder to share - * @return WString with the share name, essentially the top level folder + * @return String with the share name, essentially the top level folder * name. * @throws Exception * the exception */ - private WString createLocalShare(File shareFolder) throws Exception { + private String createLocalShare(File shareFolder) throws Exception { SHARE_INFO_2 shi = new SHARE_INFO_2(); - shi.shi2_netname = new WString(shareFolder.getName()); + shi.shi2_netname = shareFolder.getName(); shi.shi2_type = LMShare.STYPE_DISKTREE; - shi.shi2_remark = new WString(""); + shi.shi2_remark = ""; shi.shi2_permissions = LMAccess.ACCESS_ALL; shi.shi2_max_uses = -1; shi.shi2_current_uses = 0; - shi.shi2_path = new WString(shareFolder.getAbsolutePath()); - shi.shi2_passwd = new WString(""); + shi.shi2_path = shareFolder.getAbsolutePath(); + shi.shi2_passwd = ""; // Write from struct to native memory. shi.write(); @@ -268,7 +267,7 @@ private WString createLocalShare(File shareFolder) throws Exception { // computer 2, shi.getPointer(), parm_err)); - return new WString(shareFolder.getName()); + return shareFolder.getName(); } /** @@ -276,7 +275,7 @@ private WString createLocalShare(File shareFolder) throws Exception { * * @param share */ - private void deleteLocalShare(WString share) { + private void deleteLocalShare(String share) { Netapi32.INSTANCE.NetShareDel(null, share, 0); } @@ -292,14 +291,14 @@ private void deleteLocalShare(WString share) { * @throws Exception * the exception */ - private void connectToLocalShare(WString share, WString lpLocalName) throws Exception { + private void connectToLocalShare(String share, String lpLocalName) throws Exception { NETRESOURCE resource = new NETRESOURCE(); resource.dwDisplayType = 0; resource.dwScope = 0; resource.dwType = RESOURCETYPE.RESOURCETYPE_DISK; resource.lpLocalName = lpLocalName; - resource.lpRemoteName = new WString("\\\\" + getLocalComputerName() + "\\" + share); + resource.lpRemoteName = "\\\\" + getLocalComputerName() + "\\" + share; // Establish connection assertEquals(WinError.ERROR_SUCCESS, Mpr.INSTANCE.WNetAddConnection3(null, resource, null, null, 0)); @@ -317,8 +316,8 @@ private void connectToLocalShare(WString share, WString lpLocalName) throws Exce * parameter specifies a remote network resource, all connections * without devices are canceled. */ - private void disconnectFromLocalShare(WString lpName) { + private void disconnectFromLocalShare(String lpName) { // Remove connection Mpr.INSTANCE.WNetCancelConnection2(lpName, ConnectFlag.CONNECT_UPDATE_PROFILE, true); } -} \ No newline at end of file +} diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java index 5ef332b432..0e1c269949 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java @@ -14,7 +14,6 @@ import java.io.File; -import com.sun.jna.WString; import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS; import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; import com.sun.jna.platform.win32.LMAccess.GROUP_INFO_2; @@ -150,8 +149,8 @@ public void testNetUserEnum() { public void testNetUserAdd() { USER_INFO_1 userInfo = new USER_INFO_1(); - userInfo.usri1_name = new WString("JNANetapi32TestUser"); - userInfo.usri1_password = new WString("!JNAP$$Wrd0"); + userInfo.usri1_name = "JNANetapi32TestUser"; + userInfo.usri1_password = "!JNAP$$Wrd0"; userInfo.usri1_priv = LMAccess.USER_PRIV_USER; // ignore test if not able to add user (need to be administrator to do this). if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) { @@ -163,8 +162,8 @@ public void testNetUserAdd() { public void testNetUserChangePassword() { USER_INFO_1 userInfo = new USER_INFO_1(); - userInfo.usri1_name = new WString("JNANetapi32TestUser"); - userInfo.usri1_password = new WString("!JNAP$$Wrd0"); + userInfo.usri1_name = "JNANetapi32TestUser"; + userInfo.usri1_password = "!JNAP$$Wrd0"; userInfo.usri1_priv = LMAccess.USER_PRIV_USER; // ignore test if not able to add user (need to be administrator to do this). if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) { @@ -266,14 +265,14 @@ public void testNetShareAddShareInfo2() throws Exception { File fileShareFolder = createTempFolder(); SHARE_INFO_2 shi = new SHARE_INFO_2(); - shi.shi2_netname = new WString(fileShareFolder.getName()); + shi.shi2_netname = fileShareFolder.getName(); shi.shi2_type = LMShare.STYPE_DISKTREE; - shi.shi2_remark = new WString(""); + shi.shi2_remark = ""; shi.shi2_permissions = LMAccess.ACCESS_ALL; shi.shi2_max_uses = -1; shi.shi2_current_uses = 0; - shi.shi2_path = new WString(fileShareFolder.getAbsolutePath()); - shi.shi2_passwd = new WString(""); + shi.shi2_path = fileShareFolder.getAbsolutePath(); + shi.shi2_passwd = ""; // Write from struct to native memory. shi.write(); @@ -297,13 +296,13 @@ public void testNetShareAddShareInfo502() throws Exception { File fileShareFolder = createTempFolder(); SHARE_INFO_502 shi = new SHARE_INFO_502(); - shi.shi502_netname = new WString(fileShareFolder.getName()); + shi.shi502_netname = fileShareFolder.getName(); shi.shi502_type = LMShare.STYPE_DISKTREE; - shi.shi502_remark = new WString(""); + shi.shi502_remark = ""; shi.shi502_permissions = LMAccess.ACCESS_ALL; shi.shi502_max_uses = -1; shi.shi502_current_uses = 0; - shi.shi502_path = new WString(fileShareFolder.getAbsolutePath()); + shi.shi502_path = fileShareFolder.getAbsolutePath(); shi.shi502_passwd = null; shi.shi502_reserved = 0; shi.shi502_security_descriptor = null; @@ -330,14 +329,14 @@ public void testNetShareDel() throws Exception { File fileShareFolder = createTempFolder(); SHARE_INFO_2 shi = new SHARE_INFO_2(); - shi.shi2_netname = new WString(fileShareFolder.getName()); + shi.shi2_netname = fileShareFolder.getName(); shi.shi2_type = LMShare.STYPE_DISKTREE; - shi.shi2_remark = new WString(""); + shi.shi2_remark = ""; shi.shi2_permissions = LMAccess.ACCESS_ALL; shi.shi2_max_uses = -1; shi.shi2_current_uses = 0; - shi.shi2_path = new WString(fileShareFolder.getAbsolutePath()); - shi.shi2_passwd = new WString(""); + shi.shi2_path = fileShareFolder.getAbsolutePath(); + shi.shi2_passwd = ""; // Write from struct to native memory. shi.write(); diff --git a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java index 6e2e43f7bf..e6b24afa0f 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/User32Test.java @@ -35,6 +35,8 @@ import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; +import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinDef.POINT; import com.sun.jna.platform.win32.WinDef.RECT; import com.sun.jna.platform.win32.WinDef.UINT; @@ -45,6 +47,7 @@ import com.sun.jna.platform.win32.WinUser.MONITORENUMPROC; import com.sun.jna.platform.win32.WinUser.MONITORINFO; import com.sun.jna.platform.win32.WinUser.MONITORINFOEX; +import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; /** * @author dblock[at]dblock[dot]org @@ -281,9 +284,12 @@ public void testSendMessageTimeout() { assertNotNull(explorerProc); final DWORDByReference hIconNumber = new DWORDByReference(); - long result = User32.INSTANCE.SendMessageTimeout( - explorerProc.getHWND(), WinUser.WM_GETICON, WinUser.ICON_BIG, - 0, WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); + LRESULT result = User32.INSTANCE + .SendMessageTimeout(explorerProc.getHWND(), + WinUser.WM_GETICON, + new WPARAM(WinUser.ICON_BIG), + new LPARAM(0), + WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); assertNotEquals(0, result); } @@ -292,12 +298,14 @@ public void testSendMessageTimeout() { public void testGetClassLongPtr() { DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe"); - assertNotNull(explorerProc); + assertNotNull("Could not find explorer.exe process", + explorerProc); - long result = User32.INSTANCE.GetClassLongPtr(explorerProc.getHWND(), - WinUser.GCLP_HMODULE); + ULONG_PTR result = User32.INSTANCE + .GetClassLongPtr(explorerProc.getHWND(), + WinUser.GCLP_HMODULE); - assertNotEquals(0, result); + assertNotEquals(0, result.intValue()); } @Test diff --git a/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java b/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java index a82c81d425..98c1867afd 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/WindowUtilsTest.java @@ -26,6 +26,9 @@ import com.sun.jna.platform.win32.WinDef.DWORDByReference; import com.sun.jna.platform.win32.WinDef.HICON; import com.sun.jna.platform.win32.WinDef.HWND; +import com.sun.jna.platform.win32.WinDef.LPARAM; +import com.sun.jna.platform.win32.WinDef.LRESULT; +import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinUser; public class WindowUtilsTest extends TestCase { @@ -36,9 +39,10 @@ public void testGetAllWindows() { final List allVisibleWindows = WindowUtils .getAllWindows(true); - assertTrue(allWindows.size() > 0); - assertTrue(allVisibleWindows.size() > 0); - assertTrue(allWindows.size() > allVisibleWindows.size()); + assertTrue("Found no windows", allWindows.size() > 0); + assertTrue("Found no visible windows", allVisibleWindows.size() > 0); + assertTrue("Expected more non-visible windows than visible windows", + allWindows.size() > allVisibleWindows.size()); DesktopWindow explorerProc = null; for (final DesktopWindow dw : allWindows) { @@ -48,7 +52,8 @@ public void testGetAllWindows() { } } - assertNotNull(explorerProc); + assertNotNull("explorer.exe was not found among all windows", + explorerProc); explorerProc = null; for (final DesktopWindow dw : allVisibleWindows) { @@ -58,7 +63,8 @@ public void testGetAllWindows() { } } - assertNotNull(explorerProc); + assertNotNull("explorer.exe was not found among visible windows", + explorerProc); } public void testGetWindowIcon() throws Exception { @@ -70,8 +76,9 @@ public void testGetWindowIcon() throws Exception { "/res/test_icon.png").getPath()))); w.setIconImage(expectedIcon); w.setVisible(true); - HWND hwnd = new HWND(); - hwnd.setPointer(Native.getComponentPointer(w)); + Pointer p = Native.getComponentPointer(w); + assertNotNull("Couldn't obtain window HANDLE from JFrame", p); + HWND hwnd = new HWND(p); final BufferedImage obtainedIcon = WindowUtils.getWindowIcon(hwnd); @@ -149,15 +156,18 @@ public void testGetIconSize() throws Exception { .read(new FileInputStream(new File(getClass().getResource("/res/test_icon.png").getPath()))); w.setIconImage(expectedIcon); w.setVisible(true); - HWND hwnd = new HWND(); - hwnd.setPointer(Native.getComponentPointer(w)); + Pointer p = Native.getComponentPointer(w); + assertNotNull("Could not obtain native HANDLE for JFrame", p); + HWND hwnd = new HWND(p); final DWORDByReference hIconNumber = new DWORDByReference(); - long result = User32.INSTANCE.SendMessageTimeout(hwnd, - WinUser.WM_GETICON, WinUser.ICON_BIG, 0, - WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); + LRESULT result = User32.INSTANCE + .SendMessageTimeout(hwnd, WinUser.WM_GETICON, + new WPARAM(WinUser.ICON_BIG), + new LPARAM(0), + WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber); - assertNotEquals(0, result); + assertNotEquals(0, result.intValue()); final HICON hIcon = new HICON(new Pointer(hIconNumber.getValue() .longValue()));