Comparar commits

..

143 Commits

Autor SHA1 Mensagem Data
Timothy Wall ed1cc99506 update CHANGES with current version 2011-06-17 10:36:51 -04:00
twall f66cb26c58 Merge pull request #1 from dblock/master
Initial documentation in markdown format.
2011-06-17 07:30:49 -07:00
dblock 707412d1b6 Merge branch 'master' of github.com:twall/jna 2011-06-07 20:25:46 -04:00
dblock a7ebdc5453 Sync with svn, 3.3.0 release. 2011-06-07 20:22:40 -04:00
dblock dc35957f63 Updating revisions 1197 and 1998 from svn. 2011-05-30 15:30:38 -04:00
dblock 0711483bb7 Updated readme. 2011-05-23 11:26:05 -04:00
dblock f4f5ff1887 Fixed table. 2011-05-23 11:24:30 -04:00
dblock 33a4fa3203 Changes are in markdown format. 2011-05-23 11:20:46 -04:00
dblock 8b22412e55 The rest of the documentation. 2011-05-23 11:19:40 -04:00
dblock 92d721d9d0 Started porting docs into markdown. 2011-05-23 10:47:24 -04:00
dblock 0f06d0b8ce Added top-level build.xml. 2011-05-23 09:37:48 -04:00
dblock e321ec4c6f Updated classpaths to jnalib, default Eclipse import. 2011-05-23 09:13:09 -04:00
dblock 2f2892ff08 Updated classpaths to match default Eclipse import (jnalib). 2011-05-23 09:11:44 -04:00
dblock 1dd559e80e Added .gitignore. 2011-05-23 08:47:12 -04:00
Timothy Wall b7fb1b7e5a update sparc jars
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1196 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-05-17 14:24:16 +00:00
Timothy Wall eb60877793 update native jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1195 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-05-16 17:10:05 +00:00
Timothy Wall 5907ce0a02 import libffi 3.0.10-rc8
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1194 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-04-30 21:54:20 +00:00
Timothy Wall 5a1d431e51 fix javadoc warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1193 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-12 22:21:17 +00:00
Timothy Wall 0552c4a001 fix javadoc warning
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1192 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-12 22:20:48 +00:00
Timothy Wall 96d017869a move all native functions into Native class, reduce JNI crossings where possible
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1191 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-03 14:29:29 +00:00
Timothy Wall ddc2688af8 update release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1190 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-03 14:26:47 +00:00
Timothy Wall baa60b6198 fix invalid PPC relocation types
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1189 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-03 12:15:51 +00:00
Timothy Wall 8abdddf11a avoid ant warning
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1188 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-03-03 12:13:02 +00:00
Timothy Wall 9141018b27 partial repair of osx build
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1187 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-28 23:04:20 +00:00
Timothy Wall 3370fecdf2 make Memory easier to extend, use synchronized map to track buffers
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1186 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-28 22:19:33 +00:00
Daniel Doubrovkine 5e91f76f0f Added Kernel32.GetFileAttributes and Kernel32Util.getFileAttributes.
Patch by cdanninger.
http://java.net/jira/browse/JNA-175


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1185 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-28 01:33:47 +00:00
Timothy Wall 557b3e1c93 allow multiple fields of same type in union
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1184 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-26 02:51:01 +00:00
Daniel Doubrovkine 3f65e56ccd Moved release notes to www. Modified HTML to fit Kenai website.
To upload to Kenai use Webdav to jna.java.net (w/SSL), the path is /website/jna/. 
Results at http://jna.java.net/. 

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1183 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-15 18:09:05 +00:00
nguillaumin 5bd2cba2c2 Added platform.win32.Advapi32.ImpersonateSelf
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1182 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-02-03 04:04:12 +00:00
nguillaumin 3de7eb58a7 Added platform.win32.Advapi32.AdjustTokenPrivileges, platform.win32.Advapi32.LookupPrivilegeName, platform.win32.Advapi32.LookupPrivilegeValue + tests.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1181 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-01-30 22:31:15 +00:00
nguillaumin 41eb294ce6 [issue #169] Added new Win32 platform function mappings related to process creation. SECURITY_ATTRIBUTES structure has been moved to WinBase to reflect latest MSDN doco.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1180 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-01-16 22:17:34 +00:00
Timothy Wall ba94f2ebe0 add platform.jar to maven package
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1179 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-01-12 14:34:21 +00:00
Timothy Wall 7912248950 add platform.jar to maven package
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1178 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2011-01-12 14:24:50 +00:00
Daniel Doubrovkine 5d27c255b3 Killed link to forum. Forum RIP.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1177 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-12-22 04:56:38 +00:00
Eugine Lev 80e86e3b83 Bug: fix issues with starting/stopping services, caused by the service resetting progress checkpoint to 0.
Add getters for service handle and service manager handle in W32Service and W32ServiceManager respectively.

CR: dBlock

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1176 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-12-14 19:28:19 +00:00
Daniel Doubrovkine 3a759f1eea Fix platform.win32.Netapi32Util.getDC AV on Win64
https://jna.dev.java.net/issues/show_bug.cgi?id=167
Fix Advapi32Test.testGetTokenOwnerInformation AV.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1175 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-12-13 18:35:21 +00:00
Timothy Wall a09e503f19 fix Structure(Pointer) array field init bugs
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1174 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-11-24 22:59:12 +00:00
Timothy Wall da4524b05c partially fix build on OSX 10.6 (omits ppc build)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1173 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-11-24 21:59:42 +00:00
Timothy Wall 1a98283709 Fix NPE in array element initialization
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1172 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-11-24 21:50:09 +00:00
Timothy Wall acca8c5ac9 add two (failing) tests based on Samuel Audet's reports on lack of field initialization in Structure with Pointer ctors
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1171 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-11-24 20:25:03 +00:00
Timothy Wall 55eabb84e4 fix Structure.StructureSet.Iterator bug
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1170 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-11-24 20:15:45 +00:00
Daniel Doubrovkine 90ba9fce2a Added EventLogRecord.getData() and getStrings().
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1169 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-13 23:57:22 +00:00
Daniel Doubrovkine 76b3982ddd Fixed Javadoc warnings.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1168 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 21:35:28 +00:00
Daniel Doubrovkine c946f80d5b Fixed Javadoc warnings.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1167 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 21:34:20 +00:00
Eugine Lev 8d350c7d99 Add platform.win32.W32ServiceManager and W32Service.
Add platform.win32.Kernel32.GetTickCount.
CR: dBlock

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1166 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 21:18:43 +00:00
Daniel Doubrovkine 7cd7fb8d6c Add REG_BINARY, REG_EXPAND_SZ and REG_MULTI_SZ support to Advapi32Util.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1165 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 14:26:31 +00:00
Daniel Doubrovkine b12e563340 Build break: fixed service name in Advapi32Test.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1164 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 03:39:51 +00:00
Daniel Doubrovkine 9c0aadce1e Added REG_BINARY support to Advapi32Util registry functions.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1163 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 01:03:30 +00:00
Daniel Doubrovkine b8d538b1b4 Removed unused functions in NTService demo, equivalents have long been ported to platform.win32.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1162 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 01:02:18 +00:00
Daniel Doubrovkine 0219cd71b9 Fix platform.win32.Kernel32.GetNativeSystemInfo and GetSystemInfo AV on Win64.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1161 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-06 00:03:25 +00:00
Eugine Lev 899fcbdfcc Add Win32 Service functions to platform.win32.Advapi32
CR: dBlock

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1160 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-05 23:51:34 +00:00
Daniel Doubrovkine 79fed6e32f Updated projects using JNA to be a link to a forum where people can post themselves.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1159 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-10-03 20:42:48 +00:00
Daniel Doubrovkine 55263ca11d Documented EVENTLOGRECORD.
Added flags to iterate forwards and backwards.
Collapsed record ID using the value in the structure.
Shortened tests.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1158 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-30 20:04:58 +00:00
Daniel Doubrovkine fe1f4a3bac Add EventLogIterator to Advapi32Util.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1157 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-30 15:08:26 +00:00
Daniel Doubrovkine dd4fda55b5 Re-oredered test report for JNA to run after tests to avoid merging wrong results.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1156 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 14:03:56 +00:00
Daniel Doubrovkine 2aae506110 Added xml test report, generating in jnalib\contrib\platform\build\test\results\TESTS-TestSuites.xml.
Shortened runtime of testReadEventLogEntries.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1155 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 14:01:56 +00:00
Daniel Doubrovkine aae54a6f41 Added WinspoolUtil.getPrinterInfo4.
Not expecting failure in spool tests on the first call: when no printers are installed the function succeeds and returns 0 bytes required and 0 printers returned.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1154 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 12:18:31 +00:00
Daniel Doubrovkine 89da58adec Added PRINTER_INFO_4.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1153 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 02:41:40 +00:00
Daniel Doubrovkine 57ef003eb9 Added Advapi32.GetOldestEventLogRecord.
Added WinNT.EVENTLOGRECORD.
Bug: ReadEventLog broken, added full test.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1152 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 01:24:56 +00:00
Daniel Doubrovkine d378a64096 Hopefully fixed the WinspoolTest for when there're no printers installed.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1151 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-29 00:17:01 +00:00
Daniel Doubrovkine 58ac91bc10 Fixed spool tests for cases where no printers are available.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1150 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-28 23:43:19 +00:00
Daniel Doubrovkine 97602c0bf8 Fixed a number if UNUSED warnings.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1149 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-28 19:42:46 +00:00
Daniel Doubrovkine 8523c487c1 platform.win32.Advapi32Util.registryCreateKey returns true if key was created, false if it already exists.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1148 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-28 15:47:03 +00:00
Daniel Doubrovkine 3580b58bf6 Add platform.win32.Kernel32.DeleteFile and com.sun.jna.platform.win32.deleteFile.
Add Event Logging functions to platform.win32.Advapi32.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1147 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-09-27 23:51:27 +00:00
Timothy Wall 9b26a4d5ce add omitted field type which might use current value if available
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1146 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 15:46:00 +00:00
Timothy Wall c43fc68bc8 fix potential NPE
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1145 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 15:43:44 +00:00
Timothy Wall df07539331 fix unused parameter warnings under gcc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1144 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 15:22:22 +00:00
Timothy Wall 563931750b fix compiler error
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1143 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 15:22:02 +00:00
Timothy Wall 6b090de7b1 avoid potential overflow
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1142 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 14:28:54 +00:00
Timothy Wall d8863ef95f fulfill hashCode contract for Function
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1141 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 14:28:21 +00:00
Timothy Wall 36f9595ce7 make memory clear intent obvious
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1140 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-29 14:26:53 +00:00
Timothy Wall 48565e6305 integrate platform javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1139 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-22 15:08:26 +00:00
Timothy Wall 3727f9583b remove extraneous stuff from source archives
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1137 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 14:48:27 +00:00
Timothy Wall 4a6bbf0b3c update javadoc (version change)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1136 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 03:17:25 +00:00
Timothy Wall 7513a7157f ensure source properly synched with binaries
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1135 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 03:11:04 +00:00
Timothy Wall e7dbdb6ead tweak BITMAPINFO structure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1134 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 01:39:21 +00:00
Timothy Wall db5f101bfc tweak BITMAPINFO structure
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1133 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 01:39:00 +00:00
Timothy Wall 3c06e8b6fd add GDI test
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1132 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-21 01:33:44 +00:00
Timothy Wall 28f94cbd0b simplify and clean up contrib hierarchy, fix contrib builds on 64-bit platforms
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1131 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-20 02:30:38 +00:00
Timothy Wall 6f37cbd946 update platform.jar
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1128 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-20 01:39:22 +00:00
Timothy Wall 396281263b update javadoc
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1126 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 20:44:33 +00:00
Timothy Wall a00e8ac201 tweak version on main jar file
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1125 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 20:31:04 +00:00
Timothy Wall b1772a89c1 bump version in release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1124 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 20:15:58 +00:00
Timothy Wall 58f07ff045 update jars
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1123 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:56:16 +00:00
Timothy Wall 12f99d4fc7 update native lib to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1122 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:40:26 +00:00
Timothy Wall 05da0a6877 update native jar to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1121 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:21:05 +00:00
Timothy Wall 46ce871f34 update copyright notices
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1120 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:20:51 +00:00
Timothy Wall 4b22c2f044 update release notes
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1119 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:10:54 +00:00
Timothy Wall 4014828eff add some GDI32 functions
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1118 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 19:09:53 +00:00
Timothy Wall bc87a62d59 update native lib to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1117 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 15:40:33 +00:00
Timothy Wall f6862442d3 update native lib to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1116 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 15:22:42 +00:00
Timothy Wall bff7f57eb8 update native lib to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1115 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 15:17:21 +00:00
Timothy Wall e19024ca0d update native to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1114 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 15:07:25 +00:00
Timothy Wall 73997e4799 update native libs to 3.2.2
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1113 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:28:35 +00:00
Timothy Wall ffa97aa438 update native lib (w/ correct version)
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1112 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:22:00 +00:00
Timothy Wall d08244dfd8 properly patch Makefile with native version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1111 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:15:14 +00:00
Timothy Wall 2e0d367045 update native code
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1110 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:09:12 +00:00
Timothy Wall 0f1fb2e6a1 Bump native code bug revision
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1109 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:05:17 +00:00
Timothy Wall 672e362ed8 add pointer peer accessor
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1108 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-19 13:04:05 +00:00
Daniel Doubrovkine bcae16c441 Native.loadLibrary can now load .drv files.
Add platform.win32.Winspool.GetPrinterInfo.
Add platform.win32.WinspoolUtil.getPrinterInfo1.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1107 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-18 16:51:39 +00:00
Timothy Wall 19b8f5cb59 clarify FAQ entry
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1106 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-16 14:41:05 +00:00
Timothy Wall 68b37156d8 update FAQ
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1105 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-16 14:13:28 +00:00
Timothy Wall d9237b64c0 update FAQ
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1104 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-07-16 14:05:56 +00:00
Scott Palmer da037b38e3 Updated release notes.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1103 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-28 13:20:15 +00:00
Scott Palmer 62f864f4ab Added SHGetDesktopFolder.
It obtains a COM interface, so this is just to prepare
for Com4JNA support (will need to get a COM interface
to test Com4JNA).



git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1102 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-25 19:13:56 +00:00
Daniel Doubrovkine bf89f1d37d Add Kernel32.GetDiskFreeSpaceEx, GetLogicalDriveStrings, GlobalMemoryStatusEx.
Add Kernel32Util.getLogicalDriveStrings.
Add WinDef ULONGLONG and DWORDLONG.
Refactor WinNT.LARGE_INTEGER into a union.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1101 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-23 00:55:05 +00:00
Daniel Doubrovkine 3dc986e609 Added VER* constants.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1100 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-22 17:05:38 +00:00
Daniel Doubrovkine 2f5e874201 Add com.sun.jna.platform.win32.BaseTSD.DWORD_PTR.
Add com.sun.jna.platform.win32.WinBase.SYSTEM_INFO.
Add com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX.
Add Kernel32 GetVersionEx, GetSystemInfo, GetNativeSystemInfo and IsWow64Process.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1099 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-22 14:46:07 +00:00
Daniel Doubrovkine 05291932f8 Add com.sun.jna.platform.win32.Kernel32.GetVersion and GetVersionEx.
Add com.sun.jna.platform.win32.User32.GetSystemMetrics.
Refactor constants from com.sun.jna.platform.win32.GDI32 into WinGDI, matching Windows SDK headers.
Refactor constants from com.sun.jna.platform.win32.User32 into WinUser, matching Windows SDK headers.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1098 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-22 02:39:37 +00:00
Timothy Wall 72aa450ecb Provide String.replace for 1.4 compatibility
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1097 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-18 11:07:10 +00:00
Daniel Doubrovkine 926ea21fe0 Added Advapi32Util.isWellKnownSid.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1096 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-16 12:10:45 +00:00
Daniel Doubrovkine 657a077cdb Add com.sun.jna.platform.win32.WinNT.WELL_KNOWN_SID_TYPE, SECURITY_MAX_SID_SIZE and other related SID-related constants.
Add com.sun.jna.platform.win32.Advapi32.CreateWellKnownSid and IsWellKnownSid. 

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1095 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-15 14:41:44 +00:00
Daniel Doubrovkine 9a90f56845 Fixed incorrect comments on autoread/write.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1094 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-06-02 17:24:45 +00:00
Daniel Doubrovkine 7d36e0d63b Fix error not reported properly in getTokenGroups/getTokenAccount.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1093 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-28 23:29:55 +00:00
Daniel Doubrovkine 865d5ed7a1 Updated copyright notices so that Tim doesn't go to jail for my bugs (also makes my company legal happy).
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1092 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-28 21:27:01 +00:00
Daniel Doubrovkine 9dd91ee17e Deleting the wrong pointer.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1091 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-28 21:08:34 +00:00
Daniel Doubrovkine 425ea821d7 Add platform.win32.Secur32.ImpersonateSecurityContext and RevertSecurityContext.
Fix platform.win32.Secur32.QuerySecurityContextToken take a CtxtHandle, avoid indirection.
Updated release notes with win32 changes so far.


git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1090 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-28 14:58:27 +00:00
Scott Palmer bea5049a2f Updated release notes to reflect new behavior of jna.library.path.
Fixed invalid HTML in the Release 3.0 notes.

git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1089 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-20 18:54:54 +00:00
Scott Palmer eae1e34696 Re-evaluate jna.library.path on each library load instead of caching the value.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1088 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-20 14:21:59 +00:00
Scott Palmer e63b6b00bc Added ObjBase.java for constant definitions. Modified unit test to use constants from ObjBase.java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1087 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-19 13:26:45 +00:00
Daniel Doubrovkine e5b3ed226b Bug: read() of uninitialized memory in getTokenGroups/getTokenAccount.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1086 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-16 22:33:28 +00:00
Daniel Doubrovkine d5ce354c87 Added missing docs.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1085 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-14 16:50:11 +00:00
Timothy Wall e280838989 fix typo in comment
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1084 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-14 13:38:15 +00:00
Timothy Wall 2309054b1f address issue 156
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1083 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-14 13:10:56 +00:00
Timothy Wall 9dcc44a76b addrss issue 154
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1082 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-14 13:08:13 +00:00
Scott Palmer 7a417c6d3b Moved CLSCTX_* definitions to WTypes.java
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1081 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-13 20:51:44 +00:00
Scott Palmer 425ab15ae1 Added CoInitializeEx, CoUninitialize, and CoCreateInstance, with unit tests.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1080 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-13 18:47:54 +00:00
Daniel Doubrovkine c75ff4f118 Minor doc/comment changes.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1079 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-12 20:14:26 +00:00
Daniel Doubrovkine 75d3dd19ec Added Scott Palmer's oleaut32.dll interface + tests.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1078 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-12 20:11:41 +00:00
Timothy Wall 4cd556555e add note on win32 gcc version
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1077 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-05-12 13:30:03 +00:00
Daniel Doubrovkine feebe921af Fixed all the trivial warnings. Down to about 30 or so.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1076 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-28 00:38:42 +00:00
Daniel Doubrovkine 92929308bd Refactor com.sun.jna.platform.win32.WINBASE into WinDef, WinNT and BaseTSD, matching Windows SDK headers.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1075 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-27 02:10:00 +00:00
Timothy Wall ca4f14b555 fix issue 152
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1074 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-25 20:05:14 +00:00
Timothy Wall a7bcfacbd9 fix issue 151
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1073 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-15 13:22:45 +00:00
Timothy Wall e097b4820d fix deprecation warnings
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1072 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-13 21:22:45 +00:00
Timothy Wall 566ec7974c split contrib jars into its own target
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1071 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-13 17:37:45 +00:00
Timothy Wall c735d6c420 avoid deprecated function
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1070 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-13 17:31:21 +00:00
Timothy Wall cf54ca9551 fix issue 133
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1069 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-13 17:04:04 +00:00
Timothy Wall 9f1da1b562 sync libffi
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1068 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-10 16:36:02 +00:00
Timothy Wall f5a3dbf82b add OSX 10.6 SDK
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1067 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-10 16:34:00 +00:00
Daniel Doubrovkine 89f83e796a Collapsing accounts and groups, all of those are just windows accounts.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1066 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-07 19:27:20 +00:00
Daniel Doubrovkine 977a9e49c5 Extended Group to include FQN and domain.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1065 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-07 16:33:19 +00:00
Daniel Doubrovkine 7ee0a4b39f Added 3.2.5 javadoc, fixed links in index.html.
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1064 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2010-04-06 16:27:46 +00:00
1080 arquivos alterados com 406531 adições e 164135 exclusões
+8
Ver Arquivo
@@ -0,0 +1,8 @@
build
build.eclipse
build.number
.metadata
bin
jnalib/contrib/ntservice/dist
jnalib/contrib/platform/dist
Arquivo executável
+479
Ver Arquivo
@@ -0,0 +1,479 @@
Release 3.3.0
=============
Features
--------
* Facilitate `Memory` subclasses (jbellis).
* Allow multiple fields of the same type in Unions (Francis Barber).
* Add `platform.win32.Advapi32.AdjustTokenPrivileges`, `platform.win32.Advapi32.LookupPrivilegeName`, `platform.win32.Advapi32.LookupPrivilegeValue`, `platform.win32.Advapi32.ImpersonateSelf`.
* Add `platform.win32.Advapi32.DuplicateTokenEx`, `platform.win32.Advapi32.CreateProcessAsUser`, `platform.win32.Kernel32.GetExitCodeProcess`, `platform.win32.Kernel32.TerminateProcess`, `platform.win32.Kernel32.ReadFile`, `platform.win32.Kernel32.CreatePipe`, `platform.win32.Kernel32.SetHandleInformation` and related constants / structures in `platform.win32.WinBase` and `platform.win32.WinNT`. Please note that the `SECURITY_ATTRIBUTES` structure has been moved from `platform.win32.WinNT` to `platform.win32.WinBase`.
* Add `platform.win32.Kernel32.DeleteFile` and `platform.win32.Kernel32Util.deleteFile`.
* Add `platform.win32.Kernel32.GetFileAttributes` and `platform.win32.Kernel32Util.getFileAttributes`.
* Add `platform.win32.Kernel32.GetTickCount`.
* Add Win32 Service functions to `platform.win32.Advapi32`.
* Add `platform.win32.W32ServiceManager` and `W32Service`.
* Add Win32 Event Logging functions to `platform.win32.Advapi32` and `platform.win32.Advapi32Util.EventLogIterator`.
* `platform.win32.Advapi32Util.registryCreateKey` returns `true` if key was created, `false` if it already exists.
* Add `REG_BINARY`, `REG_EXPAND_SZ` and `REG_MULTI_SZ` support to `platform.win32.Advapi32Util` registry functions.
* Reduce JNI crossings in a number of native methods, moving object creation out into pure Java code.
Bug Fixes
---------
* Move all native functions into `com.sun.jna.Native`, to ensure that all dependent classes must be disposed before the `Native` class is unloaded. Note that this change is incompatible with all previous JNA native libraries.
* Fix `platform.win32.Kernel32.GetNativeSystemInfo` and `GetSystemInfo` AV on Win64.
* Fix several potential minor bugs as reported by TvT.
* Fix bug in Structure.StructureSet.toString (Blair Zajac), exposed by Tomcat ThreadLocal cleanup.
* Fix several bugs when using Structure(Pointer) ctor and array fields (Samuel Audet).
Release 3.2.7
=============
Features
--------
* Add native peer value accessors for Pointer
* The `jna.library.path` property is now re-evaluated whenever a native library is loaded. Previously this value was cached when the JNA classes loaded.
* `Native.loadLibrary` can now load `.drv` files.
* Refactor `com.sun.jna.platform.win32.WINBASE` into `WinDef`, `WinNT` and `BaseTSD`, matching Windows SDK headers.
* Refactor constants from `com.sun.jna.platform.win32.GDI32` into `WinGDI`, matching Windows SDK headers.
* Refactor constants from `com.sun.jna.platform.win32.User32` into `WinUser`, matching Windows SDK headers.
* Refactor `platform.win32.WinNT.LARGE_INTEGER` into a union.
* Add `platform.win32.ObjBase`, `com.sun.jna.platform.win32.Ole32.CoInitializeEx`, `CoUninitialize`, and `CoCreateInstance`.
* Add `platform.win32.Oleaut32.SysAllocString` and `SysFreeString`.
* Add `platform.win32.Secur32.ImpersonateSecurityContext` and `RevertSecurityContext`.
* Add `platform.win32.WinNT.WELL_KNOWN_SID_TYPE`, `SECURITY_MAX_SID_SIZE` and other related SID-related constants.
* Add `platform.win32.Advapi32.CreateWellKnownSid` and `IsWellKnownSid` and `com.sun.jna.platform.win32.Advapi32Util.isWellKnownSid`.
* Add `platform.win32.Kernel32.GetVersion`, `GetVersionEx`, `GetSystemInfo`, `GetNativeSystemInfo`, `GlobalMemoryStatusEx`, `GetLogicalDriveStrings` and `IsWow64Process`.
* Add `platform.win32.Kernel32Util.getLogicalDriveStrings`.
* Add `platform.win32.User32.GetSystemMetrics`.
* Add `platform.win32.BaseTSD.DWORD_PTR`.
* Add `platform.win32.WinBase.SYSTEM_INFO` and `MEMORYSTATUSEX`.
* Add `platform.win32.WinNT.OSVERSIONINFOEX`, `VER` constants.
* Add `platform.win32.WinDef.ULONGLONG` and `DWORDLONG`.
* Add `platform.win32.Shell32.SHGetDesktopFolder` (prep work for Com4JNA).
* Add `platform.win32.Winspool.GetPrinterInfo`.
* Add `platform.win32.WinspoolUtil.getPrinterInfo1`.
* Add `platform.win32.GDI32.GetDeviceCaps`.
* Add `platform.win32.GDI32.GetDIBits`.
Bug Fixes
---------
* Fix `ClassCastException` in `Structure.equals` (issue 152).
* Fix bug initializing a structure object from existing memory when the structure has initialized fields (issue 133).
* Fix NPE reading an array of string from a pointer when an element of the array is `NULL` (issue 151).
* Avoid calling `UnregisterNatives` in native code (issue 154).
* Compare unpacked library path against canonical (long) filename (issue 156).
* Fix `read()` of uninitialized memory in `platform.win32.Advapi32Util.getTokenGroups` and `getTokenAccount`.
* Fix `com.sun.jna.platform.win32.Secur32.QuerySecurityContextToken` to take a `CtxtHandle` instead of `PSecHandle`.
* Fix definition of BITMAPINFO (platform/win32).
Release 3.2.5
=============
Features
--------
* Split code in examples.jar into a contrib platform.jar package and individual packages for demos.
* Fix Eclipse build and added Eclipse projects for all contrib samples, import projects from jnalib and contrib.
* Ensure Structure fields correctly ordered when inherited.
* Use explicit Structure field whenever provided, regardless of whether the VM requires it.
* Add Win32 mappings for two dozen functions from Kernel32.dll, Advapi32.dll, Netapi32.dll, Secur32.dll, NtDll.dll, Ole32.dll, Shell32.dll and Crypt32.dll to com.sun.jna.platform.win32.
* Port parts of WinError.h, WinNT.h, LMAccess.h, LMCons.h, LMErr.h, LMJoin.h, NTStatus.h, ShlObj.h, WinDef.h, ShellApi.h, Wdm.h, WinReg.h, WinCrypt.h, Sspi.h, Guid.h, NtSecApi.h and DsGetDc.h.
* Add Win32 simplified utility interfaces Kernel32Util, Advapi32Util, Netapi32Util, Crypt32Util, NtDllUtil, Shell32Util, Ole32Util and Secur32Util to com.sun.jna.platform.win32.
* Support unicode paths in W32FileUtils.
* Fix exception during dispose in W32FileMonitor.
Bug Fixes
---------
* Provide String.replace for 1.4 compatibility.
* Avoid allocating memory when Structure is provided a pointer in the ctor.
* Ensure proper value returned in Pointer.getValue() for non-null, unchanged NIO Buffer values.
* Use 1.4-compatible URI generation (issue 149).
Release 3.2.4
=============
Features
--------
* Make Pointer ctor public.
* Provide access to Function objects for arbitrary Pointer values.
* Add linux/ia64 binaries (bpiwowar). See issue 134 patch.
Bug Fixes
---------
* Use a more robust method to decode a file-based URL (issue 135).
Release 3.2.3
=============
Features
--------
* Include version information in code in case package information lost.
Bug Fixes
---------
* Fix WindowUtils exception on mouse over TrayIcon.
* Fix bug toggling windows transparent/opaque (win32/OSX).
* Avoid overwriting unchanged Pointer values in arrays (function calls with Pointer[] and Structure.read).
* Ensure Structure fields marked `final` are never written.
* Fix bug preventing proper population Structure.ByReference fields on Structure read.
* Ensure double buffering is disabled in components added to a transparent window.
* Fix UnsatisfiedLinkError attempting to load system libraries under Web Start.
* Fix loading Web Start-provided libraries on OSX (libraries must have a .jnilib suffix under Web Start).
* Properly include sources in Maven zip file (Issue 129).
Release 3.2.2
=============
Features
--------
* Provide length-specified Pointer.getStringArray()
Bug Fixes
---------
* Fix crash with direct mapping if NULL struct* used (Issue 125).
* Fix case where null-valued Structure fields would get non-null values on write.
* Synch callback Structure/Structure[] arguments on callback return.
* Fix NPE when mapping an interface to the current process.
* Automatically load proper C library version from current process on Linux (avoids crashing bug on Ubuntu with libc-i686 packages active).
* Avoid scanning structure contents in Structure.toString if contents aren't actually used.
Release 3.2.1
==========
Features
--------
* Add HRESULT, LONG mapping to W32API (marc strapetz).
Bug Fixes
---------
* Fix definition of HWND_BROADCAST in W32API.
* Fix memory alignment checking (Issue 121).
* Fix Structure equals/hashCode implementation, based on current Java fields rather than strictly native memory contents. Avoid using equals/hashCode when avoiding recursive reads/writes.
Release 3.2.0
=============
Features
--------
* Handle String, Structure, Callback, Buffer, and primitive arrays in direct mappings. Handle NativeMapped and TypeMapper, with optimized paths for IntegerType and PointerType.
* Optionally throw errno/GetLastError as an exception. This is preferred to (and more efficient than) calling Native.getLastError().
* Unload/delete native library unpacked from jna.jar if Native class is garbage collected. Only install shutdown hook if using the system class loader.
* Auto-write contiguous Structure arrays when first element is written.
* Support NativeMapped[] as function arguments for interface-mapped libraries (Issue 90).
* Enable function lookup within current process on Windows.
Bug Fixes
---------
* Restrict recursive structure reads/writes by thread instead of globally. This avoids potentially missed reads/writes with concurrent access (Issue 120).
* Ensure Memory is not GC'd and freed if direct NIO buffers mapped to it are extant.
* Allow types derived from java.nio.Buffer as Structure fields.
Release 3.1.0
=============
Features
--------
* Add raw JNI mapping of static Java methods. Performance is about 10X that of traditional JNA interface mapping, although with less type conversion functionality.
* Add library option to allow passing/return of Java Objects.
* Allow handling of uncaught callback exceptions (Issue 63).
* Object oriented interface to X server (see contrib/x11)
* Make Memory class more accessible.
* Provide Structure ctor with Pointer argument (issue 102).
* Allow implicit library access to current process on linux (issue 98).
* Open all shared libraries with RTLD_GLOBAL, if applicable. This was the default behavior on OSX and changes the default behavior on linux.
* Allow NIO Buffer as Structure field (with limitations) (Issue 57)
* Add `size_t` size.
Bug Fixes
---------
* Run tests with libjsig.so, if available, which fixes some crashes when running tests on 64-bit platforms.
* Fix Issue 104.
* Fix Issue 94 (Java 1.6 update 10 regression).
* Fix Issue 51 (Java 1.6 update 10 regression).
* Fix Issue 95.
* Fix Issue 101.
* Fix Issue 111, memory leak with String-returning Callback.
* Fix missing storage of union type information (affects usage of struct/union by value as argument and return type).
* Remove non-functional Structure ctors requiring explicit size.
Release 3.0.9
=============
Bug Fixes
---------
* Fix issue 93 by only manually searching jna.library.path, then falling back to passing the mapped library name to dlopen/LoadLibrary. This fixes an issue in JRUBY where the incorrect libc.so.6 was being loaded.
Release 3.0.8
==========
Features
--------
* Auto-map Pointer[]/String[]/WString[] return values.
* Provide utility functions to convert String to primitive array.
* Add jna.library.boot.path property to define the directory that the native stub library is loaded from
Release 3.0.7
==========
Features
--------
* Improve Win32 loading of libraries with dependencies.
Bug Fixes
---------
* Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
Release 3.0.6
=============
Features
--------
* Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
* Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
* Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
* Add convenience methods to set active Union field and value simultaneously (xylo).
* Augment Union read/writeField to set the active field.
* Allow Structure auto-synch across native calls to be disabled.
* Win64 support.
Bug Fixes
---------
* Avoid overwriting unchanged Structure fields of type Pointer.
* Avoid more content dragging on OSX or warn if it's too late.
* Fix UnsatisfiedLinkError using transparent window on Win2K.
* Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
* Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
* Ensure structure memory is allocated in Structure.read/writeField.
Release 3.0.5
=============
Features
--------
* Allow explicit declaration of field order for VMs which have an unpredictable field order.
* Check for w32 libraries with a "lib" prefix in addition to normal lookup.
* Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
* Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
* Look up libraries using web start library path, if appropriate (Corey Puffalt).
* Use constants to return integer boolean values.
Bug Fixes
---------
* Properly track cursor on alpha-masked windows.
* Avoid searching /lib or /usr/lib on 64-bit Linux.
* Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
* Avoid transparent window events always dragging window bug on OSX.
* Fix division by zero error calculating structure size on OSX/ppc.
* Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
* Fix NPE reading back into StringArray.
Release 3.0.4
=============
Features
--------
* Automatically write contents of Structure.ByReference fields on Structure.write().
* Use the actual parameter type in Function invocations if no parameter type information is available (whether method is missing or untyped varargs).
* Augmented X11 library mappings (xylo).
* Support read/write of NativeMapped arrays within Structure (notably NativeLong).
Bug Fixes
---------
* Fix library load error when /usr/lib32 and /usr/lib both exist (linux) (Marek Slama).
* Avoid incorrect matches against libraries named with the same prefix (e.g. libc-client.so vs libc.so) (xylo).
* Properly handle arrays of NativeMapped (e.g. NativeLong) as a Structure field (stefan endrullis).
* Ensure structure size calculated prior to setting union active type.
* XID is 64-bits on 64-bit X clients (xylo).
* Ensure proper arch name is used on Debian (amd64 instead of x86_64).
Release 3.0.3
=============
Features
--------
* Enable build/run using IBM's J9 VM (leonardo).
* Make StdCallFunctionMapper attempt a leading underscore if the simpler mapping doesn't work.
* Allow Structure.read to overwrite final fields (may not work on some 1.4 VMs).
Bug Fixes
---------
* Fix NPE when passing an array of Structure.ByReference.
* Compare entire linux library version when finding a match.
* Don't pass struct by value unless the method signature declares it.
* Restrict custom first element structure alignment to OSX/ppc.
* Improve performance and reduce memory footprint for window masks. Optimize polygon-based masks on w32. Use XFillRectangles on X11.
* Fix linkage settings on sunos-amd64 to avoid relocation errors.
* Fix callback allocation code on w32, solaris, freebsd, darwin (libffi was misconfigured).
* Fix bug when NativeMapped fields are used in a Structure.ByValue instance.
* Fix NPE calling Structure.read() before memory is initialized.
* Fix NPE calling Structure.read/write with uninitialized NativeMapped fields.
Release 3.0.2
=============
Features
--------
* Attempt to force unload of jnidispatch library prior to deleting it (w32).
* Added amd64 targets for OSX, FreeBSD, and Solaris.
Bug Fixes
---------
* Reduce space allocated for invocation arguments.
* Fix NPE when NativeMapped type is used in a Structure.
* Fix some X11 type mappings for 64-bit.
* Fix OSX Leopard/JRE1.5+ window transparency.
* Fix window alpha compositing on X11.
* Fix loading of libraries with unicode names on OSX.
Release 3.0.1
=============
Features
--------
* Improve transparent window drawing performance on w32
* Use closure allocation from libffi
Bug Fixes
---------
* Ensure nested structure arrays initialized with Structure.toArray use the appropriate native memory.
* Ensure structure size is calculated prior to converting to array
* Avoid creating new windows when setting a window mask
* Fix bug in Pointer.setChar.
Release 3.0
===========
Features
--------
* More supported platforms, via GCC's libffi (wmeissner)
* Support struct by value as parameter and return value (duncan)
* Support struct by reference within structures
* Provide access to native peer for java.awt.Component
* Provide access to native peer on OS X.
* Support MINGW32 builds (fullung)
* Allow per-field Structure read/write by field name
* Avoid writing Structure fields marked 'volatile'
* Read and wrap function pointers in Structure fields when read with a Java proxy to allow easy Java-side invocation (Ken Larson)
* Support array-backed Buffers as arguments (wmeissner)
* Auto-conversion of custom types (wmeissner)
* Allow pointer type-safety
* Optional VM crash protection, via Native.setProtected(boolean)
* Auto-convert WString[]
* Provide library synchronization wrapper similar to Collections.synchronizedX
* Support lookup of OSX framework libraries by name
* Explicit access to shared library global data
* Invocation interception to facilitate translation of C preprocessor macros and inline functions
* Provide utility to determine Web Start native library cache location; auto-include this path if jnidispatch is included as a <nativelib> (robertengels)
* Provide access to aligned memory
* Versioning information embedded in jna.jar and native library
Bug Fixes
---------
* Avoid attempts to free native library if it failed to load (wmeissner)
* Explicitly check method signatures for varargs instead of heuristically guessing (wmeissner)
* Disallow declaring Pointer-derived fields in Structures (Function, Memory)
* Ensure Object.toString/hashCode/equals methods are intercepted on proxyied interfaces
* Update X11 library for 64-bit use (wmeissner)
* Properly map arrays of char*/wchar_t* under w32
* Allow Pointer[] as a Structure field and Function argument
* Fix some misleading Structure error messages
* Properly preserve/return GetLastError/errno after native calls
* Allocate executable memory on w32 to avoid errors with hardware-enforced data execution protection (DEP)
* Fix VM crash on w32 stdcall callbacks
* Use long offsets and sizes rather than ints (64-bit safe)
* Properly clean up references and release closure memory on JNI_Unload
* Use simpler AWT/JAWT library loading workaround
* Avoid changing array references within a Structure on read
Release 2.5
===========
Features
--------
* Unions
* Optimized shaped windows (chris deckers & olivier chafik); instantiation time improved by about 2-3 orders of magnitude for large, mostly contiguous shapes
* Provide type mapping in callback arguments/results
* Provide access to ByteBuffer direct address as a Pointer
* Provide customization of native string encoding with jna.encoding system property
Bug Fixes
---------
* Properly handle VMs with reversed Structure member storage
* Avoid making window undecorated when clearing window mask on X11
* Fix structure alignment bug on OSX/PPC when first element is > 4 bytes in size
* Clearing OSX window mask by setting to MASK_NONE now works properly
* Avoid index exceptions if native buffers are not NUL-terminated on string conversions
* Write initialized Structure[] argument memory prior to function calls
* Fix IllegalArgumentException reading WString into a Structure
* Clear memory when allocating a structure block (fixes VM crash)
* Remove versioned JAWT dependency on OSX, allowing use on 10.3/JRE1.4.
Release 2.4
===========
Features
--------
* Explicitly support unaligned structures
* Auto-reallocate structure arrays
* Automatic handling of w32 UNICODE/ASCII variants
* Automatic mapping of decorated w32 stdcall function names
* Customizable, automatic type conversion of arguments and results (wmeissner)
* Support char*[] arguments as Java String[]
* Structure supports Callback members (wmeissner)
* getByteBuffer from Pointer/Memory (wmeissner)
* Allow GC of native libraries
* Facilitate use from non-Java contexts (JRuby et al.) (wmeissner)
* Improve library path searching (wmeissner)
* Handle Structure[] arguments
* Handle native long arguments and return values
* Handle direct and array-based ByteBuffer arguments (wmeissner)
* Change default w32 build to use GCC (it's free, yo)
Bug Fixes
---------
* Structure.toArray failed to initialize members
* Disallow explicit free of Structure/Memory
* Ensure native libraries are only loaded once until released
* Properly handle NULL when the return value is a Structure
* Proper conversion to wchar_t on linux
* Copy full length of Java strings to C strings instead of stopping when a NUL character is encountered
Ver Arquivo
+73
Ver Arquivo
@@ -0,0 +1,73 @@
![Java Native Access - JNA](https://github.com/twall/jna/raw/master/www/images/jnalogo.jpg "Java Native Access - JNA")
Java Native Access (JNA)
========================
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.
The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.
While some attention is paid to performance, correctness and ease of use take priority.
JNA includes a platform library with many native functions already mapped as well as a set of utility interfaces that simplify native access.
Features
========
* Automatic mapping from Java to native functions, with simple mappings for all primitive data types
* Runs on most platforms which support Java
* Automatic conversion between C and Java strings, with customizable encoding/decoding
* Structure and Union arguments/return values, by reference and by value
* Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct
* Auto-generated Java proxies for native function pointers
* By-reference (pointer-to-type) arguments
* Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer
* Nested structures and arrays
* Wide (wchar_t-based) strings
* Native long support (32- or 64-bit as appropriate)
* Demo applications
* Supported on 1.4 or later JVMs (earlier VMs may work with stubbed NIO support)
* Customizable marshalling/unmarshalling (argument and return value conversions)
* Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros
* Support for automatic Windows ASCII/UNICODE function mappings
* Varargs support
* Type-safety for native pointers
* VM crash protection (optional)
* Optimized direct mapping for high-performance applications.
Community
=========
All questions should be posted ot the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
Using the Library
=================
* [Getting Started](jna/tree/master/www/GettingStarted.md)
* [Mapping between Java and Native](jna/tree/master/www/Mappings.md)
* [Using Pointers and Arrays](jna/tree/master/www/PointersAndArrays.md)
* [Using Structures and Unions](jna/tree/master/www/StructuresAndUnions.md)
* [Using By-Reference Arguments](jna/tree/master/www/ByRefArguments.md)
* [Customization](jna/tree/master/www/CustomMappings.md)
* [Callbacks/Closures](jna/tree/master/www/CallbacksAndClosures.md)
* [Dynamically Typed Languages (JRuby/Jython)](jna/tree/master/www/DynamicallyTypedLanguages.md)
* [Platform Library](jna/tree/master/www/PlatformLibrary.md)
* [Direct Method Mapping](jna/tree/master/www/DirectMapping.md)
* [Frequently Asked Questions (FAQ)](jna/tree/master/www/FrequentlyAskedQuestions.md)
Contributing
============
You're encouraged to contribute to JNA. Fork the code from [github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
If you are interested in paid support, feel free to say so on the [jna-users mailing list](http://groups.google.com/group/jna-users). Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development.
License
=======
This library is provided under the LGPL, version 2.1 or later.
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
+22
Ver Arquivo
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<project name="jna" basedir="." default="default">
<target name="recurse">
<ant dir="jnalib" target="${ant.target}" />
</target>
<target name="default">
<antcall target="recurse">
<param name="ant.target" value="default" />
</antcall>
</target>
<target name="clean">
<antcall target="recurse">
<param name="ant.target" value="clean" />
</antcall>
</target>
<target name="test">
<antcall target="recurse">
<param name="ant.target" value="test" />
</antcall>
</target>
</project>
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jna</name>
<name>jnalib</name>
<comment></comment>
<projects>
</projects>
+5 -5
Ver Arquivo
@@ -100,6 +100,11 @@
# DONE
* 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)
* check Structure "final" fields; should never write back to native memory
* OSX ObjC access (see rococoa)
* do Structure.write for any callback args
@@ -259,11 +264,6 @@ int findNativeWindow(Window w);
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
+63 -33
Ver Arquivo
@@ -22,7 +22,8 @@
<property name="dynlink.native" value="false"/>
<property name="native" location="native"/>
<property name="src" location="src"/>
<property name="contrib" location="contrib/src"/>
<property name="platform.src" location="contrib/platform/src"/>
<property name="contrib" location="contrib"/>
<property name="dist" location="dist"/>
<property name="test.src" location="test"/>
<property name="doc" location="doc"/>
@@ -30,21 +31,21 @@
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
<property name="vendor" value="JNA Development Team"/>
<property name="copyright"
value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
value="Copyright &amp;copy; 2007-2010 Timothy Wall. All Rights Reserved."/>
<buildnumber/>
<!-- JNA library release version -->
<property name="jna.major" value="3"/>
<property name="jna.minor" value="2"/>
<property name="jna.revision" value="5"/>
<property name="jna.minor" value="3"/>
<property name="jna.revision" value="0"/>
<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.major" value="3"/>
<property name="jni.minor" value="2"/>
<property name="jni.revision" value="1"/>
<property name="jni.minor" value="3"/>
<property name="jni.revision" value="0"/>
<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="jni.md5" value="4c69bcf40b30785215211b5a5dad211e"/>
<property name="spec.title" value="Java Native Access (JNA)"/>
<property name="spec.vendor" value="${vendor}"/>
<property name="spec.version" value="${jna.major}"/>
@@ -139,7 +140,10 @@
<condition property="jdk.home" value="${java.home}/..">
<available file="${java.home}/../include"/>
</condition>
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
<condition property="jdk.home" value="/System/Library/Frameworks/JavaVM.framework/Home">
<available file="/System/Library/Frameworks/JavaVM.framework/Headers"/>
</condition>
<fail unless="jdk.home" message="Can't find JNI headers (java.home=${java.home})"/>
<condition property="libjsig"
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
@@ -187,6 +191,7 @@
source="${compatibility}"
target="${compatibility}"
destdir="${classes}"
includeantruntime="false"
deprecation="on" debug="${debug}">
<src path="${src}"/>
</javac>
@@ -231,11 +236,19 @@
<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="contrib-jars" depends="jar" description="Build contrib jars">
<subant target="jar">
<property name="file.reference.jna.build" location="${build}"/>
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
<property name="libs.junit.classpath" location="lib/junit.jar"/>
<!-- platform.jar needs to be built first -->
<fileset dir="${contrib}" includes="platform/build.xml" />
<fileset dir="${contrib}" includes="*/build.xml" excludes="platform/build.xml"/>
</subant>
</target>
<target name="javah" depends="compile">
<javah classpath="${classes}" destdir="${build.native}" force="yes">
<class name="com.sun.jna.Function"/>
@@ -320,8 +333,8 @@
<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=.*"
replace="VERSION=${jni.version} ${comment}"
<replaceregexp match="^JNA_JNI_VERSION=.*"
replace="JNA_JNI_VERSION=${jni.version} ${comment}"
file="native/Makefile" byline="true"/>
<replaceregexp match="^CHECKSUM=.*"
replace="CHECKSUM=${jni.md5} ${comment}"
@@ -338,6 +351,10 @@
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
<isset property="SDKROOT"/>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
@@ -363,6 +380,7 @@
<os name="OpenBSD"/>
</or>
</condition>
<!-- Default make program -->
<property name="make" value="make"/>
@@ -377,7 +395,7 @@
<arg value="${make.SDKROOT}"/>
<arg value="${make.ARCH}"/>
<arg value="${make.PATH}"/>
<arg value="VERSION=${jni.version}"/>
<arg value="JNA_JNI_VERSION=${jni.version}"/>
<arg value="CHECKSUM=${jni.md5}"/>
</exec>
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
@@ -408,6 +426,7 @@
source="${test.compatibility}"
target="${test.compatibility}"
destdir="${test.classes}"
includeantruntime="false"
deprecation="on" debug="${debug}">
<src path="${test.src}"/>
</javac>
@@ -431,7 +450,7 @@
<!-- 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,compile-tests"
<target name="test" depends="jar,contrib-jars,compile-tests"
description="Run all unit tests">
<property name="test.fork" value="yes"/>
<property name="reports.junit" location="${reports}/junit"/>
@@ -478,9 +497,6 @@
</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"/>
@@ -488,6 +504,9 @@
<report todir="${reports.junit}"/>
</junitreport>
<echo>View test report in file://${reports.junit}/index.html</echo>
<subant target="test">
<fileset dir="${contrib}" includes="platform/build.xml"/>
</subant>
<fail if="testfailure" unless="clover">One or more tests failed</fail>
</target>
@@ -513,6 +532,14 @@
</target>
<target name="javadoc" depends="-setup">
<path id="javadoc.src.path">
<path refid="src.path"/>
<pathelement location="${platform.src}"/>
</path>
<path id="javadoc.compile.path">
<path refid="compile.path"/>
<pathelement location="${classes}"/>
</path>
<property name="header"
value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
<property name="footer"
@@ -521,10 +548,10 @@
<mkdir dir="${javadoc}"/>
<javadoc package="true"
windowtitle="JNA API"
sourcepathref="src.path"
classpathref="compile.path"
sourcepathref="javadoc.src.path"
classpathref="javadoc.compile.path"
maxmemory="256m"
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"
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32"
overview="${src}/com/sun/jna/overview.html"
destdir="${javadoc}">
<!-- stylesheetfile="${stylesheet}" -->
@@ -538,18 +565,21 @@
<include name="com/sun/jna/**/*"/>
</patternset>
</packageset>
<packageset dir="${platform.src}" defaultexcludes="yes">
<patternset>
<include name="com/sun/jna/platform/**/*"/>
</patternset>
</packageset>
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
<group title="Platform Specific" packages="com.sun.jna.platform"/>
<group title="Platform Utilities" packages="com.sun.jna.platform,com.sun.jna.platform.dnd"/>
<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,javadoc"
<target name="dist" depends="jar,contrib-jars,compile-tests,native,javadoc"
description="Build distribution files">
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
<manifest>
@@ -619,14 +649,13 @@
</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,LICENSE.txt"/>
<zipfileset dir="." includes="build.xml,pom.xml,LICENSE.txt"/>
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
<zipfileset dir="${native}" excludes="libffi,libffi/**/*,build,build/**/*" prefix="native"/>
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
</zip>
<!-- Full sources required to build and test everything -->
@@ -640,6 +669,7 @@
<!-- Sources package as required by maven -->
<zip zipfile="${dist}/src-mvn.zip">
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
</zip>
</target>
@@ -652,9 +682,9 @@
<fileset dir="${javadoc}"/>
<fileset dir="." includes="*~,**/*~"/>
</delete>
<subant target="clean">
<fileset dir="${contrib}" includes="*/build.xml"/>
</subant>
<subant target="clean">
<fileset dir="${contrib}" includes="*/build.xml"/>
</subant>
</target>
</project>
@@ -2,7 +2,7 @@
<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="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -4,27 +4,24 @@
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<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" />
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-alphamask.jar"/>
<property name="file.reference.jna.build" location="../../build"/>
<property name="file.reference.jna.jar" location="../../build/jna.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>
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
@@ -32,17 +29,18 @@
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
@@ -52,7 +50,7 @@
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
@@ -61,7 +59,7 @@
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
@@ -69,7 +67,7 @@
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
@@ -64,14 +64,16 @@ 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.platform.win32.WinGDI;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
import com.sun.jna.platform.win32.WinUser.POINT;
import com.sun.jna.platform.win32.WinUser.SIZE;
import com.sun.jna.ptr.PointerByReference;
// TODO: put this into a reasonable API; right now this is pretty much
@@ -127,7 +129,7 @@ public class AlphaMaskDemo implements Runnable {
private com.sun.jna.Memory buffer;
private int[] pixels;
private void updateX11(boolean a, boolean i) {
private void updateX11(boolean a, boolean i) {
X11 x11 = X11.INSTANCE;
X11.Window win = X11.Window.None;
Display dpy = x11.XOpenDisplay(null);
@@ -230,9 +232,9 @@ public class AlphaMaskDemo implements Runnable {
if (!alphaWindow.isDisplayable()) {
alphaWindow.pack();
hWnd = getHwnd(alphaWindow);
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
flags |= User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
flags |= WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
Window parent = alphaWindow.getOwner();
Point where = parent.getLocationOnScreen();
where.translate(parent.getWidth(), 0);
@@ -260,11 +262,11 @@ public class AlphaMaskDemo implements Runnable {
bmi.bmiHeader.biHeight = h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
bmi.bmiHeader.biSizeImage = w * h * 4;
PointerByReference ppbits = new PointerByReference();
hBitmap = gdi.CreateDIBSection(memDC, bmi, GDI32.DIB_RGB_COLORS,
hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
ppbits, null, 0);
oldBitmap = gdi.SelectObject(memDC, hBitmap);
Pointer pbits = ppbits.getValue();
@@ -293,9 +295,9 @@ public class AlphaMaskDemo implements Runnable {
POINT srcLoc = new POINT();
BLENDFUNCTION blend = new BLENDFUNCTION();
blend.SourceConstantAlpha = (byte)(alpha * 255);
blend.AlphaFormat = User32.AC_SRC_ALPHA;
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
user.UpdateLayeredWindow(hWnd, screenDC, loc, size, memDC, srcLoc,
0, blend, User32.ULW_ALPHA);
0, blend, WinUser.ULW_ALPHA);
}
finally {
user.ReleaseDC(null, screenDC);
@@ -309,9 +311,9 @@ public class AlphaMaskDemo implements Runnable {
else if (a) {
BLENDFUNCTION blend = new BLENDFUNCTION();
blend.SourceConstantAlpha = (byte)(alpha * 255);
blend.AlphaFormat = User32.AC_SRC_ALPHA;
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
user.UpdateLayeredWindow(hWnd, null, null, null, null, null,
0, blend, User32.ULW_ALPHA);
0, blend, WinUser.ULW_ALPHA);
}
if (!alphaWindow.isVisible()) {
@@ -386,8 +388,9 @@ public class AlphaMaskDemo implements Runnable {
JPanel p = new JPanel(new BorderLayout(8, 8));
p.setBorder(new EmptyBorder(8, 8, 8, 8));
p.setTransferHandler(new TransferHandler() {
private static final long serialVersionUID = 1L;
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
List list = Arrays.asList(transferFlavors);
List<DataFlavor> list = Arrays.asList(transferFlavors);
if (list.contains(URL_FLAVOR)
|| list.contains(URI_LIST_FLAVOR)
|| list.contains(DataFlavor.imageFlavor)
@@ -424,8 +427,8 @@ public class AlphaMaskDemo implements Runnable {
return true;
}
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
List files = (List)t.getTransferData(DataFlavor.javaFileListFlavor);
File f = (File)files.get(0);
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
File f = files.get(0);
URL url = new URL("file://" + f.toURI().toURL().getPath());
Image image = Toolkit.getDefaultToolkit().getImage(url);
setImage(image);
@@ -145,9 +145,10 @@ public class AlphaMaskDemo2 implements Runnable {
JPanel p = new JPanel(new BorderLayout(8, 8));
p.setBorder(new EmptyBorder(8, 8, 8, 8));
p.setTransferHandler(new TransferHandler() {
public boolean canImport(JComponent comp,
private static final long serialVersionUID = 1L;
public boolean canImport(JComponent comp,
DataFlavor[] transferFlavors) {
List list = Arrays.asList(transferFlavors);
List<DataFlavor> list = Arrays.asList(transferFlavors);
if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR)
|| list.contains(DataFlavor.imageFlavor)
|| list.contains(DataFlavor.javaFileListFlavor)) {
@@ -185,9 +186,8 @@ public class AlphaMaskDemo2 implements Runnable {
return true;
}
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
List files = (List)t
.getTransferData(DataFlavor.javaFileListFlavor);
File f = (File)files.get(0);
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
File f = files.get(0);
URL url = new URL("file://"
+ f.toURI().toURL().getPath());
Image image = Toolkit.getDefaultToolkit().getImage(url);

Antes

Largura:  |  Altura:  |  Tamanho: 18 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 18 KiB

@@ -4,26 +4,24 @@
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="jna-dist" location="../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-balloonmanager.jar"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
<property name="file.reference.jna.build" location="../../build"/>
<property name="file.reference.jna.jar" location="../../build/jna.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>
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
@@ -31,17 +29,18 @@
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
@@ -51,7 +50,7 @@
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
@@ -60,7 +59,7 @@
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
@@ -68,7 +67,7 @@
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
@@ -57,6 +57,7 @@ public class BalloonManager {
}
private static class DropShadow extends JWindow {
private static final long serialVersionUID = 1L;
private static final float SHADOW_ALPHA = .25f;
private static final float YSCALE = .80f;
private static final double ANGLE = 2*Math.PI/24;
@@ -149,6 +150,7 @@ public class BalloonManager {
}
private static final class BubbleWindow extends JWindow {
private static final long serialVersionUID = 1L;
private static final int Y_OFFSET = 50;
private static final int ARC = 25;
@@ -4,26 +4,24 @@
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="jna-dist" location="../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-balloontips.jar"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-balloontips.jar"/>
<property name="file.reference.jna.build" location="../../build"/>
<property name="file.reference.jna.jar" location="../../build/jna.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>
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
@@ -31,17 +29,18 @@
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
@@ -51,7 +50,7 @@
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
@@ -60,7 +59,7 @@
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
@@ -68,7 +67,7 @@
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
@@ -62,6 +62,7 @@ public class BalloonTipManager {
* The BalloonTip class defines the look of the BalloonTip object.
*/
private static final class BalloonTip extends JWindow {
private static final long serialVersionUID = 1L;
private static final Integer HMARGIN = 10;
private static final Integer VMARGIN = 6;
private static final Integer VSPACER = 4;
@@ -475,7 +476,6 @@ public class BalloonTipManager {
/*
* This class handles events spawned from moving the component.
*/
@SuppressWarnings("serial")
final class ComponentEar extends ComponentAdapter {
/*
* (non-Javadoc)
@@ -490,7 +490,6 @@ public class BalloonTipManager {
/*
* This class handles events spawned when a mouse button is pressed.
*/
@SuppressWarnings("serial")
final class MouseEar extends MouseAdapter {
/*
* (non-Javadoc)
@@ -505,7 +504,6 @@ public class BalloonTipManager {
/*
* This class handles events spawned when the component loses focus.
*/
@SuppressWarnings("serial")
final class FocusEar extends FocusAdapter {
/*
* (non-Javadoc)
@@ -2,7 +2,7 @@
<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="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -4,26 +4,24 @@
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../../dist"/>
<property name="jna-dist" location="../../dist"/>
<property name="buildClasses" location="${build}/classes"/>
<property name="buildJar" location="${build}/demo-dnd.jar"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-dnd.jar"/>
<property name="file.reference.jna.build" location="../../build"/>
<property name="file.reference.jna.jar" location="../../build/jna.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>
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${buildClasses}" />
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
@@ -31,17 +29,18 @@
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${buildClasses}"/>
<delete file="${buildJar}"/>
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${buildClasses}"/>
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
@@ -51,7 +50,7 @@
</javac>
<!-- Copy all non-java files to classes. -->
<copy todir="${buildClasses}/com">
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
@@ -60,7 +59,7 @@
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="../../../build/classes/com">
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
@@ -68,7 +67,7 @@
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${buildJar}" basedir="${buildClasses}">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
@@ -63,7 +63,8 @@ public class GhostedDragImageDemo {
}
public static class DragLabel extends JLabel {
private boolean dragging;
private static final long serialVersionUID = 1L;
private boolean dragging;
public DragLabel(Icon icon) {
super(icon);
new DragHandler(this, DnDConstants.ACTION_COPY_OR_MOVE) {

Antes

Largura:  |  Altura:  |  Tamanho: 28 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 28 KiB

@@ -3,8 +3,8 @@
<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 combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -16,8 +16,8 @@ debug.test.classpath=\
dist.dir=dist
dist.jar=${dist.dir}/contrib-ntservice.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=../../../build/jna.jar
libs.junit.classpath=../../../lib/junit.jar
file.reference.jna.jar=../../build/jna.jar
libs.junit.classpath=../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar};
@@ -18,49 +18,8 @@ import com.sun.jna.win32.*;
* @author TB
*/
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
/*
BOOL WINAPI LookupAccountName(
LPCTSTR lpSystemName,
LPCTSTR lpAccountName,
PSID Sid,
LPDWORD cbSid,
LPTSTR ReferencedDomainName,
LPDWORD cchReferencedDomainName,
PSID_NAME_USE peUse
);*/
public boolean LookupAccountName(String lpSystemName, String lpAccountName,
byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
IntByReference cchReferencedDomainName, PointerByReference peUse);
/*
BOOL WINAPI LookupAccountSid(
LPCTSTR lpSystemName,
PSID lpSid,
LPTSTR lpName,
LPDWORD cchName,
LPTSTR lpReferencedDomainName,
LPDWORD cchReferencedDomainName,
PSID_NAME_USE peUse
);*/
public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
IntByReference cchReferencedDomainName, PointerByReference peUse);
/*
BOOL ConvertSidToStringSid(
PSID Sid,
LPTSTR* StringSid
);*/
public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
/*
BOOL WINAPI ConvertStringSidToSid(
LPCTSTR StringSid,
PSID* Sid
);*/
public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
W32APIOptions.UNICODE_OPTIONS);
/*
SC_HANDLE WINAPI OpenSCManager(
@@ -163,88 +122,6 @@ BOOL WINAPI ChangeServiceConfig2(
);*/
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
/*
LONG WINAPI RegOpenKeyEx(
HKEY hKey,
LPCTSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
);*/
public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
/*
LONG WINAPI RegQueryValueEx(
HKEY hKey,
LPCTSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);*/
public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
/*
LONG WINAPI RegCloseKey(
HKEY hKey
);*/
public int RegCloseKey(int hKey);
/*
LONG WINAPI RegDeleteValue(
HKEY hKey,
LPCTSTR lpValueName
);*/
public int RegDeleteValue(int hKey, String lpValueName);
/*
LONG WINAPI RegSetValueEx(
HKEY hKey,
LPCTSTR lpValueName,
DWORD Reserved,
DWORD dwType,
const BYTE* lpData,
DWORD cbData
);*/
public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
/*
LONG WINAPI RegCreateKeyEx(
HKEY hKey,
LPCTSTR lpSubKey,
DWORD Reserved,
LPTSTR lpClass,
DWORD dwOptions,
REGSAM samDesired,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
PHKEY phkResult,
LPDWORD lpdwDisposition
);*/
public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
IntByReference lpdwDisposition);
/*
LONG WINAPI RegDeleteKey(
HKEY hKey,
LPCTSTR lpSubKey
);*/
public int RegDeleteKey(int hKey, String name);
/*
LONG WINAPI RegEnumKeyEx(
HKEY hKey,
DWORD dwIndex,
LPTSTR lpName,
LPDWORD lpcName,
LPDWORD lpReserved,
LPTSTR lpClass,
LPDWORD lpcClass,
PFILETIME lpftLastWriteTime
);*/
public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
/*
LONG WINAPI RegEnumValue(
HKEY hKey,
@@ -0,0 +1,36 @@
/*
* WINNT.java
*
* Created on 8. August 2007, 13:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINNT {
public final static int DELETE = 0x00010000;
public final static int READ_CONTROL = 0x00020000;
public final static int WRITE_DAC = 0x00040000;
public final static int WRITE_OWNER = 0x00080000;
public final static int SYNCHRONIZE = 0x00100000;
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
public final static int GENERIC_EXECUTE = 0x20000000;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
}
@@ -9,11 +9,6 @@
package jnacontrib.jna;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
/**
*
@@ -180,7 +180,6 @@ public abstract class Win32Service {
*/
public void init() {
Advapi32 advapi32;
Advapi32.SERVICE_TABLE_ENTRY[] entries = new Advapi32.SERVICE_TABLE_ENTRY[2];
Advapi32.SERVICE_TABLE_ENTRY entry;
serviceMain = new ServiceMain();
@@ -0,0 +1,2 @@
# placeholder
@@ -3,8 +3,8 @@
<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 combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -63,11 +63,20 @@
nbproject/build-impl.xml file.
-->
<condition property="tests.platform" value="win32">
<condition property="tests.platform" value="test-win32">
<os family="windows"/>
</condition>
<target name="test" description="Run unit tests." if="tests.platform">
<antcall target="test-win32" />
<antcall target="${tests.platform}" />
</target>
<target name="test-report">
<junitreport todir="${build.test.results.dir}">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${build.test.results.dir}"/>
</junitreport>
<echo message="View test report in file://${build.test.results.dir}/index.html" />
</target>
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
</project>
@@ -16,8 +16,8 @@ debug.test.classpath=\
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
file.reference.jna.jar=../../build/jna.jar
libs.junit.classpath=../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar};
@@ -20,6 +20,7 @@ import com.sun.jna.Platform;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.unix.X11.Display;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinUser;
/** Provide access to the local keyboard state. Note that this is meaningless
* on a headless system and some VNC setups.
@@ -71,30 +72,30 @@ public class KeyboardUtils {
}
if (code == KeyEvent.VK_SHIFT) {
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
return User32.VK_RSHIFT;
return WinUser.VK_RSHIFT;
}
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
return User32.VK_LSHIFT;
return WinUser.VK_LSHIFT;
}
return User32.VK_SHIFT;
return WinUser.VK_SHIFT;
}
if (code == KeyEvent.VK_CONTROL) {
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
return User32.VK_RCONTROL;
return WinUser.VK_RCONTROL;
}
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
return User32.VK_LCONTROL;
return WinUser.VK_LCONTROL;
}
return User32.VK_CONTROL;
return WinUser.VK_CONTROL;
}
if (code == KeyEvent.VK_ALT) {
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
return User32.VK_RMENU;
return WinUser.VK_RMENU;
}
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
return User32.VK_LMENU;
return WinUser.VK_LMENU;
}
return User32.VK_MENU;
return WinUser.VK_MENU;
}
return 0;
}
@@ -44,7 +44,7 @@ public class RasterRangesUtils {
0x0008, 0x0004, 0x0002, 0x0001
};
private static final Comparator COMPARATOR = new Comparator() {
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
return ((Rectangle)o1).x - ((Rectangle)o2).x;
}
@@ -116,11 +116,11 @@ public class RasterRangesUtils {
* @return true if the output succeeded, false otherwise
*/
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
Set rects = new HashSet();
Set prevLine = Collections.EMPTY_SET;
Set<Rectangle> rects = new HashSet<Rectangle>();
Set<Rectangle> prevLine = Collections.EMPTY_SET;
int scanlineBytes = binaryBits.length / h;
for (int row = 0; row < h; row++) {
Set curLine = new TreeSet(COMPARATOR);
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
int rowOffsetBytes = row * scanlineBytes;
int startCol = -1;
// Look at each batch of 8 columns in this row
@@ -163,14 +163,14 @@ public class RasterRangesUtils {
// end of last region
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
}
Set unmerged = mergeRects(prevLine, curLine);
Set<Rectangle> 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();
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
Rectangle r = i.next();
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
return false;
}
@@ -189,10 +189,10 @@ 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;
Set<Rectangle> rects = new HashSet<Rectangle>();
Set<Rectangle> prevLine = Collections.EMPTY_SET;
for (int row = 0; row < h; row++) {
Set curLine = new TreeSet(COMPARATOR);
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
int idxOffset = row * w;
int startCol = -1;
@@ -213,14 +213,14 @@ public class RasterRangesUtils {
// end of last region of current row
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
}
Set unmerged = mergeRects(prevLine, curLine);
Set<Rectangle> 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();
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
Rectangle r = i.next();
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
return false;
}
@@ -228,11 +228,11 @@ public class RasterRangesUtils {
return true;
}
private static Set mergeRects(Set prev, Set current) {
Set unmerged = new HashSet(prev);
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current) {
Set<Rectangle> unmerged = new HashSet<Rectangle>(prev);
if (!prev.isEmpty() && !current.isEmpty()) {
Rectangle[] pr = (Rectangle[])prev.toArray(new Rectangle[prev.size()]);
Rectangle[] cr = (Rectangle[])current.toArray(new Rectangle[current.size()]);
Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]);
Rectangle[] cr = current.toArray(new Rectangle[current.size()]);
int ipr = 0;
int icr = 0;
while (ipr < pr.length && icr < cr.length) {
@@ -71,15 +71,17 @@ import com.sun.jna.platform.unix.X11.Xext;
import com.sun.jna.platform.unix.X11.Xrender.XRenderPictFormat;
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.HRGN;
import com.sun.jna.platform.win32.W32API.HWND;
import com.sun.jna.platform.win32.WinGDI;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.WinDef.HRGN;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
import com.sun.jna.platform.win32.WinUser.POINT;
import com.sun.jna.platform.win32.WinUser.SIZE;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -149,6 +151,7 @@ public class WindowUtils {
* </pre></code>
*/
private static class HeavyweightForcer extends Window {
private static final long serialVersionUID = 1L;
private final boolean packed;
public HeavyweightForcer(Window parent) {
@@ -174,6 +177,7 @@ public class WindowUtils {
* invoked whenever any part of the ancestor window is repainted.
*/
protected static class RepaintTrigger extends JComponent {
private static final long serialVersionUID = 1L;
protected class Listener
extends WindowAdapter
@@ -264,6 +268,7 @@ public class WindowUtils {
public static abstract class NativeWindowUtils {
protected abstract class TransparentContentPane
extends JPanel implements AWTEventListener {
private static final long serialVersionUID = 1L;
private boolean transparent;
public TransparentContentPane(Container oldContent) {
super(new BorderLayout());
@@ -639,27 +644,27 @@ public class WindowUtils {
public void run() {
HWND hWnd = getHWnd(w);
User32 user = User32.INSTANCE;
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
byte level = (byte)((int)(255 * alpha) & 0xFF);
if (usingUpdateLayeredWindow(w)) {
// If already using UpdateLayeredWindow, continue to
// do so
User32.BLENDFUNCTION blend = new User32.BLENDFUNCTION();
BLENDFUNCTION blend = new BLENDFUNCTION();
blend.SourceConstantAlpha = level;
blend.AlphaFormat = User32.AC_SRC_ALPHA;
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
user.UpdateLayeredWindow(hWnd, null, null, null, null,
null, 0, blend,
User32.ULW_ALPHA);
WinUser.ULW_ALPHA);
}
else if (alpha == 1f) {
flags &= ~User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
flags &= ~WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
}
else {
flags |= User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
flags |= WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
user.SetLayeredWindowAttributes(hWnd, 0, level,
User32.LWA_ALPHA);
WinUser.LWA_ALPHA);
}
setForceHeavyweightPopups(w, alpha != 1f);
storeAlpha(w, level);
@@ -672,6 +677,7 @@ public class WindowUtils {
* when the window is transparent.
*/
private class W32TransparentContentPane extends TransparentContentPane {
private static final long serialVersionUID = 1L;
private HDC memDC;
private HBITMAP hBitmap;
private Pointer pbits;
@@ -728,12 +734,12 @@ public class WindowUtils {
bmi.bmiHeader.biHeight = wh;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
bmi.bmiHeader.biSizeImage = ww * wh * 4;
PointerByReference ppbits = new PointerByReference();
hBitmap = gdi.CreateDIBSection(memDC, bmi,
GDI32.DIB_RGB_COLORS,
ppbits, null, 0);
WinGDI.DIB_RGB_COLORS,
ppbits, null, 0);
pbits = ppbits.getValue();
bitmapSize = new Dimension(ww, wh);
}
@@ -769,18 +775,17 @@ public class WindowUtils {
try {
// GetLayeredwindowAttributes supported WinXP and later
if (user.GetLayeredWindowAttributes(hWnd, null, bref, iref)
&& (iref.getValue() & User32.LWA_ALPHA) != 0) {
&& (iref.getValue() & WinUser.LWA_ALPHA) != 0) {
level = bref.getValue();
}
}
catch(UnsatisfiedLinkError e) {
}
blend.SourceConstantAlpha = level;
blend.AlphaFormat = User32.AC_SRC_ALPHA;
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
user.UpdateLayeredWindow(hWnd, screenDC, winLoc, winSize, memDC,
srcLoc, 0, blend, User32.ULW_ALPHA);
}
finally {
srcLoc, 0, blend, WinUser.ULW_ALPHA);
} finally {
user.ReleaseDC(null, screenDC);
if (memDC != null && oldBitmap != null) {
gdi.SelectObject(memDC, oldBitmap);
@@ -808,7 +813,7 @@ public class WindowUtils {
public void run() {
User32 user = User32.INSTANCE;
HWND hWnd = getHWnd(w);
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
JRootPane root = ((RootPaneContainer)w).getRootPane();
JLayeredPane lp = root.getLayeredPane();
Container content = root.getContentPane();
@@ -823,12 +828,12 @@ public class WindowUtils {
JLayeredPane.DRAG_LAYER);
}
if (transparent && !usingUpdateLayeredWindow(w)) {
flags |= User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
flags |= WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
}
else if (!transparent && usingUpdateLayeredWindow(w)) {
flags &= ~User32.WS_EX_LAYERED;
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
flags &= ~WinUser.WS_EX_LAYERED;
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
}
setLayersTransparent(w, transparent);
setForceHeavyweightPopups(w, transparent);
@@ -869,11 +874,11 @@ public class WindowUtils {
GDI32 gdi = GDI32.INSTANCE;
PathIterator pi = area.getPathIterator(null);
int mode = pi.getWindingRule() == PathIterator.WIND_NON_ZERO
? GDI32.WINDING: GDI32.ALTERNATE;
? WinGDI.WINDING: WinGDI.ALTERNATE;
float[] coords = new float[6];
List points = new ArrayList();
List<POINT> points = new ArrayList<POINT>();
int size = 0;
List sizes = new ArrayList();
List<Integer> sizes = new ArrayList<Integer>();
while (!pi.isDone()) {
int type = pi.currentSegment(coords);
if (type == PathIterator.SEG_MOVETO) {
@@ -917,7 +922,7 @@ public class WindowUtils {
public boolean outputRange(int x, int y, int w, int h) {
GDI32 gdi = GDI32.INSTANCE;
gdi.SetRectRgn(tempRgn, x, y, x + w, y + h);
return gdi.CombineRgn(region, region, tempRgn, GDI32.RGN_OR) != GDI32.ERROR;
return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR;
}
});
}
@@ -1008,7 +1013,7 @@ public class WindowUtils {
fixWindowDragging(w, "setWindowAlpha");
}
whenDisplayable(w, new Runnable() {
public void run() {
public void run() {
Object peer = w.getPeer();
try {
peer.getClass().getMethod("setAlpha", new Class[]{
@@ -1049,6 +1054,7 @@ public class WindowUtils {
* @author Olivier Chafik
*/
private static class OSXMaskingContentPane extends JPanel {
private static final long serialVersionUID = 1L;
private Shape shape;
public OSXMaskingContentPane(Component oldContent) {
@@ -1123,7 +1129,7 @@ public class WindowUtils {
}
x11.XSetForeground(dpy, gc, new NativeLong(0));
x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
final List rlist = new ArrayList();
final List<Rectangle> rlist = new ArrayList<Rectangle>();
try {
RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() {
public boolean outputRange(int x, int y, int w, int h) {
@@ -1229,7 +1235,7 @@ public class WindowUtils {
IntByReference pcount = new IntByReference();
info = x11.XGetVisualInfo(dpy, mask, template, pcount);
if (info != null) {
List list = new ArrayList();
List<X11.VisualID> list = new ArrayList<X11.VisualID>();
XVisualInfo[] infos =
(XVisualInfo[])info.toArray(pcount.getValue());
for (int i = 0; i < infos.length; i++) {
@@ -1269,9 +1275,9 @@ public class WindowUtils {
x11.XQueryTree(dpy, win, rootp, parentp, childrenp, countp);
Pointer p = childrenp.getValue();
int[] ids = p.getIntArray(0, countp.getValue());
for (int i=0;i < ids.length;i++) {
for (int id : ids) {
// TODO: more verification of correct window?
X11.Window child = new X11.Window(ids[i]);
X11.Window child = new X11.Window(id);
X11.XWindowAttributes xwa = new X11.XWindowAttributes();
x11.XGetWindowAttributes(dpy, child, xwa);
offset.x = -xwa.x;
@@ -1333,6 +1339,7 @@ public class WindowUtils {
}
private class X11TransparentContentPane extends TransparentContentPane {
private static final long serialVersionUID = 1L;
public X11TransparentContentPane(Container oldContent) {
super(oldContent);
@@ -1344,7 +1351,7 @@ public class WindowUtils {
// Painting directly to the original Graphics
// fails to properly composite unless the destination
// is pure black. Too bad.
protected void paintDirect(BufferedImage buf, Rectangle bounds) {
protected void paintDirect(BufferedImage buf, Rectangle bounds) {
Window window = SwingUtilities.getWindowAncestor(this);
X11 x11 = X11.INSTANCE;
X11.Display dpy = x11.XOpenDisplay(null);
@@ -180,7 +180,7 @@ public abstract class DragHandler
private Component dragSource;
private GhostedDragImage ghost;
private Point imageOffset;
private Dimension maxGhostSize = MAX_GHOST_SIZE;
private Dimension maxGhostSize = MAX_GHOST_SIZE;
private float ghostAlpha = DEFAULT_GHOST_ALPHA;
/** Enable drags from the given component, supporting the actions in
@@ -530,4 +530,4 @@ public abstract class DragHandler
}
updateCursor(e);
}
}
}
@@ -88,7 +88,7 @@ import java.util.Set;
public abstract class DropHandler implements DropTargetListener {
private int acceptedActions;
private List acceptedFlavors;
private List<DataFlavor> acceptedFlavors;
private DropTarget dropTarget;
private boolean active = true;
private DropTargetPainter painter;
@@ -347,7 +347,7 @@ public abstract class DropHandler implements DropTargetListener {
* constructor.
*/
protected boolean isSupported(DataFlavor[] flavors) {
Set set = new HashSet(Arrays.asList(flavors));
Set<DataFlavor> set = new HashSet<DataFlavor>(Arrays.asList(flavors));
set.retainAll(acceptedFlavors);
return !set.isEmpty();
}
@@ -56,6 +56,7 @@ public class GhostedDragImage {
// FIXME ensure gc is compatible (X11)
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
dragImage = new Window(JOptionPane.getRootFrame(), gc) {
private static final long serialVersionUID = 1L;
public void paint(Graphics g) {
icon.paintIcon(this, g, 0, 0);
}
@@ -0,0 +1,14 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides integrated, extended drag and drop functionality,
allowing ghosted drag images to be used on all platforms.
</body>
</html>
@@ -30,7 +30,7 @@ public class MacFileUtils extends FileUtils {
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List failed = new ArrayList();
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());
@@ -0,0 +1,13 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides common library mappings for the OS X platform.
</body>
</html>
@@ -0,0 +1,13 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides cross-platform utilities based on platform-specific libraries.
</body>
</html>
@@ -29,12 +29,14 @@ import com.sun.jna.ptr.PointerByReference;
public interface X11 extends Library {
class VisualID extends NativeLong {
public VisualID() { }
private static final long serialVersionUID = 1L;
public VisualID() { }
public VisualID(long value) { super(value); }
}
class XID extends NativeLong {
public static final XID None = null;
private static final long serialVersionUID = 1L;
public static final XID None = null;
public XID() { this(0); }
public XID(long id) { super(id); }
protected boolean isNone(Object o) {
@@ -52,6 +54,7 @@ public interface X11 extends Library {
}
}
class Atom extends XID {
private static final long serialVersionUID = 1L;
public static final Atom None = null;
public Atom() { }
public Atom(long id) { super(id); }
@@ -143,6 +146,7 @@ public interface X11 extends Library {
}
}
class Colormap extends XID {
private static final long serialVersionUID = 1L;
public static final Colormap None = null;
public Colormap() { }
public Colormap(long id) { super(id); }
@@ -153,6 +157,7 @@ public interface X11 extends Library {
}
}
class Font extends XID {
private static final long serialVersionUID = 1L;
public static final Font None = null;
public Font() { }
public Font(long id) { super(id); }
@@ -163,6 +168,7 @@ public interface X11 extends Library {
}
}
class Cursor extends XID {
private static final long serialVersionUID = 1L;
public static final Cursor None = null;
public Cursor() { }
public Cursor(long id) { super(id); }
@@ -173,6 +179,7 @@ public interface X11 extends Library {
}
}
class KeySym extends XID {
private static final long serialVersionUID = 1L;
public static final KeySym None = null;
public KeySym() { }
public KeySym(long id) { super(id); }
@@ -183,6 +190,7 @@ public interface X11 extends Library {
}
}
class Drawable extends XID {
private static final long serialVersionUID = 1L;
public static final Drawable None = null;
public Drawable() { }
public Drawable(long id) { super(id); }
@@ -193,7 +201,8 @@ public interface X11 extends Library {
}
}
class Window extends Drawable {
public static final Window None = null;
private static final long serialVersionUID = 1L;
public static final Window None = null;
public Window() { }
public Window(long id) { super(id); }
public Object fromNative(Object nativeValue, FromNativeContext context) {
@@ -211,7 +220,8 @@ public interface X11 extends Library {
}
}
class Pixmap extends Drawable {
public static final Pixmap None = null;
private static final long serialVersionUID = 1L;
public static final Pixmap None = null;
public Pixmap() { }
public Pixmap(long id) { super(id); }
public Object fromNative(Object nativeValue, FromNativeContext context) {
@@ -268,6 +278,7 @@ public interface X11 extends Library {
public short alpha, alphaMask;
}
class PictFormat extends NativeLong {
private static final long serialVersionUID = 1L;
public PictFormat(long value) { super(value); }
public PictFormat() { }
}
@@ -0,0 +1,13 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides common library mappings for Unix and X11-based platforms.
</body>
</html>
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,21 +8,26 @@
* 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.platform.win32;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
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.Pointer;
import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.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.WinNT.SID_NAME_USE;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
@@ -33,25 +38,7 @@ import com.sun.jna.ptr.PointerByReference;
* @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.
*/
@@ -252,16 +239,48 @@ public abstract class Advapi32Util {
/**
* Convert a string representation of a security identifier (SID) to
* a binary format.
* @param sid String SID.
* @param sidString
* String SID.
* @return SID bytes.
*/
public static byte[] convertStringSidToSid(String sid) {
public static byte[] convertStringSidToSid(String sidString) {
PSIDByReference pSID = new PSIDByReference();
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sid, pSID)) {
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pSID.getValue().getBytes();
}
/**
* Compares a SID to a well known SID and returns TRUE if they match.
* @param sidString
* String representation of a SID.
* @param wellKnownSidType
* Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid.
* @return
* True if the SID is of the well-known type, false otherwise.
*/
public static boolean isWellKnownSid(String sidString, int wellKnownSidType) {
PSIDByReference pSID = new PSIDByReference();
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Advapi32.INSTANCE.IsWellKnownSid(pSID.getValue(), wellKnownSidType);
}
/**
* Compares a SID to a well known SID and returns TRUE if they match.
* @param sidBytes
* Byte representation of a SID.
* @param wellKnownSidType
* Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid.
* @return
* True if the SID is of the well-known type, false otherwise.
*/
public static boolean isWellKnownSid(byte[] sidBytes, int wellKnownSidType) {
PSID pSID = new PSID(sidBytes);
return Advapi32.INSTANCE.IsWellKnownSid(pSID, wellKnownSidType);
}
/**
* Get an account name from a string SID on the local machine.
@@ -291,36 +310,41 @@ public abstract class Advapi32Util {
* @param hToken Token.
* @return Token groups.
*/
public static Group[] getTokenGroups(HANDLE hToken) {
public static Account[] 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) {
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)) {
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
}
int rc = Kernel32.INSTANCE.GetLastError();
if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
// get token group information
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationBuffer);
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationLength.getValue());
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>();
ArrayList<Account> userGroups = new ArrayList<Account>();
// 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);
Account group = null;
try {
group.name = Advapi32Util.getAccountBySid(sidAndAttribute.Sid).name;
group = Advapi32Util.getAccountBySid(sidAndAttribute.Sid);
} catch(Exception e) {
group = new Account();
group.sid = sidAndAttribute.Sid.getBytes();
group.sidString = Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid);
group.name = group.sidString;
group.fqn = group.sidString;
group.accountType = SID_NAME_USE.SidTypeGroup;
}
userGroups.add(group);
}
return userGroups.toArray(new Group[0]);
return userGroups.toArray(new Account[0]);
}
/**
@@ -333,13 +357,15 @@ public abstract class Advapi32Util {
// 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) {
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)) {
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
}
int rc = Kernel32.INSTANCE.GetLastError();
if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
throw new Win32Exception(rc);
}
// get token user information
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationBuffer);
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationLength.getValue());
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user,
tokenInformationLength.getValue(), tokenInformationLength)) {
@@ -352,7 +378,7 @@ public abstract class Advapi32Util {
* Return the group memberships of the currently logged on user.
* @return An array of groups.
*/
public static Group[] getCurrentUserGroups() {
public static Account[] getCurrentUserGroups() {
HANDLEByReference phToken = new HANDLEByReference();
try {
// open thread or process token
@@ -370,7 +396,7 @@ public abstract class Advapi32Util {
}
return getTokenGroups(phToken.getValue());
} finally {
if (phToken.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
if (phToken.getValue() != WinBase.INVALID_HANDLE_VALUE) {
if (! Kernel32.INSTANCE.CloseHandle(phToken.getValue())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
@@ -438,7 +464,7 @@ public abstract class Advapi32Util {
throw new Win32Exception(rc);
}
} finally {
if (phkKey.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
if (phkKey.getValue() != WinBase.INVALID_HANDLE_VALUE) {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
@@ -490,6 +516,143 @@ public abstract class Advapi32Util {
}
}
/**
* Get a registry REG_EXPAND_SZ value.
* @param root
* Root key.
* @param key
* Registry path.
* @param value
* Name of the value to retrieve.
* @return
* String value.
*/
public static String registryGetExpandableStringValue(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_EXPAND_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 REG_MULTI_SZ value.
* @param root
* Root key.
* @param key
* Registry path.
* @param value
* Name of the value to retrieve.
* @return
* String value.
*/
public static String[] registryGetStringArray(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_MULTI_SZ) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
}
Memory data = new Memory(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);
}
ArrayList<String> result = new ArrayList<String>();
int offset = 0;
while(offset < data.size()) {
String s = data.getString(offset, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
result.add(s);
}
return result.toArray(new String[0]);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry REG_BINARY value.
* @param root
* Root key.
* @param key
* Registry path.
* @param value
* Name of the value to retrieve.
* @return
* String value.
*/
public static byte[] registryGetBinaryValue(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_BINARY) {
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_BINARY");
}
byte[] data = new byte[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 data;
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Get a registry DWORD value.
* @param root
@@ -539,18 +702,22 @@ public abstract class Advapi32Util {
* Parent key.
* @param keyName
* Key name.
* @return
* True if the key was created, false otherwise.
*/
public static void registryCreateKey(HKEY hKey, String keyName) {
public static boolean 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);
IntByReference lpdwDisposition = new IntByReference();
int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, WinNT.REG_OPTION_NON_VOLATILE,
WinNT.KEY_READ, null, phkResult, lpdwDisposition);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
return WinNT.REG_CREATED_NEW_KEY == lpdwDisposition.getValue();
}
/**
@@ -561,15 +728,17 @@ public abstract class Advapi32Util {
* Path to an existing registry key.
* @param keyName
* Key name.
* @return
* True if the key was created, false otherwise.
*/
public static void registryCreateKey(HKEY root, String parentPath, String keyName) {
public static boolean 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);
return registryCreateKey(phkKey.getValue(), keyName);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
@@ -583,9 +752,9 @@ public abstract class Advapi32Util {
* @param hKey
* Parent key.
* @param name
* Name.
* Value name.
* @param value
* Value.
* Value to write to registry.
*/
public static void registrySetIntValue(HKEY hKey, String name, int value) {
byte[] data = new byte[4];
@@ -606,9 +775,9 @@ public abstract class Advapi32Util {
* @param keyPath
* Path to an existing registry key.
* @param name
* Name.
* Value name.
* @param value
* Value.
* Value to write to registry.
*/
public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) {
HKEYByReference phkKey = new HKEYByReference();
@@ -631,13 +800,14 @@ public abstract class Advapi32Util {
* @param hKey
* Parent key.
* @param name
* Name.
* Value name.
* @param value
* Value.
* Value to write to registry.
*/
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);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ,
data, data.length * Native.WCHAR_SIZE);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
@@ -650,9 +820,9 @@ public abstract class Advapi32Util {
* @param keyPath
* Path to an existing registry key.
* @param name
* Name.
* Value name.
* @param value
* Value.
* Value to write to registry.
*/
public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) {
HKEYByReference phkKey = new HKEYByReference();
@@ -670,6 +840,153 @@ public abstract class Advapi32Util {
}
}
/**
* Set an expandable string value in registry.
* @param hKey
* Parent key.
* @param name
* Value name.
* @param value
* Value to write to registry.
*/
public static void registrySetExpandableStringValue(HKEY hKey, String name, String value) {
char[] data = Native.toCharArray(value);
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_EXPAND_SZ,
data, data.length * Native.WCHAR_SIZE);
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
* Value name.
* @param value
* Value to write to registry.
*/
public static void registrySetExpandableStringValue(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 {
registrySetExpandableStringValue(phkKey.getValue(), name, value);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a string array value in registry.
* @param hKey
* Parent key.
* @param name
* Name.
* @param arr
* Array of strings to write to registry.
*/
public static void registrySetStringArray(HKEY hKey, String name, String[] arr) {
int size = 0;
for(String s : arr) {
size += s.length() * Native.WCHAR_SIZE;
size += Native.WCHAR_SIZE;
}
int offset = 0;
Memory data = new Memory(size);
for(String s : arr) {
data.setString(offset, s, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
}
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_MULTI_SZ,
data.getByteArray(0, size), size);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a string array value in registry.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param name
* Value name.
* @param arr
* Array of strings to write to registry.
*/
public static void registrySetStringArray(HKEY root, String keyPath, String name, String[] arr) {
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 {
registrySetStringArray(phkKey.getValue(), name, arr);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Set a binary value in registry.
* @param hKey
* Parent key.
* @param name
* Value name.
* @param data
* Data to write to registry.
*/
public static void registrySetBinaryValue(HKEY hKey, String name, byte[] data) {
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_BINARY, data, data.length);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
/**
* Set a binary value in registry.
* @param root
* Root key.
* @param keyPath
* Path to an existing registry key.
* @param name
* Value name.
* @param data
* Data to write to registry.
*/
public static void registrySetBinaryValue(HKEY root, String keyPath, String name, byte[] data) {
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 {
registrySetBinaryValue(phkKey.getValue(), name, data);
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
/**
* Delete a registry key.
* @param hKey
@@ -818,7 +1135,7 @@ public abstract class Advapi32Util {
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
TreeMap<String, Object> keyValues = new TreeMap<String, Object>();
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++) {
@@ -830,22 +1147,44 @@ public abstract class Advapi32Util {
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
String nameString = Native.toString(name);
Memory byteData = new Memory(lpcbData.getValue());
byteData.write(0, data, 0, lpcbData.getValue());
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));
{
keyValues.put(nameString, byteData.getInt(0));
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());
}
case WinNT.REG_EXPAND_SZ:
{
keyValues.put(nameString, byteData.getString(0, true));
break;
}
case WinNT.REG_BINARY:
{
keyValues.put(nameString, byteData.getByteArray(0, lpcbData.getValue()));
break;
}
case WinNT.REG_MULTI_SZ:
{
Memory stringData = new Memory(lpcbData.getValue());
stringData.write(0, data, 0, lpcbData.getValue());
ArrayList<String> result = new ArrayList<String>();
int offset = 0;
while(offset < stringData.size()) {
String s = stringData.getString(offset, true);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
result.add(s);
}
keyValues.put(nameString, result.toArray(new String[0]));
break;
}
default:
throw new RuntimeException("Unsupported type: " + lpType.getValue());
}
@@ -876,5 +1215,267 @@ public abstract class Advapi32Util {
}
}
}
/**
* Converts a map of environment variables to an environment block suitable
* for {@link Advapi32#CreateProcessAsUser}. This environment block consists
* of null-terminated blocks of null-terminated strings. Each string is in the
* following form: name=value\0
* @param environment Environment variables
* @return A environment block
*/
public static String getEnvironmentBlock(Map<String, String> environment) {
StringBuffer out = new StringBuffer();
for (Entry<String, String> entry: environment.entrySet()) {
if (entry.getValue() != null) {
out.append(entry.getKey() + "=" + entry.getValue() + "\0");
}
}
return out.toString() + "\0";
}
/**
* Event log types.
*/
public static enum EventLogType {
Error,
Warning,
Informational,
AuditSuccess,
AuditFailure
}
/**
* An event log record.
*/
public static class EventLogRecord {
private EVENTLOGRECORD _record = null;
private String _source;
private byte[] _data;
private String[] _strings;
/**
* Raw record data.
* @return
* EVENTLOGRECORD.
*/
public EVENTLOGRECORD getRecord() {
return _record;
}
/**
* Event Id.
* @return
* Integer.
*/
public int getEventId() {
return _record.EventID.intValue();
}
/**
* Event source.
* @return
* String.
*/
public String getSource() {
return _source;
}
/**
* Status code for the facility, part of the Event ID.
* @return
* Status code.
*/
public int getStatusCode() {
return _record.EventID.intValue() & 0xFFFF;
}
/**
* Record number of the record. This value can be used with the EVENTLOG_SEEK_READ flag in
* the ReadEventLog function to begin reading at a specified record.
* @return
* Integer.
*/
public int getRecordNumber() {
return _record.RecordNumber.intValue();
}
/**
* Record length, with data.
* @return
* Number of bytes in the record including data.
*/
public int getLength() {
return _record.Length.intValue();
}
/**
* Strings associated with this event.
* @return
* Array of strings or null.
*/
public String[] getStrings() {
return _strings;
}
/**
* Event log type.
* @return
* Event log type.
*/
public EventLogType getType() {
switch(_record.EventType.intValue()) {
case WinNT.EVENTLOG_SUCCESS:
case WinNT.EVENTLOG_INFORMATION_TYPE:
return EventLogType.Informational;
case WinNT.EVENTLOG_AUDIT_FAILURE:
return EventLogType.AuditFailure;
case WinNT.EVENTLOG_AUDIT_SUCCESS:
return EventLogType.AuditSuccess;
case WinNT.EVENTLOG_ERROR_TYPE:
return EventLogType.Error;
case WinNT.EVENTLOG_WARNING_TYPE:
return EventLogType.Warning;
default:
throw new RuntimeException("Invalid type: " + _record.EventType.intValue());
}
}
/**
* Raw data associated with the record.
* @return
* Array of bytes or null.
*/
public byte[] getData() {
return _data;
}
public EventLogRecord(Pointer pevlr) {
_record = new EVENTLOGRECORD(pevlr);
_source = pevlr.getString(_record.size(), true);
// data
if (_record.DataLength.intValue() > 0) {
_data = pevlr.getByteArray(_record.DataOffset.intValue(),
_record.DataLength.intValue());
}
// strings
if (_record.NumStrings.intValue() > 0) {
ArrayList<String> strings = new ArrayList<String>();
int count = _record.NumStrings.intValue();
long offset = _record.StringOffset.intValue();
while(count > 0) {
String s = pevlr.getString(offset, true);
strings.add(s);
offset += s.length() * Native.WCHAR_SIZE;
offset += Native.WCHAR_SIZE;
count--;
}
_strings = strings.toArray(new String[0]);
}
}
}
/**
* An iterator for Event Log entries.
*/
public static class EventLogIterator
implements Iterable<EventLogRecord>, Iterator<EventLogRecord> {
private HANDLE _h = null;
private Memory _buffer = new Memory(1024 * 64); // memory buffer to store events
private boolean _done = false; // no more events
private int _dwRead = 0; // number of bytes remaining in the current buffer
private Pointer _pevlr = null; // pointer to the current record
private int _flags = WinNT.EVENTLOG_FORWARDS_READ;
public EventLogIterator(String sourceName) {
this(null, sourceName, WinNT.EVENTLOG_FORWARDS_READ);
}
public EventLogIterator(String serverName, String sourceName, int flags) {
_flags = flags;
_h = Advapi32.INSTANCE.OpenEventLog(serverName, sourceName);
if (_h == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
private boolean read() {
// finished or bytes remain, don't read any new data
if (_done || _dwRead > 0) {
return false;
}
IntByReference pnBytesRead = new IntByReference();
IntByReference pnMinNumberOfBytesNeeded = new IntByReference();
if (! Advapi32.INSTANCE.ReadEventLog(_h,
WinNT.EVENTLOG_SEQUENTIAL_READ | _flags,
0, _buffer, (int) _buffer.size(), pnBytesRead, pnMinNumberOfBytesNeeded)) {
int rc = Kernel32.INSTANCE.GetLastError();
// not enough bytes in the buffer, resize
if (rc == W32Errors.ERROR_INSUFFICIENT_BUFFER) {
_buffer = new Memory(pnMinNumberOfBytesNeeded.getValue());
if (! Advapi32.INSTANCE.ReadEventLog(_h,
WinNT.EVENTLOG_SEQUENTIAL_READ | _flags,
0, _buffer, (int) _buffer.size(), pnBytesRead, pnMinNumberOfBytesNeeded)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
} else {
// read failed, no more entries or error
close();
if (rc != W32Errors.ERROR_HANDLE_EOF) {
throw new Win32Exception(rc);
}
return false;
}
}
_dwRead = pnBytesRead.getValue();
_pevlr = _buffer;
return true;
}
/**
* Call close() in the case when the caller needs to abandon the iterator before
* the iteration completes.
*/
public void close() {
_done = true;
if (_h != null) {
if (! Advapi32.INSTANCE.CloseEventLog(_h)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
_h = null;
}
}
@Override
public Iterator<EventLogRecord> iterator() {
return this;
}
@Override
public boolean hasNext() {
read();
return ! _done;
}
@Override
public EventLogRecord next() {
read();
EventLogRecord record = new EventLogRecord(_pevlr);
_dwRead -= record.getLength();
_pevlr = _pevlr.share(record.getLength());
return record;
}
@Override
public void remove() {
}
}
}
@@ -0,0 +1,90 @@
/* Copyright (c) 2010 Daniel Doubrovkine, 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.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.win32.StdCallLibrary;
/**
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision.
* Use when casting a pointer to a long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point.
* Use for a count that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -17,13 +17,15 @@ 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.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Crypt32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Crypt32 extends W32API {
public interface Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -1,3 +1,15 @@
/* Copyright (c) 2010 Daniel Doubrovkine, 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.NativeLong;
@@ -6,6 +18,7 @@ import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
@@ -13,7 +26,7 @@ import com.sun.jna.platform.win32.WinNT.PSID;
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public abstract class DsGetDC {
public interface DsGetDC extends StdCallLibrary {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
@@ -203,6 +216,7 @@ public abstract class DsGetDC {
* @param count
* Number of domain trusts.
* @return
* An array of domain trusts.
*/
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
@@ -0,0 +1,316 @@
/* 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.Pointer;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.WinDef.HRGN;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/** Definition (incomplete) of <code>gdi32.dll</code>. */
public interface GDI32 extends StdCallLibrary {
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
W32APIOptions.DEFAULT_OPTIONS);
/**
* The ExtCreateRegion function creates a region from the specified region and transformation data.
* @param lpXform
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
* the identity transformation is used.
* @param nCount
* Specifies the number of bytes pointed to by lpRgnData.
* @param lpRgnData
* Pointer to a RGNDATA structure that contains the region data in logical units.
* @return
* If the function succeeds, the return value is the value of the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
/**
* The CombineRgn function combines two regions and stores the result in a third region.
* The two regions are combined according to the specified mode.
* @param hrgnDest
* Handle to a new region with dimensions defined by combining two other regions.
* @param hrgnSrc1
* Handle to the first of two regions to be combined.
* @param hrgnSrc2
* Handle to the second of two regions to be combined.
* @param fnCombineMode
* Specifies a mode indicating how the two regions will be combined.
* @return
* The return value specifies the type of the resulting region.
*/
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
int fnCombineMode);
/**
* The CreateRectRgn function creates a rectangular region.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
* @param nWidthEllipse
* Specifies the width of the ellipse used to create the rounded corners in logical units.
* @param nHeightEllipse
* Specifies the height of the ellipse used to create the rounded corners in logical units.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
/**
* The CreatePolyPolygonRgn function creates a region consisting of a series
* of polygons. The polygons can overlap.
* @param lppt
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
* specified only once.
* @param lpPolyCounts
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
* in the array pointed to by lppt.
* @param nCount
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
* @param fnPolyFillMode
* Specifies the fill mode used to determine which pixels are in the region.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is zero.
* To get extended error information, call GetLastError.
*/
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
int nCount, int fnPolyFillMode);
/**
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
* @param hrgn
* Handle to the region.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
* @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 SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
* @param hDC
* Handle to the device context.
* @param x
* Specifies the x-coordinate, in logical units, of the point to be set.
* @param y
* Specifies the y-coordinate, in logical units, of the point to be set.
* @param crColor
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
* @return
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
* This value may differ from the color specified by crColor; that occurs when an exact match for the
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
* information, call GetLastError. This can be the following value.
*/
int SetPixel(HDC hDC, int x, int y, int crColor);
/**
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
* @param hDC
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
* application's current screen.
* @return
* If the function succeeds, the return value is the handle to a memory DC.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HDC CreateCompatibleDC(HDC hDC);
/**
* The DeleteDC function deletes the specified device context (DC).
* @param hDC
* Handle to the device context.
* @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 DeleteDC(HDC hDC);
/**
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
* sets the bitmap bits.
* @param hDC
* Handle to a device context.
* @param lpbmih
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
* @param fdwInit
* Specifies how the system initializes the bitmap bits.
* @param lpbInit
* Pointer to an array of bytes containing the initial bitmap data.
* @param lpbmi
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
* the array pointed to by the lpbInit parameter.
* @param fuUsage
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
* fuUsage parameter must be one of the following values.
* @return
* If the function succeeds, the return value is a handle to the compatible bitmap.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
/**
* The CreateDIBSection function creates a DIB that applications can write to directly.
* The function gives you a pointer to the location of the bitmap bit values. You can supply
* a handle to a file-mapping object that the function will use to create the bitmap, or you
* can let the system allocate the memory for the bitmap.
* @param hDC
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
* device context's logical palette to initialize the DIB colors.
* @param pbmi
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
* the bitmap dimensions and colors.
* @param iUsage
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
* pointed to by pbmi (either logical palette indexes or literal RGB values).
* @param ppvBits
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
* @param hSection
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
* @param dwOffset
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
* for the bitmap bit values is to begin.
* @return
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
* for the bitmap bit values is to begin.
*/
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
PointerByReference ppvBits, Pointer hSection, int dwOffset);
/**
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
* associated with the specified device context.
* @param hDC
* Handle to a device context.
* @param width
* Specifies the bitmap width, in pixels.
* @param height
* Specifies the bitmap height, in pixels.
* @return
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
/**
* The SelectObject function selects an object into the specified device context (DC).
* The new object replaces the previous object of the same type.
* @param hDC
* Handle to the DC.
* @param hGDIObj
* Handle to the object to be selected.
* @return
* If the selected object is not a region and the function succeeds, the return value
* is a handle to the object being replaced. If the selected object is a region and the
* function succeeds, the return value is one of the REGION values.
*/
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
/**
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
* freeing all system resources associated with the object. After the object is deleted, the
* specified handle is no longer valid.
* @param hObject
* Handle to a logical pen, brush, font, bitmap, region, or palette.
* @return
* If the function succeeds, the return value is nonzero.
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
* To get extended error information, call GetLastError.
*/
boolean DeleteObject(HANDLE hObject);
/** The GetDeviceCaps function retrieves device-specific information for
* the specified device.
* @param hdc A handle to the DC.
* @param nIndex The item to be returned.
* @return
* The return value specifies the value of the desired item. When
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
* 16bpp, the return value is 16.
*/
int GetDeviceCaps(HDC hdc, int nIndex);
/** The GetDIBits function retrieves the bits fo the specified compatible
* bitmap and copies them into a buffer as a DIB using the specified
* format.
* @param hdc A handle to the device context.
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
* (DDB).
* @param uStartScan The first scan line to retrieve
* @param cScanLines The number of scan lines to retrieve.
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
* this parameter is <code>null</code>, the function passes the dimensions
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
* by the <i>lpbi</i> parameter.
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
* the desired format for the DIB data.
* @param uUsage The format of the bmiColors member of the {@link
* BITMAPINFO} structure.
*/
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -14,13 +14,14 @@ package com.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Guid.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class Guid {
public interface Guid extends StdCallLibrary {
public static class GUID extends Structure {
@@ -0,0 +1,957 @@
/* 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.platform.win32.WinBase.MEMORYSTATUSEX;
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HMODULE;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO;
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/** Definition (incomplete) of <code>kernel32.dll</code>. */
public interface Kernel32 extends StdCallLibrary {
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 GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
* @return
* Number of milliseconds that have elapsed since the system was started.
*/
int GetTickCount();
/**
* 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);
/**
* Retrieves the termination status of the specified process.
* @param hProcess A handle to the process.
* @param lpExitCode A pointer to a variable to receive the process termination status.
* @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 GetExitCodeProcess(HANDLE hProcess, IntByReference lpExitCode);
/**
* Terminates the specified process and all of its threads.
* @param hProcess A handle to the process to be terminated.
* @param uExitCode The exit code to be used by the process and threads
* terminated as a result of this call.
* @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 TerminateProcess(HANDLE hProcess, int uExitCode);
/**
* 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 lpRootPathName
* 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 lpRootPathName);
/**
* 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,
WinBase.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,
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
/**
* Reads data from the specified file or input/output (I/O) device. Reads
* occur at the position specified by the file pointer if supported by the
* device.
*
* This function is designed for both synchronous and asynchronous
* operations. For a similar function designed solely for asynchronous
* operation, see ReadFileEx
*
* @param hFile A handle to the device (for example, a file, file stream,
* physical disk, volume, console buffer, tape drive, socket, communications
* resource, mailslot, or pipe).
* @param lpBuffer A pointer to the buffer that receives the data read from a file or device.
* @param nNumberOfBytesToRead The maximum number of bytes to be read.
* @param lpNumberOfBytesRead A pointer to the variable that receives the number of bytes
* read when using a synchronous hFile parameter
* @param lpOverlapped A pointer to an OVERLAPPED structure is required if the hFile
* parameter was opened with FILE_FLAG_OVERLAPPED, otherwise it can be NULL.
* @return If the function succeeds, the return value is nonzero (TRUE).
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
* To get extended error information, call the GetLastError function.
*
* Note The GetLastError code ERROR_IO_PENDING is not a failure; it designates the read
* operation is pending completion asynchronously. For more information, see Remarks.
*/
boolean ReadFile(
HANDLE hFile,
Buffer lpBuffer,
int nNumberOfBytesToRead,
IntByReference lpNumberOfBytesRead,
WinBase.OVERLAPPED lpOverlapped);
/**
* Creates an input/output (I/O) completion port and associates it with a specified
* file handle, or creates an I/O completion port that is not yet associated with a
* file handle, allowing association at a later time.
* @param FileHandle
* An open file handle or INVALID_HANDLE_VALUE.
* @param ExistingCompletionPort
* A handle to an existing I/O completion port or NULL.
* @param CompletionKey
* The per-handle user-defined completion key that is included in every I/O completion
* packet for the specified file handle.
* @param NumberOfConcurrentThreads
* The maximum number of threads that the operating system can allow to concurrently
* process I/O completion packets for the I/O completion port.
* @return
* If the function succeeds, the return value is the handle to an I/O completion port:
* If the ExistingCompletionPort parameter was NULL, the return value is a new handle.
* If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle.
* If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port.
* If the function fails, the return value is NULL. To get extended error information, call the GetLastError function.
*/
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
Pointer CompletionKey, int NumberOfConcurrentThreads);
/**
* Attempts to dequeue an I/O completion packet from the specified I/O completion
* port. If there is no completion packet queued, the function waits for a pending
* I/O operation associated with the completion port to complete.
* @param CompletionPort
* A handle to the completion port.
* @param lpNumberOfBytes
* A pointer to a variable that receives the number of bytes transferred during
* an I/O operation that has completed.
* @param lpCompletionKey
* A pointer to a variable that receives the completion key value associated with
* the file handle whose I/O operation has completed.
* @param lpOverlapped
* A pointer to a variable that receives the address of the OVERLAPPED structure
* that was specified when the completed I/O operation was started.
* @param dwMilliseconds
* The number of milliseconds that the caller is willing to wait for a completion
* packet to appear at the completion port.
* @return
* Returns nonzero (TRUE) if successful or zero (FALSE) otherwise.
*/
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
PointerByReference lpOverlapped, int dwMilliseconds);
/**
* Posts an I/O completion packet to an I/O completion port.
* @param CompletionPort
* A handle to an I/O completion port to which the I/O completion packet is to be posted.
* @param dwNumberOfBytesTransferred
* The value to be returned through the lpNumberOfBytesTransferred parameter of the GetQueuedCompletionStatus function.
* @param dwCompletionKey
* The value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function.
* @param lpOverlapped
* The value to be returned through the lpOverlapped parameter of the GetQueuedCompletionStatus function.
* @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 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);
}
/**
* Retrieves information that describes the changes within the specified directory.
* The function does not report changes to the specified directory itself.
* Note: there's no ReadDirectoryChangesA.
* @param directory
* A handle to the directory to be monitored. This directory must be opened with the
* FILE_LIST_DIRECTORY access right.
* @param info
* A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned.
* @param length
* The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
* @param watchSubtree
* If this parameter is TRUE, the function monitors the directory tree rooted at the specified
* directory. If this parameter is FALSE, the function monitors only the directory specified by
* the hDirectory parameter.
* @param notifyFilter
* The filter criteria that the function checks to determine if the wait operation has completed.
* @param bytesReturned
* For synchronous calls, this parameter receives the number of bytes transferred into the
* lpBuffer parameter. For asynchronous calls, this parameter is undefined. You must use an asynchronous
* notification technique to retrieve the number of bytes transferred.
* @param overlapped
* A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
* Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used.
* @param completionRoutine
* A pointer to a completion routine to be called when the operation has been completed or canceled and
* the calling thread is in an alertable wait state.
* @return
* If the function succeeds, the return value is nonzero. For synchronous calls, this means that the
* operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued.
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
* If the network redirector or the target file system does not support this operation, the function
* fails with ERROR_INVALID_FUNCTION.
*/
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);
/**
* Retrieves the short path form of the specified path.
* @param lpszLongPath
* The path string.
* @param lpdzShortPath
* A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies.
* @param cchBuffer
* The size of the buffer that lpszShortPath points to, in TCHARs.
* @return
* If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to
* lpszShortPath, not including the terminating null character.
* If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer,
* in TCHARs, that is required to hold the path and the terminating null character.
* If the function fails for any other reason, the return value is zero. To get extended error information,
* call GetLastError.
*/
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);
/**
* Writes data to the specified file or input/output (I/O) device.
* @param hFile
* A handle to the file or I/O device (for example, a file, file stream, physical disk, volume,
* console buffer, tape drive, socket, communications resource, mailslot, or pipe).
* @param lpBuffer
* A pointer to the buffer containing the data to be written to the file or device.
* @param nNumberOfBytesToWrite
* The number of bytes to be written to the file or device.
* @param lpNumberOfBytesWritten
* A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.
* @param lpOverlapped
* A pointer to an OVERLAPPED structure is required if the hFile parameter was opened with FILE_FLAG_OVERLAPPED,
* otherwise this parameter can be NULL.
* @return
* If the function succeeds, the return value is nonzero (TRUE).
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
* To get extended error information, call the GetLastError function.
*/
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
IntByReference lpNumberOfBytesWritten,
WinBase.OVERLAPPED lpOverlapped);
/**
* Creates or opens a named or unnamed event object.
* @param lpEventAttributes
* A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL,
* the handle cannot be inherited by child processes.
* @param bManualReset
* If this parameter is TRUE, the function creates a manual-reset event object,
* which requires the use of the ResetEvent function to set the event state to nonsignaled.
* If this parameter is FALSE, the function creates an auto-reset event object, and system
* automatically resets the event state to nonsignaled after a single waiting thread has
* been released.
* @param bInitialState
* If this parameter is TRUE, the initial state of the event object is signaled; otherwise,
* it is nonsignaled.
* @param lpName
* The name of the event object. The name is limited to MAX_PATH characters. Name comparison
* is case sensitive.
* @return
* If the function succeeds, the return value is a handle to the event object. If the named event
* object existed before the function call, the function returns a handle to the existing object
* and GetLastError returns ERROR_ALREADY_EXISTS.
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
*/
HANDLE CreateEvent(WinBase.SECURITY_ATTRIBUTES lpEventAttributes,
boolean bManualReset, boolean bInitialState,
String lpName);
/**
* Sets the specified event object to the signaled state.
* @param hEvent
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
* @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 SetEvent(HANDLE hEvent);
/**
* Sets the specified event object to the signaled state and then resets it to the nonsignaled
* state after releasing the appropriate number of waiting threads.
* @param hEvent
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
* @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 PulseEvent(HANDLE hEvent);
/**
* Creates or opens a named or unnamed file mapping object for a specified file.
* @param hFile
* A handle to the file from which to create a file mapping object.
* @param lpAttributes
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object.
* @param flProtect
* Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection.
* @param dwMaximumSizeHigh
* The high-order DWORD of the maximum size of the file mapping object.
* @param dwMaximumSizeLow
* The low-order DWORD of the maximum size of the file mapping object.
* @param lpName
* The name of the file mapping object.
* @return
* If the function succeeds, the return value is a handle to the newly created file mapping object.
* If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and GetLastError returns ERROR_ALREADY_EXISTS.
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
*/
HANDLE CreateFileMapping(HANDLE hFile, WinBase.SECURITY_ATTRIBUTES lpAttributes,
int flProtect, int dwMaximumSizeHigh,
int dwMaximumSizeLow, String lpName);
/**
* Maps a view of a file mapping into the address space of a calling process.
* @param hFileMappingObject
* A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle.
* @param dwDesiredAccess
* The type of access to a file mapping object, which determines the protection of the pages.
* @param dwFileOffsetHigh
* A high-order DWORD of the file offset where the view begins.
* @param dwFileOffsetLow
* A low-order DWORD of the file offset where the view is to begin.
* @param dwNumberOfBytesToMap
* The number of bytes of a file mapping to map to the view.
* @return
* If the function succeeds, the return value is the starting address of the mapped view.
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
*/
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
int dwFileOffsetHigh, int dwFileOffsetLow,
int dwNumberOfBytesToMap);
/**
* Unmaps a mapped view of a file from the calling process's address space.
* @param lpBaseAddress
* A pointer to the base address of the mapped view of a file that is to be unmapped.
* @return
* If the function succeeds, the return value is the starting address of the mapped view.
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
*/
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);
/**
* The GetVersion function returns the current version number of the operating system.
* @return
* If the function succeeds, the return value includes the major and minor version numbers
* of the operating system in the low order word, and information about the operating system
* platform in the high order word.
*/
DWORD GetVersion();
/**
* The GetVersionEx function obtains extended information about the version of the operating
* system that is currently running.
* @param lpVersionInfo
* Pointer to an OSVERSIONINFO data structure that the function fills with operating system
* version information.
* @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. The function fails if you specify an invalid value for the
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
*/
boolean GetVersionEx(OSVERSIONINFO lpVersionInfo);
/**
* The GetVersionEx function obtains extended information about the version of the operating
* system that is currently running.
* @param lpVersionInfo
* Pointer to an OSVERSIONINFOEX data structure that the function fills with operating system
* version information.
* @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. The function fails if you specify an invalid value for the
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
*/
boolean GetVersionEx(OSVERSIONINFOEX lpVersionInfo);
/**
* The GetSystemInfo function returns information about the current system.
* @param lpSystemInfo
* Pointer to a SYSTEM_INFO structure that receives the information.
*/
void GetSystemInfo(SYSTEM_INFO lpSystemInfo);
/**
* The GetNativeSystemInfo function retrieves information about the current system to an
* application running under WOW64. If the function is called from a 64-bit application,
* it is equivalent to the GetSystemInfo function.
* @param lpSystemInfo
* Pointer to a SYSTEM_INFO structure that receives the information.
*/
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
/**
* The IsWow64Process function determines whether the specified process is running under WOW64.
* @param hProcess
* Handle to a process.
* @param Wow64Process
* Pointer to a value that is set to TRUE if the process is running under WOW64.
* Otherwise, the value is set to FALSE.
* @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.
*/
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
/**
* Retrieves information about the system's current usage of both physical and virtual memory.
* @param lpBuffer
* A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability.
* @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 GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);
/**
* The GetLogicalDriveStrings function fills a buffer with strings that specify
* valid drives in the system.
* @param nBufferLength
* Maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include
* the terminating null character. If this parameter is zero, lpBuffer is not used.
* @param lpBuffer
* Pointer to a buffer that receives a series of null-terminated strings, one for each valid
* drive in the system, plus with an additional null character. Each string is a device name.
* @return
* If the function succeeds, the return value is the length, in characters, of the strings
* copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII
* null character uses one byte, but a Unicode null character uses two bytes.
* If the buffer is not large enough, the return value is greater than nBufferLength. It is
* the size of the buffer required to hold the drive strings.
* If the function fails, the return value is zero. To get extended error information, use
* the GetLastError function.
*/
DWORD GetLogicalDriveStrings(DWORD nBufferLength, char[] lpBuffer);
/**
* The GetDiskFreeSpaceEx function retrieves information about the amount of space that is
* available on a disk volume, which is the total amount of space, the total amount of free
* space, and the total amount of free space available to the user that is associated with
* the calling thread.
* @param lpDirectoryName
* A pointer to a null-terminated string that specifies a directory on a disk.
* If this parameter is NULL, the function uses the root of the current disk.
* If this parameter is a UNC name, it must include a trailing backslash, for example,
* \\MyServer\MyShare\.
* This parameter does not have to specify the root directory on a disk. The function
* accepts any directory on a disk.
* @param lpFreeBytesAvailable
* A pointer to a variable that receives the total number of free bytes on a disk that
* are available to the user who is associated with the calling thread.
* This parameter can be NULL.
* @param lpTotalNumberOfBytes
* A pointer to a variable that receives the total number of bytes on a disk that are
* available to the user who is associated with the calling thread.
* This parameter can be NULL.
* @param lpTotalNumberOfFreeBytes
* A pointer to a variable that receives the total number of free bytes on a disk.
* This parameter can be NULL.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is 0 (zero). To get extended error information,
* call GetLastError.
*/
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable,
LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
/**
* Deletes an existing file.
* @param filename
* The name of the file to be deleted.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
*/
public boolean DeleteFile(String filename);
/**
* Creates an anonymous pipe, and returns handles to the read and write ends of the pipe.
* @param hReadPipe A pointer to a variable that receives the read handle for the pipe.
* @param hWritePipe A pointer to a variable that receives the write handle for the pipe.
* @param lpPipeAttributes A pointer to a SECURITY_ATTRIBUTES structure that determines whether
* the returned handle can be inherited by child processes.
* @param nSize The size of the buffer for the pipe, in bytes.
* @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 CreatePipe(
HANDLEByReference hReadPipe,
HANDLEByReference hWritePipe,
WinBase.SECURITY_ATTRIBUTES lpPipeAttributes,
int nSize);
/**
* Sets certain properties of an object handle.
* @param hObject A handle to an object whose information is to be set.
* @param dwMask A mask that specifies the bit flags to be changed. Use the same constants shown in the description of dwFlags.
* @param dwFlags Set of bit flags that specifies properties of the object handle.
* @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 SetHandleInformation(
HANDLE hObject,
int dwMask,
int dwFlags);
/**
* Retrieves file system attributes for a specified file or directory.
* @param lpFileName The name of the file or directory. Prepend \\?\ to the path for names up to 32,767 wide characters
* @return INVALID_FILE_ATTRIBUTES if the function fails, otherwise the file attributes WinNT.FILE_ATTRIBUTE_*
*/
public int GetFileAttributes(String lpFileName);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -12,10 +12,13 @@
*/
package com.sun.jna.platform.win32;
import java.util.ArrayList;
import java.util.List;
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.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -90,4 +93,56 @@ public abstract class Kernel32Util {
}
return Native.toString(buffer);
}
public static void deleteFile(String filename) {
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Returns valid drives in the system.
* @return
* An array of valid drives.
*/
public static String[] getLogicalDriveStrings() {
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
char buf[] = new char[dwSize.intValue()];
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
List<String> drives = new ArrayList<String>();
String drive = "";
// the buffer is double-null-terminated
for(int i = 0; i < buf.length - 1; i++) {
if (buf[i] == 0) {
drives.add(drive);
drive = "";
} else {
drive += buf[i];
}
}
return drives.toArray(new String[0]);
}
/**
* Retrieves file system attributes for a specified file or directory.
* @param fileName
* The name of the file or directory.
* @return
* The attributes of the specified file or directory.
*/
public static int getFileAttributes(String fileName) {
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return fileAttributes;
}
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -16,13 +16,14 @@ import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMAccess.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMAccess {
public interface LMAccess extends StdCallLibrary {
public static class LOCALGROUP_INFO_0 extends Structure {
public LOCALGROUP_INFO_0() {
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -11,13 +11,15 @@
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMCons.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMCons {
public interface LMCons extends StdCallLibrary {
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
/**
@@ -11,13 +11,15 @@
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMErr.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMErr {
public interface LMErr extends StdCallLibrary {
public static final int NERR_Success = 0;
public static final int NERR_BASE = 2100;
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -11,13 +11,15 @@
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMJoin.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMJoin {
public interface LMJoin extends StdCallLibrary {
/**
* Status of a workstation.
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -19,13 +19,14 @@ 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;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from NTSecApi.h
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class NTSecApi {
public interface NTSecApi extends StdCallLibrary {
/**
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
@@ -193,6 +194,7 @@ public abstract class NTSecApi {
/**
* Get an array of LSA_FOREST_TRUST_RECORD entries.
* @return
* An array of forest trust records.
*/
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
@@ -11,8 +11,10 @@
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.win32.StdCallLibrary;
public abstract class NTStatus {
public interface NTStatus extends StdCallLibrary {
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -23,13 +23,15 @@ 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.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Netapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Netapi32 extends W32API {
public interface Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
@@ -37,13 +39,13 @@ public interface Netapi32 extends W32API {
* 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.
* 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.
* Receives the NetBIOS name of the domain or workgroup to which
* the computer is joined.
* @param BufferType
* Join status of the specified computer.
* 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.
*/
@@ -64,27 +66,27 @@ public interface Netapi32 extends W32API {
* 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.
* 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.
* Specifies the information level of the data.
* @param bufptr
* Pointer to the address of the buffer that receives the
* information structure.
* Pointer to the address of the buffer that receives the
* information structure.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in
* bytes.
* Specifies the preferred maximum length of returned data, in
* bytes.
* @param entriesread
* Pointer to a value that receives the count of elements
* actually enumerated.
* 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.
* 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.
* 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,
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -449,7 +449,7 @@ public abstract class Netapi32Util {
dc.domainName = pdci.dci.DomainName.toString();
dc.flags = pdci.dci.Flags;
dc.name = pdci.dci.DomainControllerName.toString();
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.getPointer());
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,20 +8,23 @@
* 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.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* ntdll.dll Interface.
* @author dblock[at]dblock.org
*/
public interface NtDll extends W32API {
public interface NtDll extends StdCallLibrary {
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -0,0 +1,37 @@
/*
* Copyright 2010 Digital Rapids Corp.
*/
/* Copyright (c) 2010 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.WTypes;
/**
* Definitions from ObjBase.h
* @author scott.palmer
*/
public interface ObjBase {
public static final int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
// With DCOM, CLSCTX_REMOTE_SERVER should be included
public static final int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_INPROC_HANDLER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
public static final int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
}
@@ -0,0 +1,106 @@
/* Copyright (c) 2010 Daniel Doubrovkine, 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.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Ole32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Ole32 extends StdCallLibrary {
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);
/**
* Initializes the COM library for use by the calling thread, sets the thread's
* concurrency model, and creates a new apartment for the thread if one is required.
* @param reserved This parameter is reserved and must be NULL.
* @param dwCoInit The concurrency model and initialization options for the
* thread. Values for this parameter are taken from the COINIT enumeration.
* Any combination of values from COINIT can be used, except that the
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
*/
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
/**
* Closes the COM library on the current thread, unloads all DLLs loaded by
* the thread, frees any other resources that the thread maintains, and
* forces all RPC connections on the thread to close.
*
*/
void CoUninitialize();
/**
* Creates a single uninitialized object of the class associated with a specified CLSID.
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
* @return an HRESULT
*/
HRESULT CoCreateInstance(
GUID rclsid,
Pointer pUnkOuter,
int dwClsContext,
GUID riid,
PointerByReference ppv);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,13 +8,13 @@
* 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.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.W32API.HRESULT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Ole32 Utility API.
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2010 Digital Rapids Corp., All rights reserved.
*/
/* Copyright (c) 2010 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.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Oleaut32.dll Interface.
* @author scott.palmer
*/
public interface Oleaut32 extends StdCallLibrary {
Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary(
"Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* This function allocates a new string and copies the passed string into it.
* @param sz
* Null-terminated UNICODE string to copy.
* @return
* Null if there is insufficient memory or if a null pointer is passed in.
*/
Pointer SysAllocString(String sz);
/**
* This function frees a string allocated previously by SysAllocString,
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
* SysReAllocStringLen.
* @param bstr
* Unicode string that was allocated previously, or NULL. Setting this parameter
* to NULL causes the function to simply return.
*/
void SysFreeString(Pointer bstr);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -17,20 +17,21 @@ 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.HANDLEByReference;
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.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Secur32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Secur32 extends W32API {
public interface Secur32 extends StdCallLibrary {
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
@@ -282,6 +283,34 @@ public interface Secur32 extends W32API {
* 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,
public int QuerySecurityContextToken(CtxtHandle phContext,
HANDLEByReference phToken);
/**
* The ImpersonateSecurityContext function allows a server to impersonate a client by using
* a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken.
* This function allows the application server to act as the client, and thus all necessary
* access controls are enforced.
* @param phContext
* The handle of the context to impersonate. This handle must have been obtained by a call
* to the AcceptSecurityContext function.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or
* SEC_E_UNSUPPORTED_FUNCTION error code.
*/
public int ImpersonateSecurityContext(CtxtHandle phContext);
/**
* Allows a security package to discontinue the impersonation of the caller and restore its
* own security context.
* @param phContext
* Handle of the security context being impersonated. This handle must have been obtained in
* the call to the AcceptSecurityContext function and used in the call to the
* ImpersonateSecurityContext function.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION.
*/
public int RevertSecurityContext(CtxtHandle phContext);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,7 +8,7 @@
* 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.platform.win32;
@@ -85,15 +85,15 @@ public abstract class Secur32Util {
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
SecPkgInfo.ByReference[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
for(SecPkgInfo.ByReference packageInfo : packagesInfo) {
for(SecPkgInfo 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());
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer());
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
@@ -14,12 +14,18 @@ package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Mapping for Shell32.dll API.
* Shell32.dll Interface.
*/
public interface Shell32 extends W32API {
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
W32APIOptions.UNICODE_OPTIONS);
@@ -57,4 +63,14 @@ public interface Shell32 extends W32API {
*/
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
char[] pszPath);
/**
* Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
* The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call
* given a suitable interface definition for IShellFolder
* @param ppshf A place to put the IShellFolder interface pointer
* @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
*/
HRESULT SHGetDesktopFolder( PointerByReference ppshf );
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -8,15 +8,14 @@
* 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.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;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Shell32 Utility API.
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -15,7 +15,7 @@ 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.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
@@ -23,7 +23,7 @@ import com.sun.jna.win32.StdCallLibrary;
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract interface ShellAPI extends StdCallLibrary {
public interface ShellAPI extends StdCallLibrary {
int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE;
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -7,19 +7,20 @@
*
* 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.
* 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;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShlObj.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class ShlObj {
public interface ShlObj extends StdCallLibrary {
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
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2010 Daniel Doubrovkine, 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
@@ -17,13 +17,14 @@ import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Sspi.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public abstract class Sspi {
public interface Sspi extends StdCallLibrary {
/**
* Maximum size in bytes of a security token.

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