diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml index 8c0751775e1e..d9fed3852d8f 100644 --- a/.idea/libraries/jna.xml +++ b/.idea/libraries/jna.xml @@ -5,6 +5,9 @@ - + + + + \ No newline at end of file diff --git a/lib/jna-utils.jar b/lib/jna-utils.jar index 8f0b45741f89..b55af7e488cc 100644 Binary files a/lib/jna-utils.jar and b/lib/jna-utils.jar differ diff --git a/lib/jna.jar b/lib/jna.jar index a0e8fe576c5f..55ca1eb4e308 100644 Binary files a/lib/jna.jar and b/lib/jna.jar differ diff --git a/lib/src/jna-src.zip b/lib/src/jna-src.zip new file mode 100755 index 000000000000..dac93dc5e947 Binary files /dev/null and b/lib/src/jna-src.zip differ diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/W32API.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/W32API.java new file mode 100644 index 000000000000..fc0d7aa0c5bb --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/W32API.java @@ -0,0 +1,163 @@ +/* Copyright (c) 2007 Timothy Wall, All Rights Reserved + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package com.intellij.ide.passwordSafe.impl.providers.masterKey.windows; + +import com.sun.jna.FromNativeContext; +import com.sun.jna.IntegerType; +import com.sun.jna.Native; +import com.sun.jna.NativeLong; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; +import com.sun.jna.ptr.ByReference; +import com.sun.jna.win32.StdCallLibrary; + +/** Base type for most W32 API libraries. Provides standard options + * for unicode/ASCII mappings. Set the system property w32.ascii + * to true to default to the ASCII mappings. + */ +@SuppressWarnings("serial") +public interface W32API extends StdCallLibrary { + class HANDLE extends PointerType { + private boolean immutable; + public HANDLE() { } + public HANDLE(Pointer p) { setPointer(p); immutable = true; } + + /** Override to the appropriate object for INVALID_HANDLE_VALUE. */ + public Object fromNative(Object nativeValue, FromNativeContext context) { + Object o = super.fromNative(nativeValue, context); + if (INVALID_HANDLE_VALUE.equals(o)) + return INVALID_HANDLE_VALUE; + return o; + } + + public void setPointer(Pointer p) { + if (immutable) + throw new UnsupportedOperationException("immutable reference"); + super.setPointer(p); + } + } + + class WORD extends IntegerType { + public WORD() { this(0); } + public WORD(long value) { super(2, value); } + } + + class DWORD extends IntegerType { + public DWORD() { this(0); } + public DWORD(long value) { super(4, value); } + } + + class LONG extends IntegerType { + public LONG() { this(0); } + public LONG(long value) { super(Native.LONG_SIZE, value); } + } + + class HDC extends HANDLE { } + class HICON extends HANDLE { } + class HBITMAP extends HANDLE { } + class HRGN extends HANDLE { } + class HWND extends HANDLE { + public HWND() { } + public HWND(Pointer p) { super(p); } + } + class HINSTANCE extends HANDLE { } + class HMODULE extends HINSTANCE { } + + /** + * The HRESULT data type is a 32-bit value is used to describe an error or warning. + */ + class HRESULT extends NativeLong { + public HRESULT() { + + } + + public HRESULT(int value) { + super(value); + } + } + + /** Constant value representing an invalid HANDLE. */ + HANDLE INVALID_HANDLE_VALUE = new HANDLE(Pointer.createConstant(Pointer.SIZE==8?-1:0xFFFFFFFFL)); + + /** Special HWND value. */ + HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF)); + + /** LPHANDLE */ + class HANDLEByReference extends ByReference { + + public HANDLEByReference() { + this(null); + } + + public HANDLEByReference(HANDLE h) { + super(Pointer.SIZE); + setValue(h); + } + + public void setValue(HANDLE h) { + getPointer().setPointer(0, h != null ? h.getPointer() : null); + } + + public HANDLE getValue() { + Pointer p = getPointer().getPointer(0); + if (p == null) + return null; + if (INVALID_HANDLE_VALUE.getPointer().equals(p)) + return INVALID_HANDLE_VALUE; + HANDLE h = new HANDLE(); + h.setPointer(p); + return h; + } + } + + class LONG_PTR extends IntegerType { + public LONG_PTR() { this(0); } + public LONG_PTR(long value) { super(Pointer.SIZE, value); } + } + + class SSIZE_T extends LONG_PTR { + public SSIZE_T() { this(0); } + public SSIZE_T(long value) { super(value); } + } + + class ULONG_PTR extends IntegerType { + public ULONG_PTR() { this(0); } + public ULONG_PTR(long value) { super(Pointer.SIZE, value); } + } + + class SIZE_T extends ULONG_PTR { + public SIZE_T() { this(0); } + public SIZE_T(long value) { super(value); } + } + + class LPARAM extends LONG_PTR { + public LPARAM() { this(0); } + public LPARAM(long value) { super(value); } + } + + class LRESULT extends LONG_PTR { + public LRESULT() { this(0); } + public LRESULT(long value) { super(value); } + } + + class UINT_PTR extends IntegerType { + public UINT_PTR() { super(Pointer.SIZE); } + public UINT_PTR(long value) { super(Pointer.SIZE, value); } + public Pointer toPointer() { return Pointer.createConstant(longValue()); } + } + + class WPARAM extends UINT_PTR { + public WPARAM() { this(0); } + public WPARAM(long value) { super(value); } + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java index 17a8e5b57bff..262f177ac561 100644 --- a/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java +++ b/platform/platform-impl/src/com/intellij/ide/passwordSafe/impl/providers/masterKey/windows/WindowsCryptUtils.java @@ -20,7 +20,6 @@ import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; -import com.sun.jna.examples.win32.W32API; import com.sun.jna.win32.StdCallLibrary; import com.sun.jna.win32.W32APIFunctionMapper; import com.sun.jna.win32.W32APITypeMapper; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java index 857dd02ae020..9b08925a7be2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.java @@ -44,7 +44,7 @@ import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import com.intellij.util.EventDispatcher; import com.intellij.util.ui.UIUtil; -import com.sun.jna.examples.WindowUtils; +import com.sun.jna.platform.WindowUtils; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull;