Comparar commits

..

506 Commits

Autor SHA1 Mensagem Data
Daniel Doubrovkine 4268e3a1d2 Release 3.2.5.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1062 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-06 15:32:21 +00:00
Daniel Doubrovkine 860b9a266a Fixed demo builds to make .jar files double-clickable.
Added eclipse project to www.
Documented platform.jar in site.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1061 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-06 15:14:53 +00:00
Daniel Doubrovkine c39d752ccb Added Netapi32.DsGetDcName, DsGetForestTrustInformation and DsEnumerateDomainTrusts.
Ported some of DsGetDC.h and NTSecApi.h.
Bug: Netapi32Util.getDCName returns wrong value.
Bug: Netapi32Util.getCurrentUserLocalGroups doesn't work for a user logged onto a domain.
Added WinNT.LARGE_INTEGER.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1060 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-02 17:05:27 +00:00
Daniel Doubrovkine 15db1cf385 Updated release notes with all the win32/platform changes.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1059 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-01 15:47:49 +00:00
Daniel Doubrovkine 38d684d1e6 Used generics for several existing utility classes, fixing warnings (platform is built with Java 1.5+). Split FileUtils into win32, mac specifics so we can write os-based unit tests just like W32FileMinotorTest.
Fixed exception in W32FileMonitor which throws an unhandled exception when disposing because the watched handle is closed.
Modified W32FileUtils and ShellAPI's SHFILEOPSTRUCT to support unicode paths.
Fixed ShellApi structure alignment introduced in a previous check-in.
Readded LastErrorException string constructor.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1058 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-01 12:59:08 +00:00
Daniel Doubrovkine ccb1bc514b Split FileMonitor and W32FileMinitor into different namespaces, removed isWindows hack in the tests.
Added Kernel32.GetTempPath and Kernel32Util.getTempPath.
Added missing copyright notices.
Divided Shell32 into ShellApi (ported from ShellApi.h), ShlObj (ported from ShlObj.h).
Added Shell32Util.getFolderPath.
Added WinDef (ported from Windef.h) with MAX_PATH.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1057 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-31 15:47:04 +00:00
Daniel Doubrovkine 27c46a2c8e Added Kernel32Util.FormatMessageFromLastError and FormatMessageFromHR.
Added Win32Exception that properly maps system error messages, to be used in Win32 util classes instead of LastErrorException that's a cross-platform version that doesn't try to format the string error.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1056 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-31 14:08:25 +00:00
Daniel Doubrovkine ff2f1d237a Added Ole32.CoCreateGuid, StringFromGUID2 and IIDFromString.
Added Ole32Util.getGUIDFromString, getStringFromGUID and generateGUID.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1055 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-30 23:09:26 +00:00
Daniel Doubrovkine 402f4c162c Added Secur32.QuerySecurityContextToken.
Added Sspi.PSecHandle.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1054 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-30 21:45:14 +00:00
Daniel Doubrovkine 81013a98b4 Added Secur32.EnumerateSecurityPackages and FreeContextBuffer.
Added Secur32Util.getSecurityPackages.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1053 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-29 17:51:58 +00:00
Daniel Doubrovkine 971dd622c7 Added Sspi.java, ported from sspi.h.
Added Secur32.AcquireCredentialsHandle, InitializeSecurityContext, DeleteSecurityContext, AcceptSecurityContext.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1052 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-26 13:11:30 +00:00
Daniel Doubrovkine 0045d31e2d Added Crypt32.CryptProtectData and CryptUnprotectData.
Added WinCrypt, ported from WinCrypt.h.
Added Crypt32Util.cryptProtectData and cryptUnprotectData.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1051 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-24 14:44:30 +00:00
Daniel Doubrovkine caef8f4ebc Added Advapi32Util.registryGetKeys and registryGetValues.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1050 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-24 11:51:53 +00:00
Daniel Doubrovkine 6116c1ae71 Moved definitions from Kernel32 into WinNT where they belong.
Added Advapi32.RegOpenKeyEx, RegQueryValueEx, RegCloseKey, RegDeleteValue, RegSetValueEx, RegCreateKeyEx, RegDeleteKey, RegEnumKeyEx, RegEnumValue, RegQueryInfoKey.
Added Advapi32Util.registryKeyExists, registryValueExists, registryGetStringValue, registryGetIntValue, registryCreateKey, registrySetIntValue, registrySetStringValue, registryDeleteKey, registryDeleteValue.
Added missing documentation in Kernel32.
Added Wdm, NtDll.ZwQueryKey and NtDllUtil.getKeyName.
Added WinReg and REG* definitions from WinNT.h.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1049 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-23 18:05:45 +00:00
Timothy Wall 03ecf2b0bb use 1.4-compatible URI generation
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1048 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-23 02:43:55 +00:00
Daniel Doubrovkine d4a5005273 Wrong comment.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1047 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-21 15:17:32 +00:00
Daniel Doubrovkine 7522f29f0a Commented out impersonation test. Wild guess on which one's failing.
Fixed warnings with function parameter names.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1046 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-21 14:59:18 +00:00
Daniel Doubrovkine 09f0a2e4a6 Added Advapi32.ImpersonateLoggedOnUser and RevertToSelf.
Added Advapi32Util.GetTokenGroups, GetTokenAccount.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1045 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-18 03:52:45 +00:00
Daniel Doubrovkine aa846929f3 Added LMAccess GROUP_USERS_INFO_*, LOCALGROUP_USERS_INFO_*, GROUP_INFO_* and USE_PRIV* masks.
Added Netapi32.NetGroupEnum, NetUserEnum, NetUserGetGroups, NetUserGetLocalGroups, NetUserAdd, NetUserDel and NetUserChangePassword.
Added Netapi32Util.getGlobalGroups, getUsers, getUserLocalGroups, getCurrentUserGroups, getUserGroups.
Fixed tmp location to try to get windows tmp for File monitor test.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1044 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-16 21:59:16 +00:00
Daniel Doubrovkine b378af7cb1 Refactored Advapi32Util getAccount* functions to getAccountByName and getAccountBySid returning an Account structure.
Added Advapi32Util.getCurrentUserGroups.
Added LMAccess LOCALGROUP_INFO_1, USER_INFO_0 and USER_INFO_1.
Refactored Netapi32Util.getLocalGroups to return a Group structure.
Added WinNT TOKEN_GROUPS, SID_NAME_USE and SID_AND_ATTRIBUTES.
 

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1043 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-16 12:19:14 +00:00
Daniel Doubrovkine 8b549a487f Replaced SID references by PSID, PSIDByReference and PSID.ByReference.
Added Advapi32.IsValidSid, OpenProcessToken, DuplicateToken and GetTokenInformation.
Added WinNT.SECURITY_IMPERSONATION_LEVEL, TOKEN_INFORMATION_CLASS, SID_AND_ATTRIBUTES, TOKEN_OWNER, PSID, PSID_BY_REFERENCE, TOKEN_USER.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1042 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-12 23:11:17 +00:00
Daniel Doubrovkine 005f659eaa Renamed jnacontrib-*.jars to demo-*.jar for demos.
Added Advapi32.OpenThreadToken.
Added Kernel32.OpenThread, OpenProcess and some documentation for tested functions.
Added WinNT.java, ported from winnt.h for thread and token access defitions.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1041 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-10 17:09:03 +00:00
Daniel Doubrovkine a5aad94f24 Build break: chicken-and-egg problem of depending on dist/jna.jar.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1040 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-10 14:41:48 +00:00
Daniel Doubrovkine 52a6926da3 Added eclipse and ANT projects for all contrib folders. All build and run.
JnaContrib projects drop a jnacontrib-*.jar into dist.
Deleted leftover private settings in ntservice.
Added Advapi32.LogonUser.
Removed throws Exception in Advapi32Util.
Got rid of obsolete w32util.jar.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1039 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-10 14:12:28 +00:00
Daniel Doubrovkine b3c0f003bb Don't run win32 tests on unix.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1038 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 23:48:54 +00:00
Daniel Doubrovkine 3d2360bc56 Merged platformutil and jna.platform into a contrib/platform package.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1037 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 23:17:55 +00:00
Daniel Doubrovkine 1267f51d8c Fixed typo in build.xml.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1036 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 18:15:34 +00:00
Daniel Doubrovkine e7328001a4 Got rid of w32util and moved its code to platformutil...win32.
Now platformutil is all of specific and cross-platform APIs.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1035 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 18:12:14 +00:00
Daniel Doubrovkine fc7b53e809 Got rid of examples.jar, split into several packages.
# platform apis - com.sun.jna.platform.*, part of jna.jar.
# platform wrappers and utilities (FileMonitor, KeyboardUtils, etc.) - contrib/com.sun.jna.platformutil, new platformutil.jar.
# demo and sample code - contrib/<new project for each demo>


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1034 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 17:56:58 +00:00
Daniel Doubrovkine 50637cb3c2 - Advapi32Util.getAccountName now always returns a fully qualified name.
- Added Kernel32Util with getComputerName.
- Added Netapi32Util.getDCName and getJoinStatus.
- Added Kernel32.GetComputerName
- Doc-ed some functions in Kernel32
- Added Netapi32.NetGetDCName
- Added Winbase with MAX_COMPUTER_NAME
- Added Kernel32.WaitForMultipleObjects

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1033 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-03-09 12:31:25 +00:00
Daniel Doubrovkine 11b4203874 Fixed w32util.jar distribution.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1032 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-24 22:37:53 +00:00
Daniel Doubrovkine 60beb432eb Running tests on windows only.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1031 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-24 21:00:21 +00:00
Daniel Doubrovkine 64331c9cf0 - Fixed eclipse build by adding an eclipse .project for contrib/src/w32util.
- Added W32util standalone build.xml, invoked from jna build.xml.
- Made all example.win32-s UNICODE.
- Ported Advapi32.LookupAccountName, LookupAccountSid from the NT service example to examples.win32 (pinvoke) and contrib.win32util (wrappers). Added tests for both pinvoke functions and wrappers.
- Renamed utility functions to lowercase for consistency in contrib.w32util.
- Added w32util.getAccountSid, getAccountName, convertSidStringToSid, 
convertSidToStringSid, etc. Fixed a crash in the converts.
- Added Netapi32Util.getLocalGroups.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1030 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-24 19:59:16 +00:00
Timothy Wall 00088d4093 add 'int' version of Pointer.createConstant
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1029 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-23 20:16:19 +00:00
Timothy Wall 472f3660e0 add test for INVALID_HANDLE_VALUE, add explicit long value
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1028 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-23 20:11:50 +00:00
Daniel Doubrovkine 3c13cc8c4d Added contrib folder to build, moved source into src and added test. Tests run in test targets.
Added w32util jar.
Fixed crash in Netapi32Test.
Fixed comment in Advapi32.java.
Moved baloontips into a package.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1027 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-23 16:01:30 +00:00
Timothy Wall 0792ac8eee fix INVALID_HANDLE_VALUE (64-bit)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1026 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-23 14:17:13 +00:00
Timothy Wall 4952af4ffe Fix INVALID_HANDLE_VALUE
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1025 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-23 14:14:54 +00:00
Daniel Doubrovkine 3fcca7ef56 Tentative fix for the broken Secur32Test UT: looks like on some OSs GetUserNAmeEx returns true when passed a null buffer and a size? Also fixed documentation warnings.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1024 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-22 23:50:01 +00:00
Daniel Doubrovkine e93244fef2 Advapi32:
GetUserNameW
 LookupAccountNameW
 ConvertSidToStringSidW
 ConvertStringSidToSidW
 GetLengthSid

Netapi32:
 NetGetJoinInformation
 NetApiBufferFree

Secur32:
 GetUserNameExW

W32Errors:
 Almost full port of winerror.h

Advapi32Util:
 GetUserName
 LookupAccountName
 ConvertSidToStringSid

Netapi32Util:
 GetDomainName

Secur32Util
 GetUserNameEx

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1023 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-02-22 22:54:09 +00:00
Timothy Wall acf75ce7fe fix read of NIO Buffer fields within structure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1022 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-01-05 01:46:27 +00:00
philke 7560b6e53d added import java.util.Date;
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1021 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-12-21 18:57:12 +00:00
philke f5346bbec2 Removed @Override annotation to comply with 1.4 source code level
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1020 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-12-21 17:31:22 +00:00
philke 41958889fb Added FILETIME
Added functions for File Mapping
Added functions for Event handling
Added LocalAlloc

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1019 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-12-21 16:48:44 +00:00
Timothy Wall d439a7811d avoid auto-allocating structure memory if memory already provided
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1018 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-12-18 15:55:59 +00:00
Timothy Wall 4951c00d23 Ensure inherited structure fields are properly ordered
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1017 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-12-04 14:38:19 +00:00
Timothy Wall 202cd0d45e update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1015 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-11-20 13:57:19 +00:00
Timothy Wall 1502db6095 build 3.2.4
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1014 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-11-20 13:55:41 +00:00
Timothy Wall e8eea9e68e Fix issue 135
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1013 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-29 13:24:51 +00:00
Timothy Wall 396eb9f283 add linux/ia64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1012 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-29 13:15:22 +00:00
Dan Rollo 378f400226 increase ServerSocket timeout again. Further testing on pokey machine shows jnlp download time ~30secs, and verify/launch time also ~30secs. Two minutes should be plenty, even on the worst of days.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1011 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-25 01:23:06 +00:00
Dan Rollo 37e02dfbd5 increase ServerSocket timeout in attempt to make test tolerant of very slow machine.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1010 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-25 00:31:11 +00:00
Dan Rollo dce66ec8ec remove unused variables and unused imports
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1009 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-25 00:29:53 +00:00
Timothy Wall 2fef67a08d provide easier mapping from native pointer to Function object
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1008 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-24 15:43:53 +00:00
Timothy Wall 50a17583c7 include clover.jar in full source zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1007 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-20 14:54:18 +00:00
Timothy Wall bfe2c7df83 add COM to FAQ
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1006 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-16 13:08:02 +00:00
Timothy Wall b3186dde12 update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1005 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-08 19:14:59 +00:00
Timothy Wall 628a33eb76 update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1004 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-08 19:12:24 +00:00
Timothy Wall 4373e66b1e 3.2.3 release
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1002 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-08 19:03:44 +00:00
Timothy Wall 2e67b0ad9f update netbeans project
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1001 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-08 18:54:59 +00:00
Timothy Wall a4cbe0635f ensure version information is always available
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1000 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-08 18:54:07 +00:00
Timothy Wall 8563419280 note OSX
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@999 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-07 12:43:19 +00:00
Timothy Wall 0974bd4a90 properly include Java sources in maven source zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@998 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-07 12:39:28 +00:00
Timothy Wall e1d47adc99 add note for OSX under JNLP
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@997 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-07 12:33:02 +00:00
Timothy Wall e5e171d913 fix TrayIcon mouseover exception in WindowUtils
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@996 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-04 01:01:54 +00:00
Timothy Wall 1e313227b8 remove apple-specific reference
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@995 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-03 23:42:01 +00:00
Timothy Wall 8d45a9e0cd fix transparent window toggle on OSX
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@994 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-02 20:02:00 +00:00
Timothy Wall 95568d76d3 fix win32 bug toggling windows transparent/opaque
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@993 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-02 18:51:03 +00:00
Timothy Wall d4a3442468 avoid overwriting unmodified Pointer objects
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@992 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-10-02 17:55:11 +00:00
Timothy Wall e262de22ea fix type declarations
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@991 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-29 20:30:15 +00:00
Timothy Wall 49243f1891 fix web start native library loading bugs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@990 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-21 17:10:56 +00:00
Timothy Wall 1a099ba549 no need to set layers transparent on osx
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@989 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-20 21:39:39 +00:00
Timothy Wall 2367133b4f move double buffer handling to a more appropriate location
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@988 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-17 13:15:12 +00:00
Timothy Wall c648a1933d fix double buffering bug on transparent windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@987 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-17 12:55:14 +00:00
Timothy Wall 598acf08da fix bug reading Structure.ByReference fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@986 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-14 12:46:08 +00:00
Timothy Wall 208a8dee90 fix email address
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@985 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-09-14 12:37:18 +00:00
Timothy Wall e9fb299565 fix comments/javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@984 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-20 12:10:30 +00:00
Timothy Wall 17a514ecd0 avoid writing final Structure fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@983 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-07 14:18:32 +00:00
Timothy Wall 38ac62cedd build 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@981 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-05 17:14:24 +00:00
Timothy Wall ce280731af only set javawebstart.version if not already set
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@980 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-05 14:17:37 +00:00
Timothy Wall 751fb57f71 fix web start test under NetX
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@979 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-05 14:07:41 +00:00
Timothy Wall be7d90abbf add length-specified Pointer.getStringArray()
update sunos-amd64.jar native
remove debug output

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@978 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-05 12:15:01 +00:00
Timothy Wall d59585dd4f update natives to 3.2.1
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@977 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-04 15:49:17 +00:00
Timothy Wall 7a695707a2 avoid potential error if dispatch fails due to bad arguments
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@976 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-04 14:01:06 +00:00
Timothy Wall 4e590c9450 fix issue 125
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@975 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-04 13:55:59 +00:00
Timothy Wall b069d1c9e9 add direct version of struct by value tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@974 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-08-04 13:22:44 +00:00
Timothy Wall 9fa1f7b981 fix bug writing null-valued ByReference structure fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@973 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-31 20:57:57 +00:00
Timothy Wall 4a68e4cd9d canonicalize auto-sync of structure arrays
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@972 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-31 16:58:15 +00:00
Timothy Wall 8320b6fd7c add missing direct mappings for new tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@971 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-31 16:44:29 +00:00
Timothy Wall e40cf0a1c4 synch callback structure args on callback return
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@970 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-28 20:00:13 +00:00
Timothy Wall 19106985d7 remove debug output
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@969 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-27 22:40:33 +00:00
Timothy Wall 3d817c54da add array wrapping tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@968 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-27 22:38:35 +00:00
Timothy Wall ca31877107 find proper c library automatically, avoids ubuntu crash
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@967 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-27 13:41:16 +00:00
Timothy Wall f5f9afefb0 avoid Structure.equals in read/write
reduce overhead of Structure.toString when struct contents aren't actually used

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@966 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-27 01:33:15 +00:00
Timothy Wall d42863603e fix Structure equals/hashcode
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@964 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-26 16:53:26 +00:00
Timothy Wall 2c19cf3e31 fix definition of HWND_BROADCAST
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@963 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-25 14:42:35 +00:00
Timothy Wall e7dc918c6a use non-null conversion context
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@962 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-21 14:02:58 +00:00
Timothy Wall 64c9e8212a update docs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@961 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-21 13:45:43 +00:00
Timothy Wall 499c39f13d build linux/i386 against older glibc (2.3.4) for compatibility
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@959 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-17 18:12:48 +00:00
Timothy Wall bccdae735b rename native method according to Java class rename
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@958 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-17 02:52:47 +00:00
Timothy Wall 58120730a5 update notes on direct mapping
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@957 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-16 20:08:09 +00:00
Timothy Wall 5b8db8a680 add direct mapping note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@956 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-15 13:50:54 +00:00
Timothy Wall 0acfd583c8 add jnaerator note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@955 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-15 13:40:27 +00:00
Timothy Wall 402b7ef67e add marc strapetz' patch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@954 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-15 13:05:36 +00:00
Timothy Wall 6944871c42 fix issue #121
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@953 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-15 13:03:53 +00:00
Timothy Wall b60da35689 update direct mapping info
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@952 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 19:24:16 +00:00
Timothy Wall 5204feddb1 update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@951 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 18:10:29 +00:00
Timothy Wall 68156df66b update native libraries
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@949 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 18:03:48 +00:00
Timothy Wall a9e8b27285 ensure proper method selection when java callback returns NativeMapped
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@948 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 17:46:01 +00:00
Timothy Wall b8f470ddbd fix compilation warnings/errors on win64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@947 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 15:28:36 +00:00
Timothy Wall 9d075dd1d1 revert configury changes, incompatible w/ windows build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@946 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-14 13:30:49 +00:00
Timothy Wall 4b802c6f60 update configury
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@945 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-13 20:50:27 +00:00
Timothy Wall 8ce9344dd0 update from libffi CVS (local patches applied upstream)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@944 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-13 14:15:02 +00:00
Timothy Wall cb2b386791 document getProcess usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@943 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-08 01:25:01 +00:00
Timothy Wall 7ee4681c10 enable accessing current process on w32
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@942 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 16:37:27 +00:00
Timothy Wall 82c0ea9df2 add test for NativeLibrary.getProcess()
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@941 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 15:39:16 +00:00
Timothy Wall 9070d80880 re-throw errors as errors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@940 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 12:57:18 +00:00
Timothy Wall 45c53caf94 increase JWS timeout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@939 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 11:56:17 +00:00
Timothy Wall c4947618c1 distinguish expected web start error from other errors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@938 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 11:28:05 +00:00
Timothy Wall 941ed59c37 make structure read/write recursion detection thread-local
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@937 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 11:13:32 +00:00
Timothy Wall d76bbec1ab fix web start test for IBM J9
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@936 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-07 10:54:37 +00:00
Timothy Wall f5a1d98cf9 ensure clover.jar is signed
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@935 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 23:56:57 +00:00
Timothy Wall b0e6d837f0 provide toByteArray with String encoding option
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@934 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 13:28:28 +00:00
Timothy Wall b1cfb1b733 fix web start test on linux
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@933 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 13:15:04 +00:00
Timothy Wall 26a1212546 bump version, md5
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@932 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 10:49:59 +00:00
Timothy Wall 03b05aaae9 add test for callbacks w/type mapper w/differently-sized return types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@931 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 10:29:59 +00:00
Timothy Wall f41c87d7c9 fix failing test on osx
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@930 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 10:21:13 +00:00
Timothy Wall b74deb5e35 narrow direct callback test failure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@929 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 02:36:34 +00:00
Timothy Wall 240e2db637 improve test coverage, structure field error messages
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@928 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 01:09:07 +00:00
Timothy Wall 441947b6a4 ensure direct library mappings used in direct tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@927 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-06 01:06:40 +00:00
Timothy Wall 194bdaffcd add unicode equivalents
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@926 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-02 12:23:00 +00:00
Timothy Wall db6e9ff4c6 fix compiler warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@925 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-01 15:47:09 +00:00
Timothy Wall 57261a1164 more performance notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@924 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-07-01 12:25:53 +00:00
Timothy Wall 0b116bb409 throw call errors *after* any cleanup
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@923 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-30 19:00:47 +00:00
Timothy Wall a5ad2e5de2 enable web start test on windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@922 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-26 20:06:25 +00:00
Timothy Wall b6928ff6c0 add test for auto-write of Structure.ByReference arrays
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@921 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-26 18:17:12 +00:00
Timothy Wall 4b03dd321c fix placement of exception throw
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@920 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-26 02:48:09 +00:00
Timothy Wall f7eefbd3d7 avoid making JNI calls after thrown exceptions
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@919 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 22:49:15 +00:00
Timothy Wall b23f7f9b27 fix setjmp/longjmp compiler warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@918 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 15:41:37 +00:00
Timothy Wall b95bc7e4c4 remove redundant (and unreliable) test
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@917 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 15:29:27 +00:00
Timothy Wall 1593c0c347 add IBM J9 notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@916 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 15:26:13 +00:00
Timothy Wall c154663455 fix tests on windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@915 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 15:24:00 +00:00
Timothy Wall 13bc1901dc merge direct branch to trunk
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@913 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 13:58:15 +00:00
Timothy Wall 4f28322ac2 add ignores, update eclipse classpath
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@909 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 13:07:34 +00:00
Timothy Wall 756e2ced8b add web-start tests and test support
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@908 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-25 13:06:16 +00:00
Timothy Wall 1dc78b5209 fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@907 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-24 21:45:49 +00:00
Timothy Wall 3464093273 fix exception type
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@905 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-23 18:51:11 +00:00
Timothy Wall 4487214494 attempt to delete temporary native library in test
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@901 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-22 17:49:09 +00:00
Timothy Wall 6d7e222946 add direct mapping note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@900 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-22 17:27:15 +00:00
Timothy Wall d12a6a3178 improve test coverage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@899 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-21 19:50:29 +00:00
Timothy Wall ed9d609c35 provide more info in test failures
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@898 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-20 19:04:06 +00:00
Timothy Wall b86f359d93 Fix memory test on IBM J9
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@897 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-20 02:01:36 +00:00
Timothy Wall 02080dfcf8 fix tests on IBM J9 (windows) VM
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@896 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-20 01:54:37 +00:00
Timothy Wall 2768d25884 Fix test failures on IBM J9
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@895 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-20 00:11:21 +00:00
Timothy Wall 7bdf9896d2 Fix test failures on IBM J9
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@894 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-20 00:08:59 +00:00
Timothy Wall 3b4f84ded8 allow NativeMapped[] as function arguments
respect autoread/write structure setting in direct calls

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@893 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-19 17:05:57 +00:00
Timothy Wall 69abc52731 make tests independent of load order
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@892 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-19 01:40:43 +00:00
Timothy Wall 1671b1fb8b allow types derived from Buffer as Structure fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@891 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 21:26:24 +00:00
Timothy Wall 8735f4ef5c fix kernel32 function lookup
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@890 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 18:55:46 +00:00
Timothy Wall 86967b5786 fix w32 compilation errors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@889 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 16:23:32 +00:00
Timothy Wall ca8ceeb130 remove debug output
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@888 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 15:15:24 +00:00
Timothy Wall 41d6f8eeea add last error exception for direct calls
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@887 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 14:34:57 +00:00
Timothy Wall 27b7805608 Handle last error as an exception if declared
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@886 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-18 14:12:18 +00:00
Timothy Wall fef39f7013 replace atexit example
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@885 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-16 10:31:24 +00:00
Timothy Wall b414b54c6b fix callback example
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@884 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-15 20:19:46 +00:00
Timothy Wall ccdbb20ad0 facilitate struct members pointing to arrays of struct
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@877 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-10 13:26:57 +00:00
Timothy Wall eb7e47bf29 doc various structure type mappings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@876 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-10 13:23:53 +00:00
Timothy Wall 53988c7184 update clover library
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@874 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-08 13:45:15 +00:00
Timothy Wall 9092b2bdc5 add VM information to build output
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@873 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-07 12:19:29 +00:00
Timothy Wall 068353aa5b ensure temp test unicode-named library deleted
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@872 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-07 12:07:27 +00:00
Timothy Wall 95a17ddbf0 attempt to find cause of w32 cleanup failure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@869 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-06 11:45:09 +00:00
Timothy Wall 6c8c455f5b fix compiler warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@868 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-06 00:31:18 +00:00
Timothy Wall 282032e178 give FS more time to delete native lib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@867 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-05 22:31:54 +00:00
Timothy Wall af63e6a80d account for VM implementations returning 'null' as a classloader
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@866 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-05 19:52:06 +00:00
Timothy Wall a46ba0da29 restrict installation of shudown hook
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@865 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-05 19:37:56 +00:00
Timothy Wall f7738bf65b Add tests for library unloading and loading from jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@864 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-05 17:18:08 +00:00
Timothy Wall bb11d1fe37 unload native library unpacked from jar if Native class unloaded
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@863 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-05 15:33:51 +00:00
Timothy Wall d02a2deb52 update front page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@859 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-04 14:52:04 +00:00
Timothy Wall 46105d849d add link to IAXClient applet
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@854 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-06-02 16:09:09 +00:00
Timothy Wall f16b6c3482 Omit JNA+AWT load test on headless systems
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@849 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-28 16:55:23 +00:00
Timothy Wall a9cb497045 allow callbacks in direct mappings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@848 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-28 16:12:39 +00:00
Timothy Wall d529a34ecb revert last change
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@847 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-28 13:31:45 +00:00
Timothy Wall 5394029dc5 dynamically load libjsig if available
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@846 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-28 13:07:04 +00:00
Timothy Wall 28247737ca fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@845 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-27 20:01:14 +00:00
Timothy Wall 6448c2d8fb pass options to native library at interface definition
update javadoc to include direct mapping info

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@844 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-27 20:00:02 +00:00
Timothy Wall 4460ccc8ec fix SIGBUS/SIGSEGV on sparc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@843 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-27 13:02:46 +00:00
Timothy Wall 2b02a3c533 fix direct struct by value mapping
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@842 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-27 12:57:07 +00:00
Timothy Wall 6705513b86 add structure, string, NIO Buffer and primitive array support to direct type mapping
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@841 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-26 20:09:05 +00:00
Timothy Wall 4bd8d12481 use more appropriate exception types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@840 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-26 19:55:15 +00:00
Timothy Wall ccaf3c283b avoid premature GC of Memory with NIO Buffers extant
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@839 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-26 19:54:26 +00:00
Timothy Wall ce4276a0cb fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@838 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:17:27 +00:00
Timothy Wall 709e316e56 fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@837 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:16:30 +00:00
Timothy Wall e46635d6ab fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@836 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:15:57 +00:00
Timothy Wall 0af8677ba4 fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@835 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:13:40 +00:00
Timothy Wall 9ab13daf09 fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@834 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:04:42 +00:00
Timothy Wall 17977fbabc fix layout
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@833 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 17:02:42 +00:00
xylo 83854047b7 reverted inadvertently adding another file in last commit
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@832 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 14:27:04 +00:00
xylo 28e56fd587 added a note that Xevie has been removed from xserver
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@831 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 14:21:49 +00:00
Timothy Wall 29fc6308b8 doc tweaks
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@830 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 13:35:23 +00:00
Timothy Wall 14a7df128d add missing header
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@829 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 13:27:15 +00:00
Timothy Wall dd4ef89d0a update main page w/direct calling info
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@828 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-21 13:23:33 +00:00
Timothy Wall 830ec91cbf update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@826 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 21:16:37 +00:00
Timothy Wall aee2d55fab update natives, jna.jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@825 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 21:12:55 +00:00
Timothy Wall 89ed7982e7 update native lib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@824 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 21:04:04 +00:00
Timothy Wall 9f702c89ab update native libs (sunos)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@823 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 20:55:33 +00:00
Timothy Wall 2f76efd0f6 update native lib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@822 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 20:09:26 +00:00
Timothy Wall fae18c72c3 update native lib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@821 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 19:54:05 +00:00
Timothy Wall 1586f6ee2b update native libs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@820 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 19:45:19 +00:00
Timothy Wall 4ce6214526 update native lib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@819 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 14:36:45 +00:00
Timothy Wall e370e4b65e update native jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@818 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 14:08:14 +00:00
Timothy Wall 944de2d3f5 update native jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@817 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 13:50:29 +00:00
Timothy Wall f32146368d prep for 3.1 release
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@816 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-20 13:49:42 +00:00
Timothy Wall 8d45e9b016 add notes to setProtected javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@815 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 14:23:56 +00:00
Timothy Wall 70227861ff use libjsig.so if available
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@814 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 14:15:13 +00:00
Timothy Wall 20e542516b make gc more robust on sparc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@813 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 13:35:29 +00:00
Timothy Wall 73ad21df73 add link to windows mobile implementation
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@812 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 11:02:52 +00:00
Timothy Wall a67fe7e43d %0@& windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@811 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 10:36:10 +00:00
Timothy Wall a15ddd9f88 blank checksum between releases
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@810 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 10:22:00 +00:00
Timothy Wall b27f9bf930 fix docs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@809 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 10:13:54 +00:00
Timothy Wall d5c28f98f1 fix javadoc errors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@808 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 10:10:10 +00:00
Timothy Wall 16b283ed00 add raw call convention notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@807 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 10:04:41 +00:00
Timothy Wall 97b43889a1 add raw calling convention
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@806 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-19 09:54:12 +00:00
Timothy Wall 05efa12411 make callback gc test more robust
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@805 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 21:11:41 +00:00
Timothy Wall 3e60495232 clean up win64 patch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@804 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 20:44:36 +00:00
Timothy Wall 45522b0710 win32 tweaks, update native jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@803 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 16:08:52 +00:00
Timothy Wall d67d25eb7b remove extraneous output
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@802 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 15:47:06 +00:00
Timothy Wall 2538690fb4 unions require a structure-based ffi_type
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@801 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 15:31:12 +00:00
Timothy Wall 4c23b2518e protect old x86 code from win64 changes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@800 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-18 15:22:07 +00:00
Timothy Wall 9daade9816 fix compiler warning in 'sizeof'
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@799 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-14 18:43:11 +00:00
Timothy Wall 5f925f0070 correct OVERLAPPED types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@798 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-14 18:40:36 +00:00
Timothy Wall 38b0cd7780 provide sizeof native function, update checksum
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@797 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-12 17:32:24 +00:00
Timothy Wall e46391042b regenerated config files
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@796 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-12 14:33:50 +00:00
Timothy Wall 553a03b05f ensure sufficient space allocated for win64 ffi_call stack
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@795 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-11 21:27:01 +00:00
Timothy Wall 24c1cc4efe fix 1 byte struct by value return
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@794 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-11 15:19:09 +00:00
Timothy Wall f6eabe7b58 down to 2 failing tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@793 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-11 14:49:18 +00:00
Timothy Wall de2de1fdc7 fix win64 fp return
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@792 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-11 01:08:05 +00:00
Timothy Wall 8184ac8843 more win64 fixes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@791 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-09 04:22:30 +00:00
Timothy Wall a57d82d4cd mark more xfail (no long double)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@790 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-09 02:20:30 +00:00
Timothy Wall a266ef7337 fix some win64 bugs with structure handling
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@789 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-09 01:59:31 +00:00
Timothy Wall b30ca23180 fix a few win64 tests
use ffi_closure_alloc everywhere

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@788 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-08 22:10:53 +00:00
Timothy Wall db5c8f00fc make union test more reliable for 64-bit
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@787 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-05-08 14:14:47 +00:00
Timothy Wall d1bbacb06e fix docs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@786 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-20 19:17:40 +00:00
Timothy Wall bff4e3b0fd optionally allow Java objects in native calls
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@785 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-20 15:27:29 +00:00
Timothy Wall 14248ddbd9 update Union ctor signatures
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@784 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-17 15:47:04 +00:00
Timothy Wall 391f39d291 fix issue 111
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@783 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-15 02:45:40 +00:00
Timothy Wall b4354efa8b set binary mime type
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@782 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-13 17:53:37 +00:00
Timothy Wall 686588a6e5 fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@781 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-06 13:15:09 +00:00
Timothy Wall 294267a605 Remove non-functional and superfluous size-based Structure ctors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@780 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-04-06 13:11:29 +00:00
Timothy Wall 7b53b9108b fix unused parameter warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@779 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-31 20:14:35 +00:00
Timothy Wall 15be9ab501 fix compiler warning
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@778 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-30 22:17:18 +00:00
Timothy Wall 7cfcd2daef Allow direct Buffer as structure field
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@777 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-30 21:06:03 +00:00
Timothy Wall 6070429eec tests for union by value fix
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@776 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-30 19:18:53 +00:00
Timothy Wall b5f41ef6c7 fix cacheing of union type information
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@775 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-28 13:02:02 +00:00
ochafik 716588a8fb Added mention to JNAerator's author
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@774 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-26 20:06:56 +00:00
Timothy Wall 95bc92f005 add some projects
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@773 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-26 17:19:13 +00:00
Timothy Wall 23425abe9d add tests to check for proper base addresses for structure/union fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@772 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-25 17:35:07 +00:00
Timothy Wall 3bab5e1e78 set RTLD_GLOBAL flag
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@771 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-18 13:44:57 +00:00
Timothy Wall 79ed7e81b1 update maven2 repo url (see http://weblogs.java.net/blog/kohsuke/archive/2009/03/changes_to_the.html)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@770 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-10 01:43:03 +00:00
Timothy Wall a59e58cc94 Allow handling of uncaught callback exceptions
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@769 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-03-09 13:52:16 +00:00
Timothy Wall 72bd12e394 note fix for issue #98
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@768 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-24 22:08:43 +00:00
Timothy Wall 2c667ca016 fix issue #104
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@767 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-24 22:04:22 +00:00
Timothy Wall 209c4d724f make Memory less restrictive
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@766 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-24 22:01:59 +00:00
Timothy Wall 95cf641f50 add w64 testsuite patches
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@765 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-24 17:50:07 +00:00
Wayne Meissner 85750fd065 Small optimization of NativeString constructor - do the String writing
here instead of via Pointer#setString(), to avoid converting the String
to bytes twice.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@764 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-16 09:33:33 +00:00
Wayne Meissner 402b5c7f81 Bump JNI version for the native change in previous commit
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@763 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-13 00:50:10 +00:00
Wayne Meissner be6f52b796 Apply patch from issue #98 - support opening current process on Unix
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@762 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-13 00:39:13 +00:00
Timothy Wall f4e6c6ad94 Provide pointer-based ctor for Structure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@761 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-02 16:11:16 +00:00
Timothy Wall 99fe59cee9 update release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@760 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-02 14:40:58 +00:00
Timothy Wall 0e80ba8b91 fix contents of maven source zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@759 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-02-02 14:39:57 +00:00
Timothy Wall 8965efdce1 update MSVC note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@758 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-25 21:50:27 +00:00
Timothy Wall 1393a94804 fix win64 setup
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@757 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-17 03:06:05 +00:00
Timothy Wall 52e558d877 apply patch for issue #95
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@756 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-14 00:34:32 +00:00
Timothy Wall d9948105f1 fix issue #51
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@755 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-14 00:28:10 +00:00
Timothy Wall 87c91c1c04 use direct path to resource compiler
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@754 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-07 22:10:50 +00:00
Timothy Wall f15e471371 fix compile under msvc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@753 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-07 22:01:56 +00:00
Timothy Wall fc0a83933d Synch to libffi 1.0.8
Add win64 patches from Kai Tietz

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@752 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-07 15:56:48 +00:00
Timothy Wall f1cf2fe218 use stdint types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@751 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-07 15:52:00 +00:00
Timothy Wall 7a5679cb65 fix misleading error message
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@750 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2009-01-06 22:22:22 +00:00
xylo 571b4604db added a comment on contrib/x11 to the release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@749 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-12-21 14:17:16 +00:00
xylo 29e15a40db in contrib/x11: tidy up build.xml
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@748 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-12-20 18:04:23 +00:00
xylo 6fb2286fa4 added a build.xml
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@747 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-12-20 17:53:43 +00:00
xylo ab2f78c7b4 add the "x11" contribution containing an object oriented interface to X11
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@746 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-12-20 16:22:21 +00:00
Timothy Wall f9b918a05b synch with libffi 3.0.6 CVS - affects darwin, freebsd
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@745 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-12-16 15:42:55 +00:00
Timothy Wall a46cde174a clean up release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@744 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-11-13 17:17:23 +00:00
Timothy Wall 6eee0f8741 clean up relnotes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@743 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-11-03 13:46:17 +00:00
Timothy Wall 28d31bb9f6 add small struct return by value test
Fix issue #94

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@742 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-11-03 13:42:03 +00:00
xylo 23128be17f in X11: added some methods related to key handling of the X server and added the XTest library/extension
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@741 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-11-02 18:35:59 +00:00
Wayne Meissner 130885fda7 3.0.9 release
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@739 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-30 20:22:28 +00:00
Wayne Meissner c4fc42f8f4 Bump version to 3.0.9 and update release-notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@738 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-30 20:17:14 +00:00
Wayne Meissner 21e73c5fb9 Fix for issue #93 and JRUBY-3084.
This alters the library search algorithm slightly:
1) Searches jna.library.path and any custom (per-library) paths for a
   matching library.
2) If that fails, tries to load the mapped library name, using
   dlopen/LoadLibrary.
3) If that fails, add all paths back into the search path and try to locate
   the library in jna.platform.library.path with all the normal fallbacks.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@737 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-29 00:30:54 +00:00
Wayne Meissner b635bf5591 Build 3.0.8
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@735 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-18 21:01:42 +00:00
Timothy Wall be594bb1f6 provide String->primitive array conversion
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@734 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-17 17:29:32 +00:00
Timothy Wall 543e3fca98 add more return types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@733 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-15 02:56:51 +00:00
Wayne Meissner b385d76dc6 Add support for jna.boot.library.path property. This is a list of paths to attempt to load the jna stub library from. Its needed by JRuby and possibly Jython, to load the stub library from the file system, as they both put jna.jar in -Xbootclasspath, and java.library.path/LD_LIBRARY_PATH are ignored in that situation.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@732 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-12 06:02:31 +00:00
Timothy Wall 2adc88fec3 fix build of dependent test library on w32-x86
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@731 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-08 12:33:58 +00:00
Timothy Wall 2a9e2ceb61 support notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@730 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-07 11:13:40 +00:00
Timothy Wall 47fa804469 bump version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@728 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:44:23 +00:00
Timothy Wall f70c01eee7 fix broken link
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@727 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:37:10 +00:00
Timothy Wall eb4ea07a2d update win32 natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@726 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-10-01 13:37:01 +00:00
Timothy Wall 55cd72baaa Fix class cast exception
read all TYPE_MAPPERs regardless of access

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@725 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-29 12:20:56 +00:00
Timothy Wall 940076d101 update demo files
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@724 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-26 00:41:56 +00:00
Timothy Wall 93ebb9f7a9 improve win32 dependent library loading
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@723 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-22 15:55:59 +00:00
Timothy Wall 1a17ea52d8 add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@718 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:14:49 +00:00
Timothy Wall 68bc0c0c7c add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@717 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:09:40 +00:00
Timothy Wall 0e7dd6b350 note Memory vs primitive array usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@716 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 12:21:23 +00:00
Timothy Wall b3b0bf3845 note Memory vs primitive array usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@715 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 12:17:58 +00:00
Timothy Wall ddc32f1e43 update main page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@714 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-16 18:25:25 +00:00
Timothy Wall c9de508a2c 3.0.6 build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@712 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-16 18:15:53 +00:00
Timothy Wall fac68bca4e update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@711 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-14 20:11:57 +00:00
Timothy Wall eaf250c3c6 struct/union improvements
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@710 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-12 14:05:07 +00:00
Timothy Wall 8b99772d29 clean up field type checking
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@709 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 18:34:54 +00:00
Timothy Wall 862a32e97e Fix pointer field read bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@708 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 17:23:48 +00:00
Timothy Wall 6cfb84d6ee more mingw-64 fixes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@707 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 14:01:49 +00:00
xylo 2fda7ca6f6 in Union: added methods getTypedValue() and setTypedValue() as abridgment for the commands u.setType(), u.read(), x = u.field; also added corresonding tests to class UnionTest
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@706 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 05:48:17 +00:00
Timothy Wall f2aecb53bc fix configure/build with mingw-64 (tests still fail)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@705 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-11 03:19:41 +00:00
Timothy Wall 05fdc2f17a update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@704 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 17:21:11 +00:00
xylo b9868b993c take X11 from x11-addons branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@703 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 17:16:22 +00:00
Wayne Meissner 573d8eefd1 Updated i386-OpenBSD build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@702 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-10 15:28:33 +00:00
Timothy Wall 51d64f29e6 clean up some libffi bits
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@700 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-09 15:08:58 +00:00
Timothy Wall a39ab60ae5 update natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@698 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 15:30:23 +00:00
Timothy Wall ba9671fae5 update natives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@697 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 15:21:04 +00:00
Timothy Wall a9340f354d update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@696 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:59:09 +00:00
Timothy Wall f9d6b069f7 update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@695 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:50:59 +00:00
Timothy Wall c363d5790d update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@694 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:38:54 +00:00
Timothy Wall 15a50d2a26 update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@693 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 14:29:43 +00:00
Timothy Wall bffc188151 bump revision
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@692 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 13:06:41 +00:00
Timothy Wall e78205430c update native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@691 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 13:05:23 +00:00
Timothy Wall 4ef76d4f85 Allow arbitrary callback method names
Allow specification of callback type mapper with TYPE_MAPPER
Allow write with uninitialized boxed primitives in Structure
Fix memory leak with callbacks called from native threads w/no java context
Fix Structure derived classes to allow setting TypeMapper

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@690 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-08 12:56:04 +00:00
Timothy Wall 967da46793 Fix memory leak in callbacks
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@689 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-07 17:32:02 +00:00
xylo 46899503bd take X11 from x11-addons branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@686 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-06 17:24:37 +00:00
Timothy Wall 2dcf0f774c add win64 note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@685 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:34:24 +00:00
Timothy Wall d669db0cab update jars with win64 build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@684 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:29:52 +00:00
Timothy Wall f8aabcc50a merge win64 branch
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@683 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-04 15:04:34 +00:00
Timothy Wall 4bb3ece8dc Fix transparent window error on win2k
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@669 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-01 19:33:56 +00:00
Timothy Wall 495a7765d2 include LICENSE.txt in src.zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@648 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-26 13:39:46 +00:00
Timothy Wall 225296f253 avoid more content dragging on OSX, or warn
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@647 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-22 14:35:27 +00:00
Timothy Wall 52e6900e7a fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@645 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:56:01 +00:00
Timothy Wall 557bff1465 update doc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@644 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:53:14 +00:00
Timothy Wall add32ac107 bump version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@643 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:52:56 +00:00
Timothy Wall f7699b98fb release 3.0.5
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@641 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:47:41 +00:00
Timothy Wall 05a8ec1fec add java.net maven repo plumbing
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@640 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-14 14:33:01 +00:00
Timothy Wall 004e63c433 allow String[] as callback argument/return
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@639 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-13 14:17:40 +00:00
Timothy Wall 898f41b95a avoid reallocating Integer objects
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@638 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-13 13:51:59 +00:00
Timothy Wall 859a6a75aa apply patch #81
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@637 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-09 12:10:11 +00:00
Timothy Wall b90dae6448 add sunos-sparc build compatible with solaris 8
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@636 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:45:14 +00:00
Timothy Wall dc1ddf4cff add usb for java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@635 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:37:37 +00:00
Timothy Wall 46ef5d86c3 add usb for java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@634 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-08 04:36:27 +00:00
Timothy Wall ac63a6b125 fix field access
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@633 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-07 12:25:26 +00:00
Timothy Wall 72778c97df Allow explicit setting of structure field order
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@632 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-07 11:11:07 +00:00
Timothy Wall b4b86081f9 address issue #79, optionally omit jnilib
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@631 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-08-05 17:16:02 +00:00
Timothy Wall e4a47a4ca5 update relnotes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@630 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:17:51 +00:00
Timothy Wall 79c60f6d4e Fix cursor tracking on alpha-masked windows
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@629 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:17:10 +00:00
Timothy Wall 4c4d55e0dc add backup in case pkg-config fails
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@628 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-31 16:03:24 +00:00
Timothy Wall 9504416beb Allow link against system libffi with 'ant -Ddynlink.native=true'
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@627 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 14:55:59 +00:00
Timothy Wall 99586d9b3f Provide src.zip for linux builds, old version now src-full.zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@626 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 13:50:45 +00:00
Timothy Wall 65b19cbbd3 Fix 32/64-bit library lookup where both arch versions exist
Try 'lib' prefix on w32

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@625 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-29 00:00:40 +00:00
Wayne Meissner 7b64f4443d More OpenBSD build changes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@624 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:49:53 +00:00
Wayne Meissner abb2e857be Revert md5 sum now that OpenBSD is fixed up
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@623 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:47 +00:00
Wayne Meissner df10745963 Use ggrep for OpenBSD. Not strictly correct, but grep -A1 on OpenBSD does not print out a '--' separator between matches. Strangely, -B1 does ...
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@622 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:30 +00:00
Wayne Meissner 3d729595d1 i386-OpenBSD port
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@621 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-26 05:47:12 +00:00
Timothy Wall 96a38d1895 Fix division by zero on OSX/ppc calculating struct size
Fix overwriting of already-initialized NativeMapped field in struct when calculating struct size

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@620 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-13 18:53:49 +00:00
Timothy Wall b4c1390af8 Work around OSX transparent window dragging bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@619 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-08 14:32:52 +00:00
Timothy Wall e9604ac212 update to 3.0.4
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@617 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-05 18:55:32 +00:00
Timothy Wall ea3a4b34ea update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@616 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-05 12:17:08 +00:00
Timothy Wall 79a0d92161 update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@615 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-05 12:16:07 +00:00
Timothy Wall b10c40260c enable NativeMapped array fields in Structure read/write
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@614 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-03 19:33:25 +00:00
xylo 9e056d2097 in StructureTest.testReadWriteStructure: test constancy of references after reading structure from memory
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@610 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-03 09:49:08 +00:00
Timothy Wall 8a250c5994 Look up proper library on Linux where arch=x86_64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@607 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-07-01 14:17:56 +00:00
xylo e311ac3269 in StructureTest.testReadWriteStructure: tabs replaced by spaces
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@604 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-28 14:03:24 +00:00
xylo 28078a2d0c in StructureTest.testReadWriteStructure: compare content of arrays after write/read structure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@603 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-28 13:51:43 +00:00
xylo 7def8c1bbf in X11: remove tailing spaces in comments
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@602 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-28 12:11:26 +00:00
xylo 24ca11387e in Pointer: remove unnecessary spaces in comments
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@601 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-28 12:05:29 +00:00
xylo bccc9583c1 in X11: return Atom constants when calling Atom.fromNative(...)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@600 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-28 08:42:26 +00:00
xylo 9643747b17 in X11: added some native functions
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@599 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-27 17:51:45 +00:00
xylo c695848092 in X11: added remaining Atom constants (from 9 to 68)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@595 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-26 18:49:52 +00:00
Dan Rollo 5011613e4c Add GetDriveType() to Kernerl32 examples. Patch by Marc Strapetz.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@585 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-24 03:18:22 +00:00
Timothy Wall 6cc7f69a59 Make X11.XID NativeLong
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@583 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-23 22:48:37 +00:00
Timothy Wall db6678637b Ensure struct allocated when calling Union.setType
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@582 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-23 22:47:19 +00:00
Timothy Wall 93892e12a2 Fix incorrect solaris/x86 native library
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@581 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-23 19:01:07 +00:00
Timothy Wall c196aab89d remove trailing comment close
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@580 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-22 12:04:07 +00:00
Timothy Wall 54a7718b88 clean up X headers
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@579 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-22 12:03:20 +00:00
Timothy Wall cec6e6175a Use the actual parameter type in Function invocations if no paramter type information is available (whether method is missing or untyped varargs).
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@578 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-22 11:30:57 +00:00
Timothy Wall bc5036bd34 auto-write Structure.ByReference fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@577 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-21 21:00:37 +00:00
Timothy Wall 021826eb1b update release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@576 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-21 20:42:23 +00:00
Timothy Wall facd071967 Handle arrays of NativeMapped in Structure fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@575 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-06-21 20:40:33 +00:00
Timothy Wall 486e81ad77 upgrade to 2.x clover
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@574 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-29 14:42:11 +00:00
Timothy Wall 872cd3d7c0 Apply xylo's library load patch, fix versioned name checking tests
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@573 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-27 13:59:06 +00:00
Timothy Wall ca9851b311 Fix linux library load bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@572 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-23 14:22:08 +00:00
Timothy Wall 2fa0940d45 update jna.jar with updated linux builds
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@569 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 20:48:04 +00:00
Timothy Wall 3485338386 update linux-amd64 to 3.0.4 (native)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@568 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 20:33:43 +00:00
Timothy Wall 786a821f3f update linux-i386 jar to 3.0.4 (native)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@567 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 20:30:19 +00:00
Timothy Wall da1c9c5ea5 remove erroneous comment
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@565 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 17:04:23 +00:00
Timothy Wall 93d8cce7ac post 3.0.3 build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@564 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 17:03:51 +00:00
Timothy Wall 5086ba2a3b include project files in source zip
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@563 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-22 16:32:12 +00:00
Timothy Wall 4cf8611dcd add note
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@562 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-20 15:42:41 +00:00
Timothy Wall 101e9d705a Add more win32 type examples
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@561 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-20 15:10:57 +00:00
Timothy Wall 7d8bfa1b62 Fix NPE in NativeMappedConverter
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@560 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-20 15:09:48 +00:00
Timothy Wall 5dcf9e2f41 update perf info
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@559 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-14 14:49:13 +00:00
Timothy Wall cdf18b6c4d ensure memory is initialized before Structure.read() - avoid NPE
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@558 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-09 15:21:55 +00:00
Timothy Wall 609ce3b6e0 ensure memory is initialized before Structure.read() - avoid NPE
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@557 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-09 15:21:05 +00:00
Timothy Wall 3ba8be2e21 improve package/version information in code and manifest
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@556 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-05 23:58:48 +00:00
Timothy Wall 6b13a97ce4 fix jnlp links
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@555 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-02 20:49:20 +00:00
Dan Rollo 130e40957e Fix issue# 68 - File monitor thread terminates on any removeWatch call.
kludge: fix intermittent failures on slow W2K box.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@554 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-02 03:56:38 +00:00
Dan Rollo a7b28317d7 Fix issue# 68 - File monitor thread terminates on any removeWatch call. Change W32FileMonitor.dispose() to unwatch any remaining files in map, allows watcher thread to exit.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@553 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-02 03:29:13 +00:00
Dan Rollo 29fcd0fdcf Fix issue# 68 - File monitor thread terminates on any removeWatch call. (only formatting and debug info changes)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@552 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-02 02:04:58 +00:00
Dan Rollo 9d5f63e543 Fix issue# 68 - File monitor thread terminates on any removeWatch call.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@551 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-02 01:20:59 +00:00
Timothy Wall 208c28ead2 add entry for native long mapping
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@550 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-05-01 15:16:55 +00:00
Timothy Wall 447d5ee94b Allow 'final' modifier in Structure fields
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@549 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-25 13:43:06 +00:00
Dan Rollo bb443add17 Fix for Jira issue: 67 - FileMonitor incorrectly handles FILE_DELETED notification mask. Added a unit test and committed fix.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@548 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-24 03:33:39 +00:00
Timothy Wall cb954773ed Fix bug in ByValue structs using NativeMapped
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@547 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-15 16:51:35 +00:00
Timothy Wall 89749c7eb1 update native builds
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@546 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-11 20:22:06 +00:00
Timothy Wall 30146f8744 fix callback allocation on freebsd
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@545 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-11 19:48:27 +00:00
Timothy Wall a623f374b1 enable mmap closures on solaris
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@544 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-11 18:33:17 +00:00
Dan Rollo b41584feb3 fix test failures on amd64 with 64-bit jvm. Classloader/path was using "build" instead of "build-d64".
NOTE: I considered changing and re-using the ["vmopt.arch" value="-d64" else="-Dignore"] already defined in build.xml for this, but I wasn't sure what the "-Dignore" case was intended for.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@543 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-11 07:34:41 +00:00
Timothy Wall 77d5bbb767 Fix typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@542 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-11 01:55:21 +00:00
Timothy Wall 171d428d3a Improve StdCallFunctionMapper
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@541 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-10 14:35:35 +00:00
Timothy Wall 61254c6cc4 Fix callbacks when DEP is enabled
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@540 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-10 02:39:51 +00:00
Timothy Wall 44b3a8952e fix typos
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@539 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-08 17:54:21 +00:00
Timothy Wall 0fc8c5e7e9 add videolan project
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@538 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-08 12:45:16 +00:00
Timothy Wall 6d969eb92f improve X11 window masking performance
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@537 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-08 09:29:02 +00:00
Timothy Wall 26ea0f81ca only set vm arch option for 64-bit vms
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@536 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-03 15:19:43 +00:00
Timothy Wall dc45e38f11 fix relocation errors on sunos-amd64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@535 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-03 14:40:42 +00:00
Timothy Wall 9d5db40d3f enable ibm j9 build/run
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@534 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-03 00:57:47 +00:00
Timothy Wall 9e25d52679 improve w32 window masking
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@533 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-01 16:09:56 +00:00
Timothy Wall 1f98d4f6ff improve performance of window masking
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@532 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-04-01 00:59:12 +00:00
Timothy Wall b73883ce1d Refine test for IBM's J9 VM
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@531 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-31 14:26:32 +00:00
Timothy Wall 7af42da5d2 partial fix for aix/ppc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@530 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-31 13:18:29 +00:00
Timothy Wall cf75057b67 fix bug where struct is incorrectly passed by value instead of by reference
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@529 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-13 17:27:15 +00:00
Timothy Wall e5b1841030 Check entire linux version, not just last digit
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@528 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-11 04:48:27 +00:00
Dan Rollo 57325a22a5 refactor common code
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@527 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-09 05:31:48 +00:00
Dan Rollo c640166cf8 remove unused import, make unchanging member vars final.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@526 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-09 05:19:14 +00:00
Dan Rollo 4b4c362c03 remove unused imports
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@525 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-09 05:15:47 +00:00
Dan Rollo c71bfb1602 fix testMultipleWatches() by clearing prior events.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@524 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-09 00:43:35 +00:00
Dan Rollo 022e6349c1 make Kernel32/Test work on Win2k.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@523 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-09 00:42:00 +00:00
Timothy Wall 917671ac9a use frames link for javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@522 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-07 15:29:24 +00:00
Timothy Wall a108975d78 link to javadoc sans dev.java.net navigation
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@521 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-07 15:28:22 +00:00
Timothy Wall 62d31c5902 Fix NPE
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@520 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-04 16:28:36 +00:00
Timothy Wall 5d28314ee3 Add Emmanuel's Lego Mindstorm NXT driver
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@519 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-01 12:41:26 +00:00
Timothy Wall 1b22109f95 update platform list, support notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@518 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-03-01 12:35:53 +00:00
Timothy Wall e5c05bfd66 fix constant usage
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@517 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-29 16:07:38 +00:00
Timothy Wall 62e97858d7 tweak main page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@516 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-29 15:54:56 +00:00
Timothy Wall b9da9b977e tweak main page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@515 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-29 15:54:09 +00:00
Timothy Wall f121b6c039 tweak
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@513 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 19:51:55 +00:00
Timothy Wall c48b13bc0a update examples jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@512 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 19:36:20 +00:00
Timothy Wall 26abb9beb9 update examples jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@511 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 19:34:44 +00:00
Timothy Wall 02cc7d53b7 update demos
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@510 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 19:28:35 +00:00
Timothy Wall 67136b5986 update linux-amd64 native
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@509 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 13:50:40 +00:00
Timothy Wall 58d5175fde fix w32 api type mapper bug exposed by last round of changes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@508 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 13:43:23 +00:00
Timothy Wall c511c4063e use 'JNI_FALSE' rather than 'false'
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@507 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:43:23 +00:00
Timothy Wall 6429611b3c include sunos-amd64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@506 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:32:45 +00:00
Timothy Wall 3cea53ddca bump version on jna.jar to 3.0.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@505 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:29:50 +00:00
Timothy Wall d661e58fc3 bump version, include new architectures
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@504 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:28:13 +00:00
Timothy Wall e140b6e4e2 Disable inapplicable test on OSX
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@503 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:19:47 +00:00
Timothy Wall e1025d9337 Use UTF8 encoding for OSX library names
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@502 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 04:15:06 +00:00
Timothy Wall f1acc483c3 Disable manual WindowUtils test
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@501 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 03:49:23 +00:00
Timothy Wall 0e25e979a2 Fix window alpha compositing on X11
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@500 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 03:21:31 +00:00
Timothy Wall 0c129ff02e Fix NPE when using NativeMapped within Structure (https://jna.dev.java.net/issues/show_bug.cgi?id=54)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@499 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-28 03:15:06 +00:00
Timothy Wall 05234082a9 add rococoa
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@498 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-26 14:35:12 +00:00
Timothy Wall bdc44962a1 update javadoc for 3.0.1
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@497 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-26 14:19:37 +00:00
Timothy Wall e96a59965e add FAQ topics
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@496 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-26 14:06:05 +00:00
Timothy Wall 507f3fc74b add sunos-amd64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@495 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-25 14:59:24 +00:00
Timothy Wall 22d997fcd9 add freebsd-amd64
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@494 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-25 14:21:59 +00:00
Timothy Wall 89a98ca51b remove obsolete comment
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@493 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-14 14:58:00 +00:00
Timothy Wall 9834abe3ab Fix X11 mappings for 64-bit
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@492 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-14 03:56:59 +00:00
Timothy Wall 54ffc2c138 enable x86_64 builds on OS X
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@491 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-11 21:06:13 +00:00
Timothy Wall 4785c4f11e finalize is more thorough than unload
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@490 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-11 21:04:47 +00:00
Timothy Wall 9d5b0deb61 Add explicit test for matching linux versioned libs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@489 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-11 21:04:00 +00:00
Timothy Wall 9c0b540ddc Add explicit test for matching linux versioned libs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@488 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-11 21:01:14 +00:00
Timothy Wall c124a9f2b8 Fix OSX window transparency for 1.5+/Leopard
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@487 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-08 18:18:23 +00:00
Timothy Wall 8b0e08f9df Attempt to force the VM to unload the jnidispatch native lib before deleting it (w32)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@486 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-06 13:53:02 +00:00
Timothy Wall 9ee115d1a0 allocate minimal space for invocation args, instead of MAX_NARGS
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@485 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-06 13:46:22 +00:00
Timothy Wall a7ebf431a8 fix release notes link
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@484 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 14:21:40 +00:00
Timothy Wall d85330d54a remove svn:executable from html files
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@483 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 14:21:07 +00:00
Timothy Wall f8f93c7351 Set mime type
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@482 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 14:18:16 +00:00
Timothy Wall ee1fd4944f add folder icon
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@481 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 14:15:59 +00:00
Timothy Wall 5117fa06b8 reformat release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@480 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 14:15:25 +00:00
Timothy Wall 2ac1552bf7 add athena backup
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@479 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-05 13:55:10 +00:00
Timothy Wall 94c2647d25 update sunos jars
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@477 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-01 00:24:36 +00:00
Timothy Wall 6b2f067435 Ensure manifest is included in dist/jna.jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@476 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-02-01 00:23:44 +00:00
Timothy Wall 3e2471d0a0 Ensure tests run under appropriate VM for sparcv9
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@475 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-31 21:57:35 +00:00
Timothy Wall f0b1d33398 enable memory access protection on solaris
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@474 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-31 14:43:47 +00:00
Timothy Wall bae955f7c5 update jars to 3.0.1
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@473 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-31 02:20:34 +00:00
Timothy Wall b747e71583 clean up symbols for freebsd
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@472 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-31 00:29:59 +00:00
Timothy Wall 48160da4b7 update examples jar (WindowUtils)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@471 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-30 12:41:13 +00:00
Timothy Wall d17df6a9db Allow window masks to be set on heavyweight components (at least on w32 and x11)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@470 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-28 16:10:38 +00:00
Timothy Wall df7a9ec977 make graphics test run only if not headless
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@469 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-28 15:08:55 +00:00
Timothy Wall f2157420f2 use ffi_prep_closure_loc, not ffi_prep_closure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@468 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-28 14:55:31 +00:00
Timothy Wall ae9c56416f Use closure alloc from libffi
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@467 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-28 14:23:23 +00:00
Timothy Wall 1dec6a541a Fix linux library name mapping (sans regexp)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@466 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 18:04:18 +00:00
Timothy Wall c75157ffd8 Fix javadoc warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@465 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 17:45:29 +00:00
Timothy Wall fa77d03fea Provide explicit dispose on NativeLibrary
Cache NativeMappedConverter instances for improved performance
Preliminary support for wince (improve backwards compatibility for older VMs)
Provide 'synch after call' interface for arguments that need to perform some sort of synchronization after a native call

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@464 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 17:33:12 +00:00
Timothy Wall 618f4c533c Fix non-w32 compilation
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@463 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 16:26:59 +00:00
Timothy Wall 9b77631dd5 update project files (netbeans/eclipse)
use setjmp/longjmp to recover from w32 faults instead of simply setting SP
embed version resource information in w32 dll
don't update last error if ffi_call faults

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@462 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 16:19:02 +00:00
Timothy Wall 7aa22df1e2 Use XImage instead of XDrawRectangle point by point
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@461 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-24 15:45:39 +00:00
Timothy Wall ee0ff79820 Fix bug in Pointer.setChar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@460 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-23 23:03:30 +00:00
Timothy Wall ca772e8a9c add missing import
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@459 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-23 17:01:01 +00:00
Timothy Wall 8af05c14be Avoid creating too many windows when setting window mask
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@458 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-23 16:37:24 +00:00
Timothy Wall 20f230e910 fix md5 calculation on sunos
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@457 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-22 20:54:54 +00:00
Timothy Wall 8af51875b6 Improve test output
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@456 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-22 20:42:23 +00:00
Timothy Wall a4ead757f6 Fix bug in STructure.toArray w/nested struct arrays
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@455 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-22 13:56:31 +00:00
Timothy Wall 0cc6bc9e2e Improve transparent window drawing performance on w32
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@454 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-22 13:35:14 +00:00
Timothy Wall 00a551d2b1 fix html typo
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@453 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-19 22:28:02 +00:00
Timothy Wall b6f1652aab update main page
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@452 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-15 16:55:33 +00:00
Timothy Wall b304555389 Ensure initialized nested structure arrays use the right memory
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@451 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-14 19:43:41 +00:00
Timothy Wall 456af457bb Ensure initialized nested structure arrays use the right memory
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@450 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-14 19:42:08 +00:00
Timothy Wall e9cb67844d off_t size varies by platform
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@449 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-01-14 18:50:29 +00:00
734 arquivos alterados com 239072 adições e 95628 exclusões
+2 -2
Ver Arquivo
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
<classpathentry kind="lib" path="lib/junit.jar" sourcepath="/DEV/junit/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 1.5.0"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="build.eclipse/classes"/>
</classpath>
+80 -51
Ver Arquivo
@@ -3,14 +3,14 @@
this means no java object arguments to callbacks; use some sort of integer
key instead (hashcode?) callbacks can hold local data anyway...
o make simplest Java usage map to most common C usage
- additional constructs provided for esoteric cases (WString)
- additional constructs provided for less-common cases
(WString,Structure.ByValue/ByReference)
o structure is treated as a pointer, except within a struct
o primitive types are passed directly
o arrays are treated as pointers, except within a struct
- in structure (inline; otherwise pointer-to-X should be used)
- as function argument (auto-convert to pointer via Memory)
- pointer to type in struct should be handled with Pointer
- how to do pointer to struct in struct? (Pointer to start with)
o pointer to type in struct should use Pointer or ByReference
o "free" should be invisible wherever possible
# FUTURE DEMOS:
@@ -18,34 +18,40 @@
* get system process information, basic process control
* additional file utilities (meta info, free space, etc)
* enforce window minimum/maximum size (workaround java bug)
* OSX ObjC access
# TODO
* should structure offsets be "long"?
* fix setFieldOrder to *always* apply if used
* cache structure information
* allow return of W/String[] or Pointer[], if NULL-terminated?
* make direct calls call back *once* to Java where conversion is required,
and process all arguments from there (instead of potentially swapping back
and forth multipel times). This also makes it easer to perform conversions
(no native changes required).
* Direct buffers should be used where
hotspot inlining can improve performance.
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
* use libffi closure allocation/deallocation
* ppc64 direct/raw failures (multiple)
* parser (gluegen? others?) to auto-generate JNA interfaces from headers;
ideally get the native library build system to output preprocessed headers,
otherwise CPP crap is a nightmare to get right.
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
now
* (maybe) move all native functions into Native (limit header files, easier
management)
* combine direct and interface mapping calling code where possible
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
the signed versions, but maybe the unsigned ones, to facilitate generating
unsigned values (maybe just provide utilities to pack an unsigned int into a
signed int). What about size_t, off_t, et al.? Would either need a
bunch of native lookup functions (more accurate) or java-side conditionals
(less robust but easier to change).
o bounds checking is handled by IntegerType (pass in a long, get an
exception if the value is out of bounds).
* make native dll extraction from jar public, to use with user dlls packaged
in a jar
* Callback.PostCallWrite.write() cf PostCallRead
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
Can use annotations as shorthand to initialize a map, but basically set up a
per-NativeLibrary (or per-Function?) map of methods to mappers.
Requires separate compilation of annotation handling.
* ditch type conversion context (?)
* packaging: 'types', 'convert/marshal' subpackages?
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
@@ -55,12 +61,6 @@
Pointer into a types subpackage (which would leave just a few top-level
classes). Javadoc is cluttered by example classes anyway.
* Make a separate jar file for all OS-specific headers
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
(how useful would it really be, or is this just sorting legos?)
o same for windowutils, fileutils, etc.
* support annotations of parameters and return values w/o breaking
1.4 compatibility (retroweaver?), e.g.
-- retroweaver (requires retroweaver runtime classes to provide annotation
@@ -75,14 +75,6 @@
this only really applies to NativeLong/IntegerType types that want to use a
primitive value instead of creating an object instance.
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
o this gets tricky when reading structs from native memory; we don't know if
the value is already mapped to a buffer (cf CallbackReference)
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
and native code can't change the size anyway
* flag string(/wstring)-returning methods which need to free their result
to avoid leaking memory whan auto-creating strings from the result
(since normally we don't take explicit ownership of any returned pointers)
@@ -99,9 +91,21 @@
"pointer-requiring-free" (which is just Memory). For now, leave it up to
the user to manage the pointer, since they have to define the free method
anyway. use could always put a finalizer on a PointerType-derived type.
* provide library load/unload hooks (Runnables in options?). Examples:
o GetLastError (no longer needed)
o WSAInit?
* universal GCC build w/cross-compile (needs cross compilers...)
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
Long.SIZE, Integer.SIZE, et al.
* interface "lvalue", which can provide a pointer to itself (reference() or
addressOf())?
* bitfields for structs (how?)
# DONE
* check Structure "final" fields; should never write back to native memory
* OSX ObjC access (see rococoa)
* do Structure.write for any callback args
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
methods out of Structure, to be used by Function w/NativeMapped[] parameter
* if method has "GetLastErrorException/ErrnoException" in its signature, use
result codes + GetLastError/errno/errstr to auto-generate
runtime exceptions? (cf P/Invoke; also useful for X11 return types)
@@ -113,21 +117,16 @@
if nonzero ?
o otherwise, need an ExceptionOnZero, ExceptionOnNonZero runtime, from which
derive GetLastError/ErrnoExceptionOnZero/NZ
* determine X11 display name from current java program (if any); null is ok
since it uses getenv(DISPLAY), which is what java would do
note: DISPLAY may be available in GraphicsDevice->getIDstring
* universal GCC build w/cross-compile (needs cross compilers...)
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
Long.SIZE, Integer.SIZE, et al.
* interface "lvalue", which can provide a pointer to itself (reference() or
addressOf())?
* verify get/set methods vs read/write for performance (Pointer)?
* bitfields for structs (how?)
(see RawTest for performance comparisons)
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
o this gets tricky when reading structs from native memory; we don't know if
the value is already mapped to a buffer (cf CallbackReference)
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
* embed version in DLL ('depends'-done)/so (symlink?)
* use libffi closure allocation/deallocation
# DONE
* ensure Library options are passed to NativeFunctionHandler
(needs getLibraryOptions(Class cls))
@@ -244,5 +243,35 @@ transient callbacks, and require callback+dispose for most callbacks?
void setWindowMask(Window w, Shape clip);
// needs:
int findNativeWindow(Window w);
#MAYBE NOT
* should structure offsets be 64-bit? technically yes, but in practice I don't
think a structure that big actually works.
* (maybe) move all native functions into Native (limit header files, easier
management)
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
the signed versions, but maybe the unsigned ones, to facilitate generating
unsigned values (maybe just provide utilities to pack an unsigned int into a
signed int). What about size_t, off_t, et al.? Would either need a
bunch of native lookup functions (more accurate) or java-side conditionals
(less robust but easier to change).
o bounds checking is handled by IntegerType (pass in a long, get an
exception if the value is out of bounds).
o when used as struct fields, could allow detection of field order by order
of initialization (requires all-or-nothing usage, though)
* Make a separate jar file for all OS-specific headers
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
(how useful would it really be, or is this just sorting legos?)
o same for windowutils, fileutils, etc. (not useful)
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
and native code can't change the size anyway
* provide library load/unload hooks (Runnables in options?). Examples:
o GetLastError (no longer needed)
o WSAInit?
* determine X11 display name from current java program (if any); null is ok
since it uses getenv(DISPLAY), which is what java would do
note: DISPLAY may be available in GraphicsDevice->getIDstring
+279 -121
Ver Arquivo
@@ -15,10 +15,14 @@
<!-- (all build-related props should go in -dynamic-properties) -->
<property name="name" value="jna"/>
<property name="jar" value="${name}.jar"/>
<property name="testjar" value="${name}-test.jar"/>
<property name="debug" value="true"/>
<property name="debug.native" value="false"/>
<property name="cflags_extra.native" value=""/>
<property name="dynlink.native" value="false"/>
<property name="native" location="native"/>
<property name="src" location="src"/>
<property name="contrib" location="contrib/src"/>
<property name="dist" location="dist"/>
<property name="test.src" location="test"/>
<property name="doc" location="doc"/>
@@ -26,18 +30,27 @@
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
<property name="vendor" value="JNA Development Team"/>
<property name="copyright"
value="Copyright &amp;copy; 2007 Timothy Wall. All Rights Reserved."/>
value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
<buildnumber/>
<!-- JNA library release version -->
<property name="jna.version" value="3.0"/>
<property name="jna.major" value="3"/>
<property name="jna.minor" value="2"/>
<property name="jna.revision" value="5"/>
<property name="jna.build" value="${build.number}"/>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<!-- jnidispatch library release version -->
<property name="jni.version" value="3.0"/>
<property name="jni.md5" value="892beacd437514d23ed9b1cefeb2ead6"/>
<property name="jni.major" value="3"/>
<property name="jni.minor" value="2"/>
<property name="jni.revision" value="1"/>
<property name="jni.build" value="${build.number}"/>
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
<property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
<property name="spec.title" value="Java Native Access (JNA)"/>
<property name="spec.vendor" value="${vendor}"/>
<property name="spec.version" value="${jna.version}"/>
<property name="impl.title" value="${spec.title}"/>
<property name="spec.version" value="${jna.major}"/>
<property name="impl.title" value="com.sun.jna"/>
<property name="impl.vendor" value="${spec.vendor}"/>
<property name="impl.version" value="${spec.version}"/>
<property name="impl.version" value="${jna.version} (b${jna.build})"/>
<property name="compatibility" value="1.4"/>
<property name="test.compatibility" value="1.5"/>
@@ -47,22 +60,65 @@
<target name="default" depends="test" description="Build and Test."/>
<!-- uncomment for netbeans profiling -->
<!--<import file="nbproject/profiler-build-impl.xml"/>-->
<target name="init" depends="-setup"/>
<target name="compile-test-single" depends="compile-tests"/>
<target name="compile-single" depends="compile"/>
<target name="-dynamic-properties">
<echo>Java version: ${java.version}, compatibility: ${compatibility}</echo>
<echo>JNA version ${jna.version}, native API version ${jni.version}</echo>
<property name="build" value="build"/>
<echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
<echo>JNA version ${jna.version}, native ${jni.version}</echo>
<echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
<echo>java.home=${java.home}</echo>
<echo>java.library.path=${java.library.path}</echo>
<replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
replace="\1${jna.version}\2"
file="pom.xml"/>
<replaceregexp match='VERSION = ".*";'
replace='VERSION = "${jna.version}";'
file="src/com/sun/jna/Native.java"/>
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
<isset property="omit-jnilib"/>
</condition>
<condition property="vm.arch" value="-d64" else="">
<or>
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
<os arch="x86_64"/>
<os arch="ppc64"/>
<os arch="sparcv9"/>
<os arch="amd64"/>
</or>
</condition>
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
<and>
<os name="SunOS"/>
<equals arg1="${vm.arch}" arg2="-d64"/>
</and>
</condition>
<property name="build" value="build${vm.arch}"/>
<property name="classes" location="${build}/classes"/>
<property name="eclipse.classes" location="build.eclipse/classes"/>
<property name="test.classes" location="${build}/test-classes"/>
<property name="reports" value="${build}/reports"/>
<!-- Add other supported platforms here -->
<condition property="jre.arch" value="i386">
<equals arg1="x86" arg2="${os.arch}"/>
</condition>
<condition property="jre.arch" value="amd64">
<equals arg1="x86_64" arg2="${os.arch}"/>
</condition>
<property name="jre.arch" value="${os.arch}"/>
<condition property="os.prefix" value="linux-${jre.arch}">
<os name="Linux"/>
</condition>
<condition property="os.prefix" value="win32-${os.arch}">
<os family="windows"/>
</condition>
<condition property="os.prefix" value="linux-${os.arch}">
<os name="Linux"/>
</condition>
<!-- Darwin builds are universal, no arch required -->
<condition property="os.prefix" value="darwin">
<os family="mac"/>
@@ -73,6 +129,9 @@
<condition property="os.prefix" value="freebsd-${os.arch}">
<os name="FreeBSD"/>
</condition>
<condition property="os.prefix" value="openbsd-${os.arch}">
<os name="OpenBSD"/>
</condition>
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
<condition property="jdk.home" value="${java.home}">
<available file="${java.home}/include"/>
@@ -81,7 +140,10 @@
<available file="${java.home}/../include"/>
</condition>
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
<condition property="libjsig"
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
</condition>
<property name="native.jar" value="${os.prefix}.jar"/>
<property name="build.native" location="${build}/native"/>
<property name="md5.file" location="${build.native}/sig"/>
@@ -96,7 +158,7 @@
</target>
<target name="-setup" depends="-dynamic-properties">
<path id="compile-test.path">
<path id="compile-test.path">
<pathelement path="${test.src}"/>
<path id="test.libs">
<fileset dir="lib">
@@ -108,14 +170,13 @@
<path id="src.path">
<pathelement location="${src}"/>
</path>
</path>
</path>
</path>
<path id="test.runpath">
<pathelement path="${build}/${jar}"/>
<pathelement path="${build}/examples.jar"/>
<pathelement path="${test.classes}"/>
<pathelement path="${ant.home}/lib/clover.jar"/>
<pathelement path="lib/clover.jar"/>
<path refid="test.libs"/>
</path>
</target>
@@ -137,8 +198,6 @@
<patternset id="jar-compiled">
<include name="com/sun/jna/*"/>
<include name="com/sun/jna/**/*"/>
<exclude name="com/sun/jna/examples/*"/>
<exclude name="com/sun/jna/examples/**/*"/>
</patternset>
</srcfiles>
</uptodate>
@@ -147,29 +206,36 @@
description="Build primary jar">
<jar jarfile="${build}/${jar}">
<manifest>
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
<attribute name="Main-Class" value="com.sun.jna.Native"/>
<section name="com/sun/jna/">
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
<!-- OSGi Bundle attributes -->
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="jna"/>
<attribute name="Bundle-Description" value="JNA Library"/>
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
<attribute name="Bundle-Version" value="${spec.version}"/>
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
<attribute name="Export-Package" value="com.sun.jna*"/>
</section>
</manifest>
<fileset dir="${classes}"><patternset refid="jar-compiled"/></fileset>
<fileset dir="${classes}" excludes="${jar.omitted}">
<patternset refid="jar-compiled"/>
</fileset>
</jar>
<subant target="jar">
<fileset dir="${contrib}" includes="platform/build.xml" />
<fileset dir="${contrib}" includes="*/build.xml" />
</subant>
</target>
<target name="examples" depends="jar,native">
<jar jarfile="${build}/examples.jar">
<manifest>
<attribute name="Class-Path" value="jna.jar"/>
<attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
</manifest>
<fileset dir="${src}" includes="**/examples/**/*.png"/>
<fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
<fileset dir="${classes}" includes="jnidispatch.dll"/>
</jar>
</target>
<target name="javah" depends="compile">
<javah classpath="${classes}" destdir="${build.native}" force="yes">
<class name="com.sun.jna.Function"/>
@@ -179,7 +245,15 @@
<class name="com.sun.jna.NativeLibrary"/>
<class name="com.sun.jna.CallbackReference"/>
</javah>
<apply dir="${build.native}" executable="grep" parallel="true" relative="true" output="${md5.file}">
<condition property="grep" value="/usr/sfw/bin/ggrep">
<os name="SunOS"/>
</condition>
<condition property="grep" value="ggrep">
<os name="OpenBSD"/>
</condition>
<property name="grep" value="grep"/>
<apply dir="${build.native}" executable="${grep}" parallel="true"
failonerror="true" relative="true" output="${md5.file}">
<arg value="-A"/>
<arg value="1"/>
<arg value="JNIEXPORT"/>
@@ -188,7 +262,10 @@
<fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
<checksum property="md5" file="${md5.file}" />
<condition property="jni.valid" value="true">
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
<or>
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
<equals arg1="${jni.md5}" arg2=""/>
</or>
</condition>
</target>
@@ -197,10 +274,15 @@
<echo>Invalidating native code, new checksum is ${md5}</echo>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
<delete failOnError="false" includeEmptyDirs="true">
@@ -209,7 +291,33 @@
<fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
</target>
<target name="native" depends="-setup,javah,-native-api-check"
<target name=":rsrc">
<condition property="-rsrc">
<not><os family="windows"/></not>
</condition>
</target>
<target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
description="Generate w32 DLL version resource information">
<property name="rsrc" location="${build.native}/jnidispatch.rc"/>
<copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
<replaceregexp match="FILEVERSION.*"
replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
file="${rsrc}" byline="true"/>
<replaceregexp match="PRODUCTVERSION.*"
replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
file="${rsrc}" byline="true"/>
<replaceregexp match="FileVersion.*"
replace="FileVersion&quot;,&quot;${jni.version}&quot;"
file="${rsrc}" byline="true"/>
<replaceregexp match="Full Version.*"
replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
file="${rsrc}" byline="true"/>
<replaceregexp match="ProductVersion.*"
replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
file="${rsrc}" byline="true"/>
</target>
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
<property name="comment" value="# auto-generated by ant"/>
<replaceregexp match="^VERSION=.*"
@@ -218,14 +326,9 @@
<replaceregexp match="^CHECKSUM=.*"
replace="CHECKSUM=${jni.md5} ${comment}"
file="native/Makefile" byline="true"/>
<!-- ensure ARCH is set properly for various platforms -->
<!-- ARCH is used in native/Makefile to find the JAWT library -->
<condition property="ARCH" value="${os.arch}">
<or>
<os name="SunOS"/>
<os arch="amd64"/>
</or>
</condition>
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
<!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
<property name="ARCH" value="${os.arch}"/>
<condition property="make.CC" value="CC=${CC}" else="IGNORE=">
<isset property="CC"/>
</condition>
@@ -235,7 +338,12 @@
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
<isset property="SDKROOT"/>
</condition>
<condition property="make.SDKROOT" value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
</condition>
<!-- Windows' drive letters and spaces in absolute paths wreak havoc on
@@ -250,7 +358,10 @@
<os name="SunOS"/>
</condition>
<condition property="make" value="gmake">
<os name="FreeBSD"/>
<or>
<os name="FreeBSD"/>
<os name="OpenBSD"/>
</or>
</condition>
<!-- Default make program -->
<property name="make" value="make"/>
@@ -259,6 +370,8 @@
<arg value="JAVA_HOME=${jdk.home}"/>
<arg value="JAVAH=${build.native}"/>
<arg value="DEBUG=${debug.native}"/>
<arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
<arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
<arg value="${make.CC}"/>
<arg value="${make.BUILD}"/>
<arg value="${make.SDKROOT}"/>
@@ -269,12 +382,13 @@
</exec>
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${classes}/com/sun/jna/${os.prefix}">
<fileset dir="${build.native}"
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
failonerror="false">
<fileset dir="${build.native}"
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<!-- For web start, native libraries may be provided in the root of -->
@@ -282,14 +396,14 @@
<jar jarfile="${build}/${native.jar}">
<fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
<manifest>
<attribute name="Implementation-Version" value="${jni.version}"/>
<attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
<attribute name="Specification-Version" value="${jni.version}"/>
</manifest>
</jar>
</target>
<target name="compile-tests" depends="compile,native"
description="Compile all test code">
<target name="compile-tests" depends="compile,native,jar"
description="Compile all test code">
<javac classpathref="compile-test.path"
source="${test.compatibility}"
target="${test.compatibility}"
@@ -297,40 +411,76 @@
deprecation="on" debug="${debug}">
<src path="${test.src}"/>
</javac>
<jar jarfile="${build}/${testjar}">
<fileset dir="${test.classes}">
<patternset refid="jar-compiled"/>
</fileset>
</jar>
<mkdir dir="${build}/jws"/>
<copy todir="${build}/jws" file="${build}/${jar}"/>
<copy todir="${build}/jws" file="${build}/${testjar}"/>
<copy todir="${build}/jws" file="lib/junit.jar"/>
<copy todir="${build}/jws" file="lib/clover.jar"/>
<jar jarfile="${build}/jws/jnidispatch.jar">
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
</jar>
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
</signjar>
</target>
<!-- When running tests from an IDE, be sure to set jna.library.path -->
<!-- to where the test library (testlib) is found -->
<target name="test" depends="jar,examples,compile-tests"
<!-- to where the test library (testlib) is found. -->
<target name="test" depends="jar,compile-tests"
description="Run all unit tests">
<property name="test.fork" value="yes"/>
<property name="reports.junit" location="${reports}/junit"/>
<property name="results.junit" location="${build}/junit-results"/>
<mkdir dir="${results.junit}"/>
<echo>Saving test results in ${results.junit}</echo>
<condition property="tests.platform" value="**/win32/*Test.java">
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
<condition property="tests.platform" value="**/win32/**/*Test.java">
<os family="windows"/>
</condition>
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
<and><os family="windows"/><not><os arch="x86"/></not></and>
</condition>
<condition property="tests.platform" value="**/unix/*Test.java">
<and>
<os family="unix"/>
<not><os family="mac"/></not>
</and>
</condition>
<condition property="vmopt.arch" value="-d64" else="-Dignore">
<and>
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
<not><os family="windows"/></not>
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</and>
</condition>
<property name="tests.platform" value=""/>
<property name="tests.exclude" value=""/>
<junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
<!-- avoid VM conflicts with JNA protected mode -->
<env key="${ld.preload}" file="${libjsig}"/>
<jvmarg value="-Djna.library.path=${build.native}"/>
<!-- Avoid VM crashes, if possible -->
<jvmarg value="-Djna.protected=true"/>
<jvmarg value="-Djna.builddir=${build}"/>
<jvmarg value="${vmopt.arch}"/>
<classpath><path refid="test.runpath"/></classpath>
<formatter type="xml"/>
<batchtest todir="${results.junit}">
<fileset dir="${test.src}">
<include name="com/sun/jna/*Test.java"/>
<include name="com/sun/jna/examples/*Test.java"/>
<include name="${tests.platform}"/>
<exclude name="${tests.exclude}"/>
</fileset>
</batchtest>
</junit>
<subant target="test">
<fileset dir="${contrib}" includes="platform/build.xml"/>
</subant>
<junitreport todir="${results.junit}">
<fileset dir="${results.junit}">
<include name="TEST-*.xml"/>
@@ -342,18 +492,10 @@
</target>
<target name="with.clover" description="Enable code coverage for tests">
<taskdef resource="clovertasks"/>
<taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
<property name="clover" value="true"/>
<property name="build" value="build.clover"/>
<property name="clover.include" value="**/*.java"/>
<property name="clover.exclude" value="**/examples/**/*.java"/>
<property name="tests.exclude" value="${clover.exclude}"/>
<clover-setup initString="${build}/coverage.db">
<fileset dir="${src}">
<include name="${clover.include}"/>
<exclude name="${clover.exclude}"/>
</fileset>
</clover-setup>
<clover-setup/>
</target>
<target name="clover" depends="with.clover,test"
@@ -362,6 +504,8 @@
<mkdir dir="${reports.clover}"/>
<clover-report>
<current outfile="${reports.clover}" title="clover">
<fileset dir="." includes="**/*.java" />
<testresults dir="${results.junit}" includes="TEST-*.xml"/>
<format type="html"/>
</current>
</clover-report>
@@ -380,7 +524,7 @@
sourcepathref="src.path"
classpathref="compile.path"
maxmemory="256m"
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32,com.sun.jna.exmaples.unix"
overview="${src}/com/sun/jna/overview.html"
destdir="${javadoc}">
<!-- stylesheetfile="${stylesheet}" -->
@@ -396,17 +540,29 @@
</packageset>
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
<group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
<group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
<group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
<group title="Platform Specific" packages="com.sun.jna.platform"/>
<arg value="-notimestamp"/>
</javadoc>
<subant target="javadoc">
<fileset dir="${contrib}" includes="platform/build.xml"/>
</subant>
</target>
<target name="dist" depends="jar,compile-tests,native,examples,javadoc"
description="Build examples">
<target name="dist" depends="jar,compile-tests,native,javadoc"
description="Build distribution files">
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
<manifest>
<attribute name="Main-Class" value="com.sun.jna.Native"/>
<section name="com/sun/jna/">
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
</section>
</manifest>
<zipfileset src="${build}/${jar}"/>
<zipfileset src="${dist}/win32-x86.jar"
includes="*jnidispatch*"
@@ -420,9 +576,15 @@
<zipfileset src="${dist}/linux-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-amd64"/>
<zipfileset src="${dist}/linux-ia64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ia64"/>
<zipfileset src="${dist}/sunos-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-x86"/>
<zipfileset src="${dist}/sunos-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-amd64"/>
<zipfileset src="${dist}/sunos-sparc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-sparc"/>
@@ -432,21 +594,52 @@
<zipfileset src="${dist}/freebsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-i386"/>
<zipfileset src="${dist}/freebsd-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-amd64"/>
<zipfileset src="${dist}/openbsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-i386"/>
<zipfileset src="${dist}/win32-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-amd64"/>
</jar>
<copy todir="${dist}">
<fileset dir="${build}">
<include name="${native.jar}"/>
<include name="examples.jar"/>
</fileset>
<fileset dir="${contrib}/platform/dist">
<include name="platform.jar" />
</fileset>
</copy>
<copy todir="${dist}/jnacontrib" flatten="true">
<fileset dir="${contrib}">
<include name="**/build/demo-*.jar" />
</fileset>
</copy>
<zip zipfile="${dist}/doc.zip">
<zipfileset dir="${javadoc}" prefix="javadoc"/>
<zipfileset dir="${contrib}/platform/dist/javadoc" prefix="platform/javadoc"/>
</zip>
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
<zip zipfile="${dist}/src.zip">
<zipfileset dir="." includes="build.xml"/>
<zipfileset dir="." includes="build.xml,LICENSE.txt"/>
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
<zipfileset dir="${native}" prefix="native"/>
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
</zip>
<!-- Full sources required to build and test everything -->
<zip zipfile="${dist}/src-full.zip">
<zipfileset src="${dist}/src.zip"/>
<zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
<zipfileset dir="." includes=".classpath,.project"/>
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
<zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
</zip>
<!-- Sources package as required by maven -->
<zip zipfile="${dist}/src-mvn.zip">
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
</zip>
</target>
@@ -455,48 +648,13 @@
<fileset dir="${build}"/>
</delete>
<delete quiet="true" includeEmptyDirs="true">
<fileset dir=".clover"/>
<fileset dir="${javadoc}"/>
<fileset dir="." includes="*~,**/*~"/>
</delete>
</target>
<target name="profile-single" depends="examples" description="Profile Class">
<fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath> <pathelement location="${build}/examples.jar"/> </classpath>
</nbprofiledirect>
<java classname="${main.class}" fork="true">
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg value="${profiler.info.jvmargs}"/>
<jvmarg value="-Djna.library.path=${build.native}"/>
<classpath>
<pathelement location="${build}/examples.jar"/>
</classpath>
</java>
</target>
<target name="profile-test-single" depends="examples,compile-tests"
description="Profile Test Class">
<fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
<pathelement location="${build}/examples.jar"/>
<pathelement location="${test.classes}"/>
</classpath>
</nbprofiledirect>
<junit dir="${build.native}" jvm="${profiler.info.jvm}"
failureproperty="tests.failed" errorproperty="tests.failed" fork="true">
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg value="${profiler.info.jvmargs}"/>
<jvmarg value="-Djna.library.path=${build.native}"/>
<test name="${profile.class}"/>
<classpath>
<pathelement location="${build}/examples.jar"/>
<pathelement location="${test.classes}"/>
</classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
</junit>
<subant target="clean">
<fileset dir="${contrib}" includes="*/build.xml"/>
</subant>
</target>
</project>
Arquivo binário não exibido.
@@ -1,6 +0,0 @@
application.args=
file.reference.jna.jar=D:\\temp\\JnaContrib\\lib\\jna.jar
javac.debug=true
javadoc.preview=true
jaxws.endorsed.dir=D:\\Program Files\\netbeans551\\ide7\\modules\\ext\\jaxws21\\api
user.properties.file=C:\\Users\\tb\\.netbeans\\5.5.1\\build.properties
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>alphamaskdemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+78
Ver Arquivo
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-alphamask.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
<path id="classpath">
<fileset dir="../../../build">
<include name="jna.jar"/>
</fileset>
<fileset dir="../platform/dist">
<include name="platform.jar"/>
</fileset>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<classpath>
<path refid="classpath"/>
</classpath>
<src>
<dirset dir="${src}"/>
</src>
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
</project>
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007-2008 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
@@ -10,7 +10,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -25,6 +26,7 @@ import java.awt.Window;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
@@ -37,6 +39,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JFrame;
@@ -51,25 +54,24 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputAdapter;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.examples.unix.X11;
import com.sun.jna.examples.unix.X11.Display;
import com.sun.jna.examples.unix.X11.GC;
import com.sun.jna.examples.unix.X11.Pixmap;
import com.sun.jna.examples.unix.X11.Visual;
import com.sun.jna.examples.unix.X11.XSetWindowAttributes;
import com.sun.jna.examples.win32.GDI32;
import com.sun.jna.examples.win32.User32;
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
import com.sun.jna.examples.win32.User32.POINT;
import com.sun.jna.examples.win32.User32.SIZE;
import com.sun.jna.examples.win32.W32API.HANDLE;
import com.sun.jna.examples.win32.W32API.HBITMAP;
import com.sun.jna.examples.win32.W32API.HDC;
import com.sun.jna.examples.win32.W32API.HWND;
import com.sun.jna.platform.WindowUtils;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.unix.X11.Display;
import com.sun.jna.platform.unix.X11.GC;
import com.sun.jna.platform.win32.GDI32;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.GDI32.BITMAPINFO;
import com.sun.jna.platform.win32.User32.BLENDFUNCTION;
import com.sun.jna.platform.win32.User32.POINT;
import com.sun.jna.platform.win32.User32.SIZE;
import com.sun.jna.platform.win32.W32API.HANDLE;
import com.sun.jna.platform.win32.W32API.HBITMAP;
import com.sun.jna.platform.win32.W32API.HDC;
import com.sun.jna.platform.win32.W32API.HWND;
import com.sun.jna.ptr.PointerByReference;
// TODO: put this into a reasonable API; right now this is pretty much
@@ -89,6 +91,10 @@ public class AlphaMaskDemo implements Runnable {
private float alpha = 1f;
private Image image;
private void update() {
update(false, true);
}
private void update(boolean a, boolean i) {
String os = System.getProperty("os.name");
if (os.startsWith("Windows"))
@@ -119,6 +125,8 @@ public class AlphaMaskDemo implements Runnable {
}
}
private com.sun.jna.Memory buffer;
private int[] pixels;
private void updateX11(boolean a, boolean i) {
X11 x11 = X11.INSTANCE;
X11.Window win = X11.Window.None;
@@ -129,11 +137,6 @@ public class AlphaMaskDemo implements Runnable {
if (System.getProperty("java.version").matches("^1\\.4\\..*"))
alphaWindow.setVisible(true);
win = new X11.Window((int)Native.getWindowID(alphaWindow));
XSetWindowAttributes xswa = new XSetWindowAttributes();
xswa.background_pixel = new NativeLong(0x0);
Visual visual = x11.XDefaultVisual(dpy, x11.XDefaultScreen(dpy));
xswa.colormap = x11.XCreateColormap(dpy, win, visual, X11.AllocNone);
x11.XChangeWindowAttributes(dpy, win, new NativeLong(X11.CWBackPixel|X11.CWColormap), xswa);
Window parent = alphaWindow.getOwner();
Point where = parent.getLocationOnScreen();
where.translate(parent.getWidth(), 0);
@@ -149,34 +152,54 @@ public class AlphaMaskDemo implements Runnable {
int w = image.getWidth(null);
int h = image.getHeight(null);
alphaWindow.setSize(w, h);
if (buffer == null || buffer.getSize() != w*h*4) {
buffer = new com.sun.jna.Memory(w*h*4);
pixels = new int[w*h];
}
BufferedImage buf = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics g = buf.getGraphics();
g.drawImage(image, 0, 0, w, h, null);
long start = System.currentTimeMillis();
long blitTime, putImageTime, write;
GC gc = x11.XCreateGC(dpy, win, new NativeLong(0), null);
Pixmap pixmap = x11.XCreatePixmap(dpy, win, w, h, 32);
long gcTime = System.currentTimeMillis();
try {
x11.XSetForeground(dpy, gc, new NativeLong(0));
x11.XFillRectangle(dpy, pixmap, gc, 0, 0, w, h);
Raster raster = buf.getData();
int[] pixel = new int[4];
for (int y=0;y < h;y++) {
for (int x=0;x < w;x++) {
raster.getPixel(x, h-y-1, pixel);
raster.getPixel(x, y, pixel);
int alpha = (pixel[3]&0xFF)<<24;
int red = (pixel[2]&0xFF);
int green = (pixel[1]&0xFF)<<8;
int blue = (pixel[0]&0xFF)<<16;
x11.XSetForeground(dpy, gc, new NativeLong(alpha|red|green|blue));
x11.XFillRectangle(dpy, pixmap, gc, x, h-y-1, 1, 1);
pixels[y*w+x] = alpha|red|green|blue;
}
}
x11.XCopyArea(dpy, pixmap, win, gc, 0, 0, w, h, 0, 0);
blitTime = System.currentTimeMillis();
X11.XWindowAttributes xwa = new X11.XWindowAttributes();
x11.XGetWindowAttributes(dpy, win, xwa);
X11.XImage image = x11.XCreateImage(dpy, xwa.visual,
32, X11.ZPixmap,
0, buffer, w, h, 32, w*4);
buffer.write(0, pixels, 0, pixels.length);
write = System.currentTimeMillis();
x11.XPutImage(dpy, win, gc, image, 0,0,0,0,w,h);
x11.XFree(image.getPointer());
putImageTime = System.currentTimeMillis();
}
finally {
if (gc != null)
x11.XFreeGC(dpy, gc);
}
long end = System.currentTimeMillis();
//System.out.println("gc: " + (gcTime-start) + "ms");
//System.out.println("blit: " + (blitTime-gcTime) + "ms");
//System.out.println("write: " + (write-blitTime) + "ms");
//System.out.println("put image: " + (putImageTime-write) + "ms");
//System.out.println("total: " + (end-start) + "ms");
}
}
finally {
@@ -469,6 +492,11 @@ public class AlphaMaskDemo implements Runnable {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
centerOnScreen(frame);
frame.setVisible(true);
p.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
update();
}
});
try {
URL url = getClass().getResource("tardis.png");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007 Timothy Wall, All Rights Reserved This library is
* Copyright (c) 2007-2008 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
@@ -8,9 +8,10 @@
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
@@ -33,6 +34,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
@@ -50,16 +52,13 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MouseInputAdapter;
// TODO: put this into a reasonable API; right now this is pretty much
// just hard-coded blitting of an image into a window
// Thanks to Rui Lopes for the C# example on which this is based:
// rui@ruilopes.com
// http://www.codeproject.com/cs/media/perpxalpha_sharp.asp?df=100&forumid=3270&exp=0&select=773155
import com.sun.jna.platform.WindowUtils;
public class AlphaMaskDemo2 implements Runnable {
private static final DataFlavor URL_FLAVOR = new DataFlavor("application/x-java-url; class=java.net.URL",
"URL");
private static final DataFlavor URI_LIST_FLAVOR = new DataFlavor("text/uri-list; class=java.lang.String",
"URI list");
private static final DataFlavor URL_FLAVOR =
new DataFlavor("application/x-java-url; class=java.net.URL", "URL");
private static final DataFlavor URI_LIST_FLAVOR =
new DataFlavor("text/uri-list; class=java.lang.String", "URI list");
private JFrame frame;
private JWindow alphaWindow;
private JLabel icon;
@@ -106,6 +105,7 @@ public class AlphaMaskDemo2 implements Runnable {
frame = new JFrame("Alpha Mask Demo");
alphaWindow = new JWindow(frame, gconfig);
icon = new JLabel();
icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
alphaWindow.getContentPane().add(icon);
JButton quit = new JButton("Quit");
JLabel label = new JLabel("Drag this window by its image");
@@ -251,6 +251,7 @@ public class AlphaMaskDemo2 implements Runnable {
"<html><center>Drop an image with an alpha channel onto this window<br>"
+ "You may also adjust the overall transparency with the slider</center></html>"),
BorderLayout.NORTH);
p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
final JSlider slider = new JSlider(0, 255, 255);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {

Antes

Largura:  |  Altura:  |  Tamanho: 18 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 18 KiB

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>balloonmanagerdemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-balloonmanager.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
<path id="classpath">
<fileset dir="../../../build">
<include name="jna.jar"/>
</fileset>
<fileset dir="../platform/dist">
<include name="platform.jar"/>
</fileset>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<classpath>
<path refid="classpath"/>
</classpath>
<src>
<dirset dir="${src}"/>
</src>
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
</project>
@@ -10,7 +10,7 @@
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*/
package com.sun.jna.examples;
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -31,11 +31,14 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.RoundRectangle2D;
import javax.swing.Box;
import javax.swing.JWindow;
import javax.swing.Popup;
import javax.swing.SwingUtilities;
import com.sun.jna.platform.WindowUtils;
/**
* Provides a popup balloon containing an arbitrary component. This provides
* a form of content-specific decoration less transient than a tooltip, and less
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.contrib.demo;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -24,6 +24,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Rectangle2D;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -35,6 +36,8 @@ import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import com.sun.jna.platform.WindowUtils;
/** Demonstration of BalloonManager. */
public class BalloonManagerDemo {
private static final int ICON_SIZE = 48;
+7
Ver Arquivo
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>balloontips</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+77
Ver Arquivo
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-balloontips.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
<path id="classpath">
<fileset dir="../../../build">
<include name="jna.jar"/>
</fileset>
<fileset dir="../platform/dist">
<include name="platform.jar"/>
</fileset>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<classpath>
<path refid="classpath"/>
</classpath>
<src>
<dirset dir="${src}"/>
</src>
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
</project>
@@ -1,4 +1,4 @@
//package bms.ui.widgets;
package com.sun.jna.contrib.demo;
import java.awt.Color;
import java.awt.Component;
@@ -30,7 +30,7 @@ import javax.swing.Popup;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import com.sun.jna.examples.WindowUtils;
import com.sun.jna.platform.WindowUtils;
/**
* The BalloonTipManager class handles creation and disposal of balloon style
@@ -61,7 +61,6 @@ public class BalloonTipManager {
/*
* The BalloonTip class defines the look of the BalloonTip object.
*/
@SuppressWarnings("serial")
private static final class BalloonTip extends JWindow {
private static final Integer HMARGIN = 10;
private static final Integer VMARGIN = 6;
@@ -1,4 +1,4 @@
//package bms.ui.widgets;
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Color;
+8
Ver Arquivo
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>dnddemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+77
Ver Arquivo
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-dnd.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
<path id="classpath">
<fileset dir="../../../build">
<include name="jna.jar"/>
</fileset>
<fileset dir="../platform/dist">
<include name="platform.jar"/>
</fileset>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<classpath>
<path refid="classpath"/>
</classpath>
<src>
<dirset dir="${src}"/>
</src>
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
</project>
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.dnd;
package com.sun.jna.contrib.demo;
import java.awt.Image;
import java.awt.Point;
@@ -32,6 +32,10 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;
import com.sun.jna.platform.dnd.DragHandler;
import com.sun.jna.platform.dnd.DropHandler;
/** Demonstrate ghosted drag images. Unfortunately, Swing drag support hides
* the hooks we need to move the drag image around, so we don't use it and
* roll our own.

Antes

Largura:  |  Altura:  |  Tamanho: 28 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 28 KiB

+10
Ver Arquivo
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ntservice</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -19,7 +19,7 @@ is divided into following sections:
- cleanup
-->
<project name="JnaContrib-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
<!--
======================
@@ -14,12 +14,13 @@ debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/JnaContrib.jar
dist.jar=${dist.dir}/contrib-ntservice.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=lib/jna.jar
file.reference.jna.jar=../../../build/jna.jar
libs.junit.classpath=../../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar}
${file.reference.jna.jar};
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
@@ -3,7 +3,7 @@
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>JnaContrib</name>
<name>ntservice</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<source-roots>
<root id="src.dir"/>
+10
Ver Arquivo
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>platform</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+73
Ver Arquivo
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="default" basedir=".">
<description>Builds, tests, and runs the project platform.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JnaContrib-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<condition property="tests.platform" value="win32">
<os family="windows"/>
</condition>
<target name="test" description="Run unit tests." if="tests.platform">
<antcall target="test-win32" />
</target>
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
</project>
@@ -0,0 +1,541 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
For the purpose of easier reading the script
is divided into following sections:
- initialization
- compilation
- jar
- execution
- debugging
- javadoc
- junit compilation
- junit execution
- junit debugging
- applet
- cleanup
-->
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
<!--
======================
INITIALIZATION SECTION
======================
-->
<target name="-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-init-private" depends="-pre-init">
<property file="nbproject/private/private.properties"/>
</target>
<target name="-init-user" depends="-pre-init,-init-private">
<property file="${user.properties.file}"/>
<!-- The two properties below are usually overridden -->
<!-- by the active platform. Just a fallback. -->
<property name="default.javac.source" value="1.4"/>
<property name="default.javac.target" value="1.4"/>
</target>
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
<property file="nbproject/project.properties"/>
</target>
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
<available file="${manifest.file}" property="manifest.available"/>
<condition property="manifest.available+main.class">
<and>
<isset property="manifest.available"/>
<isset property="main.class"/>
<not>
<equals arg1="${main.class}" arg2="" trim="true"/>
</not>
</and>
</condition>
<condition property="manifest.available+main.class+mkdist.available">
<and>
<istrue value="${manifest.available+main.class}"/>
<isset property="libs.CopyLibs.classpath"/>
</and>
</condition>
<condition property="have.tests">
<or>
<available file="${test.src.dir}"/>
</or>
</condition>
<condition property="have.sources">
<or>
<available file="${src.dir}"/>
</or>
</condition>
<condition property="netbeans.home+have.tests">
<and>
<isset property="netbeans.home"/>
<isset property="have.tests"/>
</and>
</condition>
<condition property="no.javadoc.preview">
<isfalse value="${javadoc.preview}"/>
</condition>
<property name="run.jvmargs" value=""/>
<property name="javac.compilerargs" value=""/>
<property name="work.dir" value="${basedir}"/>
<condition property="no.deps">
<and>
<istrue value="${no.dependencies}"/>
</and>
</condition>
<property name="javac.debug" value="true"/>
<property name="javadoc.preview" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
<fail unless="dist.dir">Must set dist.dir</fail>
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
<fail unless="dist.jar">Must set dist.jar</fail>
</target>
<target name="-init-macrodef-property">
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-javac">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="srcdir" default="${src.dir}"/>
<attribute name="destdir" default="${build.classes.dir}"/>
<attribute name="classpath" default="${javac.classpath}"/>
<attribute name="debug" default="${javac.debug}"/>
<element name="customize" optional="true"/>
<sequential>
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
<classpath>
<path path="@{classpath}"/>
</classpath>
<compilerarg line="${javac.compilerargs}"/>
<customize/>
</javac>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-junit">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="includes" default="**/*Test.java"/>
<sequential>
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" includes="@{includes}"/>
</batchtest>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper type="glob" from="test-sys-prop.*" to="*"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg line="${run.jvmargs}"/>
</junit>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="name" default="${main.class}"/>
<attribute name="classpath" default="${debug.classpath}"/>
<attribute name="stopclassname" default=""/>
<sequential>
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
<classpath>
<path path="@{classpath}"/>
</classpath>
</nbjpdastart>
</sequential>
</macrodef>
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="dir" default="${build.classes.dir}"/>
<sequential>
<nbjpdareload>
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
</nbjpdareload>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-debug">
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="classname" default="${main.class}"/>
<attribute name="classpath" default="${debug.classpath}"/>
<element name="customize" optional="true"/>
<sequential>
<java fork="true" classname="@{classname}" dir="${work.dir}">
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=none"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="@{classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper type="glob" from="run-sys-prop.*" to="*"/>
</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-java">
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="classname" default="${main.class}"/>
<element name="customize" optional="true"/>
<sequential>
<java fork="true" classname="@{classname}" dir="${work.dir}">
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="${run.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper type="glob" from="run-sys-prop.*" to="*"/>
</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>
<target name="-init-presetdef-jar">
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
<jar jarfile="${dist.jar}" compress="${jar.compress}">
<j2seproject1:fileset dir="${build.classes.dir}"/>
</jar>
</presetdef>
</target>
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
<!--
===================
COMPILATION SECTION
===================
-->
<target name="deps-jar" depends="init" unless="no.deps"/>
<target name="-pre-pre-compile" depends="init,deps-jar">
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="-pre-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
<j2seproject3:javac/>
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
</copy>
</target>
<target name="-post-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
<target name="-pre-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<j2seproject3:javac>
<customize>
<patternset includes="${javac.includes}"/>
</customize>
</j2seproject3:javac>
</target>
<target name="-post-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
<!--
====================
JAR BUILDING SECTION
====================
-->
<target name="-pre-pre-jar" depends="init">
<dirname property="dist.jar.dir" file="${dist.jar}"/>
<mkdir dir="${dist.jar.dir}"/>
</target>
<target name="-pre-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
<j2seproject1:jar/>
</target>
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
<j2seproject1:jar manifest="${manifest.file}"/>
</target>
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
<j2seproject1:jar manifest="${manifest.file}">
<j2seproject1:manifest>
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
</j2seproject1:manifest>
</j2seproject1:jar>
<echo>To run this application from the command line without Ant, try:</echo>
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
<property name="dist.jar.resolved" location="${dist.jar}"/>
<pathconvert property="run.classpath.with.dist.jar">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
</pathconvert>
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
</target>
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
<pathconvert property="run.classpath.without.build.classes.dir">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to=""/>
</pathconvert>
<pathconvert property="jar.classpath" pathsep=" ">
<path path="${run.classpath.without.build.classes.dir}"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
</copylibs>
<echo>To run this application from the command line without Ant, try:</echo>
<property name="dist.jar.resolved" location="${dist.jar}"/>
<echo>java -jar "${dist.jar.resolved}"</echo>
</target>
<target name="-post-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
<!--
=================
EXECUTION SECTION
=================
-->
<target name="run" depends="init,compile" description="Run a main class.">
<j2seproject1:java>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject1:java>
</target>
<target name="run-single" depends="init,compile-single">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<j2seproject1:java classname="${run.class}"/>
</target>
<!--
=================
DEBUGGING SECTION
=================
-->
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
<j2seproject1:nbjpdastart name="${debug.class}"/>
</target>
<target name="-debug-start-debuggee" depends="init,compile">
<j2seproject3:debug>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
</target>
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
<j2seproject3:debug classname="${debug.class}"/>
</target>
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
<target name="-pre-debug-fix" depends="init">
<fail unless="fix.includes">Must set fix.includes</fail>
<property name="javac.includes" value="${fix.includes}.java"/>
</target>
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
<j2seproject1:nbjpdareload/>
</target>
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
<!--
===============
JAVADOC SECTION
===============
-->
<target name="-javadoc-build" depends="init">
<mkdir dir="${dist.javadoc.dir}"/>
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<sourcepath>
<pathelement location="${src.dir}"/>
</sourcepath>
<packageset dir="${src.dir}" includes="*/**"/>
<fileset dir="${src.dir}" includes="*.java"/>
</javadoc>
</target>
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
</target>
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
<!--
=========================
JUNIT COMPILATION SECTION
=========================
-->
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
<mkdir dir="${build.test.classes.dir}"/>
</target>
<target name="-pre-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="-post-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
<target name="-pre-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
<customize>
<patternset includes="${javac.includes}"/>
</customize>
</j2seproject3:javac>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="-post-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
<!--
=======================
JUNIT EXECUTION SECTION
=======================
-->
<target name="-pre-test-run" if="have.tests" depends="init">
<mkdir dir="${build.test.results.dir}"/>
</target>
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
<j2seproject3:junit/>
</target>
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
<target name="test-report" if="have.tests" depends="init"/>
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
<target name="-pre-test-run-single" if="have.tests" depends="init">
<mkdir dir="${build.test.results.dir}"/>
</target>
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
<j2seproject3:junit includes="${test.includes}"/>
</target>
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
<!--
=======================
JUNIT DEBUGGING SECTION
=======================
-->
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
<customize>
<arg line="${test.class}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
</target>
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
</target>
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
<!--
=========================
APPLET EXECUTION SECTION
=========================
-->
<target name="run-applet" depends="init,compile-single">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer">
<customize>
<arg value="${applet.url}"/>
</customize>
</j2seproject1:java>
</target>
<!--
=========================
APPLET DEBUGGING SECTION
=========================
-->
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer">
<customize>
<arg value="${applet.url}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
<!--
===============
CLEANUP SECTION
===============
-->
<target name="deps-clean" depends="init" unless="no.deps"/>
<target name="-do-clean" depends="init">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="-post-clean">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
</project>
@@ -0,0 +1,59 @@
application.args=
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/platform.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=../../../build/jna.jar
libs.junit.classpath=../../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar};
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.source=1.5
javac.target=1.5
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.junit.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
src.dir=src
test.src.dir=test
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>platform</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>
@@ -0,0 +1,135 @@
/* 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.
* <p/>
* 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.sun.jna.platform;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sun.jna.platform.win32.W32FileMonitor;
/** Provides notification of file system changes. Actual capabilities may
* vary slightly by platform.
* <p>
* Watched files which are removed from the filesystem are no longer watched.
* @author twall
*/
@SuppressWarnings("serial")
public abstract class FileMonitor {
public static final int FILE_CREATED = 0x1;
public static final int FILE_DELETED = 0x2;
public static final int FILE_MODIFIED = 0x4;
public static final int FILE_ACCESSED = 0x8;
public static final int FILE_NAME_CHANGED_OLD = 0x10;
public static final int FILE_NAME_CHANGED_NEW = 0x20;
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
public static final int FILE_SIZE_CHANGED = 0x40;
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
public static final int FILE_SECURITY_CHANGED = 0x100;
public static final int FILE_ANY = 0x1FF;
public interface FileListener {
public void fileChanged(FileEvent e);
}
public class FileEvent extends EventObject {
private final File file;
private final int type;
public FileEvent(File file, int type) {
super(FileMonitor.this);
this.file = file;
this.type = type;
}
public File getFile() { return file; }
public int getType() { return type; }
public String toString() {
return "FileEvent: " + file + ":" + type;
}
}
private final Map<File, Integer> watched = new HashMap<File, Integer>();
private List<FileListener> listeners = new ArrayList<FileListener>();
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
protected abstract void unwatch(File file);
public abstract void dispose();
public void addWatch(File dir) throws IOException {
addWatch(dir, FILE_ANY);
}
public void addWatch(File dir, int mask) throws IOException {
addWatch(dir, mask, dir.isDirectory());
}
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
watched.put(dir, new Integer(mask));
watch(dir, mask, recursive);
}
public void removeWatch(File file) {
if (watched.remove(file) != null) {
unwatch(file);
}
}
protected void notify(FileEvent e) {
for (FileListener listener : listeners) {
listener.fileChanged(e);
}
}
public synchronized void addFileListener(FileListener listener) {
List<FileListener> list = new ArrayList<FileListener>(listeners);
list.add(listener);
listeners = list;
}
public synchronized void removeFileListener(FileListener x) {
List<FileListener> list = new ArrayList<FileListener>(listeners);
list.remove(x);
listeners = list;
}
protected void finalize() {
for (File watchedFile : watched.keySet()) {
removeWatch(watchedFile);
}
dispose();
}
/** Canonical lazy loading of a singleton. */
private static class Holder {
public static final FileMonitor INSTANCE;
static {
String os = System.getProperty("os.name");
if (os.startsWith("Windows")) {
INSTANCE = new W32FileMonitor();
}
else {
throw new Error("FileMonitor not implemented for " + os);
}
}
}
public static FileMonitor getInstance() {
return Holder.INSTANCE;
}
}
@@ -10,11 +10,15 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.platform;
import java.io.File;
import com.sun.jna.examples.win32.Shell32;
import com.sun.jna.examples.win32.Shell32.SHFILEOPSTRUCT;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.platform.mac.MacFileUtils;
import com.sun.jna.platform.win32.W32FileUtils;
/** Miscellaneous file utils not provided for by Java. */
public abstract class FileUtils {
@@ -24,9 +28,9 @@ public abstract class FileUtils {
}
/** Move the given file to the system trash, if one is available.
Returns whether the operation was successful.
Throws an exception on failure.
*/
public abstract boolean moveToTrash(File[] files);
public abstract void moveToTrash(File[] files) throws IOException;
/** Canonical lazy loading of a singleton. */
private static class Holder {
@@ -47,48 +51,7 @@ public abstract class FileUtils {
public static FileUtils getInstance() {
return Holder.INSTANCE;
}
private static class W32FileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public boolean moveToTrash(File[] files) {
Shell32 shell = Shell32.INSTANCE;
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
fileop.wFunc = Shell32.FO_DELETE;
String[] paths = new String[files.length];
for (int i=0;i < paths.length;i++) {
paths[i] = files[i].getAbsolutePath();
}
fileop.pFrom = fileop.encodePaths(paths);
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
return shell.SHFileOperation(fileop) == 0;
}
}
private static class MacFileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public boolean moveToTrash(File[] files) {
// TODO: use native API for moving to trash (if any)
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (trash.exists()) {
boolean success = true;
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
success = false;
}
}
return success;
}
return false;
}
}
}
private static class DefaultFileUtils extends FileUtils {
@@ -105,6 +68,9 @@ public abstract class FileUtils {
trash = new File(desktop, ".Trash");
if (!trash.exists()) {
trash = new File(desktop, "Trash");
if (!trash.exists()) {
trash = new File(System.getProperty("fileutils.trash", "Trash"));
}
}
}
}
@@ -119,19 +85,22 @@ public abstract class FileUtils {
/** The default implementation attempts to move the file to
* the desktop "Trash" folder.
*/
public boolean moveToTrash(File[] files) {
public void moveToTrash(File[] files) throws IOException {
File trash = getTrashDirectory();
if (trash.exists()) {
boolean success = true;
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target))
success = false;
}
return success;
if (!trash.exists()) {
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
}
List<File> failed = new ArrayList<File>();
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
failed.add(src);
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
return false;
}
}
}
@@ -10,16 +10,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.platform;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.event.KeyEvent;
import com.sun.jna.Platform;
import com.sun.jna.examples.unix.X11;
import com.sun.jna.examples.unix.X11.Display;
import com.sun.jna.examples.win32.User32;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.unix.X11.Display;
import com.sun.jna.platform.win32.User32;
/** Provide access to the local keyboard state. Note that this is meaningless
* on a headless system and some VNC setups.
@@ -153,7 +153,7 @@ public class KeyboardUtils {
int idx = code / 8;
int shift = code % 8;
if ((keys[idx] & (1 << shift)) != 0) {
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0);
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
if (sym == keysym)
return true;
}
@@ -1,16 +1,17 @@
/* Copyright (c) 2007 Olivier Chafik, All Rights Reserved
*
* Copyright (c) 2008 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.
* Lesser General Public License for more details.
*/
package com.sun.jna.examples;
package com.sun.jna.platform;
import java.awt.Rectangle;
import java.awt.image.DataBuffer;
@@ -20,10 +21,16 @@ import java.awt.image.MultiPixelPackedSampleModel;
import java.awt.image.Raster;
import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
/**
* Methods that are useful to decompose a raster in ranges of contiguous unoccupied pixels.
* An occupied pixel has two possible meanings, depending on the raster :
* Methods that are useful to decompose a raster into a set of rectangles.
* An occupied pixel has two possible meanings, depending on the raster :
* <ul>
* <li>if the raster has an alpha layer, occupied means with alpha not null</li>
* <li>if the raster doesn't have any alpha layer, occupied means not completely black</li>
@@ -31,12 +38,18 @@ import java.awt.image.SinglePixelPackedSampleModel;
* @author Olivier Chafik
*/
public class RasterRangesUtils {
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
private static final int[] subColMasks = new int[] {
0x0080, 0x0040, 0x0020, 0x0010,
0x0008, 0x0004, 0x0002, 0x0001
};
private static final Comparator COMPARATOR = new Comparator() {
public int compare(Object o1, Object o2) {
return ((Rectangle)o1).x - ((Rectangle)o2).x;
}
};
/**
* Abstraction of a sink for ranges.
*/
@@ -45,13 +58,13 @@ public class RasterRangesUtils {
* Output a rectangular range.
* @param x x coordinate of the top-left corner of the range
* @param y y coordinate of the top-left corner of the range
* @param w witdh of the range
* @param w width of the range
* @param h height of the range
* @return true if the output succeeded, false otherwise
*/
public boolean outputRange(int x, int y, int w, int h);
boolean outputRange(int x, int y, int w, int h);
}
/**
* Outputs ranges of occupied pixels.
* In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null.
@@ -64,15 +77,15 @@ public class RasterRangesUtils {
Rectangle bounds = raster.getBounds();
SampleModel sampleModel = raster.getSampleModel();
boolean hasAlpha = sampleModel.getNumBands() == 4;
// Try to use the underlying data array directly for a few common raster formats
if (raster.getParent() == null && bounds.x == 0 && bounds.y == 0) {
// No support for subraster (as obtained with Image.getSubimage(...))
DataBuffer data = raster.getDataBuffer();
if (data.getNumBanks() == 1) {
// There is always a single bank for all BufferedImage types, except maybe TYPE_CUSTOM
if (sampleModel instanceof MultiPixelPackedSampleModel) {
MultiPixelPackedSampleModel packedSampleModel = (MultiPixelPackedSampleModel)sampleModel;
if (packedSampleModel.getPixelBitStride() == 1) {
@@ -93,18 +106,21 @@ public class RasterRangesUtils {
int[] pixels = raster.getPixels(0, 0, bounds.width, bounds.height, (int[])null);
return outputOccupiedRanges(pixels, bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
}
/**
* Output the non-null values of a binary image as ranges of contiguous values.
* @param binaryBits byte-packed binary bits of an image
* @param w width of the image (in pixels)
* @param h height of the image
* @param output
* @param out
* @return true if the output succeeded, false otherwise
*/
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput output) {
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
Set rects = new HashSet();
Set prevLine = Collections.EMPTY_SET;
int scanlineBytes = binaryBits.length / h;
for (int row = 0; row < h; row++) {
Set curLine = new TreeSet(COMPARATOR);
int rowOffsetBytes = row * scanlineBytes;
int startCol = -1;
// Look at each batch of 8 columns in this row
@@ -115,9 +131,7 @@ public class RasterRangesUtils {
// all 8 bits are zeroes
if (startCol >= 0) {
// end of current region
if (!output.outputRange(startCol, row, firstByteCol - startCol, 1)) {
return false;
}
curLine.add(new Rectangle(startCol, row, firstByteCol - startCol, 1));
startCol = -1;
}
} else if (byteColBits == 0xff) {
@@ -138,9 +152,7 @@ public class RasterRangesUtils {
} else {
if (startCol >= 0) {
// end of current region
if (!output.outputRange(startCol, row, col - startCol, 1)) {
return false;
}
curLine.add(new Rectangle(startCol, row, col - startCol, 1));
startCol = -1;
}
}
@@ -149,15 +161,23 @@ public class RasterRangesUtils {
}
if (startCol >= 0) {
// end of last region
if (!output.outputRange(startCol, row, w - startCol, 1)) {
return false;
}
startCol = -1;
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
}
Set unmerged = mergeRects(prevLine, curLine);
rects.addAll(unmerged);
prevLine = curLine;
}
// Add anything left over
rects.addAll(prevLine);
for (Iterator i=rects.iterator();i.hasNext();) {
Rectangle r = (Rectangle)i.next();
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
return false;
}
}
return true;
}
/**
* Output the occupied values of an integer-pixels image as ranges of contiguous values.
* A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null.
@@ -169,11 +189,13 @@ public class RasterRangesUtils {
* @return true if the output succeeded, false otherwise
*/
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
Set rects = new HashSet();
Set prevLine = Collections.EMPTY_SET;
for (int row = 0; row < h; row++) {
Set curLine = new TreeSet(COMPARATOR);
int idxOffset = row * w;
int startCol = -1;
for (int col = 0; col < w; col++) {
if ((pixels[idxOffset + col] & occupationMask) != 0) {
if (startCol < 0) {
@@ -182,21 +204,55 @@ public class RasterRangesUtils {
} else {
if (startCol >= 0) {
// end of current region
if (!out.outputRange(startCol, row, col - startCol, 1)) {
return false;
}
curLine.add(new Rectangle(startCol, row, col-startCol, 1));
startCol = -1;
}
}
}
if (startCol >= 0) {
// end of last region of current row
if (!out.outputRange(startCol, row, w - startCol, 1)) {
return false;
}
startCol = -1;
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
}
Set unmerged = mergeRects(prevLine, curLine);
rects.addAll(unmerged);
prevLine = curLine;
}
// Add anything left over
rects.addAll(prevLine);
for (Iterator i=rects.iterator();i.hasNext();) {
Rectangle r = (Rectangle)i.next();
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
return false;
}
}
return true;
}
private static Set mergeRects(Set prev, Set current) {
Set unmerged = new HashSet(prev);
if (!prev.isEmpty() && !current.isEmpty()) {
Rectangle[] pr = (Rectangle[])prev.toArray(new Rectangle[prev.size()]);
Rectangle[] cr = (Rectangle[])current.toArray(new Rectangle[current.size()]);
int ipr = 0;
int icr = 0;
while (ipr < pr.length && icr < cr.length) {
while (cr[icr].x < pr[ipr].x) {
if (++icr == cr.length) {
return unmerged;
}
}
if (cr[icr].x == pr[ipr].x && cr[icr].width == pr[ipr].width) {
unmerged.remove(pr[ipr]);
cr[icr].y = pr[ipr].y;
cr[icr].height = pr[ipr].height + 1;
++icr;
}
else {
++ipr;
}
}
}
return unmerged;
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.dnd;
package com.sun.jna.platform.dnd;
import java.awt.AlphaComposite;
import java.awt.Component;
@@ -38,6 +38,7 @@ import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.InvalidDnDOperationException;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import javax.swing.Icon;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
@@ -162,7 +163,7 @@ public abstract class DragHandler
try {
// getTransferable is available during drag only on 1.5+
return (Transferable)
e.getClass().getMethod("getTransferable", null).invoke(e, null);
e.getClass().getMethod("getTransferable", (Class[])null).invoke(e, (Object[])null);
}
catch(Exception ex) {
// Method not available
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.dnd;
package com.sun.jna.platform.dnd;
import java.awt.Component;
import java.awt.Point;
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.dnd;
package com.sun.jna.platform.dnd;
import java.awt.Point;
import java.awt.dnd.DropTargetEvent;
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.dnd;
package com.sun.jna.platform.dnd;
import java.awt.Component;
import java.awt.Dimension;
@@ -29,7 +29,7 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import com.sun.jna.examples.WindowUtils;
import com.sun.jna.platform.WindowUtils;
/** Provide a ghosted drag image for use during drags where
* {@link DragSource#isDragImageSupported} returns false.<p>
@@ -0,0 +1,45 @@
/* 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.sun.jna.platform.mac;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.platform.FileUtils;
public class MacFileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public void moveToTrash(File[] files) throws IOException {
// TODO: use native API for moving to trash (if any)
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List failed = new ArrayList();
for (int i=0;i < files.length;i++) {
File src = files[i];
File target = new File(trash, src.getName());
if (!src.renameTo(target)) {
failed.add(src);
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -0,0 +1,623 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.platform.win32.WinNT.PSIDByReference;
import com.sun.jna.platform.win32.WinNT.SECURITY_ATTRIBUTES;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
/**
* Advapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Advapi32 extends W32API {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves the name of the user associated with the current thread.
* http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx
*
* @param buffer
* Buffer to receive the user's logon name.
* @param len
* On input, the size of the buffer, on output the number of
* characters copied into the buffer, including the terminating
* null character.
* @return
* True if succeeded.
*/
public boolean GetUserNameW(char[] buffer, IntByReference len);
/**
* Accepts the name of a system and anaccount as input and retrieves a security
* identifier (SID) for the account and the name of the domain on which the
* account was found.
* http://msdn.microsoft.com/en-us/library/aa379159(VS.85).aspx
*
* @param lpSystemName
* Specifies the name of the system.
* @param lpAccountName
* Specifies the account name.
* @param Sid
* Receives the SID structure that corresponds to the account
* name pointed to by the lpAccountName parameter.
* @param cbSid
* On input, this value specifies the size, in bytes, of the Sid
* buffer. If the function fails because the buffer is too small
* or if cbSid is zero, this variable receives the required
* buffer size.
* @param ReferencedDomainName
* Receives the name of the domain where the account name is found.
* @param cchReferencedDomainName
* On input, this value specifies the size, in TCHARs, of the
* ReferencedDomainName buffer. If the function fails because the
* buffer is too small, this variable receives the required
* buffer size, including the terminating null character.
* @param peUse
* SID_NAME_USE enumerated type that indicates the type of the
* account when the function returns.
* @return
* True if the function was successful, False otherwise.
*/
public boolean LookupAccountName(String lpSystemName,
String lpAccountName, PSID Sid, IntByReference cbSid,
char[] ReferencedDomainName,
IntByReference cchReferencedDomainName, PointerByReference peUse);
/**
* Retrieves the name of the account for this SID and the name of the first domain
* on which this SID is found.
*
* @param lpSystemName Specifies the target computer.
* @param Sid The SID to look up.
* @param lpName
* Buffer that receives a null-terminated string that contains the
* account name that corresponds to the lpSid parameter.
* @param cchName
* On input, specifies the size, in TCHARs, of the lpName buffer. If the function fails
* because the buffer is too small or if cchName is zero, cchName receives the required
* buffer size, including the terminating null character.
* @param ReferencedDomainName
* Pointer to a buffer that receives a null-terminated string that contains the name of
* the domain where the account name was found.
* @param cchReferencedDomainName
* On input, specifies the size, in TCHARs, of the lpReferencedDomainName buffer. If the
* function fails because the buffer is too small or if cchReferencedDomainName is zero,
* cchReferencedDomainName receives the required buffer size, including the terminating
* null character.
* @param peUse
* Pointer to a variable that receives a SID_NAME_USE value that indicates the type of
* the account.
* @return
* If the function succeeds, the function returns nonzero.
* If the function fails, it returns zero. To get extended error information, call
* GetLastError.
*/
public boolean LookupAccountSid(String lpSystemName, PSID Sid,
char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
IntByReference cchReferencedDomainName, PointerByReference peUse);
/**
* Convert a security identifier (SID) to a string format suitable for display,
* storage, or transmission.
* http://msdn.microsoft.com/en-us/library/aa376399(VS.85).aspx
*
* @param Sid
* The SID structure to be converted.
* @param StringSid
* Pointer to a variable that receives a pointer to a
* null-terminated SID string. To free the returned buffer, call
* the LocalFree function.
* @return True if the function was successful, False otherwise.
*/
public boolean ConvertSidToStringSid(PSID Sid,
PointerByReference StringSid);
/**
* Convert a string-format security identifier (SID) into a valid, functional SID.
* http://msdn.microsoft.com/en-us/library/aa376402(VS.85).aspx
*
* @param StringSid The string-format SID to convert.
* @param Sid Receives a pointer to the converted SID.
* @return True if the function was successful, False otherwise.
*/
public boolean ConvertStringSidToSid(String StringSid,
PSIDByReference Sid);
/**
* Returns the length, in bytes, of a valid security identifier (SID).
* http://msdn.microsoft.com/en-us/library/aa446642(VS.85).aspx
*
* @param pSid A pointer to the SID structure whose length is returned.
* @return Length of the SID.
*/
public int GetLengthSid(PSID pSid);
/**
* The IsValidSid function validates a security identifier (SID) by verifying that
* the revision number is within a known range, and that the number of subauthorities
* is less than the maximum.
* @param pSid
* Pointer to the SID structure to validate. This parameter cannot be NULL.
* @return
* If the SID structure is valid, the return value is nonzero.
* If the SID structure is not valid, the return value is zero. There is no extended
* error information for this function; do not call GetLastError.
*/
public boolean IsValidSid(PSID pSid);
/**
* The LogonUser function attempts to log a user on to the local computer. The local computer is
* the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote
* computer. You specify the user with a user name and domain, and authenticate the user with a
* plaintext password. If the function succeeds, you receive a handle to a token that represents
* the logged-on user. You can then use this token handle to impersonate the specified user or,
* in most cases, to create a process that runs in the context of the specified user.
* @param lpszUsername
* A pointer to a null-terminated string that specifies the name of the user. This is the name of
* the user account to log on to. If you use the user principal name (UPN) format,
* user@DNS_domain_name, the lpszDomain parameter must be NULL.
* @param lpszDomain
* A pointer to a null-terminated string that specifies the name of the domain or server whose
* account database contains the lpszUsername account. If this parameter is NULL, the user name
* must be specified in UPN format. If this parameter is ".", the function validates the account
* using only the local account database.
* @param lpszPassword
* A pointer to a null-terminated string that specifies the plaintext password for the user
* account specified by lpszUsername.
* @param logonType
* The type of logon operation to perform.
* @param logonProvider
* Specifies the logon provider.
* @param phToken
* A pointer to a handle variable that receives a handle to a token that represents the specified user.
* @return
* If the function succeeds, the function returns nonzero.
* If the function fails, it returns zero. To get extended error information, call GetLastError.
*/
public boolean LogonUser(
String lpszUsername,
String lpszDomain,
String lpszPassword,
int logonType,
int logonProvider,
HANDLEByReference phToken);
/**
* The OpenThreadToken function opens the access token associated with a thread.
* @param ThreadHandle
* Handle to the thread whose access token is opened.
* @param DesiredAccess
* Specifies an access mask that specifies the requested types of access to the access token.
* These requested access types are reconciled against the token's discretionary access
* control list (DACL) to determine which accesses are granted or denied.
* @param OpenAsSelf
* Indicates whether the access check is to be made against the security context of the
* thread calling the OpenThreadToken function or against the security context of the
* process for the calling thread.
* @param TokenHandle
* Pointer to a variable that receives the handle to the newly opened access token.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
public boolean OpenThreadToken(
HANDLE ThreadHandle,
int DesiredAccess,
boolean OpenAsSelf,
HANDLEByReference TokenHandle);
/**
* The OpenProcessToken function opens the access token associated with a process.
* @param ProcessHandle
* Handle to the process whose access token is opened. The process must have the
* PROCESS_QUERY_INFORMATION access permission.
* @param DesiredAccess
* Specifies an access mask that specifies the requested types of access to the access
* token. These requested access types are compared with the discretionary access
* control list (DACL) of the token to determine which accesses are granted or denied.
* @param TokenHandle
* Pointer to a handle that identifies the newly opened access token when the function returns.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
public boolean OpenProcessToken(
HANDLE ProcessHandle,
int DesiredAccess,
HANDLEByReference TokenHandle);
/**
* The DuplicateToken function creates a new access token that duplicates
* one already in existence.
*
* @param ExistingTokenHandle
* Handle to an access token opened with TOKEN_DUPLICATE access.
* @param ImpersonationLevel
* Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that supplies
* the impersonation level of the new token.
* @param DuplicateTokenHandle
* Pointer to a variable that receives a handle to the duplicate token.
* This handle has TOKEN_IMPERSONATE and TOKEN_QUERY access to the new token.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
public boolean DuplicateToken(
HANDLE ExistingTokenHandle,
int ImpersonationLevel,
HANDLEByReference DuplicateTokenHandle);
/**
* Retrieves a specified type of information about an access token.
* The calling process must have appropriate access rights to obtain the information.
* @param tokenHandle
* Handle to an access token from which information is retrieved. If TokenInformationClass
* specifies TokenSource, the handle must have TOKEN_QUERY_SOURCE access. For all other
* TokenInformationClass values, the handle must have TOKEN_QUERY access.
* @param tokenInformationClass
* Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type to identify the type of
* information the function retrieves.
* @param tokenInformation
* Pointer to a buffer the function fills with the requested information. The structure put
* into this buffer depends upon the type of information specified by the TokenInformationClass
* parameter.
* @param tokenInformationLength
* Specifies the size, in bytes, of the buffer pointed to by the TokenInformation parameter.
* If TokenInformation is NULL, this parameter must be zero.
* @param returnLength
* Pointer to a variable that receives the number of bytes needed for the buffer pointed to by
* the TokenInformation parameter. If this value is larger than the value specified in the
* TokenInformationLength parameter, the function fails and stores no data in the buffer.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
*/
public boolean GetTokenInformation(
HANDLE tokenHandle,
int tokenInformationClass,
Structure tokenInformation,
int tokenInformationLength,
IntByReference returnLength);
/**
* The ImpersonateLoggedOnUser function lets the calling thread impersonate the
* security context of a logged-on user. The user is represented by a token
* handle.
* @param hToken
* Handle to a primary or impersonation access token that represents a logged-on
* user. This can be a token handle returned by a call to LogonUser,
* CreateRestrictedToken, DuplicateToken, DuplicateTokenEx, OpenProcessToken,
* or OpenThreadToken functions. If hToken is a primary token, it must have
* TOKEN_QUERY and TOKEN_DUPLICATE access. If hToken is an impersonation token,
* it must have TOKEN_QUERY and TOKEN_IMPERSONATE access.
* @return
* If the function succeeds, the return value is nonzero.
*/
public boolean ImpersonateLoggedOnUser(
HANDLE hToken);
/**
* The RevertToSelf function terminates the impersonation of a client application.
* @return If the function succeeds, the return value is nonzero.
*/
public boolean RevertToSelf();
/**
* The RegOpenKeyEx function opens the specified registry key.
* Note that key names are not case sensitive.
* @param hKey
* Handle to an open key.
* @param lpSubKey
* Pointer to a null-terminated string containing the name of the subkey to open.
* @param ulOptions
* Reserved; must be zero.
* @param samDesired
* Access mask that specifies the desired access rights to the key. The function
* fails if the security descriptor of the key does not permit the requested access
* for the calling process.
* @param phkResult
* Pointer to a variable that receives a handle to the opened key. If the key is
* not one of the predefined registry keys, call the RegCloseKey function after
* you have finished using the handle.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS.
* If the function fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegOpenKeyEx(HKEY hKey, String lpSubKey, int ulOptions, int samDesired,
HKEYByReference phkResult);
/**
* The RegQueryValueEx function retrieves the type and data for a specified value name
* associated with an open registry key.
* @param hKey
* Handle to an open key. The key must have been opened with the
* KEY_QUERY_VALUE access right.
* @param lpValueName
* Pointer to a null-terminated string containing the name of the value to query.
* If lpValueName is NULL or an empty string, "", the function retrieves the type
* and data for the key's unnamed or default value, if any.
* @param lpReserved
* Reserved; must be NULL.
* @param lpType
* Pointer to a variable that receives a code indicating the type of data stored
* in the specified value.
* @param lpData
* Pointer to a buffer that receives the value's data. This parameter can be NULL
* if the data is not required. If the data is a string, the function checks for
* a terminating null character. If one is not found, the string is stored with a
* null terminator if the buffer is large enough to accommodate the extra
* character. Otherwise, the string is stored as is.
* @param lpcbData
* Pointer to a variable that specifies the size of the buffer pointed to by the
* lpData parameter, in bytes. When the function returns, this variable contains
* the size of the data copied to lpData. The lpcbData parameter can be NULL only
* if lpData is NULL. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ
* type, this size includes any terminating null character or characters.
* If the buffer specified by lpData parameter is not large enough to hold the
* data, the function returns ERROR_MORE_DATA and stores the required buffer size
* in the variable pointed to by lpcbData. In this case, the contents of the lpData
* buffer are undefined. If lpData is NULL, and lpcbData is non-NULL, the function
* returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable
* pointed to by lpcbData. This enables an application to determine the best way
* to allocate a buffer for the value's data.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS.
* If the function fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, char[] lpData, IntByReference lpcbData);
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
IntByReference lpType, IntByReference lpData, IntByReference lpcbData);
/**
* The RegCloseKey function releases a handle to the specified registry key.
* @param hKey
* Handle to the open key to be closed. The handle must have been opened by the
* RegCreateKeyEx, RegOpenKeyEx, or RegConnectRegistry function.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegCloseKey(HKEY hKey);
/**
* The RegDeleteValue function removes a named value from the specified registry
* key. Note that value names are not case sensitive.
* @param hKey
* Handle to an open key. The key must have been opened with the KEY_SET_VALUE
* access right.
* @param lpValueName
* Pointer to a null-terminated string that names the value to remove. If this
* parameter is NULL or an empty string, the value set by the RegSetValue function
* is removed.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegDeleteValue(HKEY hKey, String lpValueName);
/**
* The RegSetValueEx function sets the data and type of a specified value under a
* registry key.
* @param hKey
* Handle to an open key. The key must have been opened with the KEY_SET_VALUE
* access right.
* @param lpValueName
* Pointer to a string containing the name of the value to set. If a value with
* this name is not already present in the key, the function adds it to the key.
* If lpValueName is NULL or an empty string, "", the function sets the type and
* data for the key's unnamed or default value.
* @param Reserved
* Reserved; must be zero.
* @param dwType
* Type of data pointed to by the lpData parameter.
* @param lpData
* Pointer to a buffer containing the data to be stored with the specified value name.
* @param cbData
* Size of the information pointed to by the lpData parameter, in bytes. If the data
* is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of
* the terminating null character or characters.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
char[] lpData, int cbData);
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
byte[] lpData, int cbData);
/**
*
* @param hKey
* @param lpSubKey
* @param Reserved
* @param lpClass
* @param dwOptions
* @param samDesired
* @param lpSecurityAttributes
* @param phkResult
* @param lpdwDisposition
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegCreateKeyEx(HKEY hKey, String lpSubKey, int Reserved, String lpClass,
int dwOptions, int samDesired, SECURITY_ATTRIBUTES lpSecurityAttributes,
HKEYByReference phkResult, IntByReference lpdwDisposition);
/**
*
* @param hKey
* @param name
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegDeleteKey(HKEY hKey, String name);
/**
* The RegEnumKeyEx function enumerates subkeys of the specified open registry key.
* The function retrieves information about one subkey each time it is called.
* @param hKey
* Handle to an open key. The key must have been opened with the
* KEY_ENUMERATE_SUB_KEYS access right.
* @param dwIndex
* Index of the subkey to retrieve. This parameter should be zero for the first
* call to the RegEnumKeyEx function and then incremented for subsequent calls.
* Because subkeys are not ordered, any new subkey will have an arbitrary index.
* This means that the function may return subkeys in any order.
* @param lpName
* Pointer to a buffer that receives the name of the subkey, including the
* terminating null character. The function copies only the name of the subkey,
* not the full key hierarchy, to the buffer.
* @param lpcName
* Pointer to a variable that specifies the size of the buffer specified by the
* lpName parameter, in TCHARs. This size should include the terminating null
* character. When the function returns, the variable pointed to by lpcName
* contains the number of characters stored in the buffer. The count returned
* does not include the terminating null character.
* @param reserved
* Reserved; must be NULL.
* @param lpClass
* Pointer to a buffer that receives the null-terminated class string of the
* enumerated subkey. This parameter can be NULL.
* @param lpcClass
* Pointer to a variable that specifies the size of the buffer specified by the
* lpClass parameter, in TCHARs. The size should include the terminating null
* character. When the function returns, lpcClass contains the number of
* characters stored in the buffer. The count returned does not include the
* terminating null character. This parameter can be NULL only if lpClass is NULL.
* @param lpftLastWriteTime
* Pointer to a variable that receives the time at which the enumerated subkey
* was last written.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegEnumKeyEx(HKEY hKey, int dwIndex, char[] lpName, IntByReference lpcName,
IntByReference reserved, char[] lpClass, IntByReference lpcClass,
WinBase.FILETIME lpftLastWriteTime);
/**
* The RegEnumValue function enumerates the values for the specified open registry
* key. The function copies one indexed value name and data block for the key each
* time it is called.
* @param hKey
* Handle to an open key. The key must have been opened with the KEY_QUERY_VALUE
* access right.
* @param dwIndex
* Index of the value to be retrieved. This parameter should be zero for the first
* call to the RegEnumValue function and then be incremented for subsequent calls.
* Because values are not ordered, any new value will have an arbitrary index.
* This means that the function may return values in any order.
* @param lpValueName
* Pointer to a buffer that receives the name of the value, including the
* terminating null character.
* @param lpcchValueName
* Pointer to a variable that specifies the size of the buffer pointed to by the
* lpValueName parameter, in TCHARs. This size should include the terminating null
* character. When the function returns, the variable pointed to by lpcValueName
* contains the number of characters stored in the buffer. The count returned
* does not include the terminating null character.
* @param reserved
* Reserved; must be NULL.
* @param lpType
* Pointer to a variable that receives a code indicating the type of data stored
* in the specified value.
* @param lpData
* Pointer to a buffer that receives the data for the value entry. This parameter
* can be NULL if the data is not required.
* @param lpcbData
* Pointer to a variable that specifies the size of the buffer pointed to by the
* lpData parameter, in bytes.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegEnumValue(HKEY hKey, int dwIndex, char[] lpValueName,
IntByReference lpcchValueName, IntByReference reserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
/**
* The RegQueryInfoKey function retrieves information about the specified
* registry key.
* @param hKey
* A handle to an open key. The key must have been opened with the
* KEY_QUERY_VALUE access right.
* @param lpClass
* A pointer to a buffer that receives the null-terminated class
* string of the key. This parameter can be ignored. This parameter can be NULL.
* @param lpcClass
* A pointer to a variable that specifies the size of the buffer pointed to by
* the lpClass parameter, in characters.
* @param lpReserved
* Reserved; must be NULL.
* @param lpcSubKeys
* A pointer to a variable that receives the number of subkeys that are contained by the specified key.
* This parameter can be NULL.
* @param lpcMaxSubKeyLen
* A pointer to a variable that receives the size of the key's subkey with the
* longest name, in characters, not including the terminating null character.
* This parameter can be NULL.
* @param lpcMaxClassLen
* A pointer to a variable that receives the size of the longest string that
* specifies a subkey class, in characters. The count returned does not include
* the terminating null character. This parameter can be NULL.
* @param lpcValues
* A pointer to a variable that receives the number of values that are associated
* with the key. This parameter can be NULL.
* @param lpcMaxValueNameLen
* A pointer to a variable that receives the size of the key's longest value name,
* in characters. The size does not include the terminating null character. This
* parameter can be NULL.
* @param lpcMaxValueLen
* A pointer to a variable that receives the size of the longest data component
* among the key's values, in bytes. This parameter can be NULL.
* @param lpcbSecurityDescriptor
* A pointer to a variable that receives the size of the key's security descriptor,
* in bytes. This parameter can be NULL.
* @param lpftLastWriteTime
* A pointer to a FILETIME structure that receives the last write time.
* This parameter can be NULL.
* @return
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
* fails, the return value is a nonzero error code defined in Winerror.h.
*/
public int RegQueryInfoKey(HKEY hKey, char[] lpClass,
IntByReference lpcClass, IntByReference lpReserved,
IntByReference lpcSubKeys, IntByReference lpcMaxSubKeyLen,
IntByReference lpcMaxClassLen, IntByReference lpcValues,
IntByReference lpcMaxValueNameLen, IntByReference lpcMaxValueLen,
IntByReference lpcbSecurityDescriptor,
WinBase.FILETIME lpftLastWriteTime);
}
@@ -0,0 +1,880 @@
/* 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.sun.jna.platform.win32;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.TreeMap;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.W32API.HANDLE;
import com.sun.jna.platform.win32.W32API.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.platform.win32.WinNT.PSIDByReference;
import com.sun.jna.platform.win32.WinNT.SID_AND_ATTRIBUTES;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Advapi32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Advapi32Util {
/**
* A group.
*/
public static class Group {
/**
* Group name. When unavailable, always equals to sidString.
*/
public String name;
/**
* String representation of the group SID.
*/
public String sidString;
/**
* Binary representation of the group SID.
*/
public byte[] sid;
}
/**
* An account.
*/
public static class Account {
/**
* Account name.
*/
public String name;
/**
* Account domain.
*/
public String domain;
/**
* Account SID.
*/
public byte[] sid;
/**
* String representation of the account SID.
*/
public String sidString;
/**
* Account type, one of SID_NAME_USE.
*/
public int accountType;
/**
* Fully qualified account name.
*/
public String fqn;
}
/**
* Retrieves the name of the user associated with the current thread.
* @return A user name.
*/
public static String getUserName() {
char[] buffer = new char[128];
IntByReference len = new IntByReference(buffer.length);
boolean result = Advapi32.INSTANCE.GetUserNameW(buffer, len);
if (! result) {
int rc = Kernel32.INSTANCE.GetLastError();
switch(rc) {
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
buffer = new char[len.getValue()];
break;
default:
throw new Win32Exception(Native.getLastError());
}
result = Advapi32.INSTANCE.GetUserNameW(buffer, len);
}
if (! result) {
throw new Win32Exception(Native.getLastError());
}
return Native.toString(buffer);
}
/**
* Retrieves a security identifier (SID) for the account on the current system.
* @param accountName Specifies the account name.
* @return A structure containing the account SID;
*/
public static Account getAccountByName(String accountName) {
return getAccountByName(null, accountName);
}
/**
* Retrieves a security identifier (SID) for a given account.
* @param systemName Name of the system.
* @param accountName Account name.
* @return A structure containing the account SID.
*/
public static Account getAccountByName(String systemName, String accountName) {
IntByReference pSid = new IntByReference(0);
IntByReference cchDomainName = new IntByReference(0);
PointerByReference peUse = new PointerByReference();
if (Advapi32.INSTANCE.LookupAccountName(systemName, accountName, null, pSid, null, cchDomainName, peUse)) {
throw new RuntimeException("LookupAccountNameW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
}
int rc = Kernel32.INSTANCE.GetLastError();
if (pSid.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
Memory sidMemory = new Memory(pSid.getValue());
PSID result = new PSID(sidMemory);
char[] referencedDomainName = new char[cchDomainName.getValue() + 1];
if (! Advapi32.INSTANCE.LookupAccountName(systemName, accountName, result, pSid, referencedDomainName, cchDomainName, peUse)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
Account account = new Account();
account.accountType = peUse.getPointer().getInt(0);
account.name = accountName;
String[] accountNamePartsBs = accountName.split("\\\\", 2);
String[] accountNamePartsAt = accountName.split("@", 2);
if (accountNamePartsBs.length == 2) {
account.name = accountNamePartsBs[1];
} else if (accountNamePartsAt.length == 2) {
account.name = accountNamePartsAt[0];
} else {
account.name = accountName;
}
if (cchDomainName.getValue() > 0) {
account.domain = Native.toString(referencedDomainName);
account.fqn = account.domain + "\\" + account.name;
} else {
account.fqn = account.name;
}
account.sid = result.getBytes();
account.sidString = convertSidToStringSid(new PSID(account.sid));
return account;
}
/**
* Get the account by SID on the local system.
*
* @param sid SID.
* @return Account.
*/
public static Account getAccountBySid(PSID sid) {
return getAccountBySid(null, sid);
}
/**
* Get the account by SID.
*
* @param systemName Name of the system.
* @param sid SID.
* @return Account.
*/
public static Account getAccountBySid(String systemName, PSID sid) {
IntByReference cchName = new IntByReference();
IntByReference cchDomainName = new IntByReference();
PointerByReference peUse = new PointerByReference();
if (Advapi32.INSTANCE.LookupAccountSid(null, sid,
null, cchName, null, cchDomainName, peUse)) {
throw new RuntimeException("LookupAccountSidW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
}
int rc = Kernel32.INSTANCE.GetLastError();
if (cchName.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
char[] domainName = new char[cchDomainName.getValue()];
char[] name = new char[cchName.getValue()];
if (! Advapi32.INSTANCE.LookupAccountSid(null, sid,
name, cchName, domainName, cchDomainName, peUse)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
Account account = new Account();
account.accountType = peUse.getPointer().getInt(0);
account.name = Native.toString(name);
if (cchDomainName.getValue() > 0) {
account.domain = Native.toString(domainName);
account.fqn = account.domain + "\\" + account.name;
} else {
account.fqn = account.name;
}
account.sid = sid.getBytes();
account.sidString = convertSidToStringSid(sid);
return account;
}
/**
* Convert a security identifier (SID) to a string format suitable for display,
* storage, or transmission.
* @param sid SID bytes.
* @return String SID.
*/
public static String convertSidToStringSid(PSID sid) {
PointerByReference stringSid = new PointerByReference();
if (! Advapi32.INSTANCE.ConvertSidToStringSid(sid, stringSid)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
String result = stringSid.getValue().getString(0, true);
Kernel32.INSTANCE.LocalFree(stringSid.getValue());
return result;
}
/**
* Convert a string representation of a security identifier (SID) to
* a binary format.
* @param sid String SID.
* @return SID bytes.
*/
public static byte[] convertStringSidToSid(String sid) {
PSIDByReference pSID = new PSIDByReference();
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sid, pSID)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pSID.getValue().getBytes();
}
/**
* Get an account name from a string SID on the local machine.
*
* @param sidString SID.
* @return Account.
*/
public static Account getAccountBySid(String sidString) {
return getAccountBySid(null, sidString);
}
/**
* Get an account name from a string SID.
*
* @param systemName System name.
* @param sidString SID.
* @return Account.
*/
public static Account getAccountBySid(String systemName, String sidString) {
return getAccountBySid(systemName, new PSID(convertStringSidToSid(sidString)));
}
/**
* This function returns the groups associated with a security token,
* such as a user token.
*
* @param hToken Token.
* @return Token groups.
*/
public static Group[] getTokenGroups(HANDLE hToken) {
// get token group information size
IntByReference tokenInformationLength = new IntByReference();
if (Advapi32.INSTANCE.GetTokenInformation(hToken,
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)
|| Kernel32.INSTANCE.GetLastError() != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
}
// get token group information
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationBuffer);
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, groups,
tokenInformationLength.getValue(), tokenInformationLength)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
ArrayList<Group> userGroups = new ArrayList<Group>();
// make array of names
for (SID_AND_ATTRIBUTES sidAndAttribute : groups.getGroups()) {
Group group = new Group();
group.sid = sidAndAttribute.Sid.getBytes();
group.sidString = Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid);
try {
group.name = Advapi32Util.getAccountBySid(sidAndAttribute.Sid).name;
} catch(Exception e) {
group.name = group.sidString;
}
userGroups.add(group);
}
return userGroups.toArray(new Group[0]);
}
/**
* This function returns the information about the user who owns a security token,
*
* @param hToken Token.
* @return Token user.
*/
public static Account getTokenAccount(HANDLE hToken) {
// get token group information size
IntByReference tokenInformationLength = new IntByReference();
if (Advapi32.INSTANCE.GetTokenInformation(hToken,
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)
|| Kernel32.INSTANCE.GetLastError() != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
}
// get token user information
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationBuffer);
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user,
tokenInformationLength.getValue(), tokenInformationLength)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return getAccountBySid(user.User.Sid);
}
/**
* Return the group memberships of the currently logged on user.
* @return An array of groups.
*/
public static Group[] getCurrentUserGroups() {
HANDLEByReference phToken = new HANDLEByReference();
try {
// open thread or process token
HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
if (! Advapi32.INSTANCE.OpenThreadToken(threadHandle,
WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) {
if (W32Errors.ERROR_NO_TOKEN != Kernel32.INSTANCE.GetLastError()) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
if (! Advapi32.INSTANCE.OpenProcessToken(processHandle,
WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
return getTokenGroups(phToken.getValue());
} finally {
if (phToken.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
if (! Kernel32.INSTANCE.CloseHandle(phToken.getValue())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
}
/**
* Checks whether a registry key exists.
* @param root
* HKEY_LOCAL_MACHINE, etc.
* @param key
* Path to the registry key.
* @return
* True if the key exists.
*/
public static boolean registryKeyExists(HKEY root, String key) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
switch(rc) {
case W32Errors.ERROR_SUCCESS:
Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
return true;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
}
/**
* Checks whether a registry value exists.
* @param root
* HKEY_LOCAL_MACHINE, etc.
* @param key
* Registry key path.
* @param value
* Value name.
* @return
* True if the value exists.
*/
public static boolean registryValueExists(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
try {
switch(rc) {
case W32Errors.ERROR_SUCCESS:
break;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
switch(rc) {
case W32Errors.ERROR_SUCCESS:
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
return true;
case W32Errors.ERROR_FILE_NOT_FOUND:
return false;
default:
throw new Win32Exception(rc);
}
} finally {
if (phkKey.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get a registry REG_SZ value.
* @param root
* Root key.
* @param key
* Registry path.
* @param value
* Name of the value to retrieve.
* @return
* String value.
*/
public static String registryGetStringValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_SZ) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
char[] data = new char[lpcbData.getValue()];
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return Native.toString(data);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry DWORD value.
* @param root
* Root key.
* @param key
* Registry key path.
* @param value
* Name of the value to retrieve.
* @return
* Integer value.
*/
public static int registryGetIntValue(HKEY root, String key, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
IntByReference lpcbData = new IntByReference();
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
if (lpType.getValue() != WinNT.REG_DWORD) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
IntByReference data = new IntByReference();
rc = Advapi32.INSTANCE.RegQueryValueEx(
phkKey.getValue(), value, 0, lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
return data.getValue();
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Create a registry key.
* @param hKey
* Parent key.
* @param keyName
* Key name.
*/
public static void registryCreateKey(HKEY hKey, String keyName) {
HKEYByReference phkResult = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, 0,
WinNT.KEY_READ, null, phkResult, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Create a registry key.
* @param root
* Root key.
* @param parentPath
* Path to an existing registry key.
* @param keyName
* Key name.
*/
public static void registryCreateKey(HKEY root, String parentPath, String keyName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, parentPath, 0, WinNT.KEY_CREATE_SUB_KEY, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registryCreateKey(phkKey.getValue(), keyName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set an integer value in registry.
* @param hKey
* Parent key.
* @param name
* Name.
* @param value
* Value.
*/
public static void registrySetIntValue(HKEY hKey, String name, int value) {
byte[] data = new byte[4];
data[0] = (byte)(value & 0xff);
data[1] = (byte)((value >> 8) & 0xff);
data[2] = (byte)((value >> 16) & 0xff);
data[3] = (byte)((value >> 24) & 0xff);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_DWORD, data, 4);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set an integer value in registry.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param name
* Name.
* @param value
* Value.
*/
public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetIntValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a string value in registry.
* @param hKey
* Parent key.
* @param name
* Name.
* @param value
* Value.
*/
public static void registrySetStringValue(HKEY hKey, String name, String value) {
char[] data = Native.toCharArray(value);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ, data, data.length * 2);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a string value in registry.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param name
* Name.
* @param value
* Value.
*/
public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registrySetStringValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Delete a registry key.
* @param hKey
* Parent key.
* @param keyName
* Name of the key to delete.
*/
public static void registryDeleteKey(HKEY hKey, String keyName) {
int rc = Advapi32.INSTANCE.RegDeleteKey(hKey, keyName);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Delete a registry key.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param keyName
* Name of the key to delete.
*/
public static void registryDeleteKey(HKEY root, String keyPath, String keyName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registryDeleteKey(phkKey.getValue(), keyName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Delete a registry value.
* @param hKey
* Parent key.
* @param valueName
* Name of the value to delete.
*/
public static void registryDeleteValue(HKEY hKey, String valueName) {
int rc = Advapi32.INSTANCE.RegDeleteValue(hKey, valueName);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Delete a registry value.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param valueName
* Name of the value to delete.
*/
public static void registryDeleteValue(HKEY root, String keyPath, String valueName) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
registryDeleteValue(phkKey.getValue(), valueName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get names of the registry key's sub-keys.
* @param hKey
* Registry key.
* @return
* Array of registry key names.
*/
public static String[] registryGetKeys(HKEY hKey) {
IntByReference lpcSubKeys = new IntByReference();
IntByReference lpcMaxSubKeyLen = new IntByReference();
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null,
lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
ArrayList<String> keys = new ArrayList<String>(lpcSubKeys.getValue());
char[] name = new char[lpcMaxSubKeyLen.getValue() + 1];
for (int i = 0; i < lpcSubKeys.getValue(); i++) {
IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1);
rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName,
null, null, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
keys.add(Native.toString(name));
}
return keys.toArray(new String[0]);
}
/**
* Get names of the registry key's sub-keys.
* @param root
* Root key.
* @param keyPath
* Path to a registry key.
* @return
* Array of registry key names.
*/
public static String[] registryGetKeys(HKEY root, String keyPath) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
try {
return registryGetKeys(phkKey.getValue());
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a table of registry values.
* @param hKey
* Registry key.
* @return
* Table of values.
*/
public static TreeMap<String, Object> registryGetValues(HKEY hKey) {
IntByReference lpcValues = new IntByReference();
IntByReference lpcMaxValueNameLen = new IntByReference();
IntByReference lpcMaxValueLen = new IntByReference();
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null, null,
null, null, lpcValues, lpcMaxValueNameLen, lpcMaxValueLen, null, null);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
TreeMap<String, Object> keyValues = new TreeMap<String, Object>();
char[] name = new char[lpcMaxValueNameLen.getValue() + 1];
byte[] data = new byte[lpcMaxValueLen.getValue()];
for (int i = 0; i < lpcValues.getValue(); i++) {
IntByReference lpcchValueName = new IntByReference(lpcMaxValueNameLen.getValue() + 1);
IntByReference lpcbData = new IntByReference(lpcMaxValueLen.getValue());
IntByReference lpType = new IntByReference();
rc = Advapi32.INSTANCE.RegEnumValue(hKey, i, name, lpcchValueName, null,
lpType, data, lpcbData);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
switch(lpType.getValue()) {
case WinNT.REG_DWORD:
keyValues.put(Native.toString(name),
((int)(data[0] & 0xff)) +
(((int)(data[1] & 0xff)) << 8) +
(((int)(data[2] & 0xff)) << 16) +
(((int)(data[3] & 0xff)) << 24));
break;
case WinNT.REG_SZ:
try {
keyValues.put(Native.toString(name),
new String(data, 0, data.length - 2, "UTF-16LE"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage());
}
break;
default:
throw new RuntimeException("Unsupported type: " + lpType.getValue());
}
}
return keyValues;
}
/**
* Get a table of registry values.
* @param root
* Registry root.
* @param keyPath
* Regitry key path.
* @return
* Table of values.
*/
public static TreeMap<String, Object> registryGetValues(HKEY root, String keyPath) {
HKEYByReference phkKey = new HKEYByReference();
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc);
}
try {
return registryGetValues(phkKey.getValue());
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
}
@@ -0,0 +1,110 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
/**
* Crypt32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Crypt32 extends W32API {
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
* structure. Typically, only a user with the same logon credential as the encrypter
* can decrypt the data. In addition, the encryption and decryption usually must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
* @param szDataDescr
* String with a readable description of the data to be encrypted. This description
* string is included with the encrypted data. This parameter is optional and can
* be set to NULL, except on Windows 2000.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
* phase must also be used in the decryption phase. This parameter can be set to NULL
* for no additional entropy.
* @param pvReserved
* Reserved for future use and must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL in both the encryption and decryption
* phases.
* @param dwFlags
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
* CRYPTPROTECT_VERIFY_PROTECTION.
* @param pDataOut
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
* finished using the DATA_BLOB structure, free its pbData member by calling the
* LocalFree function.
* @return
* If the function succeeds, the function returns TRUE. If the function fails,
* it returns FALSE. For extended error information, call GetLastError.
*/
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
/**
* The CryptUnprotectData function decrypts and does an integrity check of the data in
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
* encrypter can decrypt the data. In addition, the encryption and decryption must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
* structure's cbData member holds the length of the pbData member's byte string that
* contains the text to be encrypted.
* @param szDataDescr
* Pointer to a string-readable description of the encrypted data included with the
* encrypted data. This parameter can be set to NULL. When you have finished using
* ppszDataDescr, free it by calling the LocalFree function.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used when the data was encrypted. This parameter can be set to NULL;
* however, if an optional entropy DATA_BLOB structure was used in the encryption
* phase, that same DATA_BLOB structure must be used for the decryption phase.
* @param pvReserved
* Reserved for future use; must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL.
* @param dwFlags
* DWORD value that specifies options for this function. This parameter can be zero,
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
* @param pDataOut
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
* When you have finished using the DATA_BLOB structure, free its pbData member by
* calling the LocalFree function.
* @return
* If the function succeeds, the return value is TRUE. If the function fails, the
* return value is FALSE.
*/
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
}
@@ -0,0 +1,140 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
/**
* Crypt32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Crypt32Util {
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data) {
return cryptProtectData(data, 0);
}
/**
* Protect a blob of data with optional flags.
* @param data
* Data to protect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data, int flags) {
return cryptProtectData(data, null, flags, "", null);
}
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param description
* Optional description.
* @param prompt
* Prompt structure.
* @return
* Protected bytes.
*/
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataProtected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
try {
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
pEntropy, null, prompt, flags, pDataProtected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataProtected.getData();
} finally {
if (pDataProtected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
}
}
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data) {
return cryptUnprotectData(data, 0);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, int flags) {
return cryptUnprotectData(data, null, flags, null);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param prompt
* Optional prompt structure.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataUnprotected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
PointerByReference pDescription = new PointerByReference();
try {
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
pEntropy, null, prompt, flags, pDataUnprotected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataUnprotected.getData();
} finally {
if (pDataUnprotected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
}
if (pDescription.getValue() != null) {
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
}
}
}
}
@@ -0,0 +1,211 @@
package com.sun.jna.platform.win32;
import com.sun.jna.NativeLong;
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;
/**
* Ported from DsGetDC.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public abstract class DsGetDC {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
* function to receive data about a domain controller.
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO() {
}
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated WString 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 name is not available, the
* flat-style name (for example, "\\phoenix") is returned. This example would apply
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
* IP family of protocols.
*/
public WString DomainControllerName;
/**
* Pointer to a null-terminated WString that specifies the address of the discovered
* domain controller. The address is prefixed with "\\". This WString is one of the
* types defined by the DomainControllerAddressType member.
*/
public WString DomainControllerAddress;
/**
* Indicates the type of WString that is contained in the DomainControllerAddress member.
*/
public int DomainControllerAddressType;
/**
* The GUID of the domain. This member is zero if the domain controller does not have
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
* controller.
*/
public GUID DomainGuid;
/**
* Pointer to a null-terminated WString 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;
/**
* Pointer to a null-terminated WString 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;
/**
* 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 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;
/**
* Pointer to a null-terminated WString 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;
}
/**
* Pointer to DOMAIN_CONTROLLER_INFO.
*/
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
}
/**
* Domain is a member of the forest.
*/
public static final int DS_DOMAIN_IN_FOREST = 0x0001;
/**
* Domain is directly trusted.
*/
public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
/**
* Domain is root of a tree in the forest.
*/
public static final int DS_DOMAIN_TREE_ROOT = 0x0004;
/**
* Domain is the primary domain of queried server.
*/
public static final int DS_DOMAIN_PRIMARY = 0x0008;
/**
* Primary domain is running in native mode.
*/
public static final int DS_DOMAIN_NATIVE_MODE = 0x0010;
/**
* Domain is directly trusting.
*/
public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
/**
* Valid domain flags.
*/
public static final int DS_DOMAIN_VALID_FLAGS =
DS_DOMAIN_IN_FOREST |
DS_DOMAIN_DIRECT_OUTBOUND |
DS_DOMAIN_TREE_ROOT |
DS_DOMAIN_PRIMARY |
DS_DOMAIN_NATIVE_MODE |
DS_DOMAIN_DIRECT_INBOUND;
/**
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
* contain trust data for a domain.
*/
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
*/
public WString NetbiosDomainName;
/**
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
*/
public WString DnsDomainName;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public NativeLong Flags;
/**
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
* corresponds to the parent domain of the domain represented by this structure.
*/
public NativeLong ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public NativeLong TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public NativeLong TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID.ByReference DomainSid;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
};
/**
* A pointer to an array of DS_DOMAIN_TRUSTS.
*/
public static class PDS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
}
public DS_DOMAIN_TRUSTS.ByReference t;
/**
* Returns domain trusts.
* @param count
* Number of domain trusts.
* @return
*/
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
}
}
}
@@ -8,9 +8,9 @@
* 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.
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.win32;
package com.sun.jna.platform.win32;
import java.awt.Rectangle;
@@ -18,14 +18,15 @@ import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
/** Definition (incomplete) of <code>gdi32.dll</code>. */
public interface GDI32 extends W32API {
GDI32 INSTANCE = (GDI32)
Native.loadLibrary("gdi32", GDI32.class, DEFAULT_OPTIONS);
public static class RECT extends Structure {
GDI32 INSTANCE = (GDI32)
Native.loadLibrary("gdi32", GDI32.class, W32APIOptions.DEFAULT_OPTIONS);
class RECT extends Structure {
public int left;
public int top;
public int right;
@@ -39,14 +40,14 @@ public interface GDI32 extends W32API {
}
int RDH_RECTANGLES = 1;
public static class RGNDATAHEADER extends Structure {
class RGNDATAHEADER extends Structure {
public int dwSize = size();
public int iType = RDH_RECTANGLES; // required
public int nCount;
public int nRgnSize;
public RECT rcBound;
public RECT rcBound;
}
public static class RGNDATA extends Structure {
class RGNDATA extends Structure {
public RGNDATAHEADER rdh;
public byte[] Buffer;
public RGNDATA(int bufferSize) {
@@ -54,7 +55,7 @@ public interface GDI32 extends W32API {
allocateMemory();
}
}
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
int RGN_AND = 1;
@@ -62,35 +63,38 @@ public interface GDI32 extends W32API {
int RGN_XOR = 3;
int RGN_DIFF = 4;
int RGN_COPY = 5;
int ERROR = 0;
int NULLREGION = 1;
int SIMPLEREGION = 2;
int COMPLEXREGION = 3;
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2, int fnCombineMode);
HRGN CreateRectRgn(int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect);
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect,
int nWidthEllipse,
int nWidthEllipse,
int nHeightEllipse);
int ALTERNATE = 1;
int WINDING = 2;
HRGN CreatePolyPolygonRgn(User32.POINT[] lppt, int[] lpPolyCounts, int nCount, int fnPolyFillMode);
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
int SetPixel(HDC hDC, int x, int y, int crColor);
HDC CreateCompatibleDC(HDC hDC);
boolean DeleteDC(HDC hDC);
int BI_RGB = 0;
int BI_RLE8 = 1;
int BI_RLE4 = 2;
int BI_BITFIELDS = 3;
int BI_JPEG = 4;
int BI_PNG = 5;
public static class BITMAPINFOHEADER extends Structure {
class BITMAPINFOHEADER extends Structure {
public int biSize = size();
public int biWidth;
public int biHeight;
@@ -103,13 +107,13 @@ public interface GDI32 extends W32API {
public int biClrUsed;
public int biClrImportant;
}
public static class RGBQUAD extends Structure {
class RGBQUAD extends Structure {
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved = 0;
}
public static class BITMAPINFO extends Structure {
class BITMAPINFO extends Structure {
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
//RGBQUAD:
//byte rgbBlue;
@@ -131,7 +135,7 @@ public interface GDI32 extends W32API {
PointerByReference ppvBits, Pointer hSection,
int dwOffset);
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
boolean DeleteObject(HANDLE p);
}
@@ -0,0 +1,51 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
* Ported from Guid.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class Guid {
public static class GUID extends Structure {
public static class ByReference extends GUID implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public GUID() {
}
public GUID(Pointer memory) {
useMemory(memory);
read();
}
public int Data1;
public short Data2;
public short Data3;
public byte[] Data4 = new byte[8];
}
}
@@ -0,0 +1,514 @@
/* 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.
* <p/>
* 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.sun.jna.platform.win32;
import java.nio.Buffer;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
/** Definition (incomplete) of <code>kernel32.dll</code>. */
public interface Kernel32 extends W32API {
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* Frees the specified local memory object and invalidates its handle.
* @param hLocal
* A handle to the local memory object.
* @return
* If the function succeeds, the return value is NULL.
* If the function fails, the return value is equal to a handle to the local memory object.
* To get extended error information, call GetLastError.
*/
Pointer LocalFree(Pointer hLocal);
/**
* Frees the specified global memory object and invalidates its handle.
* @param hGlobal
* A handle to the global memory object.
* @return
* If the function succeeds, the return value is NULL
* If the function fails, the return value is equal to a handle to the global memory object.
* To get extended error information, call GetLastError.
*/
Pointer GlobalFree(Pointer hGlobal);
/**
* The GetModuleHandle function retrieves a module handle for the specified module
* if the file has been mapped into the address space of the calling process.
* @param name
* Pointer to a null-terminated string that contains the name of the module
* (either a .dll or .exe file).
* @return
* If the function succeeds, the return value is a handle to the specified module.
* If the function fails, the return value is NULL. To get extended error
* information, call GetLastError.
*/
HMODULE GetModuleHandle(String name);
/**
* The GetSystemTime function retrieves the current system date and time.
* The system time is expressed in Coordinated Universal Time (UTC).
* @param lpSystemTime
* Pointer to a SYSTEMTIME structure to receive the current system date and time.
*/
void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime);
/**
* The GetCurrentThreadId function retrieves the thread identifier of the calling thread.
* @return The return value is the thread identifier of the calling thread.
*/
int GetCurrentThreadId();
/**
* The GetCurrentThread function retrieves a pseudo handle for the current thread.
* @return The return value is a pseudo handle for the current thread.
*/
HANDLE GetCurrentThread();
/**
* This function returns the process identifier of the calling process.
* @return The return value is the process identifier of the calling process.
*/
int GetCurrentProcessId();
/**
* This function returns a pseudohandle for the current process.
* @return The return value is a pseudohandle to the current process.
*/
HANDLE GetCurrentProcess();
/**
* The GetProcessId function retrieves the process identifier of the
* specified process.
* @param process
* Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right.
* @return
* If the function succeeds, the return value is the process identifier of the
* specified process. If the function fails, the return value is zero. To get
* extended error information, call GetLastError.
*/
int GetProcessId(HANDLE process);
/**
* The GetProcessVersion function retrieves the major and minor version numbers of the system
* on which the specified process expects to run.
* @param processId
* Process identifier of the process of interest. A value of zero specifies the
* calling process.
* @return
* If the function succeeds, the return value is the version of the system on
* which the process expects to run. The high word of the return value contains
* the major version number. The low word of the return value contains the minor
* version number. If the function fails, the return value is zero. To get extended
* error information, call GetLastError. The function fails if ProcessId is an
* invalid value.
*/
int GetProcessVersion(int processId);
/**
* The GetLastError function retrieves the calling thread's last-error code value.
* The last-error code is maintained on a per-thread basis. Multiple threads do not
* overwrite each other's last-error code.
* @return
* The return value is the calling thread's last-error code value.
*/
int GetLastError();
/**
* The SetLastError function sets the last-error code for the calling thread.
* @param dwErrCode
* Last-error code for the thread.
*/
void SetLastError(int dwErrCode);
/**
* The GetDriveType function determines whether a disk drive is a removable,
* fixed, CD-ROM, RAM disk, or network drive.
* @param rootPathName
* Pointer to a null-terminated string that specifies the root directory of
* the disk to return information about. A trailing backslash is required.
* If this parameter is NULL, the function uses the root of the current directory.
* @return
* The return value specifies the type of drive.
*/
int GetDriveType(String rootPathName);
/**
* The FormatMessage function formats a message string. The function requires a
* message definition as input. The message definition can come from a buffer
* passed into the function. It can come from a message table resource in an
* already-loaded module. Or the caller can ask the function to search the
* system's message table resource(s) for the message definition. The function
* finds the message definition in a message table resource based on a message
* identifier and a language identifier. The function copies the formatted message
* text to an output buffer, processing any embedded insert sequences if requested.
* @param dwFlags
* Formatting options, and how to interpret the lpSource parameter. The low-order
* byte of dwFlags specifies how the function handles line breaks in the output
* buffer. The low-order byte can also specify the maximum width of a formatted
* output line.
* @param lpSource
* Location of the message definition.
* @param dwMessageId
* Message identifier for the requested message.
* @param dwLanguageId
* Language identifier for the requested message.
* @param lpBuffer
* Pointer to a buffer that receives the null-terminated string that specifies the
* formatted message.
* @param nSize
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
* set, this parameter specifies the minimum number of TCHARs to allocate for an
* output buffer.
* @param va_list
* Pointer to an array of values that are used as insert values in the formatted message.
* @return
* If the function succeeds, the return value is the number of TCHARs stored in
* the output buffer, excluding the terminating null character. If the function
* fails, the return value is zero. To get extended error information, call
* GetLastError.
*/
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
int dwLanguageId, PointerByReference lpBuffer,
int nSize, Pointer va_list);
/**
* The FormatMessage function formats a message string. The function requires a
* message definition as input. The message definition can come from a buffer
* passed into the function. It can come from a message table resource in an
* already-loaded module. Or the caller can ask the function to search the
* system's message table resource(s) for the message definition. The function
* finds the message definition in a message table resource based on a message
* identifier and a language identifier. The function copies the formatted message
* text to an output buffer, processing any embedded insert sequences if requested.
* @param dwFlags
* Formatting options, and how to interpret the lpSource parameter. The low-order
* byte of dwFlags specifies how the function handles line breaks in the output
* buffer. The low-order byte can also specify the maximum width of a formatted
* output line.
* @param lpSource
* Location of the message definition.
* @param dwMessageId
* Message identifier for the requested message.
* @param dwLanguageId
* Language identifier for the requested message.
* @param lpBuffer
* Pointer to a buffer that receives the null-terminated string that specifies the
* formatted message.
* @param nSize
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
* set, this parameter specifies the minimum number of TCHARs to allocate for an
* output buffer.
* @param va_list
* Pointer to an array of values that are used as insert values in the formatted message.
* @return
* If the function succeeds, the return value is the number of TCHARs stored in
* the output buffer, excluding the terminating null character. If the function
* fails, the return value is zero. To get extended error information, call
* GetLastError.
*/
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
int dwLanguageId, Buffer lpBuffer,
int nSize, Pointer va_list);
/**
* The CreateFile function creates or opens a file, file stream, directory, physical
* disk, volume, console buffer, tape drive, communications resource, mailslot, or
* named pipe. The function returns a handle that can be used to access an object.
* @param lpFileName
* A pointer to a null-terminated string that specifies the name of an object to create or open.
* @param dwDesiredAccess
* The access to the object, which can be read, write, or both.
* @param dwShareMode
* The sharing mode of an object, which can be read, write, both, or none.
* @param lpSecurityAttributes
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not
* the returned handle can be inherited by child processes. If lpSecurityAttributes
* is NULL, the handle cannot be inherited.
* @param dwCreationDisposition
* An action to take on files that exist and do not exist.
* @param dwFlagsAndAttributes
* The file attributes and flags.
* @param hTemplateFile
* Handle to a template file with the GENERIC_READ access right. The template file
* supplies file attributes and extended attributes for the file that is being
* created. This parameter can be NULL.
* @return
* If the function succeeds, the return value is an open handle to a specified file.
* If a specified file exists before the function call and dwCreationDisposition is
* CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS,
* even when the function succeeds. If a file does not exist before the call,
* GetLastError returns 0 (zero). If the function fails, the return value is
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
*/
HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition,
int dwFlagsAndAttributes, HANDLE hTemplateFile);
/**
* The CreateDirectory function creates a new directory. If the underlying file
* system supports security on files and directories, the function applies a
* specified security descriptor to the new directory.
* @param lpPathName
* Pointer to a null-terminated string that specifies the path of the directory
* to be created.
* @param lpSecurityAttributes
* Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member
* of the structure specifies a security descriptor for the new directory. If
* lpSecurityAttributes is NULL, the directory gets a default security descriptor.
* @return
* If the function succeeds, the return value is nonzero. If the function fails,
* the return value is zero. To get extended error information, call GetLastError.
*/
boolean CreateDirectory(String lpPathName,
WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes);
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
Pointer CompletionKey, int NumberOfConcurrentThreads);
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
PointerByReference lpOverlapped, int dwMilliseconds);
boolean PostQueuedCompletionStatus(HANDLE CompletionPort,
int dwNumberOfBytesTransferred, Pointer dwCompletionKey,
WinBase.OVERLAPPED lpOverlapped);
/**
* Waits until the specified object is in the signaled state or the time-out interval elapses.
* To enter an alertable wait state, use the WaitForSingleObjectEx function.
* To wait for multiple objects, use the WaitForMultipleObjects.
* @param hHandle
* A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
* If this handle is closed while the wait is still pending, the function's behavior is undefined.
* The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
* @param dwMilliseconds
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses.
* If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.
* If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
* @return
* If the function succeeds, the return value indicates the event that caused the function to return.
*/
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
/**
* Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
* To enter an alertable wait state, use the WaitForMultipleObjectsEx function.
* @param nCount
* The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS.
* @param hHandle
* An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types.
* It may not contain multiple copies of the same handle.
* If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
* The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
* @param bWaitAll
* If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled.
* If FALSE, the function returns when the state of any one of the objects is set to signaled.
* In the latter case, the return value indicates the object whose state caused the function to return.
* @param dwMilliseconds
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses.
* If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately.
* If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
* @return
* If the function succeeds, the return value indicates the event that caused the function to return.
*/
int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds);
/**
* The DuplicateHandle function duplicates an object handle.
*
* @param hSourceProcessHandle
* Handle to the process with the handle to duplicate.
* The handle must have the PROCESS_DUP_HANDLE access right.
* @param hSourceHandle
* Handle to duplicate. This is an open object handle that is valid in the
* context of the source process.
* @param hTargetProcessHandle
* Handle to the process that is to receive the duplicated handle.
* The handle must have the PROCESS_DUP_HANDLE access right.
* @param lpTargetHandle
* Pointer to a variable that receives the duplicate handle. This handle value is valid in
* the context of the target process. If hSourceHandle is a pseudo handle returned by
* GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to
* a process or thread, respectively.
* @param dwDesiredAccess
* Access requested for the new handle.
* @param bInheritHandle
* Indicates whether the handle is inheritable.
* @param dwOptions
* Optional actions.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
boolean DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle,
int dwDesiredAccess, boolean bInheritHandle, int dwOptions);
/**
* The CloseHandle function closes an open object handle.
*
* @param hObject
* Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
boolean CloseHandle(HANDLE hObject);
// TODO: figure out how OVERLAPPED is used and apply an appropriate mapping
interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback {
void callback(int errorCode, int nBytesTransferred,
WinBase.OVERLAPPED overlapped);
}
/** NOTE: only exists in unicode form (W suffix). Define this method
* explicitly with the W suffix to avoid inadvertent calls in ASCII mode.
*/
public boolean ReadDirectoryChangesW(HANDLE directory,
WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree,
int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped,
OVERLAPPED_COMPLETION_ROUTINE completionRoutine);
/** ASCII version. Use {@link Native#toString(byte[])} to obtain the short
* path from the <code>byte</code> array.
* Use only if <code>w32.ascii==true</code>.
*/
int GetShortPathName(String lpszLongPath, byte[] lpdzShortPath, int cchBuffer);
/** Unicode version (the default). Use {@link Native#toString(char[])} to
* obtain the short path from the <code>char</code> array.
*/
int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer);
/**
* The LocalAlloc function allocates the specified number of bytes from the heap.
* Windows memory management does not provide a separate local heap and global heap.
* @param type
* Memory allocation attributes. The default is the LMEM_FIXED value.
* @param cbInput
* Number of bytes to allocate. If this parameter is zero and the uFlags parameter
* specifies LMEM_MOVEABLE, the function returns a handle to a memory object that
* is marked as discarded.
* @return
* If the function succeeds, the return value is a handle to the newly allocated memory object.
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
*/
Pointer LocalAlloc(int type, int cbInput);
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
IntByReference lpNumberOfBytesWritten,
WinBase.OVERLAPPED lpOverlapped);
HANDLE CreateEvent(WinNT.SECURITY_ATTRIBUTES lpEventAttributes,
boolean bManualReset, boolean bInitialState,
String lpName);
boolean SetEvent(HANDLE hEvent);
boolean PulseEvent(HANDLE hEvent);
HANDLE CreateFileMapping(HANDLE hFile, WinNT.SECURITY_ATTRIBUTES lpAttributes,
int flProtect, int dwMaximumSizeHigh,
int dwMaximumSizeLow, String lpName);
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
int dwFileOffsetHigh, int dwFileOffsetLow,
int dwNumberOfBytesToMap);
boolean UnmapViewOfFile(Pointer lpBaseAddress);
/**
* Retrieves only the NetBIOS name of the local computer.
*
* @param buffer
* A pointer to a buffer that receives the computer name or the cluster virtual server
* name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1
* characters.
* @param lpnSize
* On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs
* copied to the destination buffer, not including the terminating null character. If
* the buffer is too small, the function fails and GetLastError returns
* ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required,
* including the terminating null character.
* @return
* If the function succeeds, the return value is a nonzero value.
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
public boolean GetComputerName(char[] buffer, IntByReference lpnSize);
/**
* The OpenThread function opens an existing thread object.
* @param dwDesiredAccess
* Access to the thread object. This access right is checked against any security
* descriptor for the thread.
* @param bInheritHandle
* If this parameter is TRUE, the new process inherits the handle. If the parameter
* is FALSE, the handle is not inherited.
* @param dwThreadId
* Identifier of the thread to be opened.
* @return
* If the function succeeds, the return value is an open handle to the specified process.
* If the function fails, the return value is NULL. To get extended error information,
* call GetLastError.
*/
HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId);
/**
* This function returns a handle to an existing process object.
* @param fdwAccess
* Not supported; set to zero.
* @param fInherit
* Not supported; set to FALSE.
* @param IDProcess
* Specifies the process identifier of the process to open.
* @return
* An open handle to the specified process indicates success.
* NULL indicates failure.
* To get extended error information, call GetLastError.
*/
HANDLE OpenProcess(int fdwAccess, boolean fInherit, int IDProcess);
/**
* The GetTempPath function retrieves the path of the directory designated
* for temporary files.
* @param nBufferLength
* Size of the string buffer identified by lpBuffer, in TCHARs.
* @param buffer
* Pointer to a string buffer that receives the null-terminated string specifying the
* temporary file path. The returned string ends with a backslash, for example,
* C:\TEMP\.
* @return
* If the function succeeds, the return value is the length, in TCHARs, of the string
* copied to lpBuffer, not including the terminating null character. If the return value
* is greater than nBufferLength, the return value is the length, in TCHARs, of the
* buffer required to hold the path.
*
* If the function fails, the return value is zero. To get extended error information,
* call GetLastError.
*/
DWORD GetTempPath(DWORD nBufferLength, char[] buffer);
}
@@ -0,0 +1,93 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.LastErrorException;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.W32API.DWORD;
import com.sun.jna.platform.win32.W32API.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Kernel32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Kernel32Util {
/**
* Get current computer NetBIOS name.
* @return
* Netbios name.
*/
public static String getComputerName() {
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1];
IntByReference lpnSize = new IntByReference(buffer.length);
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Format a message from an HRESULT.
* @param code
* HRESULT
* @return
* Formatted message.
*/
public static String formatMessageFromHR(HRESULT code) {
PointerByReference buffer = new PointerByReference();
if (0 == Kernel32.INSTANCE.FormatMessage(
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
null,
code.intValue(),
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
buffer,
0,
null)) {
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
}
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
s = s.replace(".\r",".").replace(".\n",".");
Kernel32.INSTANCE.LocalFree(buffer.getValue());
return s;
}
/**
* Format a system message from an error code.
* @param code
* Error code, typically a result of GetLastError.
* @return
* Formatted message.
*/
public static String formatMessageFromLastErrorCode(int code) {
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
}
/**
* Return the path designated for temporary files.
* @return
* Path.
*/
public static String getTempPath() {
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
char[] buffer = new char[nBufferLength.intValue()];
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
}
@@ -0,0 +1,309 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinNT.PSID;
/**
* Ported from LMAccess.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMAccess {
public static class LOCALGROUP_INFO_0 extends Structure {
public LOCALGROUP_INFO_0() {
super();
}
public LOCALGROUP_INFO_0(Pointer memory) {
useMemory(memory);
read();
}
public WString lgrui0_name;
}
public static class LOCALGROUP_INFO_1 extends Structure {
public LOCALGROUP_INFO_1() {
super();
}
public LOCALGROUP_INFO_1(Pointer memory) {
useMemory(memory);
read();
}
public WString lgrui1_name;
public WString lgrui1_comment;
}
//
// bit masks for the NetUserEnum filter parameter.
//
public static final int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
public static final int FILTER_NORMAL_ACCOUNT = 0x0002;
// public static final int FILTER_PROXY_ACCOUNT = 0x0004;
public static final int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
public static final int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
public static final int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
/**
* The USER_INFO_0 structure contains a user account name.
*/
public static class USER_INFO_0 extends Structure {
public USER_INFO_0() {
super();
}
public USER_INFO_0(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a Unicode string that specifies the name of the user account.
*/
public WString usri0_name;
}
/**
* The USER_INFO_1 structure contains information about a user account, including
* account name, password data, privilege level, and the path to the user's home
* directory.
*/
public static class USER_INFO_1 extends Structure {
public USER_INFO_1() {
super();
}
public USER_INFO_1(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a Unicode string that specifies the name of the user
* account.
*/
public WString usri1_name;
/**
* Pointer to a Unicode string that specifies the password of the user
* indicated by the usri1_name member.
*/
public WString usri1_password;
/**
* Specifies a DWORD value that indicates the number of seconds that have
* elapsed since the usri1_password member was last changed.
*/
public int usri1_password_age;
/**
* Specifies a DWORD value that indicates the level of privilege assigned
* to the usri1_name member.
*/
public int usri1_priv;
/**
* 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;
/**
* Pointer to a Unicode string that contains a comment to associate with
* the user account.
*/
public WString usri1_comment;
/**
* Specifies a DWORD value that determines several features.
*/
public int usri1_flags;
/**
* Pointer to a Unicode string specifying the path for the user's
* logon script file.
*/
public WString usri1_script_path;
}
/**
* The GROUP_USERS_INFO_0 structure contains global group member information.
*/
public static class GROUP_USERS_INFO_0 extends Structure {
public GROUP_USERS_INFO_0() {
super();
}
public GROUP_USERS_INFO_0(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that specifies a name.
*/
public WString grui0_name;
}
/**
* The LOCALGROUP_USERS_INFO_0 structure contains local group member information.
*/
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
public LOCALGROUP_USERS_INFO_0() {
super();
}
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
*/
public WString lgrui0_name;
}
/**
* The GROUP_INFO_0 structure contains the name of a global group in the security
* database, which is the security accounts manager (SAM) database or, in the case
* of domain controllers, the Active Directory.
*/
public static class GROUP_INFO_0 extends Structure {
public GROUP_INFO_0() {
super();
}
public GROUP_INFO_0(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that specifies
* the name of the global group.
*/
public WString grpi0_name;
}
/**
* The GROUP_INFO_1 structure contains a global group name and a comment to
* associate with the group.
*/
public static class GROUP_INFO_1 extends Structure {
public GROUP_INFO_1() {
super();
}
public GROUP_INFO_1(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that specifies
* the name of the global group.
*/
public WString 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;
}
/**
* The GROUP_INFO_2 structure contains information about a global group, including
* name, identifier, and resource attributes.
*/
public static class GROUP_INFO_2 extends Structure {
public GROUP_INFO_2() {
super();
}
public GROUP_INFO_2(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that
* specifies the name of the global group.
*/
public WString 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;
/**
* Specifies a DWORD value that contains the relative identifier (RID) of
* the global group.
*/
public int grpi2_group_id;
/**
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED,
* and SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi2_attributes;
}
/**
* The GROUP_INFO_3 structure contains information about a global group, including
* name, security identifier (SID), and resource attributes.
*/
public static class GROUP_INFO_3 extends Structure {
public GROUP_INFO_3() {
super();
}
public GROUP_INFO_3(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that
* specifies the name of the global group.
*/
public WString 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;
/**
* Pointer to a SID structure that contains the security identifier (SID) that
* uniquely identifies the global group.
*/
public PSID grpi3_group_sid;
/**
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and
* SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi3_attributes;
}
//
// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
//
public static final int USER_PRIV_MASK = 3;
public static final int USER_PRIV_GUEST = 0;
public static final int USER_PRIV_USER = 1;
public static final int USER_PRIV_ADMIN = 2;
}
@@ -0,0 +1,28 @@
/* 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.sun.jna.platform.win32;
/**
* Ported from LMCons.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMCons {
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
/**
* Value to be used with APIs which have a "preferred maximum length" parameter.
* This value indicates that the API should just allocate "as much as it takes."
*/
public static final int MAX_PREFERRED_LENGTH = -1;
}
@@ -0,0 +1,564 @@
/* 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.sun.jna.platform.win32;
/**
* Ported from LMErr.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMErr {
public static final int NERR_Success = 0;
public static final int NERR_BASE = 2100;
public static final int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */
public static final int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */
public static final int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */
public static final int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */
public static final int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */
public static final int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */
/* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
/* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
/* UNUSED BASE + 10 */
/* UNUSED BASE + 11 */
/* UNUSED BASE + 12 */
/* UNUSED BASE + 13 */
public static final int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */
public static final int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */
public static final int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */
public static final int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */
public static final int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */
public static final int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */
/* UNUSED BASE + 20 */
public static final int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */
public static final int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */
public static final int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */
/* UNUSED BASE + 24 */
/* UNUSED BASE + 25 */
/* UNUSED BASE + 26 */
public static final int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */
/* UNUSED BASE + 28 */
/* UNUSED BASE + 29 */
/* UNUSED BASE + 30 */
public static final int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */
/* UNUSED BASE + 32 */
/* UNUSED BASE + 33 */
/* UNUSED BASE + 34 */
/* UNUSED BASE + 35 */
public static final int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */
public static final int NERR_WkstaInconsistentState = NERR_BASE + 37;
/* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */
public static final int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */
public static final int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */
public static final int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/
public static final int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */
public static final int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */
public static final int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */
public static final int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */
/*
* Config API related
* Error codes from BASE + 45 to BASE + 49
*/
/* UNUSED BASE + 45 */
public static final int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */
public static final int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */
public static final int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */
/*
* Spooler API related
* Error codes from BASE + 50 to BASE + 79
*/
public static final int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */
public static final int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */
public static final int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */
public static final int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */
public static final int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */
public static final int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */
public static final int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */
public static final int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */
public static final int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */
public static final int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */
public static final int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */
public static final int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */
public static final int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */
public static final int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */
public static final int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */
public static final int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */
public static final int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */
public static final int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */
public static final int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */
/*
* Service API related
* Error codes from BASE + 80 to BASE + 99
*/
public static final int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */
public static final int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */
public static final int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */
public static final int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */
public static final int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */
public static final int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */
public static final int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */
public static final int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */
public static final int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */
public static final int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */
public static final int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */
public static final int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */
public static final int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */
public static final int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */
public static final int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */
/*
* Wksta and Logon API related
* Error codes from BASE + 100 to BASE + 118
*/
public static final int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */
public static final int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */
public static final int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */
public static final int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */
public static final int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */
public static final int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */
public static final int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */
public static final int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */
/* UNUSED BASE + 108 */
public static final int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */
public static final int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */
public static final int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */
public static final int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */
/* UNUSED BASE + 113 */
public static final int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */
public static final int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */
public static final int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */
public static final int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */
/*
* ACF API related = access, user, group;
* Error codes from BASE + 119 to BASE + 149
*/
public static final int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */
public static final int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */
public static final int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */
public static final int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */
public static final int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */
public static final int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */
public static final int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */
public static final int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */
public static final int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */
public static final int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */
public static final int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/
public static final int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */
public static final int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */
public static final int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */
public static final int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */
public static final int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */
public static final int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */
public static final int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */
public static final int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */
public static final int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */
public static final int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */
public static final int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */
public static final int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */
public static final int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */
public static final int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */
public static final int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */
public static final int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */
public static final int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */
public static final int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */
public static final int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */
public static final int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */
/*
* Use API related
* Error codes from BASE + 150 to BASE + 169
*/
public static final int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */
public static final int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */
public static final int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */
public static final int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */
/*
* Message Server related
* Error codes BASE + 170 to BASE + 209
*/
public static final int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */
public static final int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */
public static final int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */
public static final int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */
public static final int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */
public static final int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */
public static final int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */
public static final int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */
public static final int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/
public static final int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */
public static final int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */
public static final int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */
public static final int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */
public static final int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */
public static final int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */
public static final int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */
public static final int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */
public static final int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */
public static final int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */
public static final int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */
public static final int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */
public static final int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */
/* UNUSED BASE + 196 */
public static final int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */
public static final int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */
public static final int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */
public static final int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */
/*
* Server API related
* Error codes BASE + 210 to BASE + 229
*/
public static final int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/
public static final int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */
public static final int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */
public static final int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */
public static final int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */
public static final int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */
public static final int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */
public static final int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */
public static final int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */
public static final int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */
public static final int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */
/*
* CharDev API related
* Error codes BASE + 230 to BASE + 249
*/
/* UNUSED BASE + 230 */
public static final int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */
public static final int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */
public static final int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */
public static final int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */
public static final int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */
public static final int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */
public static final int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */
public static final int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */
public static final int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */
public static final int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */
public static final int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */
/*
* NetICanonicalize and NetIType and NetIMakeLMFileName
* NetIListCanon and NetINameCheck
* Error codes BASE + 250 to BASE + 269
*/
public static final int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */
/* UNUSED BASE + 252 */
/* UNUSED BASE + 253 */
public static final int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */
/* UNUSED BASE + 255 */
public static final int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */
public static final int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */
/* UNUSED BASE + 258 */
/* UNUSED BASE + 259 */
public static final int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */
/*
* NetProfile
* Error codes BASE + 270 to BASE + 276
*/
public static final int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */
public static final int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */
public static final int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */
public static final int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/
public static final int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */
public static final int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */
/*
* NetAudit and NetErrorLog
* Error codes BASE + 277 to BASE + 279
*/
public static final int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */
public static final int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */
public static final int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */
/*
* NetRemote
* Error codes BASE + 280 to BASE + 299
*/
public static final int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */
public static final int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */
public static final int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */
public static final int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */
/* UNUSED BASE + 284 */
public static final int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */
/* UNUSED BASE + 286 */
/* UNUSED BASE + 287 */
/* UNUSED BASE + 288 */
public static final int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */
/* UNUSED BASE + 290 */
public static final int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */
public static final int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/
/* UNUSED BASE + 293 */
/* UNUSED BASE + 294 */
/*
* NetWksta.sys = redir; returned error codes.
*
* NERR_BASE + = 300-329;
*/
public static final int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */
public static final int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */
public static final int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */
public static final int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */
public static final int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */
public static final int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */
/*
* Alert error codes.
*
* NERR_BASE + = 330-339;
*/
public static final int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */
public static final int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */
public static final int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */
public static final int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/
public static final int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted
* because the user's logon hours are no longer valid. */
/*
* Additional Error and Audit log codes.
*
* NERR_BASE + (340-343;
*/
public static final int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */
/* UNUSED BASE + 341 */
/* UNUSED BASE + 342 */
/* UNUSED BASE + 343 */
/*
* Additional UAS and NETLOGON codes
*
* NERR_BASE + (350-359;
*/
public static final int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */
public static final int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */
public static final int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */
public static final int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */
public static final int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */
public static final int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */
public static final int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */
public static final int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */
public static final int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */
/*
* Server Integration error codes.
*
* NERR_BASE + (360-369;
*/
public static final int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */
public static final int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */
public static final int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */
public static final int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */
public static final int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */
public static final int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */
public static final int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */
public static final int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */
/* UNUSED BASE + 368 */
/* UNUSED BASE + 369 */
public static final int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */
/*
* UPS error codes.
*
* NERR_BASE + = 380-384;
*/
public static final int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */
public static final int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */
public static final int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */
public static final int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */
public static final int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */
/*
* Remoteboot error codes.
*
* NERR_BASE + = 400-419;
* Error codes 400 - 405 are used by RPLBOOT.SYS.
* Error codes 403, 407 - 416 are used by RPLLOADR.COM,
* Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;.
* Error code 418 is for when REMOTEBOOT can't start
* Error code 419 is for a disallowed 2nd rpl connection
*
*/
public static final int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/
public static final int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/
public static final int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/
public static final int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/
public static final int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/
public static final int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/
public static final int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/
public static final int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/
public static final int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/
public static final int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/
public static final int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/
public static final int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/
public static final int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/
public static final int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/
public static final int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/
public static final int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/
public static final int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/
public static final int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/
public static final int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/
public static final int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/
/*
* FTADMIN API error codes
*
* NERR_BASE + = 425-434;
*
* = Currently not used in NT;
*
*/
/*
* Browser service API error codes
*
* NERR_BASE + = 450-475;
*
*/
public static final int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */
/*
* Additional Remoteboot error codes.
*
* NERR_BASE + = 510-550;
*/
public static final int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/
public static final int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/
public static final int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/
public static final int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/
public static final int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/
public static final int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/
public static final int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/
public static final int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/
public static final int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/
public static final int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/
public static final int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/
public static final int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/
public static final int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/
public static final int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/
public static final int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/
public static final int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/
public static final int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/
public static final int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/
public static final int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/
public static final int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/
public static final int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/
public static final int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/
public static final int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/
public static final int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/
public static final int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/
public static final int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/
public static final int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/
public static final int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/
public static final int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/
public static final int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/
public static final int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/
public static final int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/
/**INTERNAL_ONLY**/
/*
* Dfs API error codes.
*
* NERR_BASE + = 560-590;
*/
public static final int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/
public static final int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/
public static final int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/
public static final int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/
public static final int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/
public static final int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/
public static final int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/
public static final int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/
public static final int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/
public static final int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/
public static final int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/
public static final int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/
public static final int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/
public static final int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/
public static final int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/
public static final int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/
public static final int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/
public static final int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/
public static final int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/
public static final int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/
public static final int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/
public static final int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/
public static final int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/
public static final int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/
public static final int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/
/*
* Net setup error codes.
*
* NERR_BASE + = 591-600;
*/
public static final int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/
public static final int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/
public static final int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/
public static final int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/
public static final int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/
public static final int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/
public static final int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/
public static final int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/
public static final int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/
/*
* Some Password and account error results
*
* NERR_BASE + = 601 - 608;
*/
public static final int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */
public static final int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */
public static final int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */
public static final int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */
public static final int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */
/***********WARNING ****************
*The range 2750-2799 has been *
*allocated to the IBM LAN Server *
***********************************/
/***********WARNING ****************
*The range 2900-2999 has been *
*reserved for Microsoft OEMs *
***********************************/
public static final int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */
}
@@ -1,26 +1,32 @@
/* 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.
* <p/>
*
* 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.sun.jna.examples;
import com.sun.jna.Library;
import com.sun.jna.Native;
/** Sample implementation of C library access. */
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)
Native.loadLibrary((System.getProperty("os.name").startsWith("Windows")
? "msvcrt" : "c"), CLibrary.class);
int atol(String s);
}
package com.sun.jna.platform.win32;
/**
* Ported from LMJoin.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMJoin {
/**
* Status of a workstation.
*/
public abstract class NETSETUP_JOIN_STATUS {
public static final int NetSetupUnknownStatus = 0;
public static final int NetSetupUnjoined = 1;
public static final int NetSetupWorkgroupName = 2;
public static final int NetSetupDomainName = 3;
};
}
@@ -0,0 +1,213 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Memory;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinNT.PSID;
/**
* Ported from NTSecApi.h
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class NTSecApi {
/**
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
* functions to specify a Unicode string.
*/
public static class LSA_UNICODE_STRING extends Structure {
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
}
/**
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
* not including the terminating null character, if any.
*/
public short Length;
/**
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
* MaximumLength bytes can be written into the buffer without trampling memory.
*/
public short MaximumLength;
/**
* Pointer to a wide character string. Note that the strings returned by the
* various LSA functions might not be null terminated.
*/
public Pointer Buffer;
/**
* String representation of the buffer.
* @return
* Unicode string.
*/
public String getString() {
byte[] data = Buffer.getByteArray(0, Length);
if (data.length < 2 || data[data.length - 1] != 0) {
Memory newdata = new Memory(data.length + 2);
newdata.write(0, data, 0, data.length);
return newdata.getString(0, true);
}
return Buffer.getString(0, true);
}
}
/**
* Pointer to an LSA_UNICODE_STRING.
*/
public static class PLSA_UNICODE_STRING {
public static class ByReference extends PLSA_UNICODE_STRING
implements Structure.ByReference {
}
public LSA_UNICODE_STRING.ByReference s;
}
/**
* Record contains an included top-level name.
*/
public static final int ForestTrustTopLevelName = 0;
/**
* Record contains an excluded top-level name.
*/
public static final int ForestTrustTopLevelNameEx = 1;
/**
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
*/
public static final int ForestTrustDomainInfo = 2;
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
public PSID.ByReference Sid;
public LSA_UNICODE_STRING DnsName;
public LSA_UNICODE_STRING NetbiosName;
}
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
public NativeLong Length;
public Pointer Buffer;
}
public static class LSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
public LSA_UNICODE_STRING TopLevelName;
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
public LSA_FOREST_TRUST_BINARY_DATA Data;
}
/**
* Flags that control the behavior of the operation.
*/
public NativeLong Flags;
/**
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
* The following table shows the possible values.
* ForestTrustTopLevelName
* Record contains an included top-level name.
* ForestTrustTopLevelNameEx
* Record contains an excluded top-level name.
* ForestTrustDomainInfo
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
* ForestTrustRecordTypeLast
* Marks the end of an enumeration.
*/
public int ForestTrustType;
public LARGE_INTEGER Time;
/**
* Data type depending on ForestTrustType.
*/
public UNION u;
public void read() {
super.read();
switch(ForestTrustType) {
case NTSecApi.ForestTrustTopLevelName:
case NTSecApi.ForestTrustTopLevelNameEx:
u.setType(LSA_UNICODE_STRING.class);
break;
case NTSecApi.ForestTrustDomainInfo:
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
break;
default:
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
break;
}
u.read();
}
}
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public LSA_FOREST_TRUST_RECORD.ByReference tr;
}
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
/**
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
* Entries member.
*/
public NativeLong RecordCount;
/**
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
* each of which contains one piece of forest trust information.
*/
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
/**
* Get an array of LSA_FOREST_TRUST_RECORD entries.
* @return
*/
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
}
}
/**
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
* forest trust information.
*/
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
}
}
@@ -0,0 +1,88 @@
/* 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.sun.jna.platform.win32;
public abstract class NTStatus {
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
//
// MessageId: STATUS_WAIT_0
//
// MessageText:
//
// STATUS_WAIT_0
//
public static final int STATUS_WAIT_0 = 0x00000000; // winnt
//
// MessageId: STATUS_WAIT_1
//
// MessageText:
//
// STATUS_WAIT_1
//
public static final int STATUS_WAIT_1 = 0x00000001;
//
// MessageId: STATUS_WAIT_2
//
// MessageText:
//
// STATUS_WAIT_2
//
public static final int STATUS_WAIT_2 = 0x00000002;
//
// MessageId: STATUS_WAIT_3
//
// MessageText:
//
// STATUS_WAIT_3
//
public static final int STATUS_WAIT_3 = 0x00000003;
//
// MessageId: STATUS_WAIT_63
//
// MessageText:
//
// STATUS_WAIT_63
//
public static final int STATUS_WAIT_63 = 0x0000003F;
//
// The success status codes 128 - 191 are reserved for wait completion
// status with an abandoned mutant object.
//
public static final int STATUS_ABANDONED = 0x00000080;
//
// MessageId: STATUS_ABANDONED_WAIT_0
//
// MessageText:
//
// STATUS_ABANDONED_WAIT_0
//
public static final int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt
//
// MessageId: STATUS_ABANDONED_WAIT_63
//
// MessageText:
//
// STATUS_ABANDONED_WAIT_63
//
public static final int STATUS_ABANDONED_WAIT_63 = 0x000000BF;
}
@@ -0,0 +1,401 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
/**
* Netapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Netapi32 extends W32API {
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves join status information for the specified computer.
*
* @param lpServer
* Specifies the DNS or NetBIOS name of the computer on which to
* call the function.
* @param lpNameBuffer
* Receives the NetBIOS name of the domain or workgroup to which
* the computer is joined.
* @param BufferType
* Join status of the specified computer.
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetGetJoinInformation(String lpServer,
PointerByReference lpNameBuffer, IntByReference BufferType);
/**
* Frees the memory that the NetApiBufferAllocate function allocates.
*
* @param buffer
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetApiBufferFree(Pointer buffer);
/**
* Returns information about each local group account on the specified
* server.
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the address of the buffer that receives the
* information structure.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in
* bytes.
* @param entriesread
* Pointer to a value that receives the count of elements
* actually enumerated.
* @param totalentries
* Pointer to a value that receives the approximate total number
* of entries that could have been enumerated from the current
* resume position.
* @param resume_handle
* Pointer to a value that contains a resume handle that is used
* to continue an existing local group search.
* @return If the function succeeds, the return value is NERR_Success.
*/
public int NetLocalGroupEnum(String serverName, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* Returns the name of the primary domain controller (PDC).
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute. If this parameter is NULL, the local computer is used.
* @param domainName
* Specifies the name of the domain.
* @param bufptr
* Receives a string that specifies the server name of the PDC of the domain.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGetDCName(String serverName, String domainName,
PointerByReference bufptr);
/**
* The NetGroupEnum function retrieves information about each global group
* in the security database, which is the security accounts manager (SAM) database or,
* in the case of domain controllers, the Active Directory.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer to receive the global group information structure.
* The format of this data depends on the value of the level parameter.
* @param prefmaxlen
* Specifies the preferred maximum length of the returned data, in bytes.
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
* memory required to hold the data. If you specify another value in this
* parameter, it can restrict the number of bytes that the function returns.
* If the buffer size is insufficient to hold all entries, the function
* returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. The total number of entries
* is only a hint.
* @param resume_handle
* Pointer to a variable that contains a resume handle that is used to continue
* the global group enumeration. The handle should be zero on the first call and
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
* is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserEnum function provides information about all user accounts on a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param filter
* Specifies a value that filters the account types for enumeration.
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends
* on the value of the level parameter. This buffer is allocated by the system and
* must be freed using the NetApiBufferFree function. Note that you must free the
* buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
* required for the data. If you specify another value in this parameter, it can
* restrict the number of bytes that the function returns. If the buffer size is
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. Note that applications should
* consider this value only as a hint.
* @param resume_handle
* Pointer to a value that contains a resume handle which is used to continue an
* existing user search. The handle should be zero on the first call and left
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
* handle is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserGetGroups function retrieves a list of global groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user to search for
* in each group account. For more information, see the following Remarks section.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer that receives the data. This buffer is allocated by the
* system and must be freed using the NetApiBufferFree function. Note that you must
* free the buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number
* of bytes that the function returns. If the buffer size is insufficient to hold
* all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually retrieved.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been retrieved.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetGroups(String servername, String username, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user for which to return
* local group membership information. If the string is of the form DomainName\UserName
* the user name is expected to be found on that domain. If the string is of the form
* UserName, the user name is expected to be found on the server specified by the
* servername parameter.
* @param level
* Specifies the information level of the data.
* @param flags
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
* defined. If this bit is set, the function also returns the names of the local
* groups in which the user is indirectly a member (that is, the user has membership
* in a global group that is itself a member of one or more local groups).
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends on
* the value of the level parameter. This buffer is allocated by the system and must
* be freed using the NetApiBufferFree function. Note that you must free the buffer
* even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number of
* bytes that the function returns. If the buffer size is insufficient to hold all
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
* Management Function Buffers and Network Management Function Buffer Lengths.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been enumerated.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetLocalGroups(String servername, String username, int level,
int flags, PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserAdd function adds a user account and assigns a password and privilege level.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
* on which the function is to execute.
* @param level
* Specifies the information level of the data.
* @param buf
* Pointer to the buffer that specifies the data. The format of this data depends on the
* value of the level parameter.
* @param parm_err
* Pointer to a value that receives the index of the first member of the user information
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
* not returned on error.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserAdd(String servername, int level,
Structure buf, IntByReference parm_err);
/**
* The NetUserDel function deletes a user account from a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user account to delete.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserDel(String servername, String username);
/**
* The NetUserChangePassword function changes a user's password for a specified
* network server or domain.
* @param domainname
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
* server or domain on which the function is to execute. If this parameter is NULL,
* the logon domain of the caller is used.
* @param username
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
* function changes the password for the specified user. If this parameter is NULL,
* the logon name of the caller is used.
* @param oldpassword
* Pointer to a constant string that specifies the user's old password.
* @param newpassword
* Pointer to a constant string that specifies the user's new password.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserChangePassword(String domainname, String username,
String oldpassword, String newpassword);
/**
* The DsGetDcName function returns the name of a domain controller in a specified domain.
* This function accepts additional domain controller selection criteria to indicate
* preference for a domain controller with particular characteristics.
* @param ComputerName
* Pointer to a null-terminated string that specifies the name of the server to process
* this function. Typically, this parameter is NULL, which indicates that the local
* computer is used.
* @param DomainName
* Pointer to a null-terminated string that specifies the name of the domain or application
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
* may be specified with or without a trailing period.
* @param DomainGuid
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
* by DomainGuid.
* @param SiteName
* Pointer to a null-terminated string that specifies the name of the site where the returned
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
* to return a domain controller in the site closest to the site of the computer specified by
* ComputerName. This parameter should be NULL, by default.
* @param Flags
* Contains a set of flags that provide additional data used to process the request.
* @param DomainControllerInfo
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
* This structure is allocated by DsGetDcName. The caller must free the structure using
* the NetApiBufferFree function when it is no longer required.
* @return
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
* If the function fails, the return code is one of ERROR_* values.
*/
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO.ByReference DomainControllerInfo);
/**
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
* @param serverName
* Contains the name of the domain controller that DsGetForestTrustInformationW
* is connected to remotely. The caller must be an authenticated user on this server.
* If this parameter is NULL, the local server is used.
* @param trustedDomainName
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
* trust attribute. If this parameter is NULL, the forest trust data for the domain
* hosted by ServerName is retrieved.
* @param Flags
* Contains a set of flags that modify the behavior of this function.
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
* @param ForestTrustInfo
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
* trust data that describes the namespaces claimed by the domain specified by
* TrustedDomainName. The Time member of all returned records will be zero.
* @return
* Returns NO_ERROR if successful or a Win32 error code otherwise.
*/
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
PLSA_FOREST_TRUST_INFORMATION.ByReference ForestTrustInfo);
/**
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
* @param serverName
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
* obtain the trust information for. This computer must be running the Windows 2000 or later
* operating system. If this parameter is NULL, the name of the local computer is used.
* The caller must be an authenticated user in this domain.
* @param Flags
* Contains a set of flags that determines which domain trusts to enumerate.
* @param Domains
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
* Each structure in this array contains trust data about a domain. The caller must free this
* memory when it is no longer required by calling NetApiBufferFree.
* @param DomainCount
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
* @return
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
*/
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
}
@@ -0,0 +1,605 @@
/* 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.sun.jna.platform.win32;
import java.util.ArrayList;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
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.DsGetDC.PDS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Netapi32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Netapi32Util {
/**
* A group.
*/
public static class Group {
/**
* Group name.
*/
public String name;
}
/**
* A user.
*/
public static class User {
/**
* The name of the user account.
*/
public String name;
/**
* Contains a comment associated with the user account.
*/
public String comment;
}
/**
* A local group.
*/
public static class LocalGroup extends Group {
/**
* Group comment.
*/
public String comment;
}
/**
* Returns the name of the primary domain controller (PDC) on the current computer.
* @return The name of the primary domain controller.
*/
public static String getDCName() {
return getDCName(null, null);
}
/**
* Returns the name of the primary domain controller (PDC).
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute.
* @param domainName
* Specifies the name of the domain.
* @return
* Name of the primary domain controller.
*/
public static String getDCName(String serverName, String domainName) {
PointerByReference bufptr = new PointerByReference();
try {
int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
return bufptr.getValue().getString(0, true);
} finally {
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
/**
* Return the domain/workgroup join status for a computer.
* @return Join status.
*/
public static int getJoinStatus() {
return getJoinStatus(null);
}
/**
* Return the domain/workgroup join status for a computer.
* @param computerName Computer name.
* @return Join status.
*/
public static int getJoinStatus(String computerName) {
PointerByReference lpNameBuffer = new PointerByReference();
IntByReference bufferType = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
return bufferType.getValue();
} finally {
if (lpNameBuffer.getPointer() != null) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get information about a computer.
* @param computerName
* @return Domain or workgroup name.
*/
public static String getDomainName(String computerName) {
PointerByReference lpNameBuffer = new PointerByReference();
IntByReference bufferType = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
// type of domain: bufferType.getValue()
return lpNameBuffer.getValue().getString(0, true);
} finally {
if (lpNameBuffer.getPointer() != null) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of local groups on the current computer.
* @return An array of local group names.
*/
public static LocalGroup[] getLocalGroups() {
return getLocalGroups(null);
}
/**
* Get the names of local groups on a computer.
* @param serverName Name of the computer.
* @return An array of local group names.
*/
public static LocalGroup[] getLocalGroups(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LOCALGROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.lgrui1_name.toString();
lgp.comment = lgpi.lgrui1_comment.toString();;
result.add(lgp);
}
return result.toArray(new LocalGroup[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of global groups on a computer.
* @return An array of group names.
*/
public static Group[] getGlobalGroups() {
return getGlobalGroups(null);
}
/**
* Get the names of global groups on a computer.
* @param serverName Name of the computer.
* @return An array of group names.
*/
public static Group[] getGlobalGroups(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.grpi1_name.toString();
lgp.comment = lgpi.grpi1_comment.toString();;
result.add(lgp);
}
return result.toArray(new LocalGroup[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of users on a local computer.
* @return Users.
*/
public static User[] getUsers() {
return getUsers(null);
}
/**
* Get the names of users on a computer.
* @param serverName Name of the computer.
* @return An array of users.
*/
public static User[] getUsers(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
ArrayList<User> result = new ArrayList<User>();
for(LMAccess.USER_INFO_1 lu : users) {
User auser = new User();
auser.name = lu.usri1_name.toString();
result.add(auser);
}
return result.toArray(new User[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get local groups of the current user.
* @return Local groups.
*/
public static Group[] getCurrentUserLocalGroups() {
return getUserLocalGroups(Secur32Util.getUserNameEx(
EXTENDED_NAME_FORMAT.NameSamCompatible));
}
/**
* Get local groups of a given user.
* @param userName User name.
* @return Local groups.
*/
public static Group[] getUserLocalGroups(String userName) {
return getUserLocalGroups(userName, null);
}
/**
* Get local groups of a given user on a given system.
* @param userName User name.
* @param serverName Server name.
* @return Local groups.
*/
public static Group[] getUserLocalGroups(String userName, String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
ArrayList<Group> result = new ArrayList<Group>();
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.lgrui0_name.toString();
result.add(lgp);
}
return result.toArray(new Group[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get groups of a given user.
* @param userName User name.
* @return Groups.
*/
public static Group[] getUserGroups(String userName) {
return getUserGroups(userName, null);
}
/**
* Get groups of a given user on a given system.
* @param userName User name.
* @param serverName Server name.
* @return Groups.
*/
public static Group[] getUserGroups(String userName, String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
ArrayList<Group> result = new ArrayList<Group>();
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
Group lgp = new Group();
lgp.name = lgpi.grui0_name.toString();
result.add(lgp);
}
return result.toArray(new Group[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* A domain controller.
*/
public static class DomainController {
/**
* Specifies the computer name of the discovered domain controller.
*/
public String name;
/**
* Specifies the address of the discovered domain controller.
*/
public String address;
/**
* Indicates the type of WString that is contained in the
* DomainControllerAddress member.
*/
public int addressType;
/**
* The GUID of the domain.
*/
public GUID domainGuid;
/**
* Pointer to a null-terminated WString that specifies the name of the domain.
*/
public String domainName;
/**
* Pointer to a null-terminated WString that specifies the name of the domain at the root
* of the DS tree.
*/
public String dnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int flags;
/**
* The name of the site that the computer belongs to.
*/
public String clientSiteName;
}
/**
* Return the domain controller for a current computer.
* @return
* Domain controller information.
*/
public static DomainController getDC() {
PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
if (W32Errors.ERROR_SUCCESS != rc) {
throw new Win32Exception(rc);
}
DomainController dc = new DomainController();
dc.address = pdci.dci.DomainControllerAddress.toString();
dc.addressType = pdci.dci.DomainControllerAddressType;
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
dc.dnsForestName = pdci.dci.DnsForestName.toString();
dc.domainGuid = pdci.dci.DomainGuid;
dc.domainName = pdci.dci.DomainName.toString();
dc.flags = pdci.dci.Flags;
dc.name = pdci.dci.DomainControllerName.toString();
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.getPointer());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
return dc;
}
/**
* A domain trust relationship.
*/
public static class DomainTrust {
/**
* NetBIOS name of the domain.
*/
public String NetbiosDomainName;
/**
* DNS name of the domain.
*/
public String DnsDomainName;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID DomainSid;
/**
* Contains the string representation of the security identifier of the domain
* represented by this structure.
*/
public String DomainSidString;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
/**
* Contains the string representation of the GUID of the domain represented by
* this structure.
*/
public String DomainGuidString;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
private int flags;
/**
* The domain represented by this structure is a member of the same forest
* as the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isInForest() {
return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0;
}
/**
* The domain represented by this structure is directly trusted by the domain
* that the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function is a member of.
* @return
* True or false.
*/
public boolean isOutbound() {
return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0;
}
/**
* The domain represented by this structure is the root of a tree and a member
* of the same forest as the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isRoot() {
return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0;
}
/**
* The domain represented by this structure is the primary domain of the server
* specified in the ServerName parameter of the DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isPrimary() {
return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0;
}
/**
* The domain represented by this structure is running in the Windows 2000 native mode.
* @return
* True or false.
*/
public boolean isNativeMode() {
return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0;
}
/**
* The domain represented by this structure directly trusts the domain that
* the server specified in the ServerName parameter of the DsEnumerateDomainTrusts
* function is a member of.
* @return
* True or false.
*/
public boolean isInbound() {
return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0;
}
}
/**
* Retrieve all domain trusts.
* @return
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts() {
return getDomainTrusts(null);
}
/**
* Retrieve all domain trusts for a given server.
* @param serverName
* Server name.
* @return
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts(String serverName) {
NativeLongByReference domainCount = new NativeLongByReference();
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
try {
int domainCountValue = domainCount.getValue().intValue();
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
DomainTrust t = new DomainTrust();
t.DnsDomainName = trust.DnsDomainName.toString();
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
t.DomainSid = trust.DomainSid;
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
t.DomainGuid = trust.DomainGuid;
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
t.flags = trust.Flags.intValue();
trusts.add(t);
}
return trusts.toArray(new DomainTrust[0]);
} finally {
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
}
}
}
@@ -0,0 +1,52 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.W32APIOptions;
/**
* ntdll.dll Interface.
* @author dblock[at]dblock.org
*/
public interface NtDll extends W32API {
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The ZwQueryKey routine provides information about the class of a registry key,
* and the number and sizes of its subkeys.
* @param KeyHandle
* Handle to the registry key to obtain information about. This handle is created by
* a successful call to ZwCreateKey or ZwOpenKey.
* @param KeyInformationClass
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
* returned in the KeyInformation buffer.
* @param KeyInformation
* Pointer to a caller-allocated buffer that receives the requested information.
* @param Length
* Specifies the size, in bytes, of the KeyInformation buffer.
* @param ResultLength
* Pointer to a variable that receives the size, in bytes, of the requested key
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
* required buffer size.
* @return
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
*/
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
Structure KeyInformation, int Length, IntByReference ResultLength);
}
@@ -0,0 +1,47 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.platform.win32.Wdm.KEY_BASIC_INFORMATION;
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.ptr.IntByReference;
/**
* NtDll Utility API.
* @author dblock[at]dblock.org
*/
public abstract class NtDllUtil {
/**
* Retrieve the name of an opened registry key.
* @param hkey Opened registry key.
* @return Basic key name, not including node information.
*/
public static String getKeyName(HKEY hkey) {
IntByReference resultLength = new IntByReference();
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
null, 0, resultLength);
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
throw new Win32Exception(rc);
}
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
resultLength.getValue());
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
keyInformation, resultLength.getValue(), resultLength);
if (rc != NTStatus.STATUS_SUCCESS) {
throw new Win32Exception(rc);
}
return keyInformation.getName();
}
}
@@ -0,0 +1,63 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.win32.W32APIOptions;
/**
* Ole32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Ole32 extends W32API {
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
* @param pguid
* A pointer to the requested GUID.
* @return
* S_OK if the GUID was successfully created.
*/
HRESULT CoCreateGuid(GUID.ByReference pguid);
/**
* Converts a globally unique identifier (GUID) into a string of printable characters.
* @param rguid
* The GUID to be converted.
* @param lpsz
* A pointer to a caller-allocated string variable to receive the resulting string.
* @param cchMax
* The number of characters available in the lpsz buffer.
* @return
* If the function succeeds, the return value is the number of characters in the
* returned string, including the null terminator. If the buffer is too small to contain
* the string, the return value is 0.
*/
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
/**
* Converts a string generated by the StringFromIID function back into the
* original interface identifier (IID).
* @param lpsz
* A pointer to the string representation of the IID.
* @param lpiid
* A pointer to the requested IID on return.
* @return
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
* and S_OK.
*/
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
}
@@ -0,0 +1,73 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.W32API.HRESULT;
/**
* Ole32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Ole32Util {
/**
* Convert a string to a GUID.
* @param guidString
* String representation of a GUID, including { }.
* @return
* A GUID.
*/
public static GUID getGUIDFromString(String guidString) {
GUID.ByReference lpiid = new GUID.ByReference();
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return lpiid;
}
/**
* Convert a GUID into a string.
* @param guid
* GUID.
* @return
* String representation of a GUID.
*/
public static String getStringFromGUID(GUID guid) {
GUID.ByReference pguid = new GUID.ByReference(guid.getPointer());
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
if (len == 0) {
throw new RuntimeException("StringFromGUID2");
}
lpsz[len - 1] = 0;
return Native.toString(lpsz);
}
/**
* Generate a new GUID.
* @return
* New GUID.
*/
public static GUID generateGUID() {
GUID.ByReference pguid = new GUID.ByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return pguid;
}
}
@@ -0,0 +1,287 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Sspi.CredHandle;
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
import com.sun.jna.platform.win32.Sspi.PSecHandle;
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
import com.sun.jna.platform.win32.Sspi.TimeStamp;
import com.sun.jna.platform.win32.WinNT.LUID;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.win32.W32APIOptions;
/**
* Secur32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Secur32 extends W32API {
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Specifies a format for a directory service object name.
* http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx
*/
public abstract class EXTENDED_NAME_FORMAT {
public static final int NameUnknown = 0;
public static final int NameFullyQualifiedDN = 1;
public static final int NameSamCompatible = 2;
public static final int NameDisplay = 3;
public static final int NameUniqueId = 6;
public static final int NameCanonical = 7;
public static final int NameUserPrincipal = 8;
public static final int NameCanonicalEx = 9;
public static final int NameServicePrincipal = 10;
public static final int NameDnsDomain = 12;
};
/**
* Retrieves the name of the user or other security principal associated with
* the calling thread. You can specify the format of the returned name.
* @param nameFormat The format of the name.
* @param lpNameBuffer A pointer to a buffer that receives the name in the specified format.
* @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character.
* @return True if the function succeeds. False otherwise.
*/
public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len);
/**
* The AcquireCredentialsHandle function acquires a handle to preexisting credentials
* of a security principal. This handle is required by the AcceptSecurityContext
* and InitializeSecurityContext functions. These can be either preexisting credentials,
* which are established through a system logon that is not described here, or the
* caller can provide alternative credentials.
* @param pszPrincipal
* A pointer to a null-terminated string that specifies the name of the principal whose
* credentials the handle will reference.
* @param pszPackage
* A pointer to a null-terminated string that specifies the name of the security package
* with which these credentials will be used.
* @param fCredentialUse
* A flag that indicates how these credentials will be used.
* @param pvLogonID
* A pointer to a locally unique identifier (LUID) that identifies the user.
* @param pAuthData
* A pointer to package-specific data. This parameter can be NULL, which indicates
* that the default credentials for that package must be used. To use supplied
* credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials
* in this parameter.
* @param pGetKeyFn
* This parameter is not used and should be set to NULL.
* @param pvGetKeyArgument
* This parameter is not used and should be set to NULL.
* @param phCredential
* A pointer to a CredHandle structure to receive the credential handle.
* @param ptsExpiry
* A pointer to a TimeStamp structure that receives the time at which the returned
* credentials expire. The value returned in this TimeStamp structure depends on
* the security package. The security package must return this value in local time.
* @return
* If the function succeeds, the function returns one of the SEC_I_ success codes.
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
NativeLong fCredentialUse, LUID pvLogonID,
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
Pointer pvGetKeyArgument, CredHandle phCredential,
TimeStamp ptsExpiry);
/**
* The InitializeSecurityContext function initiates the client side, outbound security
* context from a credential handle. The function is used to build a security context
* between the client application and a remote peer. InitializeSecurityContext returns
* a token that the client must pass to the remote peer, which the peer in turn submits
* to the local security implementation through the AcceptSecurityContext call. The
* token generated should be considered opaque by all callers.
*
* Typically, the InitializeSecurityContext function is called in a loop until a
* sufficient security context is established.
*
* @param phCredential
* A handle to the credentials returned by AcquireCredentialsHandle. This handle is
* used to build the security context. The InitializeSecurityContext function requires
* at least OUTBOUND credentials.
* @param phContext
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
* this pointer is NULL. On the second call, this parameter is a pointer to the handle
* to the partially formed context returned in the phNewContext parameter by the first
* call.
* @param pszTargetName
* A pointer to a null-terminated string that indicates the target of the context.
* The string contents are security-package specific.
* @param fContextReq
* Bit flags that indicate requests for the context. Not all packages can support all
* requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example,
* ISC_REQ_DELEGATE.
* @param Reserved1
* This parameter is reserved and must be set to zero.
* @param TargetDataRep
* The data representation, such as byte ordering, on the target. This parameter can be
* either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
* @param pInput
* A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied
* as input to the package. The pointer must be NULL on the first call to the function.
* On subsequent calls to the function, it is a pointer to a buffer allocated with enough
* memory to hold the token returned by the remote peer.
* @param Reserved2
* This parameter is reserved and must be set to zero.
* @param phNewContext
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
* this pointer receives the new context handle. On the second call, phNewContext can be
* the same as the handle specified in the phContext parameter.
* @param pOutput
* A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure
* that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it
* will be there on output. The system will allocate a buffer for the security token if
* requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer
* descriptor for the security token.
* @param pfContextAttr
* A pointer to a variable to receive a set of bit flags that indicate the attributes of
* the established context. Flags used for this parameter are prefixed with ISC_RET,
* such as ISC_RET_DELEGATE.
* @param ptsExpiry
* A pointer to a TimeStamp structure that receives the expiration time of the context.
* It is recommended that the security package always return this value in local time.
* This parameter is optional and NULL should be passed for short-lived clients.
* @return
* If the function succeeds, the function returns one of the SEC_I_ success codes.
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
TimeStamp ptsExpiry);
/**
* The DeleteSecurityContext function deletes the local data structures associated
* with the specified security context.
* @param phContext
* Handle of the security context to delete.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
*/
public int DeleteSecurityContext(CtxtHandle phContext);
/**
* The FreeCredentialsHandle function notifies the security system that the
* credentials are no longer needed. An application calls this function to free
* the credential handle acquired in the call to the AcquireCredentialsHandle
* function. When all references to this credential set have been removed, the
* credentials themselves can be removed.
* @param phCredential
* A pointer to the credential handle obtained by using the AcquireCredentialsHandle
* function.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
*/
public int FreeCredentialsHandle(CredHandle phCredential);
/**
* The AcceptSecurityContext function enables the server component of a transport
* application to establish a security context between the server and a remote client.
* The remote client uses the InitializeSecurityContext function to start the process
* of establishing a security context. The server can require one or more reply tokens
* from the remote client to complete establishing the security context.
* @param phCredential
* A handle to the credentials of the server. The server calls the AcquireCredentialsHandle
* function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve
* this handle.
* @param phContext
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
* this pointer is NULL. On subsequent calls, phContext is the handle to the partially
* formed context that was returned in the phNewContext parameter by the first call.
* @param pInput
* A pointer to a SecBufferDesc structure generated by a client call to
* InitializeSecurityContext that contains the input buffer descriptor.
* @param fContextReq
* Bit flags that specify the attributes required by the server to establish the
* context. Bit flags can be combined by using bitwise-OR operations.
* @param TargetDataRep
* The data representation, such as byte ordering, on the target. This parameter can
* be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
* @param phNewContext
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
* this pointer receives the new context handle. On subsequent calls, phNewContext
* can be the same as the handle specified in the phContext parameter.
* @param pOutput
* A pointer to a SecBufferDesc structure that contains the output buffer descriptor.
* This buffer is sent to the client for input into additional calls to
* InitializeSecurityContext. An output buffer may be generated even if the function
* returns SEC_E_OK. Any buffer generated must be sent back to the client application.
* @param pfContextAttr
* A pointer to a variable that receives a set of bit flags that indicate the
* attributes of the established context. For a description of the various attributes,
* see Context Requirements. Flags used for this parameter are prefixed with ASC_RET,
* for example, ASC_RET_DELEGATE.
* @param ptsTimeStamp
* A pointer to a TimeStamp structure that receives the expiration time of the context.
* @return
* This function returns one of SEC_* values.
*/
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
TimeStamp ptsTimeStamp);
/**
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
* describe the security packages available to the client.
* @param pcPackages
* A pointer to a ULONG variable that receives the number of packages returned.
* @param ppPackageInfo
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
* Each structure contains information from the security support provider (SSP) that
* describes a security package that is available within that SSP.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code.
*/
public int EnumerateSecurityPackages(IntByReference pcPackages,
PSecPkgInfo.ByReference ppPackageInfo);
/**
* The FreeContextBuffer function enables callers of security package functions to free a memory
* buffer that was allocated by the security package as a result of calls to InitializeSecurityContext
* and AcceptSecurityContext.
* @param buffer
* A pointer to memory allocated by the security package.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code.
*/
public int FreeContextBuffer(Pointer buffer);
/**
* The QuerySecurityContextToken function obtains the access token for a client security context
* and uses it directly.
* @param phContext
* Handle of the context to query.
* @param phToken
* Returned handle to the access token.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code. One possible error code return is
* SEC_E_INVALID_HANDLE.
*/
public int QuerySecurityContextToken(PSecHandle phContext,
HANDLEByReference phToken);
}
@@ -0,0 +1,102 @@
/* 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.sun.jna.platform.win32;
import java.util.ArrayList;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
import com.sun.jna.ptr.IntByReference;
/**
* Secur32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Secur32Util {
/**
* An SSPI package.
*/
public static class SecurityPackage {
/**
* Package name.
*/
public String name;
/**
* Package comment.
*/
public String comment;
}
/**
* Retrieves the name of the user or other security principal associated
* with the calling thread.
*
* @param format User name format.
* @return User name in a given format.
*/
public static String getUserNameEx(int format) {
char[] buffer = new char[128];
IntByReference len = new IntByReference(buffer.length);
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
if (! result) {
int rc = Kernel32.INSTANCE.GetLastError();
switch(rc) {
case W32Errors.ERROR_MORE_DATA:
buffer = new char[len.getValue() + 1];
break;
default:
throw new Win32Exception(Native.getLastError());
}
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
}
if (! result) {
throw new Win32Exception(Native.getLastError());
}
return Native.toString(buffer);
}
/**
* Get the security packages installed on the current computer.
* @return
* An array of SSPI security packages.
*/
public static SecurityPackage[] getSecurityPackages() {
IntByReference pcPackages = new IntByReference();
PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference();
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
SecPkgInfo.ByReference[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
for(SecPkgInfo.ByReference packageInfo : packagesInfo) {
SecurityPackage securityPackage = new SecurityPackage();
securityPackage.name = packageInfo.Name.toString();
securityPackage.comment = packageInfo.Comment.toString();
packages.add(securityPackage);
}
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.getPointer());
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
return packages.toArray(new SecurityPackage[0]);
}
}
@@ -0,0 +1,60 @@
/* 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.
* <p/>
* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
import com.sun.jna.win32.W32APIOptions;
/**
* Mapping for Shell32.dll API.
*/
public interface Shell32 extends W32API {
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* This function can be used to copy, move, rename, or delete a file system object.
* @param fileop
* Address of an SHFILEOPSTRUCT structure that contains information this function
* needs to carry out the specified operation.
* @return
* Returns zero if successful, or nonzero otherwise.
*/
int SHFileOperation(SHFILEOPSTRUCT fileop);
/**
* Takes the CSIDL of a folder and returns the path.
* @param hwndOwner
* Handle to an owner window. This parameter is typically set to NULL. If it is not NULL,
* and a dial-up connection needs to be made to access the folder, a user interface (UI)
* prompt will appear in this window.
* @param nFolder
* A CSIDL value that identifies the folder whose path is to be retrieved. Only real
* folders are valid. If a virtual folder is specified, this function will fail. You can
* force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with
* CSIDL_FLAG_CREATE.
* @param hToken
* An access token that can be used to represent a particular user.
* @param dwFlags
* Flags to specify which path is to be returned.
* @param pszPath
* Pointer to a null-terminated string of length MAX_PATH which will receive the path.
* If an error occurs or S_FALSE is returned, this string will be empty.
* @return
* Returns standard HRESULT codes.
*/
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
char[] pszPath);
}
@@ -0,0 +1,59 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.W32API.DWORD;
import com.sun.jna.platform.win32.W32API.HRESULT;
import com.sun.jna.platform.win32.W32API.HWND;
/**
* Shell32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Shell32Util {
/**
* Get a special folder path.
* @param hwnd
* Parent window.
* @param nFolder
* Folder CSLID.
* @param dwFlags
* Flags.
* @return
* Special folder.
*/
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
nFolder, null, dwFlags,
pszPath);
if (! hr.equals(W32Errors.S_OK)) {
throw new Win32Exception(hr);
}
return Native.toString(pszPath);
}
/**
* Get a special folder path.
* @param nFolder
* Folder CSLID.
* @return
* Special folder path.
*/
public static String getFolderPath(int nFolder) {
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
}
}
@@ -0,0 +1,111 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.W32API.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShellAPI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract interface ShellAPI extends StdCallLibrary {
int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE;
public static final int FO_MOVE = 0x0001;
public static final int FO_COPY = 0x0002;
public static final int FO_DELETE = 0x0003;
public static final int FO_RENAME = 0x0004;
public static final int FOF_MULTIDESTFILES = 0x0001;
public static final int FOF_CONFIRMMOUSE = 0x0002;
public static final int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
public static final int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
public static final int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
public static final int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
public static final int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
public static final int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
public static final int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
public static final int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
public static final int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
public static final int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
public static final int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
public static final int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
public static final int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
public static final int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
public static final int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
public static final int PO_DELETE = 0x0013; // printer is being deleted
public static final int PO_RENAME = 0x0014; // printer is being renamed
public static final int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
public static final int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
/**
* Contains information that the SHFileOperation function uses to perform file operations.
*/
public static class SHFILEOPSTRUCT extends Structure {
/**
* A window handle to the dialog box to display information about
* the status of the file operation.
*/
public HANDLE hwnd;
/**
* An FO_* value that indicates which operation to perform.
*/
public int wFunc;
/**
* A pointer to one or more source file names, double null-terminated.
*/
public WString pFrom;
/**
* A pointer to the destination file or directory name.
*/
public WString pTo;
/**
* Flags that control the file operation.
*/
public short fFlags;
/**
* When the function returns, this member contains TRUE if any file operations
* were aborted before they were completed; otherwise, FALSE. An operation can
* be manually aborted by the user through UI or it can be silently aborted by
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
*/
public boolean fAnyOperationsAborted;
/**
* When the function returns, this member contains a handle to a name mapping
* object that contains the old and new names of the renamed files. This member
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
*/
public Pointer pNameMappings;
/**
* A pointer to the title of a progress dialog box. This is a null-terminated string.
*/
public WString lpszProgressTitle;
/** Use this to encode <code>pFrom/pTo</code> paths. */
public String encodePaths(String[] paths) {
String encoded = "";
for (int i=0; i < paths.length;i++) {
encoded += paths[i];
encoded += "\0";
}
return encoded + "\0";
}
}
}
@@ -0,0 +1,84 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.platform.win32.W32API.DWORD;
/**
* Ported from ShlObj.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class ShlObj {
public static final DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
public static final DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
public static final int CSIDL_DESKTOP = 0x0000; // <desktop>
public static final int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
public static final int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
public static final int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
public static final int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
public static final int CSIDL_PERSONAL = 0x0005; // My Documents
public static final int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
public static final int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
public static final int CSIDL_RECENT = 0x0008; // <user name>\Recent
public static final int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
public static final int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
public static final int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
public static final int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
public static final int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
public static final int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
public static final int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
public static final int CSIDL_DRIVES = 0x0011; // My Computer
public static final int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
public static final int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
public static final int CSIDL_FONTS = 0x0014; // windows\fonts
public static final int CSIDL_TEMPLATES = 0x0015;
public static final int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
public static final int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
public static final int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
public static final int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
public static final int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
public static final int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
public static final int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
public static final int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
public static final int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
public static final int CSIDL_COMMON_FAVORITES = 0x001f;
public static final int CSIDL_INTERNET_CACHE = 0x0020;
public static final int CSIDL_COOKIES = 0x0021;
public static final int CSIDL_HISTORY = 0x0022;
public static final int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
public static final int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
public static final int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
public static final int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
public static final int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
public static final int CSIDL_PROFILE = 0x0028; // USERPROFILE
public static final int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
public static final int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
public static final int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
public static final int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
public static final int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
public static final int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
public static final int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
public static final int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
public static final int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
public static final int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
public static final int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
public static final int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
public static final int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
public static final int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
public static final int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
public static final int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
public static final int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
}
@@ -0,0 +1,466 @@
/* 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.sun.jna.platform.win32;
import com.sun.jna.Memory;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
/**
* Ported from Sspi.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class Sspi {
/**
* Maximum size in bytes of a security token.
*/
public static final int MAX_TOKEN_SIZE = 12288;
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
/**
* Validate an incoming server credential. Inbound credentials might be validated
* by using an authenticating authority when InitializeSecurityContext or
* AcceptSecurityContext is called. If such an authority is not available, the function will
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
*/
public static final int SECPKG_CRED_INBOUND = 1;
/**
* Allow a local client credential to prepare an outgoing token.
*/
public static final int SECPKG_CRED_OUTBOUND = 2;
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
/**
* Specifies Native data representation.
*/
public static final int SECURITY_NATIVE_DREP = 0x10;
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
/**
* The security package allocates output buffers for you.
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
*/
public static final int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
/**
* Encrypt messages by using the EncryptMessage function.
*/
public static final int ISC_REQ_CONFIDENTIALITY = 0x00000010;
/**
* The security context will not handle formatting messages. This value is the default.
*/
public static final int ISC_REQ_CONNECTION = 0x00000800;
/**
* The server can use the context to authenticate to other servers as the client.
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
* Ignore this flag for constrained delegation.
*/
public static final int ISC_REQ_DELEGATE = 0x00000001;
/**
* When errors occur, the remote party will be notified.
*/
public static final int ISC_REQ_EXTENDED_ERROR = 0x00004000;
/**
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
*/
public static final int ISC_REQ_INTEGRITY = 0x00010000;
/**
* The mutual authentication policy of the service will be satisfied.
*/
public static final int ISC_REQ_MUTUAL_AUTH = 0x00000002;
/**
* Detect replayed messages that have been encoded by using the
* EncryptMessage or MakeSignature functions.
*/
public static final int ISC_REQ_REPLAY_DETECT = 0x00000004;
/**
* Detect messages received out of sequence.
*/
public static final int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
/**
* Support a stream-oriented connection.
*/
public static final int ISC_REQ_STREAM = 0x00008000;
/**
* Version of the SecBuffer struct.
*/
public static final int SECBUFFER_VERSION = 0;
/**
* This is a placeholder in the buffer array.
*/
public static final int SECBUFFER_EMPTY = 0;
/**
* This buffer type is used for common data. The security package can read
* and write this data.
*/
public static final int SECBUFFER_DATA = 1;
/**
* This buffer type is used to indicate the security token portion of the message.
* This is read-only for input parameters or read/write for output parameters.
*/
public static final int SECBUFFER_TOKEN = 2;
/**
* Security handle.
*/
public static class SecHandle extends Structure {
public Pointer dwLower;
public Pointer dwUpper;
public static class ByReference extends SecHandle implements Structure.ByReference {
}
/**
* An empty SecHandle.
*/
public SecHandle() {
dwLower = null;
dwUpper = null;
}
/**
* Returns true if the handle is NULL.
* @return
* True if NULL, False otherwise.
*/
public boolean isNull() {
return dwLower == null && dwUpper == null;
}
}
/**
* A pointer to a SecHandle
*/
public static class PSecHandle extends Structure {
public static class ByReference extends PSecHandle implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecHandle.ByReference secHandle;
public PSecHandle() {
}
public PSecHandle(SecHandle h) {
useMemory(h.getPointer());
read();
}
}
/**
* Credentials handle.
*/
public static class CredHandle extends SecHandle {
}
/**
* Security context handle.
*/
public static class CtxtHandle extends SecHandle {
}
/**
* The SecBuffer structure describes a buffer allocated by a transport application
* to pass to a security package.
*/
public static class SecBuffer extends Structure {
/**
* A ByReference SecBuffer.
*/
public static class ByReference extends SecBuffer implements Structure.ByReference {
/**
* Create a SECBUFFER_EMPTY SecBuffer.
*/
public ByReference() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public ByReference(int type, int size) {
super(type, size);
}
public ByReference(int type, byte[] token) {
super(type, token);
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return super.getBytes();
}
}
/**
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
*/
public NativeLong cbBuffer;
/**
* Bit flags that indicate the type of buffer. Must be one of the values of
* the SecBufferType enumeration.
*/
public NativeLong BufferType;
/**
* A pointer to a buffer.
*/
public Pointer pvBuffer;
/**
* Create a new SECBUFFER_EMPTY buffer.
*/
public SecBuffer() {
cbBuffer = new NativeLong(0);
pvBuffer = null;
BufferType = new NativeLong(SECBUFFER_EMPTY);
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public SecBuffer(int type, int size) {
cbBuffer = new NativeLong(size);
pvBuffer = new Memory(size);
BufferType = new NativeLong(type);
allocateMemory();
}
/**
* Create a SecBuffer of a given type with initial data.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param token
* Existing token.
*/
public SecBuffer(int type, byte[] token) {
cbBuffer = new NativeLong(token.length);
pvBuffer = new Memory(token.length);
pvBuffer.write(0, token, 0, token.length);
BufferType = new NativeLong(type);
allocateMemory();
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return pvBuffer.getByteArray(0, cbBuffer.intValue());
}
}
public static class SecBufferDesc extends Structure {
/**
* Version number.
*/
public NativeLong ulVersion;
/**
* Number of buffers.
*/
public NativeLong cBuffers;
/**
* Pointer to array of buffers.
*/
public SecBuffer.ByReference[] pBuffers;
/**
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
*/
public SecBufferDesc() {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
/**
* Create a new SecBufferDesc with initial data.
* @param type
* Token type.
* @param token
* Initial token data.
*/
public SecBufferDesc(int type, byte[] token) {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
/**
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
* @param type
* @param tokenSize
*/
public SecBufferDesc(int type, int tokenSize) {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize);
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
public byte[] getBytes() {
if (pBuffers == null || cBuffers == null) {
throw new RuntimeException("pBuffers | cBuffers");
}
if (cBuffers.intValue() == 1) {
return pBuffers[0].getBytes();
}
throw new RuntimeException("cBuffers > 1");
}
}
/**
* A security integer.
*/
public static class SECURITY_INTEGER extends Structure {
public NativeLong dwLower;
public NativeLong dwUpper;
/**
* An security integer of 0.
*/
public SECURITY_INTEGER() {
dwLower = new NativeLong(0);
dwUpper = new NativeLong(0);
}
}
/**
* A timestamp.
*/
public static class TimeStamp extends SECURITY_INTEGER {
}
/**
* A pointer to an array of SecPkgInfo structures.
*/
public static class PSecPkgInfo extends Structure {
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference pPkgInfo;
public PSecPkgInfo() {
}
/**
* An array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference[] toArray(int size) {
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
}
}
/**
* The SecPkgInfo structure provides general information about a security package,
* such as its name and capabilities.
*/
public static class SecPkgInfo extends Structure {
/**
* A reference pointer to a SecPkgInfo structure.
*/
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
}
/**
* Set of bit flags that describes the capabilities of the security package.
*/
public NativeLong fCapabilities;
/**
* Specifies the version of the package protocol. Must be 1.
*/
public short wVersion;
/**
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
*/
public short wRPCID;
/**
* Specifies the maximum size, in bytes, of the token.
*/
public NativeLong cbMaxToken;
/**
* Pointer to a null-terminated string that contains the name of the security package.
*/
public WString Name;
/**
* Pointer to a null-terminated string. This can be any additional string passed
* back by the package.
*/
public WString Comment;
/**
* Create a new package info.
*/
public SecPkgInfo() {
fCapabilities = new NativeLong(0);
wVersion = 1;
wRPCID = 0;
cbMaxToken = new NativeLong(0);
}
}
}
@@ -8,31 +8,27 @@
* 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.
* Lesser General Public License for more details.
*/
package com.sun.jna.examples.win32;
import com.sun.jna.FromNativeContext;
import com.sun.jna.IntegerType;
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.NativeMapped;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.examples.win32.GDI32.RECT;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.W32APIOptions;
/** Provides access to the w32 user32 library.
* Incomplete implementation to support demos.
*
*
* @author Todd Fast, todd.fast@sun.com
* @author twall@users.sf.net
* @author twalljava@dev.java.net
*/
public interface User32 extends W32API {
User32 INSTANCE = (User32)
Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS);
HDC GetDC(HWND hWnd);
int ReleaseDC(HWND hWnd, HDC hDC);
@@ -42,8 +38,8 @@ public interface User32 extends W32API {
int FLASHW_ALL = (FLASHW_CAPTION|FLASHW_TRAY);
int FLASHW_TIMER = 4;
int FLASHW_TIMERNOFG = 12;
public static class FLASHWINFO extends Structure {
class FLASHWINFO extends Structure {
public int cbSize;
public HANDLE hWnd;
public int dwFlags;
@@ -71,24 +67,27 @@ public interface User32 extends W32API {
int LR_SHARED =0x8000;
HWND FindWindow(String winClass, String title);
/** ASCII version. */
int GetClassName(HWND hWnd, byte[] lpClassName, int nMaxCount);
public static class GUITHREADINFO extends Structure {
/** Unicode version. */
int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount);
class GUITHREADINFO extends Structure {
public int cbSize = size();
public int flags;
HWND hwndActive;
HWND hwndFocus;
HWND hwndCapture;
HWND hwndMenuOwner;
HWND hwndMoveSize;
HWND hwndCaret;
RECT rcCaret;
public HWND hwndActive;
public HWND hwndFocus;
public HWND hwndCapture;
public HWND hwndMenuOwner;
public HWND hwndMoveSize;
public HWND hwndCaret;
public GDI32.RECT rcCaret;
}
boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
public static class WINDOWINFO extends Structure {
class WINDOWINFO extends Structure {
public int cbSize = size();
public RECT rcWindow;
public RECT rcClient;
public GDI32.RECT rcWindow;
public GDI32.RECT rcClient;
public int dwStyle;
public int dwExStyle;
public int dwWindowStatus;
@@ -98,28 +97,35 @@ public interface User32 extends W32API {
public short wCreatorVersion;
}
boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi);
boolean GetWindowRect(HWND hWnd, RECT rect);
boolean GetWindowRect(HWND hWnd, GDI32.RECT rect);
/** ASCII version. */
int GetWindowText(HWND hWnd, byte[] lpString, int nMaxCount);
/** Unicode version. */
int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount);
int GetWindowTextLength(HWND hWnd);
/** ASCII version. */
int GetWindowModuleFileName(HWND hWnd, byte[] lpszFileName, int cchFileNameMax);
/** Unicode version. */
int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName, int cchFileNameMax);
int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId);
interface WNDENUMPROC extends StdCallCallback {
/** Return whether to continue enumeration. */
boolean callback(HWND hWnd, Pointer data);
}
boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);
boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc, Pointer data);
boolean FlashWindowEx(FLASHWINFO info);
HICON LoadIcon(HINSTANCE hInstance, String iconName);
HANDLE LoadImage(HINSTANCE hinst, // handle to instance
String name, // image to load
int type, // image type
int xDesired, // desired width
int yDesired, // desired height
int load // load options
HANDLE LoadImage(HINSTANCE hinst, // handle to instance
String name, // image to load
int type, // image type
int xDesired, // desired width
int yDesired, // desired height
int load // load options
);
boolean DestroyIcon(HICON hicon);
@@ -140,7 +146,7 @@ public interface User32 extends W32API {
int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
// Do not use this version on win64
Pointer SetWindowLong(HWND hWnd, int nIndex, Pointer dwNewLong);
LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex);
LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLongPtr);
Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr);
@@ -150,7 +156,7 @@ public interface User32 extends W32API {
int ULW_COLORKEY = 1;
int ULW_ALPHA = 2;
int ULW_OPAQUE = 4;
boolean SetLayeredWindowAttributes(HWND hwnd, int crKey,
boolean SetLayeredWindowAttributes(HWND hwnd, int crKey,
byte bAlpha, int dwFlags);
boolean GetLayeredWindowAttributes(HWND hwnd,
IntByReference pcrKey,
@@ -158,26 +164,30 @@ public interface User32 extends W32API {
IntByReference pdwFlags);
/** Defines the x- and y-coordinates of a point. */
public static class POINT extends Structure {
class POINT extends Structure {
public int x, y;
public POINT() { }
public POINT(int x, int y) { this.x = x; this.y = y; }
}
/** Specifies the width and height of a rectangle. */
public static class SIZE extends Structure {
class SIZE extends Structure {
public int cx, cy;
public SIZE() { }
public SIZE(int w, int h) { this.cx = w; this.cy = h; }
}
int AC_SRC_OVER = 0x00;
int AC_SRC_ALPHA = 0x01;
int AC_SRC_NO_PREMULT_ALPHA = 0x01;
int AC_SRC_NO_ALPHA = 0x02;
public static class BLENDFUNCTION extends Structure {
class BLENDFUNCTION extends Structure {
public byte BlendOp = AC_SRC_OVER; // only valid value
public byte BlendFlags = 0; // only valid value
public byte SourceConstantAlpha;
public byte AlphaFormat;
}
boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst,
POINT pptDst, SIZE psize,
HDC hdcSrc, POINT pptSrc, int crKey,
boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst,
POINT pptDst, SIZE psize,
HDC hdcSrc, POINT pptSrc, int crKey,
BLENDFUNCTION pblend, int dwFlags);
int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw);
int VK_SHIFT = 16;
@@ -196,28 +206,28 @@ public interface User32 extends W32API {
int WH_MOUSE = 7;
int WH_KEYBOARD_LL = 13;
int WH_MOUSE_LL = 14;
public static class HHOOK extends HANDLE { }
public static interface HOOKPROC extends StdCallCallback { }
class HHOOK extends HANDLE { }
interface HOOKPROC extends StdCallCallback { }
int WM_KEYDOWN = 256;
int WM_KEYUP = 257;
int WM_SYSKEYDOWN = 260;
int WM_SYSKEYUP = 261;
public static class KBDLLHOOKSTRUCT extends Structure {
class KBDLLHOOKSTRUCT extends Structure {
public int vkCode;
public int scanCode;
public int flags;
public int time;
public ULONG_PTR dwExtraInfo;
}
public static interface LowLevelKeyboardProc extends HOOKPROC {
interface LowLevelKeyboardProc extends HOOKPROC {
LRESULT callback(int nCode, WPARAM wParam, KBDLLHOOKSTRUCT lParam);
}
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod, int dwThreadId);
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam);
boolean UnhookWindowsHookEx(HHOOK hhk);
public static class MSG extends Structure {
class MSG extends Structure {
public HWND hWnd;
public int message;
public WPARAM wParam;

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais