Comparar commits

..

836 Commits

Autor SHA1 Mensagem Data
Timothy Wall f0080de225 prepare for release 2013-04-06 06:51:55 -04:00
Timothy Wall e176d09eac distinguish PRs from issues 2013-04-06 06:28:17 -04:00
Timothy Wall 9ff14b0a90 distinguish PRs from issues 2013-04-06 06:27:38 -04:00
Timothy Wall 1b234b6c3b remove non-ascii character 2013-04-06 06:25:19 -04:00
Timothy Wall 84cfea1ac0 make resource prefix available via Platform 2013-04-06 06:14:18 -04:00
Timothy Wall 85d8d08972 update docs 2013-04-06 06:07:54 -04:00
Timothy Wall 5cf120de75 Merge pull request #210 from bertfrees/24f60158d4bf25c3fa57f53ae2ba6fb0c80a1637
OSGi fix for Mac OS X
2013-04-06 02:39:49 -07:00
Timothy Wall bdf38eaf8e fix compile error 2013-04-05 07:28:22 -04:00
Timothy Wall 3823533c17 add support for loading native libraries from classpath (FS or jar) 2013-04-05 05:13:53 -04:00
Timothy Wall fecaf92ec1 auto-generate copyright year 2013-04-05 02:14:06 -04:00
Timothy Wall 830dc666ad avoid NPE 2013-04-04 06:50:30 -04:00
Timothy Wall b7951759ec avoid having to edit/commit file to toggle between maven modes 2013-04-03 05:30:03 -04:00
Timothy Wall ead2c70a1a avoid inadvertent AWT library load 2013-04-03 05:29:22 -04:00
Timothy Wall e0016e875f avoid inadvertent AWT library load 2013-04-03 05:21:05 -04:00
Bert Frees 24f60158d4 OSGi fix for Max OS X 2013-04-01 21:34:58 +02:00
Timothy Wall 910642248d add OSX framework search options 2013-03-30 08:11:06 -04:00
Timothy Wall 6fdb21414d fix #206 2013-03-24 19:44:07 -04:00
Timothy Wall 6178c5c6a0 Merge branch 'master' of github.com:twall/jna 2013-03-24 19:41:25 -04:00
Timothy Wall e7b0c5d05d tweak javadoc dependency for platform target 2013-03-24 18:52:46 -04:00
Timothy Wall 1140b4eed2 fix typo 2013-03-24 14:09:57 -03:00
Timothy Wall 99613775b1 Merge pull request #204 from twall/optimized-struct-init
Avoid superfluous memory allocation when Structure base address provided...
2013-03-24 09:59:59 -07:00
Timothy Wall 13c1a17018 Merge branch 'master' of github.com:twall/jna 2013-03-22 10:39:11 -04:00
Timothy Wall e51a82e19d Fix Carbon library declaration 2013-03-22 10:38:44 -04:00
Timothy Wall 5180a7e092 fix JNI containing classname in performance test 2013-03-22 10:38:08 -04:00
Dan Rollo a2bfccb15b Merge pull request #207 from bhamail/master
remove obsolete comments now that empty Structures are defined as invalid
2013-03-18 20:28:22 -07:00
Dan Rollo 7904663f14 remove obsolete comments now that empty Structures are defined as invalid and test for by StructureTest class. 2013-03-18 23:24:07 -04:00
Timothy Wall 69fbc85665 make conditional read perform auto-read 2013-03-16 10:51:39 -04:00
Timothy Wall 65a246f39b merge from upstream 2013-03-16 10:06:40 -04:00
Timothy Wall 0d9bd6d96b add explicit tests for empty structs and structs with only private fields 2013-03-16 09:56:00 -04:00
Timothy Wall ed58f42176 restore deleted files 2013-03-15 18:42:48 -04:00
Tobias 626bf14b2d Merge pull request #205 from twall/com-branch
some changes regarding COM and Variant support
2013-03-15 03:48:19 -07:00
Timothy Wall 683e7351f0 fix contrib reference to deprecated method 2013-03-15 06:46:23 -04:00
Tobias 5242a7d826 some changes 2013-03-15 11:36:53 +01:00
Timothy Wall f3a384f011 Merge branch 'master' of github.com:twall/jna into optimized-struct-init 2013-03-14 16:35:38 -04:00
Timothy Wall 5267a6ddde add javadoc dependency to platform.jar 2013-03-14 13:56:25 -04:00
Timothy Wall a9f757f39c Merge branch 'master' of github.com:twall/jna into optimized-struct-init 2013-03-14 13:52:41 -04:00
Timothy Wall af1ef9330f fix javadoc errors/warnings 2013-03-14 13:51:58 -04:00
Timothy Wall cf58970bdf remove deprecated methods 2013-03-14 13:39:42 -04:00
Timothy Wall 4595abcebe Merge branch 'master' of github.com:twall/jna 2013-03-14 13:31:37 -04:00
Tobias 4b73c277fa Merge pull request #200 from wolftobias/master
some changes for the Variant date structure
2013-03-14 07:01:23 -07:00
Tobias 9f80a92973 Merge remote-tracking branch 'upstream/master'
Conflicts:
	contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java
	contrib/platform/src/com/sun/jna/platform/win32/OleAuto.java
2013-03-14 14:56:55 +01:00
Dan Rollo b4091b4f45 fix SNAPSHOT publish doc typo 2013-03-08 16:24:08 -05:00
Dan Rollo cb714b9f8b Merge pull request #202 from bhamail/master
Add Publish SNAPSHOT docs
2013-03-08 12:23:09 -08:00
Dan Rollo 0769a8e597 fix typo 2013-03-08 15:21:42 -05:00
Dan Rollo 846cbb3c96 fix typo 2013-03-08 15:20:55 -05:00
Dan Rollo e6d7829ca2 doc format fix 2013-03-08 15:19:23 -05:00
Dan Rollo 404cf22380 doc format fix 2013-03-08 15:17:33 -05:00
Dan Rollo 6c75db5003 add notes on how to publish development SNAPSHOT for pre-release testing. 2013-03-08 15:16:01 -05:00
Tobias 71a8ecfd27 Merge pull request #201 from wolftobias/jnaCOM
Merge the new jnaCOM branch with the master branch to bring the new COM feature to live with the main jna code tree.
2013-03-07 05:25:55 -08:00
Tobias 2582708b2f some fixed and extension for Variant date 2013-03-07 14:14:44 +01:00
Tobias 5587a8fadc fix to VARIANT class 2013-03-07 13:30:09 +01:00
Tobias 22cb28ec50 Update FrequentlyAskedQuestions.md 2013-03-07 13:05:53 +01:00
Timothy Wall c4d9966709 don't check structure memory allocation on direct mappings (yet) 2013-03-03 16:40:31 -05:00
Timothy Wall c69d03a74b more Structure(Pointer) implementations and tests 2013-03-03 10:03:47 -05:00
Timothy Wall 38643d974b update more Structure.newInstance calls 2013-03-02 20:58:38 -05:00
Timothy Wall 00308279df update change log 2013-03-02 14:15:16 -05:00
Timothy Wall 896f4b8b85 used optimized structure+pointer ctor when possible 2013-03-02 12:43:14 -05:00
Timothy Wall ae1bafb39b remove deprecated methods 2013-03-02 12:41:45 -05:00
Daniel Doubrovkine (dB.) 3e2e7ffec7 Merge pull request #197 from headcrashing/WindowMessages
Destroying temporarily created HWND after test
2013-02-24 06:59:08 -08:00
Head Crashing Informatics 46bc91fc63 Destroying temporarily created HWND after test
To demonstrate prevention of resource leaking, this code utilizes the try-finally idiom to destroy tempoarily created HWND even in case of any exceptions or failed assertions.
2013-02-23 18:55:21 +01:00
Daniel Doubrovkine (dB.) fb9e4c6262 Merge pull request #196 from headcrashing/WindowMessages
RegisterWindowMessage
2013-02-23 06:52:02 -08:00
Markus KARG aa043c73e7 Fixed PR number in CHANGES.md 2013-02-23 15:46:43 +01:00
Daniel Doubrovkine (dB.) 68ed3e521e Merge pull request #194 from headcrashing/CLSIDFromProgID
Clsid from prog
2013-02-23 06:37:01 -08:00
Markus KARG b6b3a51d32 Added line to CHANGES.md for this pull request. 2013-02-23 15:31:35 +01:00
Markus KARG 7573196742 Merge branch 'master' of https://github.com/twall/jna into CLSIDFromProgID 2013-02-23 15:27:47 +01:00
Markus KARG b2e16a0ca5 Added info to CHANGES.md about this pull request. 2013-02-23 14:50:20 +01:00
Markus KARG 53809b3c38 Merge branch 'master' of https://github.com/twall/jna into WindowMessages 2013-02-23 14:42:43 +01:00
Daniel Doubrovkine (dB.) 2549728a97 Update CHANGES.md 2013-02-22 14:18:42 -05:00
Daniel Doubrovkine (dB.) 06fde953b1 Merge pull request #192 from headcrashing/master
New Windows Shell API mapping: SHGetSpecialFolderPath
2013-02-22 11:15:40 -08:00
Markus KARG 21b9287cfd Added feature line in CHANGES.md for this pull request. 2013-02-22 19:33:50 +01:00
Markus KARG eeeed87239 Test for CLSIDFromProgID 2013-02-22 17:11:54 +01:00
Markus KARG 97e50d7a35 Mapped RegisterWindowMessage of User32.dll, added User32Util
which wraps registerWindowMessage, createWindow and createWindowEx.
2013-02-22 16:37:58 +01:00
Markus KARG f0195711b5 Mapped GetPrivateProfileString, GetPrivateProfileInt and
WritePrivateProfileString of Kernel32.dll
2013-02-22 15:02:25 +01:00
Markus KARG 68ba4117f6 Mapped SHGetSpecialFolderPath of Shell32.dll 2013-02-21 22:19:39 +01:00
Timothy Wall dbd584d305 skip javah target on skip-native 2013-02-18 12:52:27 -05:00
Tobias e69d7fa485 some changes 2013-02-09 16:57:35 +01:00
Timothy Wall cdb4797fa3 move IUnknownTest to its rightful place (w/rename) 2013-02-07 20:39:24 -05:00
Timothy Wall bd4207dfa4 fix compilation error 2013-02-07 20:32:30 -05:00
Timothy Wall c9493636a9 fix some compilation errors/warnings 2013-02-07 20:29:13 -05:00
Tobias e6d76b9bc8 some util changes 2013-02-07 14:00:58 +01:00
Timothy Wall 49868b8203 use SIZE_T size for size_t 2013-02-07 07:00:00 -05:00
Tobias 528e1bcbe9 some changes 2013-02-06 18:03:09 +01:00
Timothy Wall f0fd47dbdb Merge pull request #185 from wolftobias/master
New implementation to support COM
2013-02-05 18:01:25 -08:00
Timothy Wall e1c2632941 Merge pull request #190 from wolftobias/patch-2
Update www/PlatformLibrary.md
2013-02-05 18:00:57 -08:00
Tobias Wolf ef19ab440b some changes 2013-02-05 22:28:25 +01:00
Tobias 75bb17e11f Update www/PlatformLibrary.md 2013-02-05 11:31:50 +01:00
Tobias 2c2f4bee15 typlib utils 2013-02-05 10:16:39 +01:00
Tobias Wolf 58696f0c2c some changes 2013-02-04 07:05:05 +01:00
Tobias 4130e11693 some changes 2013-02-01 15:28:37 +01:00
Tobias 19de232dd2 some changes 2013-01-31 17:20:37 +01:00
Tobias afb3fb6ab1 some changes 2013-01-30 17:50:36 +01:00
Tobias Wolf 4dda1bcdd1 some changes for typelib parsing 2013-01-29 19:52:40 +01:00
Tobias Wolf c665f2ccb9 some changes 2013-01-27 20:02:17 +01:00
Timothy Wall 1f01a50e09 update javadoc 2013-01-26 07:57:06 -05:00
Timothy Wall 9cc0ce3148 fix string field write issue where native-derived struct is assigned to an inner structure field 2013-01-26 07:32:39 -05:00
Timothy Wall bd0425966f javadoc fixes 2013-01-26 07:31:23 -05:00
Dan Rollo 7089c83878 Merge pull request #188 from bhamail/test-getFieldOrder
Test get field order
2013-01-25 08:03:52 -08:00
Dan Rollo 9511c34c54 update changes 2013-01-25 11:02:09 -05:00
Dan Rollo c6e9d44c7d remove unused reference to peer. 2013-01-25 11:01:57 -05:00
Dan Rollo 3d051ecbb5 Merge pull request #187 from bhamail/test-getFieldOrder
Test runs under linux and Structure fixes all pass, so I will commit this. build.xml changes still need cleanup. Please holler with any other suggestions.
2013-01-24 21:58:39 -08:00
Dan Rollo f0ae20f0b6 kluges to get at least the Structure test to run under linux. This needs cleanup. 2013-01-25 00:39:46 -05:00
Dan Rollo 2c83e4c22b fix getFieldOrder() to return correct field names for X11 structures. 2013-01-25 00:38:23 -05:00
Dan Rollo 07eaffd28f comment out manual test method. 2013-01-24 23:21:06 -05:00
Dan Rollo 8c1f995e4e changes to allow StructureFieldOrderTest to run on linux. Still needs fixes to platform build.xml to allow this to run under linux AND fixes are needed for X11 Structure.getFieldOrder() methods. 2013-01-24 23:16:15 -05:00
Dan Rollo f721075ac3 Merge pull request #186 from bhamail/master
fix platform project compile on linux
2013-01-24 19:54:55 -08:00
Dan Rollo da711cc76b allow platform project to compile on non-windows jvm. 2013-01-24 22:48:49 -05:00
Dan Rollo d9fb94a13d Merge pull request #183 from bhamail/test-getFieldOrder
Test Structure.getFieldOrder()

All Structure warnings are solved, so I'm going to commit this.

BTW, I saw something odd ("has unknown size" error) when instantiating an empty Structure (one with no instance fields). Please see the @todo comments in com.sun.jna.StructureFieldOrderInspectorTest.java. Restore the test: testCheckMethodGetFieldOrderStaticFieldOnlyStatic() to reproduce the behavior.
2013-01-24 18:51:37 -08:00
Dan Rollo 9da1b4528d re-do skip windows tests that will fail if current user is non-admin 2013-01-24 21:12:13 -05:00
Dan Rollo 768ea368a6 re-update changes doc 2013-01-24 20:52:46 -05:00
Dan Rollo 6ff34c29db Revert "update changes doc"
This reverts commit 6d608dd49b.
2013-01-24 20:39:56 -05:00
Dan Rollo acdfd6ea20 Revert "skip test that will fail if user it non-admin"
This reverts commit f10c45b1f8.
2013-01-24 20:38:22 -05:00
Dan Rollo b9bf45ecce Revert "skip test that will fail if current user is non-admin"
This reverts commit be0e5b51cd.
2013-01-24 20:37:54 -05:00
Dan Rollo b5df2c589a Revert "skip test that will fail if user is non-admin"
This reverts commit f8d521999c.
2013-01-24 20:37:32 -05:00
Dan Rollo dff973e9ee Revert "Resolve merge conflicts."
This reverts commit 4a0644f3cd, reversing
changes made to f8d521999c.
2013-01-24 20:36:20 -05:00
Dan Rollo 4a0644f3cd Resolve merge conflicts. 2013-01-24 17:51:09 -05:00
Dan Rollo f8d521999c skip test that will fail if user is non-admin 2013-01-24 17:27:16 -05:00
Dan Rollo be0e5b51cd skip test that will fail if current user is non-admin 2013-01-24 17:20:27 -05:00
Dan Rollo f10c45b1f8 skip test that will fail if user it non-admin 2013-01-24 17:05:44 -05:00
Dan Rollo 6d608dd49b update changes doc 2013-01-24 16:55:37 -05:00
Dan Rollo 70658a0279 add commented example of test for individual Structure class. 2013-01-24 16:33:10 -05:00
Dan Rollo f3ceebecfd fix getFieldOrder() to return correct field name: grpi3_group_sid instead of grpi3_group_id. 2013-01-24 16:26:30 -05:00
Dan Rollo 251eae5cac include super classes when looking for fields and getFieldOrder() method. 2013-01-24 16:15:41 -05:00
Dan Rollo 07b88af439 ignore ctor errors in stuctures manually validated by wolftobias. 2013-01-24 15:46:53 -05:00
Dan Rollo 959616e992 patch from twall: addresses the missing default constructor warnings. 2013-01-24 15:25:05 -05:00
Dan Rollo f7b2f910b7 ignore static fields as per twall notes. 2013-01-24 15:10:00 -05:00
Dan Rollo 4220566fb4 support compiling platform project with 64bit jvm. 2013-01-24 14:05:46 -05:00
Dan Rollo 415179f9b7 fix compiler warning from invalid chars in javadoc, like: User32.java:1511: warning: unmappable character for encoding UTF8 2013-01-24 13:56:11 -05:00
Tobias Wolf 9a9f8cbd99 added some Excel example 2013-01-24 15:17:23 +01:00
Tobias Wolf 319f6e9047 some cosmetic changes 2013-01-24 13:47:55 +01:00
Tobias Wolf 9b7d02618e some changes to the Word implementation 2013-01-24 13:05:09 +01:00
Dan Rollo ed2f4d3b05 add unit test to platform project to scan for Structure.getFieldOrder() problems. 2013-01-24 02:34:21 -05:00
Dan Rollo fef81ce17f change ignore constructor error list to be list of classname prefixes. allows for ignoring all inner classes of a given class. 2013-01-24 02:22:54 -05:00
Dan Rollo 1942640b2d add batch version of check method 2013-01-24 02:07:44 -05:00
Dan Rollo d8232c9122 allow user supplied list of classes for which to ignore constructor errors. 2013-01-24 01:45:58 -05:00
Dan Rollo 1a8b3b55d8 handle inaccessible getFieldOrder() method. 2013-01-24 01:32:55 -05:00
Dan Rollo 156d2015a5 try adding reflections test libs via file name pattern. 2013-01-24 01:09:43 -05:00
Dan Rollo 8cbbb1eec8 try adding reflections test lib file name pattern. 2013-01-24 01:06:31 -05:00
Dan Rollo 351d68faf6 try adding reflections test libs via *.jar pattern. 2013-01-24 01:04:56 -05:00
Dan Rollo 6d0651acbc add jna test classes to test classpath so we can use StructureFieldOrder scanner. 2013-01-24 00:56:02 -05:00
Dan Rollo 7bd83c65f9 remove stale imports 2013-01-24 00:49:15 -05:00
Dan Rollo dfe8862e0f add jna test classes to test classpath so we can use StructureFieldOrder scanner. 2013-01-24 00:44:21 -05:00
Dan Rollo e89e70c9a6 add helper method 2013-01-24 00:32:24 -05:00
Dan Rollo 8f06411357 remove unneeded cast 2013-01-24 00:04:16 -05:00
Dan Rollo 011a2eaed7 testToScanForGetFieldOrderIssues 2013-01-24 00:02:39 -05:00
Dan Rollo f29b2f5c51 Add test utility to scan for Structure.getFieldOrder() issues. 2013-01-23 23:17:33 -05:00
twall 1a9d2daef3 Update CHANGES.md 2013-01-23 11:40:33 -05:00
twall 662f961d91 Announce DLL-based callbacks
Somehow forgot to include this when 3.5 went out.
2013-01-23 11:40:00 -05:00
twall 7e06d1ab81 Update CHANGES.md 2013-01-23 11:32:13 -05:00
Tobias Wolf 6a22e39d4c some new changes 2013-01-21 17:08:15 +01:00
Daniel Doubrovkine ff27aaffe3 Merged from xwizard/jna. 2013-01-21 08:22:55 -05:00
twall 601f1026eb Add line for linux-amd64 rebuild 2013-01-21 08:17:33 -05:00
xwizard bdf59518fb Update CHANGES.md 2013-01-21 11:09:31 +01:00
Daniel Doubrovkine (dB.) 3f7e52a4d9 Merge pull request #178 from davidmc24/platform-userinfo10
platform: add mapping of USER_INFO_10 structure to LMAccess
2013-01-20 14:29:41 -08:00
David M. Carr 8da7dc2e56 changes: add entry for addition of USER_INFO_10 2013-01-20 15:00:26 -05:00
xwizard b1cda9cd72 Fixes "XDestroyWindowEvent does not provide enough names" error 2013-01-20 20:48:20 +01:00
David M. Carr 811d025b88 platform tests: add coverage for Netapi32.NetUserEnum with user level 10 2013-01-19 22:27:09 -05:00
David M. Carr c7e96bd3c0 platform: add mapping of USER_INFO_10 structure to LMAccess 2013-01-19 22:20:45 -05:00
Timothy Wall bc67864e57 compile linux-amd64 against glibc 2.3.6, with GLIBC_2.2.5 as newest symbol 2013-01-19 13:10:48 -05:00
twall 96a4450d70 Update www/FrequentlyAskedQuestions.md 2013-01-18 19:16:32 -05:00
twall 8591ebd55f Update www/FrequentlyAskedQuestions.md 2013-01-18 15:33:04 -05:00
Tobias 16b6d591d5 some changes regarding right structure size 2013-01-18 15:05:51 +01:00
Tobias 5e3e485d4d some changes 2013-01-18 11:04:17 +01:00
Tobias Wolf f7bd979d1b some changes 2013-01-17 18:02:52 +01:00
Tobias 176b44fd65 some changes 2013-01-17 16:34:32 +01:00
Tobias Wolf 548714343a some changes 2013-01-15 20:26:04 +01:00
twall 8ce6297b97 Merge pull request #175 from bnbeckwith/patch-1
Update contrib/platform/src/com/sun/jna/platform/unix/X11.java
2013-01-15 04:33:43 -08:00
Tobias 52897e2693 some changes 2013-01-15 13:20:58 +01:00
Tobias Wolf d5582d6181 fix for Variant structure
- the vt variable was from type Integer, correct is type USHORT
2013-01-14 20:16:49 +01:00
Tobias Wolf d9868285a0 some changes 2013-01-14 19:54:47 +01:00
Tobias Wolf 429bed5aba datatypes overworked 2 2013-01-14 17:49:58 +01:00
Tobias Wolf 3442e07023 datatypes over-worked 2013-01-14 17:43:07 +01:00
Benjamin Beckwith fef7e3786e Update contrib/platform/src/com/sun/jna/platform/unix/X11.java
Added "event" to the list of fields for XDestroyWindowEvent's getFieldOrder() method.
2013-01-14 11:22:04 -05:00
Tobias Wolf e77f69908a changed brecord struct 2013-01-14 14:22:46 +01:00
Tobias c2be88fd9c some changes 2013-01-14 12:32:26 +01:00
Tobias 85f8c409de some changes in Variant 2013-01-14 11:18:25 +01:00
Tobias ad442d822d some changes 2013-01-11 16:28:49 +01:00
Tobias bbfc36e8c6 some changes 2013-01-11 16:19:07 +01:00
Tobias 136dbaa257 some changes to Variant 2013-01-11 14:05:13 +01:00
Tobias b6215a24b5 some changes in the Variant structure 2013-01-10 14:34:44 +01:00
Tobias Wolf c62b73bdf5 some changes 2013-01-09 14:48:10 +01:00
Tobias Wolf 2832feaa8e Additional changes to the com implementation 2013-01-03 19:37:31 +01:00
Tobias Wolf f90fd1288b added MS COM support and MS Office samples 2013-01-01 14:14:56 +01:00
Tobias Wolf 2e27312ea0 Variant structure added 2013-01-01 14:14:55 +01:00
unknown f2b6eb5e7a Updated CHANGES. 2012-12-11 20:35:01 -05:00
Daniel Doubrovkine 24439832da Merge branch 'master' of https://github.com/wolftobias/jna into wolftobias 2012-12-11 20:09:02 -05:00
Daniel Doubrovkine (dB.) 89c1f7fa4c Removed extra dot. 2012-12-10 16:02:20 -05:00
Tobias Wolf b78eef7789 add unit test to guid structure 2012-12-10 15:20:38 +01:00
Tobias Wolf aaa7fd0123 fixed some changes asked by the jna team 2012-12-09 19:30:44 +01:00
Tobias Wolf 8b17879219 Fixed some problems with the guid structure
- Now the java guid structure can be used directly as alternative to
'Ole32Util.getGUIDFromString()'.
- The listening for usb devices is now working also with filter usage
2012-12-08 10:51:48 +01:00
Tobias Wolf 6ab495c8eb extension for listening to windows devices (usb) 2012-12-07 16:41:05 +01:00
twall 03be32b103 Add Native.register() call. 2012-12-05 09:34:36 -05:00
Tobias Wolf 4218a07549 code extension for creating and registering win32 windows
Create new code for registering new window classes and creating window
example. Listening for win32 window events. Listening for logoff/logon
events. Created also new api for 'Wtsapi32.dll'.
2012-12-01 17:46:10 +01:00
Dan Rollo 17a26e7dbc Merge pull request #160 from bhamail/master
re-fix broken download links (to maven central for now). See Issue #158
2012-11-21 18:33:22 -08:00
Dan Rollo 580dd76041 re-fix broken download links (reported by hanneshorn). For now pointing to maven central copies. Not sure why github blob links work, then don't. 2012-11-21 21:30:13 -05:00
Dan Rollo 74ae45c476 re-fix broken download links (reported by hanneshorn). For now pointing to maven central copies. Not sure why github blob links work, then don't. 2012-11-21 21:26:35 -05:00
Dan Rollo d6d99a9b6b re-fix broken download links (reported by hanneshorn). For now pointing to maven central copies. Not sure why github blob links work, then don't. 2012-11-21 21:25:02 -05:00
Dan Rollo 3854e50e64 Merge pull request #159 from bhamail/master
fix dead download links.
2012-11-21 18:15:57 -08:00
Dan Rollo a8966e8dcf fix broken download links (reported by hanneshorn). 2012-11-21 21:13:15 -05:00
twall 98c7993a41 Bump UnsatisfiedLinkError help 2012-11-09 09:32:48 -05:00
twall 662763fdcc Indicate getFieldOrder() usage 2012-11-09 09:31:13 -05:00
twall 47211510b0 Use getFieldOrder() 2012-11-09 09:29:32 -05:00
Dan Rollo 997ff2e7ed Merge pull request #157 from bhamail/master
add release step info to exclude committing platform specific jar.
2012-11-08 09:07:45 -08:00
Dan Rollo 32d19f0a61 add release step info to exclude committing platform specific jar. 2012-11-08 12:04:41 -05:00
Dan Rollo a5ce77f5c4 add release step info to exclude committing platform specific jar. 2012-11-08 12:01:30 -05:00
Dan Rollo 464e03172f add release step info to exclude committing platform specific jar. 2012-11-08 11:55:51 -05:00
Dan Rollo d9ad71341c Merge pull request #156 from bhamail/fix-snapshot-deploy
Fix snapshot deploy
2012-11-07 13:51:22 -08:00
Dan Rollo 4eedc67bf0 make regex global to replace both 'version' tag values (artifact version and jna dependency version) in pom-platform.xml. 2012-11-07 16:47:25 -05:00
Dan Rollo c96712eadc fix deploy snapshot target to include sources and javadoc. 2012-11-07 16:45:30 -05:00
Timothy Wall 3b2fd06dc0 compile against GNU C Library 2.3.6 2012-10-31 20:50:38 -04:00
Dan Rollo 296b97d58a Merge pull request #153 from bhamail/master
Prep for next development iteration.
2012-10-27 18:44:07 -07:00
Dan Rollo 363db04779 Increment version for next development iteration. 2012-10-27 21:20:03 -04:00
Dan Rollo 13f2419f33 For some reason, depenency version on jna didn't get updated in pom-platform.xml, so update now 2012-10-27 20:57:32 -04:00
Dan Rollo ec9868b85b Merge pull request #152 from bhamail/master
Release 3.5.1 - dist jars, etc.
2012-10-27 17:40:39 -07:00
Dan Rollo a31faf3026 Release 3.5.1 - commit 'ant clean dist' generated files. 2012-10-27 20:35:00 -04:00
Dan Rollo e1fda6694b Release 3.5.1 - add notes about 'ant clean dist' additional files to commit. 2012-10-27 20:33:04 -04:00
Dan Rollo 2fb117023b Release 3.5.1 - add note about 'ant clean dist'. 2012-10-27 15:28:19 -04:00
Dan Rollo d2a70dac78 Release 3.5.1 - add note about manual delete of platform.jar 2012-10-27 14:54:00 -04:00
Dan Rollo 18218163fd Release 3.5.1 - Update README.md links 2012-10-27 14:45:49 -04:00
Dan Rollo fccab0ac15 Release 3.5.1 - set release versions, update notes 2012-10-27 14:40:39 -04:00
Daniel Doubrovkine 02a01db39a Made 3.5.0 links go to Maven. 2012-10-27 08:24:40 -04:00
Dan Rollo bd950aa654 Merge pull request #149 from bhamail/master
update release docs
2012-10-24 20:59:50 -07:00
Dan Rollo 32758ee8e2 add note to send release notice. 2012-10-24 23:57:35 -04:00
Dan Rollo 0c79114d30 typo 2012-10-24 23:57:18 -04:00
Dan Rollo 43b426410d update release docs to include incrementing version for next development iteration. 2012-10-24 23:52:08 -04:00
Dan Rollo 26de4b0dd0 update release notes to include incrementing version for next development iteration. 2012-10-24 23:51:09 -04:00
Dan Rollo 58243488fc Merge pull request #148 from bhamail/master
revert publish sources SNAPSHOT jar. Only do jars for now.
2012-10-24 20:01:40 -07:00
Dan Rollo 489b5ddde1 Merge remote branch 'upstream/master' 2012-10-24 22:59:51 -04:00
Dan Rollo 0d0d36d599 revert: deploy sources and javadoc SNAPSHOT jars. Only do jar for now. 2012-10-24 22:58:57 -04:00
Dan Rollo 2d454fb7dc Merge pull request #147 from bhamail/master
also deploy sources and javadoc SNAPSHOT jars.
2012-10-24 18:58:49 -07:00
Dan Rollo 5097ed533f update 'deploy snapshot' target to also deploy sources and javadoc SNAPSHOT jars. 2012-10-24 21:56:59 -04:00
Dan Rollo 160dee7d84 Merge pull request #146 from bhamail/master
increment to next development version (if "-SNAPSHOT" suffix causes problems, I will remove it).
2012-10-24 17:40:43 -07:00
Dan Rollo 7395736b9f increment jna.version to next development version (3.5.1-SNAPSHOT). 2012-10-24 20:10:59 -04:00
Daniel Doubrovkine (dB.) b64c489135 Update CHANGES.md 2012-10-24 19:11:14 -03:00
Daniel Doubrovkine (dB.) fffc3f0f7c Merge pull request #145 from aikidojohn/master
Fixing Netapi32Util.getDomainTrusts() includes "empty" domain object
2012-10-24 15:10:00 -07:00
John Hite 5dd4e0c846 Updating CHANGES.md 2012-10-24 17:20:44 -04:00
John Hite e32ae1cae6 Fixing the DOMAIN_CONTROLLER_INFO structure. It was missing a field declaration. This should fix the getDC method and unit test 2012-10-24 17:09:32 -04:00
John Hite 8771dce348 Fixing null values in first domain trust array entry 2012-10-24 16:15:50 -04:00
Daniel Doubrovkine (dB.) 3ac6f75611 Update www/Contributing.md 2012-10-20 17:33:17 -03:00
Dan Rollo f88d243071 Merge pull request #143 from bhamail/master
Release 3.5.0 - dist jars and doc links
2012-10-18 18:53:11 -07:00
Dan Rollo feb7b88279 Release 3.5.0 - Update README.md, commit and push. 2012-10-18 21:33:40 -04:00
Dan Rollo 070b47e825 Release 3.5.0 - Run ant dist target. Commit and push generated jar files in dist. Includes new jna-min.jar. 2012-10-18 21:25:14 -04:00
Dan Rollo c1289c07be Merge pull request #141 from bhamail/master
typo
2012-10-15 09:12:47 -07:00
Dan Rollo e68fd9dfaf doc typo 2012-10-15 12:00:35 -04:00
twall f23a4bf9d5 Merge pull request #139 from trespasserw/patch-1
Diagnostic for temp jnidispatch file creation
2012-10-13 06:05:36 -07:00
Roman Shevchenko b769daec0c Diagnostic for temp jnidispatch file creation
Nesting underlying exception will provide more insight
on what may caused an error.
2012-10-11 14:38:59 +03:00
Daniel Doubrovkine (dB.) 4e36f71f3a Merge pull request #137 from danwi/registry_get_empty_values
Add issue #135 to CHANGES.md
2012-10-08 08:32:02 -07:00
Daniel Wiklund 25db8ccfa7 Add issue #135 to CHANGES.md 2012-10-08 16:56:44 +02:00
Daniel Doubrovkine (dB.) 5c2923c0af Merge pull request #136 from danwi/registry_get_empty_values
Add fix for issue #135 in Advapi32Util (reading empty values)
2012-10-08 07:33:25 -07:00
Daniel Wiklund 018ad7f2c0 Add fix for issue #135 in Advapi32Util (reading empty values)
With this fix it is possible to read values from registry of the following
types even when the size of the value is 0:

REG_SZ
REG_EXPAND_SZ
REG_MULTI_SZ
REG_NONE
REG_BINARY (fixed by earlier committer)

Advapi32UtilTest updated with unit test triggering the bug.
2012-10-08 16:16:30 +02:00
Timothy Wall c1a7fd7267 Merge branch 'master' of github.com:twall/jna 2012-10-06 11:49:59 -04:00
Timothy Wall 3c086de42c add 'min' jar to dist 2012-10-06 11:49:09 -04:00
Timothy Wall b48390fc1e note platforms where test fails 2012-10-06 10:30:50 -04:00
Timothy Wall 136fe02333 Merge branch 'master' of github.com:twall/jna 2012-10-06 09:01:54 -04:00
Timothy Wall 5f9d100b2d attach native thread as daemon to avoid tests hanging on exit 2012-10-06 09:01:30 -04:00
twall 176f3f32d4 Update www/FrequentlyAskedQuestions.md 2012-10-06 09:47:27 -03:00
twall 2667202a3f Move native long != Java long to top of list 2012-10-06 09:46:50 -03:00
Timothy Wall 245eb88b40 fix #128, use 16-bit mask for upper/lower parts of DWORD 2012-10-06 00:49:17 -04:00
Timothy Wall d51479c357 update changes, fixes #113, fixes #114 2012-10-06 00:44:07 -04:00
Timothy Wall 7a583b1aaa apply PR #114, support for gnu/kfreebsd 2012-10-06 00:38:56 -04:00
Timothy Wall eaff9bd176 fixes #129 2012-10-05 06:58:14 -04:00
Timothy Wall da4d941906 add dlopen mods to changelog 2012-10-05 05:48:30 -04:00
Dan Rollo ed94e60da3 Merge pull request #132 from bhamail/maven-cleanup
note maven changes
2012-10-04 19:24:38 -07:00
Dan Rollo 2fe6c956b4 note maven changes 2012-10-04 22:22:45 -04:00
Timothy Wall 559c7d7f13 add library open options 2012-10-04 21:58:28 -04:00
Timothy Wall 6b7f2eeadb catch all AWT loading errors 2012-10-02 07:26:58 -04:00
Dan Rollo 7bda1b3d0e Merge pull request #131 from bhamail/maven-cleanup
Maven cleanup
2012-10-01 17:10:45 -07:00
Dan Rollo d516b01c75 Add note about settings.xml location. 2012-10-01 20:07:45 -04:00
Dan Rollo 08c579f0cb Add note about settings.xml location. 2012-10-01 20:06:33 -04:00
Timothy Wall c231069066 fix typos 2012-09-29 11:26:17 -04:00
Timothy Wall ec16947808 update w32ce-arm build, native 2012-09-29 09:13:39 -04:00
Dan Rollo 2d61573175 Merge pull request #126 from bhamail/maven-cleanup
Maven cleanup
2012-09-27 15:06:49 -07:00
Dan Rollo 507c065c0e fix typo 2012-09-27 17:47:18 -04:00
Dan Rollo cf6b6299e0 Keep pom-platform.xml version tag in since automatically (same as pom.xml version tag). Update release docs to match. Add a note that 'deploy' target only works for SNAPSHOT. 2012-09-27 17:45:31 -04:00
Dan Rollo 862a746170 Update maven release step links. 2012-09-27 15:02:00 -04:00
Dan Rollo 14717ce21f Update maven release steps. 2012-09-27 14:59:06 -04:00
Dan Rollo 72aade4f8f fix typo 2012-09-27 14:52:35 -04:00
Dan Rollo fbf75539f9 fix typo 2012-09-27 14:51:45 -04:00
Dan Rollo 879402d020 md format cleanup 2012-09-27 14:49:15 -04:00
Dan Rollo 7296f2213d Add step in release process to update the pom <version> values to match the version (jna.version) in build.xml. 2012-09-27 14:44:25 -04:00
Dan Rollo fb243c6cf5 Add reference to java.net maven repo docs. 2012-09-27 13:50:47 -04:00
Dan Rollo 20d1a720ce Add slash to urls, to match doc's examples. 2012-09-27 13:50:22 -04:00
Dan Rollo ea12e0755b settings.xml example 2012-09-26 22:37:48 -04:00
Dan Rollo 83cc22a24c settings.xml example 2012-09-26 22:36:44 -04:00
Dan Rollo c795c80439 Go back to using java.net maven repo. Add settings.xml example. 2012-09-26 22:31:36 -04:00
Dan Rollo edab625da6 Change deploy snapshot target to include platform jar. 2012-09-26 11:33:36 -04:00
Dan Rollo 9f9240391b Add failonerror=true to mvn calls so ant build will fail if mvn goal fails. 2012-09-25 21:11:10 -04:00
Dan Rollo 4fbbc6b42a comment cleanup 2012-09-25 21:01:45 -04:00
Dan Rollo cdbc379608 comment cleanup 2012-09-25 20:59:38 -04:00
Dan Rollo bfeac30452 Add warning about quiet mvn failures. 2012-09-25 20:54:08 -04:00
Dan Rollo 2e7d188afa Add warning about quiet mvn failures. 2012-09-25 20:53:39 -04:00
Dan Rollo d291bd52cd Extract maven-gpg-plugin version to common property. Add 'useagent' so will be prompted for gpg passphrase. 2012-09-25 20:45:47 -04:00
Dan Rollo d8e8fd09a6 Remove obsolete maven artifact files. 2012-09-25 19:55:52 -04:00
Dan Rollo d66471e4c0 Restore 'depends' to maven targets - some jars are not banked in 'dist'. Make maven artifact jar names more consistent. Only include files (src, javadoc) for the specific project (jna or platform). 2012-09-25 19:49:54 -04:00
Dan Rollo bb7d364f45 Update maven repo URL's to use sonatype for publishing to central repo. Remove 'depends' from maven deploy and stage tasks - will use what is in 'dist' folder. 2012-09-25 17:19:34 -04:00
Dan Rollo f9f8474e7f Add maven ant tasks jar to lib dir for use in deploying maven artifacts. Update maven repo URL's to use sonatype for publishing to central repo. Remove 'depends' from maven deploy and stage tasks - will use what is in 'dist' folder. 2012-09-25 17:05:47 -04:00
Dan Rollo e2cac3a280 Remove unused tags, add dependency to jna 2012-09-25 12:45:51 -04:00
Dan Rollo d6b5c2c797 Remove unused tags 2012-09-25 12:00:36 -04:00
twall c0e51cb47f Update www/DirectMapping.md 2012-09-25 11:57:04 -03:00
twall 03f054b474 Update www/DirectMapping.md 2012-09-25 11:56:18 -03:00
twall 511676e0e9 Update www/GettingStarted.md 2012-09-25 08:11:06 -03:00
twall 94ac8af162 Update www/GettingStarted.md 2012-09-25 08:08:43 -03:00
twall a814936bd7 Note direct mapping and link 2012-09-25 08:06:52 -03:00
twall e42b2ca09d Link directly to examples 2012-09-25 08:02:43 -03:00
Timothy Wall 7be159d0c2 update solarix/intel natives 2012-09-24 19:33:02 -04:00
Timothy Wall c53c384096 update sunos natives 2012-09-24 23:46:00 +02:00
dblock 6a52c22a02 Moved some hanging docs into www. 2012-09-24 09:09:53 -04:00
Daniel Doubrovkine 6f30debd34 Minor prettifications to CHANGES. 2012-09-23 18:43:24 -04:00
Timothy Wall d400921e17 Merge branch 'master' of github.com:twall/jna 2012-09-23 17:30:28 -04:00
Timothy Wall e95b37e5de update android-arm native 2012-09-23 17:29:51 -04:00
Timothy Wall b9cc27c1ad update win32-x86 native 2012-09-23 15:14:11 -04:00
Timothy Wall c8852f7c44 update win32-x86 native 2012-09-23 14:44:22 -04:00
Timothy Wall 18b0700337 obsolete outdated native jars, update darwin 2012-09-23 14:08:04 -04:00
Timothy Wall 8d535e72c7 update win32-amd64 native 2012-09-23 12:43:56 -04:00
Timothy Wall 2f51fc68cb fix file perms 2012-09-23 09:28:00 -04:00
Timothy Wall 1f1972bf0e remove msvc90 dependency, spurious '-g' flags in libffi, fix compiler warnings against dlmalloc.c 2012-09-23 08:37:30 -04:00
Timothy Wall e91fbd35c2 tweaks for win32-amd64 build 2012-09-23 02:24:52 -04:00
Timothy Wall f46c5ffc2b w32 tweaks 2012-09-22 22:40:33 -04:00
Timothy Wall a9f90b508a fix build on w32 2012-09-22 21:03:29 -04:00
Timothy Wall 7dd96c6978 fix build on win32 2012-09-22 20:45:03 -04:00
Timothy Wall 0c888d992b accommodate makefile variable overrides from ant or environment 2012-09-22 19:58:14 -04:00
Timothy Wall 14da21e9f9 Merge branch 'master' of github.com:twall/jna 2012-09-22 17:06:20 -04:00
Timothy Wall 019e861539 merge android branch 2012-09-22 17:05:24 -04:00
Kristian Rosenvold 79d208096b o Added first (untested) verison of how to publish to maven central 2012-09-22 11:32:47 +02:00
Timothy Wall 28c4c5fef5 merge from upstream 2012-09-21 06:57:14 -04:00
Timothy Wall 5e211134d5 merge from master 2012-09-21 06:55:08 -04:00
Timothy Wall 310e829d70 note changes 2012-09-21 00:29:29 -04:00
Timothy Wall 3d0040a183 check more thoroughly for unanticipated exceptions 2012-09-20 23:57:20 -04:00
Timothy Wall bbb0501f76 properly propagate exceptions through native code 2012-09-20 23:41:03 -04:00
Timothy Wall 641b7aa3ad fix crash on win64 2012-09-20 22:45:22 -04:00
Timothy Wall 1572b12f75 merge from master 2012-09-20 17:37:25 -04:00
Timothy Wall 689ddc493f android doesn't support shlib jar unpack; place in a convenient location instead 2012-09-20 17:28:33 -04:00
Timothy Wall cb05293c11 clean up thread termination handling 2012-09-20 16:19:25 -04:00
Timothy Wall d5e2ee902d update change log 2012-09-20 15:59:14 -04:00
Timothy Wall b9995b2ad0 w32 thread auto-cleanup 2012-09-20 15:02:07 -04:00
Timothy Wall bd243519df w32 implementation 2012-09-20 13:52:34 -04:00
Timothy Wall f11614bc27 simplified thread-local destructor (pthreads) 2012-09-20 13:17:47 -04:00
Timothy Wall 58a5185c20 auto-cleanup of attached callback threads 2012-09-20 08:41:57 -04:00
Timothy Wall e92ff82c19 update android instructions 2012-09-20 07:21:36 -04:00
Timothy Wall c4c07d7878 fixes issue #121 2012-09-20 01:17:55 -04:00
Timothy Wall e07ed3082d clean up some var usage 2012-09-20 01:14:09 -04:00
Timothy Wall 5728822dad tweak formatting 2012-09-19 13:49:32 -04:00
Timothy Wall fd13022f7c don't copy out-of-date.jar to dist, copy native jars *only* directly from lib/native 2012-09-19 11:23:39 -04:00
Timothy Wall 296eaec0e6 perform cross-builds into dedicated build directory 2012-09-19 10:28:45 -04:00
Timothy Wall 8b8672214c add android native jar 2012-09-19 10:08:04 -04:00
Timothy Wall 2f662bcf6d remove obsolete setFieldOrder references 2012-09-19 10:03:39 -04:00
Timothy Wall 35f12b7027 merge from master 2012-09-19 09:51:01 -04:00
Timothy Wall 719fab1ad2 fix main class reference 2012-09-18 22:38:44 -04:00
Timothy Wall 67ffdd5168 pushed wrong versions of demo jars 2012-09-18 22:32:34 -04:00
Timothy Wall afc3fe3687 update demos to include full native libs 2012-09-18 22:27:14 -04:00
Timothy Wall 14dbeda4ed fix broken demo jars 2012-09-18 22:24:28 -04:00
Timothy Wall f5ee066cc0 demos must be in same directory as jna.jar to run properly 2012-09-18 20:43:43 -04:00
Timothy Wall ad65bcccfb avoid spurious errors when common osx frameworks don't actually exist 2012-09-18 20:36:05 -04:00
Timothy Wall fab66d7d49 search additional OSX paths 2012-09-18 18:49:40 -04:00
Timothy Wall d78c38e4e2 update changelog 2012-09-19 00:14:22 +02:00
Timothy Wall 21cecef8ef fix crash with native mapped callback args 2012-09-18 21:58:39 +02:00
Timothy Wall 3e8511fbc6 Merge branch 'master' of github.com:twall/jna 2012-09-18 09:34:58 -04:00
Timothy Wall 21863e190d use upstream libffi as subtree instead of separate local copy 2012-09-18 09:28:54 -04:00
Timothy Wall fb84300563 Merge libffi as native/libffi 2012-09-18 09:06:50 -04:00
Timothy Wall a8de00b8e5 fix MSVC dll callbacks build (mingw64 required) 2012-09-17 07:23:01 -04:00
Timothy Wall 5fd52be589 add missing file 2012-09-16 15:47:12 -04:00
Timothy Wall 6335fef0b1 fix build for MSVC express 10 2012-09-16 13:24:35 -04:00
Daniel Doubrovkine 3455742d89 The javadoc and src-mvn.zip should be ignored; out-of-date.jar is used to wipe all the native binaries when there's an incompatible JNI change. 2012-09-15 22:08:25 -04:00
Timothy Wall 6ba364f64f Merge branch 'master' of github.com:twall/jna into dll-callback 2012-09-15 21:58:55 -04:00
Daniel Doubrovkine 164da6cf1c Minor updates to CHANGES. 2012-09-15 21:28:33 -04:00
Daniel Doubrovkine 1b6bc6342e Re-added missing declaration. 2012-09-15 21:26:54 -04:00
Daniel Doubrovkine bde74fdccf Merged 3.5.0 from master. 2012-09-15 21:15:47 -04:00
Timothy Wall 6dd612162d synch with master 2012-09-15 17:58:44 -04:00
Timothy Wall 2ff4d20fad require structure field order 2012-09-15 17:52:01 -04:00
unknown fbcd02ae6e Merge branch 'master' of github.com:twall/jna into netapi32-fixes 2012-09-15 09:31:01 -04:00
Timothy Wall 6de51cdf5a move field validation out of layout derivation 2012-09-14 21:10:48 -04:00
unknown e97b1df6ee Merge branch 'master' of github.com:twall/jna into netapi32-fixes 2012-09-14 07:53:37 -04:00
Timothy Wall 65d68b8d70 avoid using deprecated setTypeMapper 2012-09-14 07:00:55 -04:00
Daniel Doubrovkine f915ec7e05 Merge branch 'master' of github.com:twall/jna into netapi32-fixes 2012-09-08 20:39:06 -04:00
Timothy Wall 44b4bc0cac fix gcc version check, avoid deprecated function in structure test 2012-09-08 16:27:08 -04:00
Daniel Doubrovkine 2a6ac9a20d Fixed ANT build and package name. 2012-09-08 16:22:52 -04:00
Daniel Doubrovkine 076298e343 Merged from master. 2012-09-08 16:11:47 -04:00
Timothy Wall 1c3ab0f80f fix javadoc errors 2012-09-08 16:04:27 -04:00
Timothy Wall a0ae2836d9 merge from upstream 2012-09-08 15:02:25 -04:00
Timothy Wall 2309762aca fix broken Structure.setFieldOrder issue 2012-09-08 11:07:05 -04:00
Daniel Doubrovkine e4d89f7087 Fixed typos. 2012-09-08 08:42:36 -04:00
Daniel Doubrovkine 44c41b6faf Fix: Netapi32Test broken. 2012-09-08 08:41:57 -04:00
Daniel Doubrovkine 8003de03ec Fix: w32keyhook package to make Eclipse happy. 2012-09-08 08:40:58 -04:00
twall c5ae6a3cbb Merge pull request #117 from phailwhale22/master
Closes issue #116
2012-09-07 16:34:22 -07:00
twall 4581cb2f61 Avoid invalid 3.4.2 build 2012-09-07 20:32:46 -03:00
phailwhale22 804795c5f8 fix for issue #116 (continued yet again)
I'm failing hard... ok to merge? Indentation was fixed and I removed the
try block.
2012-09-07 18:26:30 -04:00
Timothy Wall efce3ec30e update OSX native reference 2012-09-06 07:27:45 -04:00
Timothy Wall e56835fccc fix native jar file refresh 2012-09-06 07:25:42 -04:00
Timothy Wall 4f495756aa Merge branch 'master' of github.com:twall/jna 2012-09-06 07:05:38 -04:00
Timothy Wall 9dce43affa fix file perms 2012-09-06 07:03:33 -04:00
Timothy Wall 7200f90633 fix native jar propagation 2012-09-06 07:02:39 -04:00
Daniel Doubrovkine (dB.) 861e4cc3bc Update www/Contributing.md
Updated link to Windows Development Environment.
2012-09-05 11:46:33 -03:00
phailwhale22 c2c1f81ea5 fix for issue #116 (continued)
Some stuff that was missing from my previous commit. Sorry for the
hurdles, this is my first time contributing to a project. Updated the
appropriate unit test and CHANGES.md for version 3.4.3.
2012-09-04 19:00:17 -04:00
phailwhale22 14481ee346 fix for issue #116 2012-09-04 18:07:13 -04:00
Timothy Wall a92256bc72 keep native builds separate from dist; copy on dist 2012-09-03 09:13:07 -04:00
Timothy Wall be42dda63d update javadoc 2012-09-03 08:27:53 -04:00
Timothy Wall 7313da6156 bump version to 3.4.2 2012-08-31 09:17:01 -04:00
Timothy Wall b7d94d6a14 fix minor javadoc, compile bugs 2012-08-31 08:12:41 -04:00
Timothy Wall 782b11f201 fix issue #107 2012-08-27 23:23:34 -04:00
Timothy Wall aea387ce02 fix failing tests in StructureTest (avoid returning self when sharing memory) 2012-08-22 16:38:21 -04:00
Timothy Wall 4ddad49369 save function field offsets instead of actual function pointers, which may change 2012-08-21 21:43:17 -04:00
Timothy Wall 224f18fef4 fix file perms 2012-08-21 19:29:43 -04:00
Timothy Wall 2390543445 add dll callbacks, tests, explicit flags for dlopen 2012-08-21 19:28:40 -04:00
Timothy Wall 473d48b39b fix up Netapi32Test to match DS_DOMAIN_TRUSTS changes elsewhere; I vaguely recall db saying something about removing a related test entirely for duplication of effort, perhaps this was missed checking in? 2012-08-11 22:27:44 -04:00
Timothy Wall a947dfdac5 address issue #84 2012-08-11 18:03:27 -04:00
Timothy Wall b83e977839 ensure memory always initialized when calling useMemory, even if layout is unknown 2012-08-03 07:10:06 -04:00
Timothy Wall ab2d5a72e7 enforce declaration of structure field order 2012-08-02 07:28:30 -04:00
Timothy Wall bc5855e900 Merge branch 'master' of github.com:twall/jna 2012-08-02 07:08:47 -04:00
twall 2c5993d680 simplify env settings 2012-07-27 07:52:29 -03:00
Timothy Wall 2cc7fe3272 Merge branch 'master' of github.com:twall/jna 2012-07-27 06:39:38 -04:00
twall 958ecde56b Update www/WindowsDevelopmentEnvironment.md 2012-07-26 22:37:05 -03:00
twall 0a9a4c926a Update www/WindowsDevelopmentEnvironment.md 2012-07-26 22:36:20 -03:00
Daniel Doubrovkine a0b50515e2 Moved windows development environment to www. 2012-07-26 21:15:49 -04:00
Daniel Doubrovkine (dB.) edf2dacfac Made instructions prettier. 2012-07-26 22:13:06 -03:00
Timothy Wall d65bd51895 add windows build notes 2012-07-26 20:17:17 -04:00
Timothy Wall e0bd677ffc update win64 build to work with MSVS C++ Express 10 and cygwin+mingw64 2012-07-26 19:58:59 -04:00
Timothy Wall c7123cf59b add change note 2012-07-19 06:39:00 -04:00
Timothy Wall 187fcdc2fb use a more applicable return type 2012-07-19 06:37:42 -04:00
Timothy Wall a064b2a0e1 add android link 2012-07-17 07:38:50 -04:00
Daniel Doubrovkine (dB.) 777406eb7b Merge pull request #98 from trejkaz/master
Third attempt at fixing Netapi32Util.getDomainTrusts()
2012-07-13 15:31:19 -07:00
twall 37f108fa51 Merge pull request #70 from jglick/master
Warnings reported by FindBugs et al.
2012-07-13 04:47:37 -07:00
Daniel Doubrovkine (dB.) f0817a3e75 Update master 2012-07-13 08:35:18 -03:00
Daniel Doubrovkine (dB.) 0eb9636bdf Prettified CHANGES, more consistent between w32 and win32. 2012-07-13 08:34:29 -03:00
Timothy Wall 3f3872974e closes #100 2012-07-13 07:32:34 -04:00
Timothy Wall 99533d2052 more unsigned fixes 2012-07-13 07:21:17 -04:00
Timothy Wall dce035056a fix some unsigned pointer-aliasing types, platform/win32 2012-07-13 07:12:47 -04:00
Trejkaz (pen name) 53cb504e90 Use Structure.toArray() instead of domains.getTrusts() 2012-07-13 10:46:39 +10:00
Daniel Doubrovkine 2162f14786 Moved Kernel32 definitions into Kernel32.java, added GetEnvironmentVariable. 2012-07-12 19:48:48 -04:00
Trejkaz (pen name) bd7fdf2438 Third attempt at fixing Netapi32Util.getDomainTrusts(). 2012-07-13 09:13:46 +10:00
Daniel Doubrovkine cc399eca28 Fixed testReadFile, not always null-terminated. 2012-07-12 16:08:40 -04:00
Daniel Doubrovkine adb048c01a Don't use NativeLong, equivalent to int on Windows. 2012-07-12 15:54:19 -04:00
Daniel Doubrovkine 738900d840 Using int and IntByReference for ULONG, also added ULONG. 2012-07-12 14:25:26 -04:00
Timothy Wall 3755747fda update notes 2012-07-12 08:45:48 -04:00
twall 36020c6d33 Merge pull request #95 from buckensens/master
Check for null-ness in initializeFields() before overwriting a field.
2012-07-12 03:33:01 -07:00
Patrik Burkhalter b64e24691b Properly getting fields in initializeFields() 2012-07-12 09:33:37 +02:00
Patrik Burkhalter a97377bb4a Merge remote branch 'upstream/master' 2012-07-12 09:12:16 +02:00
Daniel Doubrovkine (dB.) b661a7ecbd Update master 2012-07-12 01:53:27 -03:00
Daniel Doubrovkine (dB.) 2f3807d9a4 Merge pull request #96 from trejkaz/master
Fixing crash in Netapi32Util (or anyone who calls DsEnumerateDomainTrusts)
2012-07-11 21:31:56 -07:00
Trejkaz (pen name) 9932ce345e Updating changelog for my fixes 2012-07-12 14:05:01 +10:00
Trejkaz (pen name) b254399c02 NetApiBufferFree was freeing the pointer we were passing in rather than the pointer to what DsEnumerateDomainTrusts allocated. 2012-07-12 14:00:28 +10:00
Trejkaz (pen name) 5c08bfcd5c Some DS_DOMAIN_TRUSTS fields were mapping ULONG to NativeLong instead of int. 2012-07-12 11:09:24 +10:00
Trejkaz (pen name) fcd4cafe8a Second attempt at fixing the crash in Netapi32Util.
This time we change the definition of Netapi32.DsEnumerateDomainTrusts. Crash is still not happening and this fix is more likely to be correct.
2012-07-12 09:02:44 +10:00
Trejkaz (pen name) cd6a1f48c8 Merge branch 'master' of https://github.com/twall/jna 2012-07-12 08:38:16 +10:00
Patrik Burkhalter 2996d99914 Test for null on fields in initializeFields(). 2012-07-11 16:38:53 +02:00
Timothy Wall 785173f106 Avoid overwriting string fields within structures when unnecessary; fix failing direct mode tests 2012-07-10 07:30:53 -04:00
Trejkaz (pen name) bf66cb55d6 Fixing a crash when trying to free the wrong pointer in Netapi32Util. 2012-07-10 15:56:15 +10:00
Daniel Doubrovkine (dB.) 9ce2f894c3 Update master 2012-07-09 19:59:12 -03:00
Daniel Doubrovkine (dB.) 436e842faa Update master 2012-07-09 19:58:59 -03:00
Daniel Doubrovkine (dB.) adf4a382a3 Update master 2012-07-09 12:53:10 -03:00
Daniel Doubrovkine d4ba6b3575 Updated CHANGES. 2012-07-09 11:49:53 -04:00
Daniel Doubrovkine 6439e36464 Fix: platform.win32.Secur32.AcquireCredentialsHandle, InitializeSecurityContext and AcceptSecurityContext. 2012-07-09 11:49:10 -04:00
Timothy Wall 57ded8d803 android tweaks 2012-07-09 07:39:10 -04:00
Timothy Wall aa5fc9b3d8 tweak resource path for android 2012-07-09 07:14:54 -04:00
Timothy Wall afb3a7cc84 fix path to strip 2012-07-06 17:25:00 -04:00
Timothy Wall e14201201d remove superflous section marker 2012-06-26 21:15:31 -04:00
Timothy Wall 92b5085dd8 remove superflous section marker 2012-06-26 21:14:44 -04:00
Timothy Wall 4c814e7700 auto-sync memory for struct** arguments, add tests 2012-06-24 15:17:05 -04:00
twall fb6d9e6908 !@#$% magic links 2012-06-13 08:25:40 -03:00
twall 1398a5764b fix download links 2012-06-13 08:24:17 -03:00
twall e66bea10d4 Update master 2012-06-12 08:28:08 -03:00
twall 8ba666dfe0 Update master 2012-06-12 08:19:17 -03:00
twall 882bd3dd11 Update master 2012-06-12 08:14:54 -03:00
twall 317d41e1df Update master 2012-06-12 08:13:26 -03:00
twall 02bd142758 Update master 2012-06-12 08:00:18 -03:00
Daniel Doubrovkine 5f2620944f Made prettier. 2012-06-09 16:37:56 -04:00
Daniel Doubrovkine 0405f305f9 Updated changelog. 2012-06-09 16:37:09 -04:00
Daniel Doubrovkine 501dc9054a Fix: #78 NPE platform.win32.Netapi32Util.getDomainTrusts. 2012-06-09 16:33:07 -04:00
Timothy Wall b2c3c585db bump version 2012-06-08 09:27:55 -04:00
Timothy Wall 481010d0b3 Merge branch 'master' of github.com:twall/jna 2012-06-08 09:26:58 -04:00
Timothy Wall 4f79bd12e1 fix javadoc error 2012-06-08 09:26:36 -04:00
Timothy Wall 0bfd959bcb fix OSGI entries (closes issue #71 and issue #63) 2012-06-08 09:26:16 -04:00
twall d7845899b4 update javadoc links 2012-06-06 22:39:41 -03:00
Timothy Wall 76f7b189fa add closures patch from auris 2012-05-22 08:13:17 -04:00
Nicolas Lelong d330f19292 iOS build fixes. 2012-05-05 09:37:02 -04:00
Timothy Wall b14ccb8eab update jna.jar 2012-05-04 07:28:06 -04:00
Timothy Wall d873f6f6be add android binary 2012-05-04 07:27:25 -04:00
Timothy Wall 7f0d465e98 set all structure fields, add android as a recognized platform 2012-05-04 07:24:00 -04:00
Jesse Glick 7855615a9d FindBugs has some other suggestions about nested classes which could be static.
In the case of LayoutInfo, this is especially important because otherwise
the layoutInfo WeakHashMap leaks references (compare issue #40).
2012-05-03 17:12:40 -04:00
Timothy Wall 9889489355 successful compilation/link of android 2012-05-03 08:09:54 -04:00
Anthony Green 09b23cfc1d Update README with Blackfin/uClinux support 2012-04-27 08:29:48 -04:00
Anthony Green 213ed15c70 Add blackfin supprt from Alexandre Keunecke. 2012-04-27 01:34:15 -04:00
Jesse Glick 6f7ece8603 FindBugs points out that StructField could be static. 2012-04-20 18:31:38 -04:00
Jesse Glick 5d44e011b9 API error in Structure.getFieldTypeInfo: StructField is not accessible outside this package,
so the method could not possibly be overridden outside it either.
Revealed by SigTest run on JNA 3.4.0:
Hidden class found: com.sun.jna.Structure$StructField in method protected com.sun.jna.Pointer com.sun.jna.Structure.getFieldTypeInfo(com.sun.jna.Structure$StructField) in class com.sun.jna.Structure
2012-04-20 18:29:04 -04:00
Anthony Green ff3d76fd42 3.0.11 2012-04-11 23:16:48 -04:00
Anthony Green 7e0a412c4f Update files to ship 2012-04-11 22:47:44 -04:00
Zachary Waldowski 39e6a58604 More mac/ios build improvements 2012-04-11 22:39:46 -04:00
Anthony Green 853cc722a1 Fix typo for darwin targets 2012-04-10 06:33:33 -04:00
Anthony Green 3f5023068c mend 2012-04-06 20:34:51 -04:00
Mike Lewis ebb8e89456 Build iOS library with xcode 2012-04-06 20:02:08 -04:00
Anthony Green a098b44f4c Reapply missing testsuite changes for arm 2012-04-06 17:04:35 -04:00
Anthony Green 10d1e51393 Update to rc4. Upgrade autoconf version. 2012-04-06 11:58:33 -04:00
Anthony Green 9bcc884276 Fix Linux/x32 reference in README 2012-04-06 11:53:07 -04:00
Anthony Green a044a56b1c Linux/x32 libtool fix 2012-04-06 10:39:10 -04:00
Anthony Green 59bb61a366 Update libtool version, README, tests dists 2012-04-06 08:26:14 -04:00
Anthony Green f2981454cb Revert debug code changes 2012-04-05 15:45:19 -04:00
Zachary Waldowski 39dccddb60 Fix building with Clang for Darwin (OS X 10.6+ and iOS
4.0+)
2012-04-05 12:32:41 -04:00
Peter Rosin 3afaa9a34a Fix return_uc.c test case on windows. 2012-04-03 07:40:31 -04:00
Anthony Green 65f40c35a2 Repair ppc build regression. 2012-04-03 07:35:59 -04:00
Peter Rosin 0a1ab12a8d Various MSVC-related changes. 2012-03-30 08:14:08 -04:00
Anthony Green e1539266e6 ARM VFP fix for old toolchains 2012-03-30 00:40:18 -04:00
Anthony Green 7c5e60b5f4 Rebase on fixed GCC sources 2012-03-29 08:48:22 -04:00
Anthony Green e72ed5eeaa Fix vararg float test 2012-03-21 09:52:28 -04:00
Anthony Green bd78c9c331 More cygwin fixes 2012-03-21 08:09:30 -04:00
Anthony Green 84d3253f86 Rebase post GCC merge 2012-03-19 23:07:35 -04:00
Anthony Green 964c5b93f8 abi check fixes and Linux/x32 support 2012-03-03 14:46:20 -05:00
Anthony Green 6c194233a5 Add -no-undefined for both 32- and 64-bit x86
windows-like hosts.
2012-03-03 14:17:54 -05:00
Anthony Green 8360bf1cd0 Ensure that users don't include ffitarget.h directly 2012-02-23 07:01:13 -05:00
Anthony Green d578b89619 Fix ABI check regression 2012-02-15 00:18:18 -05:00
Anthony Green dee20f8e45 Rebased from gcc 2012-02-10 13:06:46 -05:00
Anthony Green 4130e1972d Refresh autoconf-archive m4 scripts 2012-02-03 13:18:27 -06:00
Anthony Green 1ff9c604bb Rebase from GCC 2012-02-01 16:34:30 -06:00
Anthony Green 211060eb8f Alpha fix 2012-01-23 14:24:01 -05:00
Anthony Green 78d9c638ba mend 2012-01-23 14:17:24 -05:00
Anthony Green afaf338160 mend 2012-01-23 14:17:13 -05:00
Anthony Green 9e9c4aeb77 Add Amiga support 2012-01-23 14:11:23 -05:00
Anthony Green 8efc0b1f40 Unlikely fixes 2012-01-23 13:47:38 -05:00
Anthony Green 1df51398ae mend 2012-01-23 13:43:59 -05:00
Anthony Green cd2277cc79 mend 2012-01-23 13:43:38 -05:00
Anthony Green 164e6fe04b m68k fixes 2012-01-23 12:41:06 -05:00
Anthony Green c365ee7577 Refresh 2012-01-23 11:13:18 -05:00
Anthony Green f22c38bbd9 Update variadic patch 2011-11-18 15:13:41 -05:00
Anthony Green 03e9ee321a Fix cls_double_va.c and update docs 2011-11-18 15:13:00 -05:00
Anthony Green 95f31151ec Rerun automake 2011-11-12 23:46:05 -05:00
Anthony Green 198ed1ef85 Update version number 2011-11-12 23:45:20 -05:00
Anthony Green 4f17e1f142 Fix last patch 2011-11-12 17:22:24 -05:00
Anthony Green ff9454da44 Add David Gilbert's variadic function call support 2011-11-12 17:18:51 -05:00
Anthony Green ea14ae85e8 clean up 2011-11-12 16:36:59 -05:00
Anthony Green 52891f8a93 Add powerpc soft float support 2011-11-12 16:35:55 -05:00
Anthony Green c8f1bde8e2 Remove junk file 2011-11-12 16:21:02 -05:00
Anthony Green 6a6e7f862f Fix kfreebsd 2011-11-12 16:20:42 -05:00
Anthony Green d52fbed05c Add missing ChangeLog entry 2011-11-12 16:13:41 -05:00
Anthony Green 322052ce65 Fix arm wince alignment issue 2011-11-12 16:11:49 -05:00
Anthony Green af18df2bc2 Remove use of ppc string instructions 2011-11-12 15:52:08 -05:00
Anthony Green 236c939132 Fix darwin11 build problem 2011-11-12 07:37:40 -05:00
Anthony Green c411f140f3 Fix ax_enable_builddir macro on BSD systems 2011-11-12 07:32:36 -05:00
Anthony Green 3d56106b07 Rebase 2011-11-12 07:20:24 -05:00
Anthony Green 8c01954c50 Build assembly files with debug info 2011-09-06 14:26:32 -04:00
Anthony Green fed646a207 Regenerate configury with missing m4 macros 2011-09-06 09:50:20 -04:00
Anthony Green d76441cf71 Update list of supported OpenBSD systems 2011-08-24 10:14:23 -04:00
Anthony Green ee6696fdf4 3.0.11-rc1. soname bump. 2011-08-23 12:30:29 -04:00
Anthony Green c6265c36a9 Version 3.0.10 2011-08-23 10:31:33 -04:00
Anthony Green cc5e41bf32 Fix use of autoconf macros 2011-08-22 16:34:24 -04:00
Anthony Green 049d8386ff Many new patches 2011-08-22 14:50:10 -04:00
Anthony Green 3b7efa4e74 Revert remove-debug-code patch temporarily (for ARM Fedora release) 2011-08-15 13:25:13 -04:00
Anthony Green d992ac54a2 Refresh from GCC 2011-07-29 17:32:53 -04:00
Anthony Green 2d3fb36420 Fix darwin EH 2011-03-30 16:54:42 -04:00
Anthony Green 30ff28e1d8 Fix permissions 2011-02-28 15:36:23 -05:00
Anthony Green 09f8f310f4 More AIX fixes. rc9. 2011-02-28 15:36:07 -05:00
Anthony Green 53d7b16564 Merge branch 'master' of https://github.com/landonf/libffi-ios 2011-02-28 15:23:31 -05:00
Anthony Green 18dd85d6cb rc8. fix last patch. 2011-02-25 16:23:04 -05:00
Anthony Green 74ee6ea8b4 rc7. More AIX fixes. 2011-02-25 15:52:14 -05:00
Anthony Green 2541679dbd Fix ppc32 bug 2011-02-25 15:09:13 -05:00
Anthony Green cbb062cc35 Another non-GCC configury fix 2011-02-17 20:39:21 -05:00
Anthony Green 8cf8878425 Fix ax_cc_maxopt.m4 2011-02-15 15:19:49 -05:00
Anthony Green 24b72070c0 Fix warning and msvcc patches 2011-02-14 15:30:57 -05:00
Anthony Green d72c49e556 Add missing msvcc.sh 2011-02-13 11:41:05 -05:00
Landon Fuller 3000dc237f Merge remote branch 'upstream/master' 2011-02-13 08:55:53 -05:00
Anthony Green 1fbf9dc44f Fix bad_abi test. rc5. 2011-02-13 08:06:39 -05:00
Anthony Green 90af15ef5c iOS fixes 2011-02-12 12:29:36 -05:00
Landon Fuller 55e4a5aa15 Add support for building a full armv6/armv7/i386 universal iOS library 2011-02-12 12:13:46 -05:00
Landon Fuller a0c80f279b Update my e-mail address. 2011-02-12 11:43:49 -05:00
Landon Fuller 8195e0e11d Fix symbol prefixes on Darwin. 2011-02-12 11:27:00 -05:00
Landon Fuller 56b3f8cef0 Modify the ffi_closure structures to hold table/table entry pointers instead of a code buffer.
This re-integrates commit da2773e02a.
2011-02-12 11:14:54 -05:00
Landon Fuller 28a00f61ff Apple assembler support; fixed most gas/ELF-isms. 2011-02-12 11:01:48 -05:00
Landon Fuller 7f2ea33a80 Replace RETLDM macro.
The macro is incompatible with Apple's assembler; switch to
a simple inline version.
2011-02-12 10:39:18 -05:00
Landon Fuller 92ff23e77f Switch to the current iOS 4.2 SDK. 2011-02-12 10:24:49 -05:00
Landon Fuller 58fb8ca2df Merge remote branch 'upstream/master' 2011-02-12 10:23:19 -05:00
Landon Fuller cc3fbd975c Merge branch 'master' of github.com:landonf/libffi-ios 2011-02-12 10:21:02 -05:00
Landon Fuller e449a43bbe Allow specification of the minimum supported iOS version. 2011-02-12 10:20:42 -05:00
Anthony Green 71c792f51b rc4 2011-02-12 09:33:11 -05:00
Anthony Green 7c7c9f3272 ungccify parts of the build 2011-02-12 09:29:29 -05:00
Anthony Green ed62e48b95 Fix permissions 2011-02-11 12:23:58 -05:00
Anthony Green 17d9e9e68d Use newer autotools. Only build debug.c when --enable-debug. 2011-02-11 12:23:20 -05:00
Anthony Green 6972a4ffda Fix xlc build on AIX 2011-02-11 07:32:51 -05:00
Anthony Green 1833aa0fb9 sparc ABI test fix. 2011-02-11 07:11:04 -05:00
Anthony Green f1fb139b4e Fix tests 2011-02-09 18:30:02 -05:00
Anthony Green 5cb470331d Fix permissions 2011-02-09 15:23:06 -05:00
Anthony Green 269deef6db rc3 2011-02-09 15:22:23 -05:00
Anthony Green 42695e7250 Fix IRIX support 2011-02-09 15:12:35 -05:00
Anthony Green a6e56b97f6 Add powerpc64-*-darwin* support 2011-02-09 15:00:42 -05:00
Anthony Green 747d6c32d4 Add Interix support 2011-02-09 14:56:23 -05:00
Anthony Green eab6e41cde Remove README.markdown form libffi-ios 2011-02-09 10:15:02 -05:00
Anthony Green 69dbe845f4 Fix xfails 2011-02-09 07:38:43 -05:00
Anthony Green f498318c07 Update README for iOS again 2011-02-09 06:26:46 -05:00
Anthony Green 630b9c0ac4 Update to rc2 2011-02-09 06:24:23 -05:00
Anthony Green 0cad4386fa Add ChangeLog entry. Fix copyright headers. 2011-02-09 06:11:46 -05:00
Anthony Green 09cb76f264 Add missing change 2011-02-08 20:39:51 -05:00
Anthony Green 2e3a48ccdd Fix make dist 2011-02-08 20:37:26 -05:00
Anthony Green 5e4814d992 fix permissions 2011-02-08 19:46:28 -05:00
Anthony Green 5c0cc6f153 3.0.10rc1 2011-02-08 19:45:59 -05:00
Anthony Green 857fe3de46 Clean ups 2011-02-08 19:39:20 -05:00
Anthony Green e2214f8adb Update README 2011-02-08 19:22:56 -05:00
Anthony Green 1106229a57 Add iOS support 2011-02-08 19:20:09 -05:00
Anthony Green bc9d0be295 3.0.10rc0 changes 2011-02-08 17:04:26 -05:00
Anthony Green 3b836249fe Rebase from GCC 2011-02-08 14:28:59 -05:00
Anthony Green a26e394061 copyright updates patch 2011-02-08 13:56:12 -05:00
Anthony Green b8099539f0 Fix msvcc.sh botch 2011-02-08 13:50:43 -05:00
Anthony Green dc411e8f99 Fix HP-UX build 2011-02-08 10:49:29 -05:00
Anthony Green 404585d134 Fix sparc v8 aggregate type returns for sun's compiler 2011-02-08 10:44:36 -05:00
Anthony Green 19ce713188 grammar fix 2011-02-08 10:34:23 -05:00
Anthony Green 89284fe55f Fix AIX build with IBM XLC 2011-02-08 10:19:19 -05:00
Anthony Green ba022c338a fix win64-underscore patch 2011-02-08 10:12:48 -05:00
Anthony Green 097e5f3924 x86 pcrel test part 2 2011-02-08 10:11:00 -05:00
Anthony Green ed2c518d96 x86 pcrel test 2011-02-08 10:10:07 -05:00
Anthony Green 0e5843995f Refresh from GCC 2011-02-08 07:52:40 -05:00
Anthony Green 5b9cd52784 win64-underscore patch 2010-11-22 15:19:57 -05:00
Anthony Green 2db72615b5 Rebase 2010-11-21 10:50:56 -05:00
Landon Fuller f6ab3edc23 Include the license header in the generated output. 2010-10-27 19:34:51 -04:00
Landon Fuller cef6194628 Add missing copyright/license header. 2010-10-27 14:01:01 -04:00
Landon Fuller 53f387b203 Minor README fix. 2010-09-19 19:57:17 -07:00
Landon Fuller 4fbcb5b5fb Minor README fix. 2010-09-19 19:50:37 -07:00
Landon Fuller 8e7652ef6a Add a libffi-ios-specific github README. 2010-09-19 19:49:39 -07:00
Landon Fuller 83038cf24a Implement FFI_EXEC_TRAMPOLINE_TABLE allocator for iOS/ARM.
This provides working closure support on iOS/ARM devices where
PROT_WRITE|PROT_EXEC is not permitted. The code passes basic
smoke tests, but requires further review.
2010-09-19 14:36:45 -07:00
Landon Fuller b00ff3e98f Rename the generated symbol 2010-09-19 14:22:26 -07:00
Landon Fuller da2773e02a Modify the ffi_closure structures to hold table/table entry pointers instead of a code buffer. 2010-09-19 14:21:37 -07:00
Landon Fuller 01d71b7bed Regenerated the autoconf script 2010-09-19 14:21:14 -07:00
Landon Fuller 19afda0069 Enable AC_SUBST for FFI_EXEC_TRAMPOLINE_TABLE 2010-09-19 14:20:52 -07:00
Landon Fuller 9e1196444e Add a hard-coded FFI_EXEC_TRAMPOLINE_TABLE arm implementation.
This implements support for re-mapping a shared table of executable
trampolines directly in front of a writable configuration page, working
around PROT_WRITE restrictions for sandboxed applications on Apple's
iOS.

This implementation is for testing purposes; a proper allocator is still
necessary, and ARM-specific code needs to be moved out of
src/closures.c.
2010-09-19 10:43:06 -07:00
Landon Fuller f38364b399 Fix symbol prefix for ffi_closure_SYSV_inner on Darwin. 2010-09-19 10:42:36 -07:00
Landon Fuller 36849e7716 Whitespace/comment fixes. 2010-09-19 09:35:04 -07:00
Landon Fuller b764162526 Fix the script name (build-iphone.sh -> build-ios.sh) 2010-09-19 09:04:34 -07:00
Landon Fuller a3d9aa8501 Update the autogenerated autoconf/automake files. 2010-09-19 09:03:52 -07:00
Landon Fuller c71480eaf8 Update automake/autoconf to conditionally build src/arm/trampoline.S if FFI_EXEC_TRAMPOLINE_TABLE is enabled. 2010-09-19 09:02:05 -07:00
Landon Fuller 9af9291b73 Add the trampoline table generated by gentramp.sh 2010-09-19 08:52:33 -07:00
Landon Fuller 68ce0c383e Add a shell script that generates the ARM trampoline page.
This generates a page of 340 trampolines, aligned within one page. The
trampolines use pc-relative addressing to reference config data
(context, jump address) from a page placed directly prior to the
trampoline page. This can be used on systems -- such as iOS -- that do not
support writable, executable memory by remapping the executable page
containing the trampolines directly above a newly allocated writable
config page.
2010-09-19 08:38:19 -07:00
Landon Fuller 75af086be8 Update autoconf files 2010-09-18 18:12:19 -07:00
Landon Fuller 1ac92cca9b Add autoconf check for W^X platforms that require a trampoline table.
This adds the FFI_EXEC_TRAMPOLINE_TABLE. The flag is enabled for
arm-apple-darwin, where PROT_EXEC on writable (or formerly writable) pages is
not permitted for sandboxed binaries.
2010-09-18 18:08:14 -07:00
Landon Fuller be72fbab29 Use the correct host triple for arm/darwin 2010-09-18 18:02:25 -07:00
Landon Fuller 70150bdf45 Add missing UNWIND entry; disables .pad on non-EABI targets. 2010-09-18 16:38:03 -07:00
Landon Fuller 6b452bafae Apple assembler support; fixed most gas/ELF-isms. 2010-09-18 16:21:32 -07:00
Landon Fuller 8ddac835b6 Fix placement of the __APPLE__ macro. 2010-09-18 15:38:06 -07:00
Landon Fuller 69043d0293 Work-around libffi's FP ABI detection.
On iOS, we must use the AAPCS floating point return value calling
conventions. libffi's ARM implementation will only use these conventions
if __SOFTFP__ is defined, which is not the case when GCC's
-mfloat-abi defaults to 'softfp' instead of 'soft'. To work around this
we manually define __SOFTFP__ for Apple platforms in the ARM-specific
sysv.S.

See also:
  http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iPhoneOSABIReference/Introduction/Introduction.html
  http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
2010-09-18 15:32:08 -07:00
Landon Fuller a82e6c354e Add a stub iOS build script to drive autoconf 2010-09-18 14:44:24 -07:00
Anthony Green 84e8de6e9f Restore execute permissions 2010-08-06 01:35:12 -04:00
Anthony Green 3aeecc9eb1 Fix win64-struct-args patch 2010-08-05 15:19:00 -04:00
Anthony Green 00d0b59cd1 Fix debug build for windows 2010-08-05 14:56:53 -04:00
Anthony Green bda487e870 Don't use -safeseh with ml64 2010-08-05 09:02:41 -04:00
Anthony Green c1d28ba8d5 stdcall-x86-closure-fix 2010-08-05 08:48:16 -04:00
Anthony Green 5feacad4a5 define generic symbols carefully 2010-08-05 08:30:04 -04:00
Anthony Green 10ea848900 don't copy win64 struct args 2010-08-05 08:24:27 -04:00
Anthony Green d14178be4c FFI_LAST_ABI fix 2010-07-23 09:14:00 -04:00
Anthony Green 3f5b1375ab rebase 2010-07-12 14:39:18 -04:00
Anthony Green eaf444eabc Fix selinux test 2010-07-10 08:59:09 -04:00
Anthony Green 6309741522 Micharl Kohler's spelling fixes 2010-05-05 20:14:56 -04:00
Anthony Green 9dc9a293f3 Rebase to latest GCC sources 2010-04-13 10:33:52 -04:00
Anthony Green f2c2a4fce9 Remove warnings and add OS/2 support 2010-04-13 10:19:28 -04:00
Anthony Green c0b69e57d5 Dan Witte's windows build fixes. 2010-03-30 08:30:22 -04:00
Anthony Green 59a259f4d3 Remove junk file 2010-03-15 05:57:51 -04:00
Anthony Green 3de1eb36d3 fix-comments patch 2010-03-15 05:57:24 -04:00
Anthony Green c3813b6d7f Rebuild Makefiles with automake 1.11.1 for CVE-2009-4029. 2010-01-26 16:48:56 -05:00
Anthony Green 8d27f68baa Mention recent changes in README 2010-01-15 11:35:37 -05:00
Anthony Green ff3cd68b8c Add msvc.sh wrapper 2010-01-15 11:27:24 -05:00
Anthony Green cadeba6cb5 Microsoft Visual C port 2010-01-15 10:46:51 -05:00
Anthony Green 0739e7dc00 Add x86 Sun Studio compiler support 2010-01-15 09:48:33 -05:00
Anthony Green edfdfd2e85 Add closure example doc 2010-01-13 02:56:19 -05:00
Anthony Green 7b7a42f221 Rebase from GCC 2010-01-12 09:14:14 -05:00
Anthony Green 4b18d1f73d Add x86-64 MingW to README 2010-01-01 10:24:27 -05:00
Anthony Green c3042afaf3 Reset quilt patches post 3.0.9 merge with GCC 2010-01-01 08:08:02 -05:00
Anthony Green b0304e9679 Update version 2009-12-31 11:32:40 -05:00
Anthony Green 2e7e03d014 Final updates before 3.0.9 2009-12-31 07:43:22 -05:00
Anthony Green aea706c528 really 3.0.9rc12 2009-12-29 10:09:31 -05:00
Anthony Green 0cfe60e9d1 3.0.9rc12 2009-12-29 10:06:04 -05:00
Anthony Green 14e2e92e86 3.0.9rc11 2009-12-27 21:03:33 -05:00
Anthony Green 884402787b HPUX support and avr32 test fixes. 2009-12-26 12:57:23 -05:00
Anthony Green 01c78756af 3.0.9rc9 2009-12-26 10:05:18 -05:00
Anthony Green 7086846465 Remove xfails for mips and arm 2009-12-26 09:58:03 -05:00
Anthony Green 838d4ad920 Remove a bunch of xfails. 2009-12-26 09:57:27 -05:00
Anthony Green 7e37eaaf77 Fix huge_struct for solaris 2009-12-26 07:46:50 -05:00
Anthony Green 07cc7a3719 3.0.9rc8 2009-12-26 07:23:04 -05:00
Anthony Green 2b9be16ffa 3.0.9rc8 2009-12-26 07:04:45 -05:00
Anthony Green 9458d88f67 Rebase from GCC 2009-12-26 07:02:27 -05:00
Anthony Green 6a34124175 Add Andreas Schwab's powerpc fix 2009-12-26 06:51:33 -05:00
Anthony Green 39c8792ece 3.0.9rc7 2009-12-25 21:52:28 -05:00
Anthony Green 1d04af52e3 Updated some mips XFAILs 2009-12-25 09:50:36 -05:00
Anthony Green 26e9509c9b Clean up ChangeLog.libffi for older patches. 2009-12-25 02:19:23 -05:00
Anthony Green 9c157d3215 Clean up undefine_AC_ARG_VAR_PRECIOUS patch. 2009-12-25 02:15:40 -05:00
Anthony Green d22de05b0b Fix patches 2009-12-25 02:04:23 -05:00
Anthony Green 1fe3dc7c20 Add windows support patch. 2009-12-25 01:39:00 -05:00
Anthony Green f7c0bc613a 3.0.9rc6 2009-12-25 01:22:11 -05:00
Anthony Green c7fa2da826 3.0.9rc6 2009-12-24 07:22:44 -05:00
Anthony Green da11bece0f Release 3.0.9rc5 2009-12-24 05:34:46 -05:00
Anthony Green e3399b11ed Update README 2009-12-24 01:09:32 -05:00
Anthony Green 115ab36fce Update missing changes for 3.0.9r4. 2009-12-24 00:22:00 -05:00
Anthony Green f8c7a245bf Switch to quilt. Rebase to latest GCC. 2009-12-23 23:46:22 -05:00
Anthony Green ce806772f0 Merge branch 'master' of git@github.com:atgreen/libffi 2009-10-05 00:41:35 -04:00
Anthony Green dcc1f6b4f1 More clean up. 2009-10-05 00:29:33 -04:00
Anthony Green 2829f5941a Clean up 2009-10-05 00:28:03 -04:00
Anthony Green cd98813de5 From Jens Rehsack. Fix for 64-bit AIX. 2009-10-05 00:25:29 -04:00
Anthony Green e4a91de766 From Abdulaziz Ghuloum. Adds special case for Snow Leopard. 2009-10-05 00:16:17 -04:00
Anthony Green 3425a763bc Fix detection of free/openbsd. From Alexis Ballier. 2009-10-04 23:57:29 -04:00
Anthony Green 2340e7a777 AVR support 2009-10-04 23:53:17 -04:00
Anthony Green 5cbe2058c1 Initial stand-alone patch. 2009-10-04 23:53:11 -04:00
Anthony Green c6dddbd02b Initial commit 2009-10-04 08:11:33 -04:00
Anthony Green 5ffc0c3748 Update version to 3.0.9rc1. Add more useful things to .gitignore. 2009-10-04 07:58:22 -04:00
Anthony Green bd29f83ee9 Add .gitignore 2009-09-29 12:07:26 -04:00
Anthony Green 9474f853f8 Remove old CVSROOT files. 2009-09-29 11:13:02 -04:00
twall 0c25275ec2 Apply Dave Korn's cygwin/GCC changes 2009-08-19 12:57:34 +00:00
aph 39228c27ed 2009-06-16 Wim Lewis <wiml@hhhh.org>
* src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are
	supposed to be callee-saved.
	* src/powerpc/sysv.S (small_struct_return_value): Fix overrun of
	return buffer for odd-size structs.
2009-06-16 18:00:47 +00:00
aph 5e93cc704d 2009-06-16 Andreas Tobler <a.tobler@schweiz.org>
PR libffi/40444
	* testsuite/lib/libffi-dg.exp (libffi_target_compile): Add
	allow_stack_execute for Darwin.
2009-06-16 17:41:47 +00:00
aph b509af8959 2009-06-16 Andrew Haley <aph@redhat.com>
* configure.ac (TARGETDIR): Add missing blank lines.
	* configure: Regenerate.
2009-06-16 16:17:52 +00:00
aph d57e96dc56 2009-06-16 Andrew Haley <aph@redhat.com>
* testsuite/libffi.call/cls_align_sint64.c,
        testsuite/libffi.call/cls_align_uint64.c,
        testsuite/libffi.call/cls_longdouble_va.c,
        testsuite/libffi.call/cls_ulonglong.c,
        testsuite/libffi.call/return_ll1.c,
        testsuite/libffi.call/stret_medium2.c: Fix printf format
        specifiers.
        * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs.
        * testsuite/libffi.call/float2.c: Fix dg-excess-errors.
        * testsuite/libffi.call/ffitest.h,
        testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
2009-06-16 09:59:02 +00:00
aph b01d6d1982 2009-06-16 Andrew Haley <aph@redhat.com>
* testsuite/libffi.call/err_bad_typedef.c: xfail everywhere.
	* testsuite/libffi.call/err_bad_abi.c: Likewise.
2009-06-16 09:44:54 +00:00
aph 35b6ded138 2009-06-11 Kaz Kojima <kkojima@gcc.gnu.org>
* testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*.
        * testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*.
        * testsuite/libffi.call/err_bad_typedef.c: Likewise.
2009-06-12 15:29:20 +00:00
aph acc46605f2 2009-06-12 Andrew Haley <aph@redhat.com>
* ChangeLog.libffi: testsuite/libffi.call/cls_align_sint64.c,
        testsuite/libffi.call/cls_align_uint64.c,
        testsuite/libffi.call/cls_ulonglong.c,
        testsuite/libffi.call/return_ll1.c,
        testsuite/libffi.call/stret_medium2.c: Fix printf format
        specifiers.
        testsuite/libffi.special/unwindtest.cc: include stdint.h.
2009-06-12 14:21:28 +00:00
twall 16d1996ed0 update changelog 2009-06-11 14:27:42 +00:00
twall 92a515c33e use ffi_closure_alloc instead of stack-based closure 2009-06-11 14:27:28 +00:00
twall e4363160ba remove unused extern 2009-06-11 14:26:23 +00:00
twall 1dc2781d2b remove not-yet-applied changelog entries 2009-06-11 11:36:16 +00:00
twall bb27735fe6 add win64 support 2009-06-10 10:42:36 +00:00
aph b2a54c100c 2009-06-08 Andrew Haley <aph@redhat.com>
* testsuite/libffi.call/err_bad_abi.c: Add xfails.
	* testsuite/libffi.call/cls_longdouble_va.c: Add xfails.
	* testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*.
	* testsuite/libffi.call/err_bad_typedef.c: Add xfails.

	* testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args.
	* testsuite/libffi.call/stret_medium.c: Likewise.
	* testsuite/libffi.call/stret_large2.c: Likewise.
	* testsuite/libffi.call/stret_large.c:  Likewise.
2009-06-08 16:50:49 +00:00
aph 25723e7141 2009-06-05 Andrew Haley <aph@redhat.com>
* src/x86/win32.S (_ffi_closure_STDCALL): Import from gcc.
2009-06-05 13:03:40 +00:00
aph 70758199c7 2009-06-04 Andrew Haley <aph@redhat.com>
* src/powerpc/ffitarget.h: Fix misapplied merge from gcc.
2009-06-04 16:29:58 +00:00
aph e8bb12563f 2009-06-04 Andrew Haley <aph@redhat.com>
* src/mips/o32.S,
	src/mips/n32.S: Fix licence formatting.
2009-06-04 14:59:18 +00:00
aph d66a8e32c3 2009-06-04 Andrew Haley <aph@redhat.com>
* src/x86/darwin.S: Fix licence formatting.
	src/x86/win32.S: Likewise.
	src/sh64/sysv.S: Likewise.
	src/sh/sysv.S: Likewise.
2009-06-04 14:43:40 +00:00
aph 7c3b7fd6b5 2009-06-04 Andrew Haley <aph@redhat.com>
* src/sh64/ffi.c: Remove lint directives.  Was missing from merge
	of Andreas Tobler's patch from 2006-04-22.
2009-06-04 14:39:20 +00:00
aph 1a2f93a8b3 2009-06-04 Andrew Haley <aph@redhat.com>
* src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of
        2007-03-07.
2009-06-04 10:45:51 +00:00
aph 944c95cf7a 2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
* src/x86/win32.S (_ffi_closure_STDCALL):  New function.
       (.eh_frame):  Add FDE for it.

2009-05-22  Dave Korn  <dave.korn.cygwin@gmail.com>

       * configure.ac:  Also check if assembler supports pc-relative
       relocs on X86_WIN32 targets.
       * configure:  Regenerate.
       * src/x86/win32.S (ffi_prep_args):  Declare extern, not global.
       (_ffi_call_SYSV):  Add missing function type symbol .def and
       add EH markup labels.
       (_ffi_call_STDCALL):  Likewise.
       (_ffi_closure_SYSV):  Likewise.
       (_ffi_closure_raw_SYSV):  Likewise.
       (.eh_frame):  Add hand-crafted EH data.

2008-11-21  Eric Botcazou  <ebotcazou@adacore.com>

       * src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for
       signed/unsigned int8/16 return values.
       * src/sparc/v8.S (ffi_call_v8): Likewise.
       (ffi_closure_v8): Likewise.

2008-03-26  Kaz Kojima  <kkojima@gcc.gnu.org>

       * src/sh/sysv.S: Add .note.GNU-stack on Linux.
       * src/sh64/sysv.S: Likewise.

2008-03-26  Daniel Jacobowitz  <dan@debian.org>

       * src/arm/sysv.S: Fix ARM comment marker.
2009-06-03 17:42:56 +00:00
twall 00fa972430 properly glob-match 2008-12-27 16:59:05 +00:00
twall f5179e6794 Mark XFAIL on longdouble tests for x86_64/mingw 2008-12-26 19:06:28 +00:00
twall 80e2b5a749 clean up tests for win64 use 2008-12-22 15:21:15 +00:00
green 7063d9996f Version 3.0.8 with x86-solaris support 2008-12-19 16:13:46 +00:00
green bdfeb13f0d Bump to 3.0.7 2008-12-19 15:47:44 +00:00
green 69205de17d Many test fixes (failures due to excessive compiler warnings). 2008-07-24 18:03:48 +00:00
green 260d513fea Version 3.0.6. sh/sh64 fixes. 2008-07-17 13:13:52 +00:00
green 3704031875 Rev 3.0.5. 2008-04-03 18:57:57 +00:00
green 8406f5f48f 3.0.5 2008-04-03 18:57:34 +00:00
green 23a9e73212 2008-03-04 Anthony Green <green@redhat.com>
Blake Chaffin
            hos@tamanegi.org

        * testsuite/libffi.call/cls_align_longdouble_split2.c
          testsuite/libffi.call/cls_align_longdouble_split.c
          testsuite/libffi.call/cls_dbls_struct.c
          testsuite/libffi.call/cls_double_va.c
          testsuite/libffi.call/cls_longdouble.c
          testsuite/libffi.call/cls_longdouble_va.c
          testsuite/libffi.call/cls_pointer.c
          testsuite/libffi.call/cls_pointer_stack.c
          testsuite/libffi.call/err_bad_abi.c
          testsuite/libffi.call/err_bad_typedef.c
          testsuite/libffi.call/huge_struct.c
          testsuite/libffi.call/stret_large2.c
          testsuite/libffi.call/stret_large.c
          testsuite/libffi.call/stret_medium2.c
          testsuite/libffi.call/stret_medium.c: New tests from Apple.
2008-03-05 00:07:02 +00:00
green 429e37d3ad clicky 2008-02-28 04:50:19 +00:00
green 51e79c4283 getclicky 2008-02-28 04:47:35 +00:00
green affcab04e2 2008-02-26 Jakub Jelinek <jakub@redhat.com>
Anthony Green  <green@redhat.com>

        * src/alpha/osf.S: Add .note.GNU-stack on Linux.
        * src/s390/sysv.S: Likewise.
        * src/powerpc/linux64.S: Likewise.
        * src/powerpc/linux64_closure.S: Likewise.
        * src/powerpc/ppc_closure.S: Likewise.
        * src/powerpc/sysv.S: Likewise.
        * src/x86/unix64.S: Likewise.
        * src/x86/sysv.S: Likewise.
        * src/sparc/v8.S: Likewise.
        * src/sparc/v9.S: Likewise.
        * src/m68k/sysv.S: Likewise.
        * src/ia64/unix.S: Likewise.
        * src/arm/sysv.S: Likewise.
2008-02-26 19:01:53 +00:00
green 59689d5522 2008-02-26 Anthony Green <green@redhat.com>
Thomas Heller  <theller@ctypes.org>

        * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
        comment.
2008-02-26 17:40:51 +00:00
green b13c84cf46 2008-02-26 Anthony Green <green@redhat.org>
Thomas Heller <theller@ctypes.org>

        * include/ffi.h.in: Change void (*)() to void (*)(void).
2008-02-26 17:38:15 +00:00
green 265289f679 2008-02-26 Anthony Green <green@spindazzle.org>
* src/alpha/ffi.c: Change void (*)() to void (*)(void).
        src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
        src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
        src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
        src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
        src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
        src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,>         src/x86/ffi64.c: Ditto.
2008-02-26 17:34:36 +00:00
green fb5036cd6d fix date 2008-02-24 17:25:25 +00:00
green 40bec108e7 New release 2008-02-24 17:25:02 +00:00
green b922048fa8 2008-02-24 Anthony Green <green@spindazzle.org>
* configure.ac: Accept openbsd*, not just openbsd.
        Bump version to 3.0.4.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
        * libtool-version: Increment revision.
        * README: Update for new release.
2008-02-24 17:24:00 +00:00
green affca4b92d sync readme with web page. 2008-02-22 21:53:29 +00:00
green 3e53d8752e New release 2008-02-22 21:52:38 +00:00
green 4d92f6c8e7 2008-02-22 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.3.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
        * libtool-version: Increment revision.
        * README: Update for new release.  Clean up test docs.
2008-02-22 21:49:46 +00:00
green 0e185fa11a Update configure script. 2008-02-22 21:43:18 +00:00
green f73986bd21 2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
Andreas Tobler  <a.tobler@schweiz.org>

        * configure.ac: Add amd64-*-freebsd* target.
        * configure: Regenerate.
2008-02-22 21:40:53 +00:00
green 0208f68fe5 2008-02-22 Thomas Heller <theller@ctypes.org>
* configure.ac: Add x86 OpenBSD support.
        * configure: Rebuilt.
2008-02-22 21:15:44 +00:00
green 01adb0e638 Fix README. 2008-02-21 16:17:26 +00:00
green 1edd456322 3.0.2 2008-02-21 13:39:01 +00:00
green c9b5428008 add missing file 2008-02-21 13:36:43 +00:00
green d5fa5633d5 2008-02-21 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.2.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
        * libtool-version: Increment revision.
        * README: Update for new release.

2008-02-21  Björn König <bkoenig@alpha-tierchen.de>

        * src/x86/freebsd.S: New file.
        * configure.ac: Add x86 FreeBSD support.
        * Makefile.am: Ditto.
2008-02-21 13:36:19 +00:00
green ac35bfc6fc Updated 2008-02-16 01:03:56 +00:00
green f7942975fe 2008-02-15 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.1.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
        * libtool-version: Increment revision.
        * README: Update for new release.

2008-02-15  David Daney  <ddaney@avtrex.com>

        * src/mips/ffi.c: Remove extra '>' from include directive.
        (ffi_prep_closure_loc): Use clear_location instead of tramp.
2008-02-16 01:02:00 +00:00
green 59aa6bb1bf Add more platforms. 2008-02-15 20:52:26 +00:00
green 45a45ab990 3.0 notes 2008-02-15 19:16:36 +00:00
green 4db74cbea8 Update 2008-02-15 19:10:26 +00:00
green c3e1101ffa 2008-02-15 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.0,
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.

2008-02-15  David Daney  <ddaney@avtrex.com>

        * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
        Define (conditionally), and use it to include cachectl.h.
        (ffi_prep_closure_loc): Fix cache flushing.
        * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
2008-02-15 18:43:40 +00:00
green 7e0cc12e92 New release 2008-02-15 15:51:03 +00:00
green 2d7dc885ec * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
Update dates and remove all references to ffi_prep_closure.
        * configure.ac: Bump version to 2.99.9.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
2008-02-15 15:30:26 +00:00
green a0525f03ee New release. 2008-02-15 15:14:30 +00:00
green 2b30dfb314 * man/ffi_prep_closure.3: Delete.
* man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
        (man_MANS): Ditto.
        * man/Makefile.in: Rebuilt.
        * configure.ac: Bump version to 2.99.8.
        * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
2008-02-15 15:12:43 +00:00
green bf41e64840 Update. 2008-02-15 01:56:50 +00:00
green 4d39ddee67 * configure.ac: Bump version to 2.99.7.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
        * include/ffi.h.in LICENSE src/debug.c src/closures.c
          src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
          src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
          src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
          src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
          src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
          src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
          src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
          src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
          src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
          src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
          src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
          src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
          src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
          src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
          src/arm/ffitarget.h src/prep_cif.c: Update license text.
2008-02-15 01:24:06 +00:00
green d58b032b41 New release 2008-02-15 00:59:25 +00:00
green 91e5478df6 Update supported platforms. Bump version. 2008-02-15 00:50:30 +00:00
green bd0768f877 * configure.ac: Bump version to 2.99.5.
* configure: Rebuilt.
        * Makefile.am (EXTRA_DIST): Add darwin64.S
        * Makefile.in: Rebuilt.
        * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
        * LICENSE: Update WARRANTY.
2008-02-15 00:45:33 +00:00
green 49d345f767 update license reference 2008-02-14 23:43:27 +00:00
green 12ac48fc79 Update WARRANTY 2008-02-14 23:42:08 +00:00
green 6b91c41da8 fix tarball reference 2008-02-14 23:38:27 +00:00
green 2b59579e35 First update in 5 years! 2008-02-14 23:35:58 +00:00
green 6cbdf3f3a3 Fix .pc file bug and bump version 2008-02-14 22:44:06 +00:00
green 1d1dc81104 Add man files and info file. Update README. Tag as 2.99.3. 2008-02-14 22:03:37 +00:00
tromey f045a2367f Move entry from ChangeLog to ChangeLog.libffi 2008-02-14 20:46:57 +00:00
tromey 6257f07d1a * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
* mdate-sh, texinfo.tex: New files.
	* Makefile.am (info_TEXINFOS): New variable.
	* doc/libffi.texi: New file.
	* doc/version.texi: Likewise.
2008-02-14 20:33:17 +00:00
green 4232af563c * Makefile.am (AM_CFLAGS): Don't compile with -D.
(lib_LTLIBRARIES): Define.
        (toolexeclib_LIBRARIES): Undefine.
        * Makefile.in: Rebuilt.
        * configure.ac: Reset version to 2.99.1.
        * configure.in: Rebuilt.
2008-02-14 16:19:21 +00:00
green 961543615c Fix typo. 2008-02-14 15:57:40 +00:00
green aeb0abab87 * libffi.pc.in: Usse @PACKAGE_NAME@ and @PACKAGE_VERSION@.
* configure.ac: Reset version to 2.99.1.
        * configure.in: Rebuilt.
        * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
        * Makefile.in: Rebuilt.
        * LICENSE: Update copyright notice.
2008-02-14 15:54:27 +00:00
green 77fe243556 Fix make dist again 2008-02-14 15:37:00 +00:00
green d4970cf452 Fix make dist 2008-02-14 15:18:56 +00:00
green f0b1462f2d Use pkgconfig. Increment libtool CURRENT version. 2008-02-14 15:01:41 +00:00
green 27e52f33ba Fix header installs when using DESTDIR. 2008-02-03 13:59:48 +00:00
twall fadab28eb6 update changelog 2008-02-03 12:32:22 +00:00
twall b5e44c8dfa offset from code base address, not data base address 2008-02-03 01:12:32 +00:00
green f359848d1a Fix header installs. 2008-02-01 21:29:43 +00:00
green c30df49e15 Revert my broken changes to twall's patch. 2008-02-01 21:13:55 +00:00
green 675561bb9a Fix make dist . 2008-01-31 13:44:25 +00:00
green abc0bbf381 Add Tim Wall's x86 windows patch. 2008-01-31 11:58:57 +00:00
green e332366d15 Add HJ's -fomit-frame-pointer struct return fix 2008-01-30 13:21:02 +00:00
green d420424039 Clean up for new automake. 2008-01-30 12:42:34 +00:00
green f4932dd020 Fixes to run testsuite 2008-01-30 12:40:25 +00:00
green 085520ddc8 New files from gcc tree. 2008-01-29 15:16:43 +00:00
green 77175b3f72 Latest gcc svn sources 2008-01-29 15:15:20 +00:00
green 2544e45a0b Install ffitarget.h in $prefix/include. 2008-01-29 14:28:13 +00:00
green 6002211b1c Add new files. 2008-01-29 12:30:10 +00:00
green ccabd2b16b Merge from gcc 2008-01-29 12:28:15 +00:00
tromey e680ecfbfc Pulled in libffi from gcc trunk.
Fixed build and install for standalone use.
2006-12-24 23:12:15 +00:00
root e7ba089659 sourcware.org 2006-06-04 23:22:24 +00:00
root 0cd4aa24e2 Add LockDir 2004-05-30 01:51:57 +00:00
green 5826120fbd Add link to Gianni's web site. 2003-11-04 06:09:08 +00:00
jsm 220aa4b27d Newer, better, increased from before! (list of acceptable anon usernames) 2003-01-21 08:07:42 +00:00
green 1c3adc892c Fixed Cygnus references. 2002-12-06 01:28:03 +00:00
green 4af66bb62f Testsuite fixes. 2001-10-21 19:18:42 +00:00
green 5435965f90 * include/ffi_common.h: Delete, after moving contents to...
* include/ffi_private.h: Subsume contents of ffi_common.h.
        * include/Makefile.am (noinst_HEADERS): Remove ffi_common.h.
        * include/Makefile.in: Rebuilt.
        * arm/ffi.c, m68k/ffi.c, mips/ffi.c, powerpc/ffi.c, s390/ffi.c,
        ia64/ffi.c: Include ffi_private.h, not ffi_common.h.
        * alpha/ffi.c, sparc/ffi.c, x86/ffi.c: Don't include ffi_common.h.
        * types.c, raw_api.c, java_raw_api.c, prep_cif.c: Don't include
        ffi_common.h.
        * debug.c: Include ffi_private.h instead of ffi_common.h.

        * mips/ffi.c (calc_n32_struct_flags): Make static.
        (FIX_ARGP): Remove call to debugging routine ffi_stop_here.

        * mips/n32.S: Include ffi_private.h.
        * mips/o32.S: Include ffi_private.h.
2001-04-23 00:32:03 +00:00
green 6fdb7de0fe * README: Update some comments.
* Makefile.am (SUBDIRS): Add include so ffi.h gets installed.
        * Makefile.in: Rebuilt.

        * include/ffi.h: Change ALPHA to __alpha__ and SPARC to __sparc__.
        * types.c: Ditto.
        * prep_cif.c (ffi_prep_cif): Ditto.

        * alpha/ffi.c, alpha/osf.S, sparc/ffi.c, sparc/v8.S, sparc/v9.S:
        Include ffi_private.h.

        * include/ffi_private.h (FFI_TYPE_LAST): Define.
2001-04-22 19:38:34 +00:00
green bc7144b01b Moved files from old home 2001-04-22 18:28:36 +00:00
green e57279831e These are dead. 2001-04-22 18:23:47 +00:00
green 7247436b5f All these files live somewhere else now. 2001-04-22 18:22:43 +00:00
green a8b0d40ff9 Many changes. Not quite there yet. 2001-04-22 18:17:14 +00:00
green f893d22733 Moved m68k files 2001-04-22 18:13:22 +00:00
green 688ddfeced New, target indepentent, header 2001-04-22 18:12:33 +00:00
green f9e40776d4 Many changes. 2001-04-22 18:11:57 +00:00
green 8c1d2eb47f Many changes 2001-04-22 18:10:47 +00:00
green 1359dfc658 Moved ia64 files 2001-04-22 18:10:20 +00:00
green 6e2de5eee3 Moved arm files 2001-04-22 18:08:11 +00:00
green 8807355af3 Many many updates. Merge from gcc and then some. 2001-04-09 00:58:38 +00:00
green f7e9f91ade Mnay fixes. 2000-04-17 03:32:37 +00:00
green c4860de618 Merge from libgcj. Merged patches from net. See ChangeLog for details. 2000-04-17 03:18:46 +00:00
jsm c578b58314 1999-10-09 Jason Molenda (jsm@bugshack.cygnus.com)
* CVSROOT/auto_checkout, CVSROOT/commit_prep, CVSROOT/log_accum:
	Deleted; generic versions now used for all repositories.

	* CVSROOT/commitinfo, CVSROOT/loginfo:  Change pathnames to
	generic versions.

        * CVSROOT/checkoutlist:  Don't try to check out the removed
        files any longer.
1999-10-09 20:18:16 +00:00
jsm acdb200512 1999-10-09 Jason Molenda (jsm@bugshack.cygnus.com)
* CVSROOT/auto_checkout, CVSROOT/commit_prep, CVSROOT/log_accum:
	Deleted; generic versions now used for all repositories.

	* CVSROOT/commitinfo, CVSROOT/loginfo:  Change pathnames to
	generic versions.

        * CVSROOT/checkoutlist:  Don't try to check out the removed
        files any longer.
1999-10-09 20:18:15 +00:00
green e75be655ce New configury 1999-08-08 13:16:41 +00:00
green d6669a0dd5 * include/ffi.h.in: Try to work around messy header problem
with PACKAGE and VERSION.

	* configure: Rebuilt.
	* configure.in: Change version to 2.00-beta.

        * fficonfig.h.in: Rebuilt.
	* acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define.

	* src/x86/ffi.c (ffi_raw_call): Rename.
1999-08-08 13:05:12 +00:00
green 4819d52b00 New file for Kresten's closure work 1999-08-04 18:02:34 +00:00
green 2dbf801eb4 Kresten's closure work. Initial checkin. 1999-08-04 18:00:05 +00:00
green d170961701 * configure.in: Add x86 and powerpc BeOS configurations.
From Makoto Kato <m_kato@ga2.so-net.ne.jp>.
1999-07-08 14:36:52 +00:00
jsm c7747d9769 1999-05-12 Jason Molenda (jsm@bugshack.cygnus.com)
* index.html: Add links to libffi* mail list archives.
1999-05-12 23:32:16 +00:00
green dd2aa9a8de * configure.in: Add warning about this being beta code.
Remove src/Makefile.am from the picture.
	* configure: Rebuilt.
	* Makefile.am: Move logic from src/Makefile.am.  Add changes
	to support libffi as a target library.
	* Makefile.in: Rebuilt.
	* aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh:
	Upgraded to new autoconf, automake, libtool.
	* README: Tweaks.
	* LICENSE: Update copyright date.
	* src/Makefile.am, src/Makefile.in: Removed.
1999-05-06 05:34:36 +00:00
green 4e9452abed Updated to new automake, libtool, autoconf - nothing works :-) 1999-05-05 22:06:13 +00:00
jsm 6d3b2bddaf 1999-04-26 Jason Molenda (jsm@bugshack.cygnus.com)
* index.html: Missed a reference to libffi-discuss@cygnus.com.  Fixed.
1999-04-26 15:55:28 +00:00
jsm ebc6a9c28a 1999-04-26 Jason Molenda (jsm@bugshack.cygnus.com)
* index.html: Change links to ftp directory to point to sourceware
        directory.
        Change mailing list subscription forms to point to sourceware lists.
1999-04-26 15:53:29 +00:00
jsm 78ffc52a8b Standard sourceware setup. 1999-04-18 01:33:21 +00:00
jsm b4d77e827d Small typeo. (I wouldn't bother except that it made the sentence hard
for me to parse on a casual read.)
1998-11-30 11:11:25 +00:00
jsm bfb73f08fd A few cleanups. Most notably, point to the correct subscribe cgi-bin
script.
1998-11-30 10:44:55 +00:00
green af8b7f037c * index.html: Reformatted and updated to reflect hosting on
sourceware.cygnus.com (new mailing lists, etc).
1998-11-30 06:20:05 +00:00
green 334f0b0609 initial snapshot of documentation 1998-11-29 16:56:12 +00:00
green 3ab5cb4a1d Initial revision 1998-11-29 16:56:10 +00:00
green d2a9eb5a8b This commit was generated by cvs2svn to compensate for changes in r7, which
included commits to RCS files with non-trunk default branches.
1998-11-29 16:48:16 +00:00
green bc75c54bd3 Import of v1 code. 1998-11-29 16:48:16 +00:00
jsm d3782ec816 Send commit messages to mailing lists. 1998-11-20 20:18:00 +00:00
jsm 8d8d3843c4 initial checkin 1998-10-01 22:08:36 +00:00
jsm 49634f3bf2 Add standard setup. 1998-10-01 22:08:35 +00:00
jsm c64a84c769 Add readers and standard modules file. 1998-10-01 22:08:34 +00:00
jsm 9813273b07 initial checkin 1998-10-01 22:08:33 +00:00
670 arquivos alterados com 296919 adições e 14157 exclusões
+11 -17
Ver Arquivo
@@ -1,17 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="contrib/ntservice/src"/>
<classpathentry kind="src" path="contrib/platform/src"/>
<classpathentry kind="src" path="contrib/x11/src"/>
<classpathentry excluding="build*" kind="src" path="contrib/balloontips"/>
<classpathentry excluding="build*" kind="src" path="contrib/shapedwindowdemo"/>
<classpathentry excluding="build*" kind="src" path="contrib/dnddemo"/>
<classpathentry excluding="build*" kind="src" path="contrib/w32keyhook"/>
<classpathentry excluding="build*" kind="src" path="contrib/alphamaskdemo"/>
<classpathentry excluding="build*" kind="src" path="contrib/balloonmanagerdemo"/>
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="build.eclipse/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="jna/build.eclipse/test-classes" path="contrib/platform/test"/>
<classpathentry kind="src" path="contrib/platform/src"/>
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="output" path="build.eclipse/classes"/>
</classpath>
+9
Ver Arquivo
@@ -2,9 +2,18 @@ build
build-d64
build.eclipse
build.number
build.clover
.metadata
.DS_Store
bin
contrib/ntservice/dist
contrib/platform/dist
doc
*~
**/*~
dist/*.asc
dist/*-sources.jar
dist/*-javadoc.jar
dist/src-mvn.zip
dist/out-of-date.jar
perf*.txt
+96
Ver Arquivo
@@ -1,3 +1,99 @@
Release 3.5.2
=============
Features
--------
* Basic [COM support](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md) for w32 - [@wolftobias](https://github.com/wolftobias).
* Avoid superfluous Structure memory allocation by using Structure(Pointer) ctors if available - [@twall](https://github.com/twall).
* [PR#120](https://github.com/twall/jna/pull/120): Provide methods for extracting native libraries from the class path for use by JNA - [@Zlika](https://github.com/Zlika).
* [PR#163](https://github.com/twall/jna/pull/163): The Java `GUID` structure can be used directly as alternative to `Ole32Util.getGUIDFromString()` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Ported Win32 `dbt.h` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `WTSRegisterSessionNotification()` and `WTSUnRegisterSessionNotification()` from `Wtsapi32.dll` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `native_window_msg` that creates windows, registers for USB device and logon/logoff notifications - [@wolftobias](https://github.com/wolftobias).
* [PR#178](https://github.com/twall/jna/pull/178): Added Win32 `USER_INFO_10` structure from `LMAccess.h` - [@davidmc24](https://github.com/davidmc24).
* [PR#174](https://github.com/twall/jna/pull/174): Recompile linux-amd64 natives to remove glibc-2.11 dependencies, now requires only 2.2.5 or better - [@twall](https://github.com/twall).
* [PR#183](https://github.com/twall/jna/pull/183): Added `StructureFieldOrderInspector` unit test utility to scan for `Structure` field issues; see: `com.sun.jna.platform.StructureFieldOrderTest.testMethodGetFieldOrder` - [@bhamail](https://github.com/bhamail).
* [PR#187](https://github.com/twall/jna/pull/187): Allow `StructureFieldOrderTest` unit test in platform project to run on Linux - [@bhamail](https://github.com/bhamail).
* [PR#192](https://github.com/twall/jna/pull/192): Added Win32 `SHGetSpecialFolderPath()` and initialization file (.ini) API functions from `kernel32.dll` - [@headcrashing](https://github.com/headcrashing).
* [PR#194](https://github.com/twall/jna/pull/194): Added Unit Test for `CLSIDFromProgID()` - [@headcrashing](https://github.com/headcrashing).
* [PR#196](https://github.com/twall/jna/pull/196): Added Win32 `RegisterWindowMessage()` and new wrapper `User32Util` for convenient use of `RegisterWindowMessage`, `CreateWindow` and `CreateWindowEx` - [@headcrashing](https://github.com/headcrashing).
* [PR#187](https://github.com/twall/jna/pull/187): Allow StructureFieldOrderTest unit test in platform project to run on Linux. - [@bhamail](https://github.com/bhamail).
Bug Fixes
---------
* [PR#180](https://github.com/twall/jna/pull/180): Fix: added missing fields in `XEvents.getFieldOrder()` - [@xwizard](https://github.com/xwizard).
* [PR#183](https://github.com/twall/jna/pull/183): Fix `LMAccess.GROUP_INFO_3.getFieldOrder()` to return correct fields names - [@bhamail](https://github.com/bhamail).
* [PR#187](https://github.com/twall/jna/pull/187): Fix `getFieldOrder()` to return correct field names for some X11 structures - [@bhamail](https://github.com/bhamail).
* Remove deprecated methods on Memory (getSize,isValid) and Structure (getSize) - [@twall](https://github.com/twall).
* [PR#206](https://github.com/twall/jna/pull/206): Fix `moveToTrash()` on OSX to work with symlinks - [@twall](https://github.com/twall).
* Remove problematic AWT check via `Class.forName("java.awt.Component")` (see [here](https://bugs.eclipse.org/bugs/show_bug.cgi?id=388170)) - [@twall](https://github.com/twall).
* [PR#210](https://github.com/twall/jna/pull/210) Add OSGI processor specs for Mac OS X - [@bertfrees](https://github.com/bertfrees).
Release 3.5.1
=============
Bug Fixes
---------
* Fix bug where string fields sometimes failed to be writtern - [@twall](https://github.com/twall) (roman kisluhin).
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
* [PR#151](https://github.com/twall/jna/pull/151): 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
Release 3.5.0
=============
Features
--------
* [#62](https://github.com/twall/jna/issues/62) If a callback is required to reside in a DLL, use [`DLLCallback`](http://twall.github.com/jna/3.5.1/javadoc/com/sun/jna/win32/DLLCallback.html) to tag your Callback object - [@twall](https://github.com/twall).
* `Structure.getFieldOrder()` supersedes `Structure.setFieldOrder()` and is now required - [@twall](https://github.com/twall).
* Search `~/Library/Frameworks` and `/Library/Frameworks` on OSX - [@shaneholloway](https://github.com/shaneholloway).
* Automatic cleanup of native threads (based on suggestions from neil smith) - [@twall](https://github.com/twall).
* Add `android-arm` target - [@ochafik](https://github.com/ochafik), [@twall](https://github.com/twall).
* Add `jna.tmpdir` to override temporary JNA storage location - [@twall](https://github.com/twall).
* Add `EXTRA_MAKE_OPTS` ant property to override make variables - [@twall](https://github.com/twall).
* Add `Library.OPTION_OPEN_FLAGS` to customize dlopen behavior - [@twall](https://github.com/twall).
* [#113](https://github.com/twall/jna/issues/113), [#114](https://github.com/twall/jna/issues/114): Add support for GNU/kFreeBSD and debian multi-arch distros - [@twall](https://github.com/twall).
Bug Fixes
---------
* Fix `Advapi32Util.registryGetValues()` tried to allocate memory for a zero-length `REG_BINARY` value - [@phailwhale22](https://github.com/phailwhale22).
* Fix crash in direct mode callbacks with certain type conversions - [@twall](https://github.com/twall).
* More thoroughly propagate unexpected exceptions generated in jnidispatch - [@twall](https://github.com/twall).
* Cleanup maven poms and publishing to central repo - [@bhamail](https://github.com/bhamail).
* [#129](https://github.com/twall/jna/issues/129): Allow `Memory` field in structure - [@twall](https://github.com/twall).
* Preserve `PointerType` fields on `Structure.read()` if unchanged - [@twall](https://github.com/twall).
* [#128](https://github.com/twall/jna/issues/128): Fix masking extracting DWORD upper and lower WORD values - [@twall](https://github.com/twall).
* [#135](https://github.com/twall/jna/issues/135): Fix for `Advapi32Util.registryGetValues()` when reading zero length values - [@danwi](https://github.com/danwi).
Release 3.4.2
=============
Features
--------
* Add `platform.win32.Kernel32.GetEnvironmentVariable` and `platform.win32.Kernel32Util.getEnvironmentVariable` - [@dblock](https://github.com/dblock).
* Moved `Kernel32.dll` function definitions from `WinNT.java` into `Kernel32.java` - [@dblock](https://github.com/dblock).
* Provide `toPointer()` methods on all `_PTR` types (platform win32) - [@twall](https://github.com/twall).
* Provide `ant -Dskip-native` to skip platform native build - [@twall](https://github.com/twall).
* Provide `ant -Dheadless=true` to run unit tests headless - [@twall](https://github.com/twall).
* Added Windows dev environment instructions - [@twall](https://github.com/twall).
Bug Fixes
---------
* Ensure platform win32 classes use unsigned where appropriate (`ULONG_PTR`, `UINT_PTR`, `ULONGLONG`, `WORD`, `DWORDLONG`) - [@twall](https://github.com/twall).
* [#71](https://github.com/twall/jna/issues/71), [#73](https://github.com/twall/jna/issues/73): Fix OSGI entries in manifest - [@twall](https://github.com/twall).
* [#78](https://github.com/twall/jna/issues/78): Fix NPE in `platform.win32.Netapi32Util.getDomainTrusts` - [@dblock](https://github.com/dblock).
* Fix: auto-sync memory for `struct**` arguments (array of struct pointers) - [@twall](https://github.com/twall).
* Fix: `platform.win32.Secur32.AcquireCredentialsHandle`, `InitializeSecurityContext` and `AcceptSecurityContext` on Win32 64-bit - [@dblock](https://github.com/dblock).
* Fix: avoid overwriting native `char *` or `wchar_t *` fields within structures when unmodified (similar to current operation with pointers) - [@twall](https://github.com/twall).
* Fix: `platform.win32.DsGetDC.DS_DOMAIN_TRUSTS` and `DsEnumerateDomainTrusts` on Win32 64-bit - [@trejkaz](https://github.com/trejkaz).
* Fix: Crash freeing the wrong pointer in `Netapi32Util.getDomainTrusts` - [@trejkaz](https://github.com/trejkaz).
* [#100](https://github.com/twall/jna/issues/100): Fix `platform.win32.W32FileMonitor` - [@dblock](https://github.com/dblock).
* Return INT_PTR from `platform.win32.Shell32.ShellExecute`, since returning
`HINSTANCE` is useless.
* Fix runtime error in some instances where Structure.setFieldOrder is used (never return self when sharing AutoAllocated memory).
* [#107](https://github.com/twall/jna/issues/107): `Structure.clear()` always calls `ensureAllocated()` to avoid NPE.
* Ensure internal memory pointer is *always* allocated when calling `Structure.useMemory()`, even if layout is not yet determined.
Release 3.4.1
=============
+30 -26
Ver Arquivo
@@ -3,7 +3,7 @@
Java Native Access (JNA)
========================
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.4.0/javadoc/). Please read the [overview](http://twall.github.com/jna/3.4.0/javadoc/overview-summary.html#overview_description).
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/). Please read the [overview](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#overview_description).
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.
@@ -18,15 +18,10 @@ JNA includes a platform library with many native functions already mapped as wel
Download
========
Version 3.4.1
Version 3.5.1
* [jna.jar](jna/blob/3.4.1/dist/jna.jar)
* [platform.jar](jna/blob/3.4.1/dist/platform.jar)
Version 3.4.0
* [jna.jar](jna/blob/3.4.0/dist/jna.jar)
* [platform.jar](jna/blob/3.4.0/dist/platform.jar)
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.1/jna-3.5.1.jar)
* [platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/3.5.1/platform-3.5.1.jar)
Features
========
@@ -42,7 +37,7 @@ Features
* Nested structures and arrays
* Wide (wchar_t-based) strings
* Native long support (32- or 64-bit as appropriate)
* Demo applications
* [Demo applications/examples](https://github.com/twall/jna/tree/master/contrib)
* Supported on 1.4 or later JVMs, including JavaME (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
@@ -55,7 +50,7 @@ Features
Community and Support
=====================
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).
All questions should be posted to 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).
When posting to the mailing list, please include the following:
@@ -73,29 +68,39 @@ For commercial support, please contact twalljava [at] java [dot] net.
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)
* [Getting Started](https://github.com/twall/jna/blob/master/www/GettingStarted.md)
* [Mapping between Java and Native](https://github.com/twall/jna/blob/master/www/Mappings.md)
* [Using Pointers and Arrays](https://github.com/twall/jna/blob/master/www/PointersAndArrays.md)
* [Using Structures and Unions](https://github.com/twall/jna/blob/master/www/StructuresAndUnions.md)
* [Using By-Reference Arguments](https://github.com/twall/jna/blob/master/www/ByRefArguments.md)
* [Customization of Type Mapping](https://github.com/twall/jna/blob/master/www/CustomMappings.md)
* [Callbacks/Function Pointers/Closures](https://github.com/twall/jna/blob/master/www/CallbacksAndClosures.md)
* [Dynamically Typed Languages (JRuby/Jython)](https://github.com/twall/jna/blob/master/www/DynamicallyTypedLanguages.md)
* [Platform Library](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md)
* [Direct Method Mapping](https://github.com/twall/jna/blob/master/www/DirectMapping.md) (Optimization)
* [Frequently Asked Questions (FAQ)](https://github.com/twall/jna/blob/master/www/FrequentlyAskedQuestions.md)
* [Avoiding Crashes](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#crash-protection)
Primary Documentation (JavaDoc)
===============================
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.4.0/javadoc/).
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/).
Developers
==========
* [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md)
* [Setting up a Windows Development Environment](https://github.com/twall/jna/blob/master/www/WindowsDevelopmentEnvironment.md)
* [Setting up an Android Development Environment](https://github.com/twall/jna/blob/master/www/AndroidDevelopmentEnvironment.md)
* [Releasing JNA](https://github.com/twall/jna/blob/master/www/ReleasingJNA.md)
* [Publishing to Maven Central](https://github.com/twall/jna/blob/master/www/PublishingToMavenCentral.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.
You're encouraged to contribute to JNA. Fork the code from [https://github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
For more informationon setting up a development environment see [Contributing to JNA](jna/tree/master/www/Contributing.md).
For more information on setting up a development environment see [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
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.
@@ -105,4 +110,3 @@ License
This library is provided under the LGPL, version 2.1 or later. Alternative license arrangements are negotiable.
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
+3
Ver Arquivo
@@ -21,6 +21,9 @@
# TODO
* use consistent cpu references (x86->i386, x86_64->amd64)
* osgi for osx
* make native dll extraction from jar public, to use with user dlls packaged
in a jar
+367 -254
Ver Arquivo
@@ -9,7 +9,12 @@
support it).
Cross-compile by specifying -Dos.prefix={name-arch} to ant
(cross-compile currently only configured/tested on w32ce-arm)
(cross-compile currently only configured/tested on w32ce-arm and
android-arm)
Use ANT_OPTS=-Dskip-native to skip building native parts.
Use ANT_OPTS=-Dheadless to run tests headless
Use ANT_OPTS=-Dmaven-release to stage a final, non-snapshot version
-->
<!--
@@ -25,6 +30,7 @@
<!-- (all build-related props should go in -dynamic-properties) -->
<property name="name" value="jna"/>
<property name="jar" value="${name}.jar"/>
<property name="minjar" value="${name}-min.jar"/>
<property name="testjar" value="${name}-test.jar"/>
<property name="debug" value="true"/>
<property name="debug.native" value="false"/>
@@ -35,33 +41,43 @@
<property name="platform.src" location="contrib/platform/src"/>
<property name="contrib" location="contrib"/>
<property name="dist" location="dist"/>
<property name="lib.native" location="lib/native"/>
<property name="test.src" location="test"/>
<property name="doc" location="doc"/>
<property name="javadoc" location="${doc}/javadoc"/>
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
<property name="vendor" value="JNA Development Team"/>
<tstamp>
<format property="year" pattern="yyyy" locale="en,US"/>
</tstamp>
<property name="copyright"
value="Copyright &amp;copy; 2007-2012 Timothy Wall. All Rights Reserved."/>
value="Copyright &amp;copy; 2007-${year} Timothy Wall. All Rights Reserved."/>
<buildnumber/>
<!-- JNA library release version -->
<property name="jna.major" value="3"/>
<property name="jna.minor" value="4"/>
<property name="jna.revision" value="1"/>
<property name="jna.minor" value="5"/>
<property name="jna.revision" value="2"/>
<property name="jna.build" value="${build.number}"/>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
<condition property="version.suffix" value="" else="-SNAPSHOT">
<isset property="maven-release"/>
</condition>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}${version.suffix}"/>
<!-- jnidispatch library release version -->
<property name="jni.major" value="3"/>
<property name="jni.minor" value="4"/>
<property name="jni.minor" value="5"/>
<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="4c69bcf40b30785215211b5a5dad211e"/>
<property name="jni.md5" value="60417f69d77e4d8d693b43391a4a5b91"/>
<property name="spec.title" value="Java Native Access (JNA)"/>
<property name="spec.vendor" value="${vendor}"/>
<property name="spec.version" value="${jna.major}"/>
<property name="impl.title" value="com.sun.jna"/>
<property name="impl.vendor" value="${spec.vendor}"/>
<property name="impl.version" value="${jna.version} (b${jna.build})"/>
<condition property="jni.valid" value="true">
<isset property="skip-native"/>
</condition>
<!-- Set up restrictions for w32ce, based on JavaME/CDC -->
<property name="compatibility" value="1.4"/>
@@ -69,31 +85,32 @@
<condition property="test.compatibility" value="1.4">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="tests.exclude-patterns" value="**/VarArgsTest.java,**/AnnotatedLibraryTest.java,**/WebStartTest.java,**/PointerBufferTest.java,**/HeadlessLoadLibraryTest.java,**/StructureBufferFieldTest.java,**/PerformanceTest.java,**/*BufferArgumentsMarshalTest.java">
<condition property="tests.exclude-patterns" value="**/VarArgsTest.java,**/AnnotatedLibraryTest.java,**/WebStartTest.java,**/PointerBufferTest.java,**/HeadlessLoadLibraryTest.java,**/StructureBufferFieldTest.java,**/PerformanceTest.java,**/*BufferArgumentsMarshalTest.java" else="**/wince/*.java">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<property name="test.compatibility" value="1.5"/>
<property name="dist-jar" value="${dist}/${jar}"/>
<!-- Maven -->
<!-- define Maven coordinates -->
<property name="groupId" value="net.java.dev.jna" />
<property name="artifactId" value="jna" />
<property name="version" value="${jna.major}.${jna.minor}.${jna.revision}" />
<property name="maven-jar" value="${dist}/jna.jar"/>
<property name="maven-javadoc-jar" value="${dist}/${artifactId}-${version}-javadoc.jar" />
<property name="maven-sources-jar" value="${dist}/src-mvn.zip" />
<property name="maven-javadoc-jar" value="${dist}/${artifactId}-${jna.version}-javadoc.jar" />
<property name="maven-sources-jar" value="${dist}/${artifactId}-${jna.version}-sources.jar" />
<property name="platform-jar" value="${dist}/platform.jar"/>
<property name="platform-javadoc-jar" value="${dist}/platforms-javadoc.jar" />
<property name="platform-sources-jar" value="${dist}/platforms-sources.jar" />
<property name="platform-javadoc-jar" value="${dist}/platform-${jna.version}-javadoc.jar" />
<property name="platform-sources-jar" value="${dist}/platform-${jna.version}-sources.jar" />
<property name="pom" value="pom-jna.xml" />
<property name="pom-platform" value="pom-platform.xml" />
<!-- defined maven snapshots and staging repository id and url -->
<property name="maven-snapshots-repository-id" value="snapshots.java.net" />
<property name="maven-snapshots-repository-url" value="https://maven.java.net/content/repositories/snapshots" />
<property name="maven-snapshots-repository-url" value="https://maven.java.net/content/repositories/snapshots/" />
<property name="maven-staging-repository-id" value="staging.java.net" />
<property name="maven-staging-repository-url" value="https://maven.java.net/service/local/staging/deploy/maven2" />
<property name="maven-staging-repository-url" value="https://maven.java.net/service/local/staging/deploy/maven2/" />
<!-- Miscellaneous -->
<property name="build.compiler.emacs" value="true"/>
@@ -109,6 +126,12 @@
<replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
replace="\1${jna.version}\2"
file="${pom}"/>
<replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
replace="\1${jna.version}\2"
flags="g"
file="${pom-platform}"/>
<replaceregexp match='VERSION = ".*";'
replace='VERSION = "${jna.version}";'
file="src/com/sun/jna/Native.java"/>
@@ -119,16 +142,26 @@
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
<isset property="omit-jnilib"/>
</condition>
<condition property="cross-compile" value="true">
<isset property="os.prefix"/>
</condition>
<!-- Keep cross-compiled natives separate from normal builds -->
<condition property="native.subdir" value="native-${os.prefix}" else="native">
<isset property="cross-compile"/>
</condition>
<condition property="vm.arch" value="-d64" else="">
<or>
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
<os arch="x86_64"/>
<os arch="amd64"/>
<os arch="sparcv9"/>
<os arch="ppc64"/>
<os arch="ia64"/>
</or>
<and>
<not><equals arg1="${os.prefix}" arg2="android-arm" trim="true"/></not>
<or>
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
<os arch="x86_64"/>
<os arch="amd64"/>
<os arch="sparcv9"/>
<os arch="ppc64"/>
<os arch="ia64"/>
</or>
</and>
</condition>
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
<and>
@@ -191,7 +224,7 @@
<not><equals arg1="${libjsig}" arg2=""/></not>
</condition>
<property name="native.jar" value="${os.prefix}.jar"/>
<property name="build.native" location="${build}/native"/>
<property name="build.native" location="${build}/${native.subdir}"/>
<property name="md5.file" location="${build.native}/jni.checksum"/>
<mkdir dir="${build}"/>
@@ -207,6 +240,10 @@
<echo>java.home=${java.home}</echo>
<echo>java.library.path=${java.library.path}</echo>
<echo>os.prefix=${os.prefix}</echo>
<echo>os.name=${os.name}</echo>
<echo>os.arch=${os.arch}</echo>
<echo>build=${build}</echo>
<echo>build.native=${build.native}</echo>
</target>
@@ -216,6 +253,7 @@
<fileset dir="lib">
<include name="junit.jar"/>
</fileset>
<fileset dir="lib/test"/>
<pathelement path="${classes}"/>
</path>
</path>
@@ -226,6 +264,7 @@
<path id="test.runpath">
<pathelement path="${build}/${jar}"/>
<pathelement path="${test.classes}"/>
<pathelement path="${build}/${testjar}"/>
<pathelement path="lib/clover.jar"/>
<path refid="test.libs"/>
</path>
@@ -255,23 +294,147 @@
</target>
<target name="jar" depends="-setup,native,:jar" unless="-jar"
description="Build primary jar">
<jar jarfile="${build}/${jar}">
<!-- Bundle native components with primary jar to facilitate
easy distribution to common platforms.
-->
<jar jarfile="${build}/${jar}" duplicate="preserve">
<manifest>
<attribute name="Main-Class" value="com.sun.jna.Native"/>
<section name="com/sun/jna/">
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
</section>
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
<!--
OSGi Bundle attributes
See http://www.osgi.org/Specifications/Reference
-->
<attribute name="Bundle-Category" value="jni"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="jna"/>
<attribute name="Bundle-Description" value="JNA Library"/>
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
<attribute name="Bundle-Version" value="${spec.version}"/>
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
<attribute name="Export-Package" value="com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32"/>
<!-- Note that no terminal "*" is included in this list,
which will force failure on unsupported platforms.
-->
<attribute name="Bundle-NativeCode"
value="
com/sun/jna/win32-x86/jnidispatch.dll;
processor=x86;osname=win32,
com/sun/jna/win32-amd64/jnidispatch.dll;
processor=x86-64;osname=win32,
com/sun/jna/w32ce-arm/jnidispatch.dll;
processor=arm;osname=wince,
com/sun/jna/sunos-x86/libjnidispatch.so;
processor=x86;osname=sunos,
com/sun/jna/sunos-amd64/libjnidispatch.so;
processor=x86-64;osname=sunos,
com/sun/jna/sunos-sparc/libjnidispatch.so;
processor=sparc;osname=sunos,
com/sun/jna/sunos-sparcv9/libjnidispatch.so;
processor=sparcv9;osname=sunos,
com/sun/jna/aix-ppc/libjnidispatch.a;
processor=ppc;osname=aix,
com/sun/jna/aix-ppc64/libjnidispatch.a;
processor=ppc64;osname=aix,
com/sun/jna/linux-ppc/libjnidispatch.so;
processor=ppc;osname=linux,
com/sun/jna/linux-ppc64/libjnidispatch.so;
processor=ppc64;osname=linux,
com/sun/jna/linux-i386/libjnidispatch.so;
processor=x86;osname=linux,
com/sun/jna/linux-amd64/libjnidispatch.so;
processor=x86-64;osname=linux,
com/sun/jna/linux-arm/libjnidispatch.so;
processor=arm;osname=linux,
com/sun/jna/linux-ia64/libjnidispatch.so;
processor=ia64;osname=linux,
com/sun/jna/openbsd-i386/libjnidispatch.so;
processor=x86;osname=openbsd,
com/sun/jna/freebsd-i386/libjnidispatch.so;
processor=x86;osname=freebsd,
com/sun/jna/freebsd-amd64/libjnidispatch.so;
processor=x86-64;osname=freebsd,
com/sun/jna/darwin/libjnidispatch.jnilib;
osname=macosx;processor=x86;processor=x86-64;processor=ppc
"/>
</manifest>
<fileset dir="${classes}" excludes="${jar.omitted}">
<patternset refid="jar-compiled"/>
</fileset>
<zipfileset src="${lib.native}/win32-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-x86"/>
<zipfileset src="${lib.native}/aix-ppc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/aix-ppc"/>
<zipfileset src="${lib.native}/aix-ppc64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/aix-ppc64"/>
<zipfileset src="${lib.native}/darwin.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/darwin"/>
<zipfileset src="${lib.native}/linux-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-i386"/>
<zipfileset src="${lib.native}/linux-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-amd64"/>
<zipfileset src="${lib.native}/linux-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-arm"/>
<zipfileset src="${lib.native}/linux-ia64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ia64"/>
<zipfileset src="${lib.native}/linux-ppc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ppc"/>
<zipfileset src="${lib.native}/linux-ppc64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ppc64"/>
<zipfileset src="${lib.native}/sunos-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-x86"/>
<zipfileset src="${lib.native}/sunos-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-amd64"/>
<zipfileset src="${lib.native}/sunos-sparc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-sparc"/>
<zipfileset src="${lib.native}/sunos-sparcv9.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-sparcv9"/>
<zipfileset src="${lib.native}/freebsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-i386"/>
<zipfileset src="${lib.native}/freebsd-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-amd64"/>
<zipfileset src="${lib.native}/openbsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-i386"/>
<zipfileset src="${lib.native}/win32-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-amd64"/>
<zipfileset src="${lib.native}/w32ce-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/w32ce-arm"/>
</jar>
<zip zipfile="${build}/${minjar}">
<zipfileset src="${build}/${jar}" excludes="**/*jnidispatch*"/>
</zip>
</target>
<target name="platform-jar" depends="jar">
@@ -285,12 +448,8 @@
</subant>
<!-- Sources package as required by maven -->
<zip zipfile="${platform-sources-jar}">
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
<zipfileset dir="${contrib}/platform/src" />
</zip>
<jar jarfile="${platform-javadoc-jar}">
<fileset dir="${javadoc}" />
</jar>
</target>
<target name="contrib-jars" depends="platform-jar" description="Build contrib jars">
@@ -302,10 +461,11 @@
</subant>
</target>
<target name="javah" depends="compile">
<target name="javah" depends="compile" unless="skip-native">
<javah classpath="${classes}" destdir="${build.native}" force="yes">
<class name="com.sun.jna.Function"/>
<class name="com.sun.jna.Native"/>
<class name="com.sun.jna.win32.DLLCallback"/>
</javah>
<condition property="grep" value="/usr/sfw/bin/ggrep">
<os name="SunOS"/>
@@ -348,23 +508,24 @@
<!-- Invalidate native libraries when native API changes -->
<target name="-native-api-check" depends="javah" unless="jni.valid">
<echo>Invalidating native code, new checksum is ${md5}</echo>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/w32ce-arm.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-arm.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ppc.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ppc64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-amd64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/w32ce-arm.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-i386.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-amd64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-arm.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ia64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ppc.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ppc64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-i386.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-amd64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/openbsd-i386.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-amd64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparc.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparcv9.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-arm.jar" overwrite="true"/>
<delete failOnError="false" includeEmptyDirs="true">
<fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
</delete>
@@ -400,7 +561,7 @@
file="${rsrc}" byline="true"/>
</target>
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
<target name="native" depends="-setup,javah,-native-api-check,rsrc" unless="skip-native"
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="^JNA_JNI_VERSION=.*"
@@ -410,11 +571,19 @@
replace="CHECKSUM=${jni.md5} ${comment}"
file="native/Makefile" byline="true"/>
<!-- Handle cross-compilation -->
<condition property="make.OS" value="OS=w32ce" else="IGNORE=">
<condition property="make.OS" value="OS=w32ce">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="make.OS" value="OS=android">
<equals arg1="${os.prefix}" arg2="android-arm"/>
</condition>
<property name="make.OS" value="IGNORE="/>
<!-- Ensure Makefile ARCH property properly set -->
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
<equals arg1="${os.prefix}" arg2="android-arm"/>
</condition>
<condition property="ARCH" value="ppc">
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
@@ -436,19 +605,28 @@
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
</and>
</condition>
<!-- Windows' drive letters and spaces in absolute paths wreak havoc on
make -->
<condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
<condition property="make.BUILD" value="BUILD=../${build}/${native.subdir}" else="BUILD=${build.native}">
<os family="windows"/>
</condition>
<condition property="make.PATH" value="PATH=/opt/csw/bin:/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
@@ -468,6 +646,12 @@
<os name="AIX"/>
</or>
</condition>
<!-- Allow explicit override of make variables -->
<condition property="make.OPTS" value="${EXTRA_MAKE_OPTS}" else="IGNORE=">
<isset property="EXTRA_MAKE_OPTS"/>
</condition>
<!-- Native resource path within jna.jar -->
<property name="native.path" value="com/sun/jna/${os.prefix}"/>
<!-- Default make program -->
<property name="make" value="make"/>
@@ -484,16 +668,17 @@
<arg value="${make.ARCH}"/>
<arg value="${make.PATH}"/>
<arg value="${make.OS}"/>
<arg line="${make.OPTS}"/>
<arg value="JNA_JNI_VERSION=${jni.version}"/>
<arg value="CHECKSUM=${jni.md5}"/>
</exec>
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${classes}/com/sun/jna/${os.prefix}">
<mkdir dir="${classes}/${native.path}"/>
<copy todir="${classes}/${native.path}">
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
<mkdir dir="${eclipse.classes}/${native.path}"/>
<copy todir="${eclipse.classes}/${native.path}"
failonerror="false">
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
@@ -507,6 +692,9 @@
<attribute name="Specification-Version" value="${jni.version}"/>
</manifest>
</jar>
<copy todir="${lib.native}">
<fileset dir="${build}" includes="${native.jar}"/>
</copy>
</target>
<target name="compile-tests" depends="compile,native,jar"
@@ -521,12 +709,28 @@
<src path="${test.src}"/>
<exclude name="${tests.exclude}"/>
</javac>
<!-- Create a jar for easy movement of tests -->
<!-- Move (not copy) embedded testlib to test class folder so that it will be -->
<!-- packaged into the test jar and NOT available in the FS-based class path -->
<move todir="${test.classes}/${os.prefix}">
<fileset dir="${build.native}">
<patternset id="embedded-testlib">
<include name="**/*embedded-testlib*"/>
</patternset>
</fileset>
</move>
<!-- Create a jar for easy movement of tests, and embedded load test -->
<jar jarfile="${build}/${testjar}">
<fileset dir="${test.classes}">
<patternset refid="jar-compiled"/>
<include name="**/*embedded-testlib*"/>
</fileset>
</jar>
<!-- Ensure embedded library unavailable on FS-based class path -->
<delete>
<fileset dir="${test.classes}">
<include name="**/*embedded-testlib*"/>
</fileset>
</delete>
<mkdir dir="${build}/jws"/>
<copy todir="${build}/jws" file="${build}/${jar}"/>
<copy todir="${build}/jws" file="${build}/${testjar}"/>
@@ -536,31 +740,38 @@
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
</jar>
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
<fileset dir="${build}/jws" includes="${jar},${testjar},junit.jar,jnidispatch.jar,clover.jar"/>
</signjar>
</target>
<target name="android-test-setup" depends="compile-tests"
description="Configure tests for running on an Android emulator">
<!-- 'shared' should be the path to a folder mounted as the mobile
device/simulator storage card. -->
<property name="shared" value="shared"/>
</target>
<target name="wince-test-setup" depends="compile-tests"
description="Configure tests for running on a Windows Mobile device">
description="Configure tests for running on the WM emulator">
<!-- 'shared' should be the path to a folder mounted as the mobile
device/simulator storage card. -->
<property name="shared" value="shared"/>
<!-- w32ce arm testing -->
<jar jarfile="${shared}/test.jar">
<zipfileset src="${build}/jna.jar"/>
<zipfileset src="${build}/jna-test.jar"/>
<zipfileset src="${build}/${jar}"/>
<zipfileset src="${build}/${testjar}"/>
</jar>
<copy todir="${shared}" file="${build}/jna.jar"/>
<copy todir="${shared}" file="${build}/native/jnidispatch.dll"/>
<copy todir="${shared}" file="${build}/native/testlib.dll"/>
<copy todir="${shared}" file="${build}/native/testlib2.dll"/>
<copy todir="${shared}" file="${build}/${jar}"/>
<copy todir="${shared}" file="${build.native}/jnidispatch.dll"/>
<copy todir="${shared}" file="${build.native}/testlib.dll"/>
<copy todir="${shared}" file="${build.native}/testlib2.dll"/>
<copy todir="${shared}" file="w32ce-test.lnk"/>
<chmod file="${shared}/*.dll" perm="+x"/>
</target>
<!-- When running tests from an IDE, be sure to set jna.library.path -->
<!-- to where the test library (testlib) is found. -->
<target name="test" depends="jar,compile-tests"
<target name="test" depends="jar,compile-tests" unless="cross-compile"
description="Run all unit tests">
<property name="test.fork" value="yes"/>
<property name="reports.junit" location="${reports}/junit"/>
@@ -590,7 +801,15 @@
<property name="tests.platform" value=""/>
<property name="tests.exclude" value=""/>
<property name="tests.exclude-patterns" value=""/>
<condition property="java.awt.headless" value="true">
<isset property="headless"/>
</condition>
<propertyset id="headless">
<propertyref prefix="java.awt.headless"/>
</propertyset>
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build}">
<!-- optionally run headless -->
<syspropertyset refid="headless"/>
<!-- avoid VM conflicts with JNA protected mode -->
<env key="${ld.preload.name}" file="${libjsig}"/>
<sysproperty key="jna.library.path" file="${build.native}"/>
@@ -699,152 +918,19 @@
<arg value="-notimestamp"/>
</javadoc>
<jar jarfile="${platform-javadoc-jar}">
<fileset dir="${javadoc}" />
</jar>
</target>
<target name="dist" depends="jar,javadoc,contrib-jars,compile-tests,native"
description="Build distribution files">
<copy todir="${dist}">
<fileset dir="${build}">
<include name="${native.jar}"/>
</fileset>
</copy>
<jar jarfile="${maven-jar}" duplicate="preserve">
<manifest>
<attribute name="Main-Class" value="com.sun.jna.Native"/>
<section name="com/sun/jna/">
<attribute name="Implementation-Title" value="${impl.title}"/>
<attribute name="Implementation-Vendor" value="${vendor}"/>
<attribute name="Implementation-Version" value="${impl.version}"/>
<attribute name="Specification-Title" value="${spec.title}"/>
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
<attribute name="Specification-Version" value="${spec.version}"/>
<!--
OSGi Bundle attributes
see http://www.osgi.org/Specifications/Reference
-->
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="jna"/>
<attribute name="Bundle-Description" value="JNA Library"/>
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
<attribute name="Bundle-Version" value="${spec.version}"/>
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
<attribute name="Bundle-Vendor" value="${vendor}"/>
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
<attribute name="Export-Package" value="com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32"/>
<!-- Note that no terminal "*" is included in this list,
which will force failure on unsupported platforms.
-->
<attribute name="Bundle-NativeCode"
value="
com/sun/jna/win32-x86/jnidispatch.dll;
processor=x86;osname=win32,
com/sun/jna/win32-amd64/jnidispatch.dll;
processor=x86-64;osname=win32,
com/sun/jna/w32ce-arm/jnidispatch.dll;
processor=arm;osname=wince,
com/sun/jna/sunos-x86/libjnidispatch.so;
processor=x86;osname=sunos,
com/sun/jna/sunos-amd64/libjnidispatch.so;
processor=x86-64;osname=sunos,
com/sun/jna/sunos-sparc/libjnidispatch.so;
processor=sparc;osname=sunos,
com/sun/jna/sunos-sparcv9/libjnidispatch.so;
processor=sparcv9;osname=sunos,
com/sun/jna/aix-ppc/libjnidispatch.a;
processor=ppc;osname=aix,
com/sun/jna/aix-ppc64/libjnidispatch.a;
processor=ppc64;osname=aix,
com/sun/jna/linux-ppc/libjnidispatch.so;
processor=ppc;osname=linux,
com/sun/jna/linux-ppc64/libjnidispatch.so;
processor=ppc64;osname=linux,
com/sun/jna/linux-i386/libjnidispatch.so;
processor=x86;osname=linux,
com/sun/jna/linux-amd64/libjnidispatch.so;
processor=x86-64;osname=linux,
com/sun/jna/linux-arm/libjnidispatch.so;
processor=arm;osname=linux,
com/sun/jna/linux-ia64/libjnidispatch.so;
processor=ia64;osname=linux,
com/sun/jna/openbsd-i386/libjnidispatch.so;
processor=x86;osname=openbsd,
com/sun/jna/freebsd-i386/libjnidispatch.so;
processor=x86;osname=freebsd,
com/sun/jna/freebsd-amd64/libjnidispatch.so;
processor=x86-64;osname=freebsd,
com/sun/jna/darwin/libjnidispatch.jnilib;
osname=macos,
"/>
</section>
</manifest>
<zipfileset src="${build}/${jar}"/>
<zipfileset src="${dist}/win32-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-x86"/>
<zipfileset src="${dist}/aix-ppc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/aix-ppc"/>
<zipfileset src="${dist}/aix-ppc64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/aix-ppc64"/>
<zipfileset src="${dist}/darwin.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/darwin"/>
<zipfileset src="${dist}/linux-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-i386"/>
<zipfileset src="${dist}/linux-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-amd64"/>
<zipfileset src="${dist}/linux-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-arm"/>
<zipfileset src="${dist}/linux-ia64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ia64"/>
<zipfileset src="${dist}/linux-ppc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ppc"/>
<zipfileset src="${dist}/linux-ppc64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-ppc64"/>
<zipfileset src="${dist}/sunos-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-x86"/>
<zipfileset src="${dist}/sunos-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-amd64"/>
<zipfileset src="${dist}/sunos-sparc.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-sparc"/>
<zipfileset src="${dist}/sunos-sparcv9.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-sparcv9"/>
<zipfileset src="${dist}/freebsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-i386"/>
<zipfileset src="${dist}/freebsd-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-amd64"/>
<zipfileset src="${dist}/openbsd-i386.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-i386"/>
<zipfileset src="${dist}/win32-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-amd64"/>
<zipfileset src="${dist}/w32ce-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/w32ce-arm"/>
</jar>
<copy todir="${dist}">
<fileset dir="${contrib}/platform/dist">
<include name="platform.jar" />
<fileset dir="${build}" includes="${jar},${minjar}"/>
<fileset dir="${contrib}/platform/dist" includes="platform.jar"/>
<fileset dir="${lib.native}">
<include name="*.jar"/>
<exclude name="out-of-date.jar"/>
</fileset>
</copy>
<copy todir="${dist}/jnacontrib" flatten="true">
@@ -856,6 +942,10 @@ osname=macos,
<fileset dir="${javadoc}" />
</jar>
<zip zipfile="${dist}/doc.zip">
<zipfileset dir="${javadoc}" prefix="javadoc"/>
</zip>
<!-- Javadoc -->
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
<zip zipfile="${dist}/src.zip">
<zipfileset dir="." includes="build.xml,${pom},LICENSE.txt"/>
@@ -873,8 +963,7 @@ osname=macos,
</zip>
<!-- Sources package as required by maven -->
<zip zipfile="${maven-sources-jar}">
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
<zipfileset dir="${src}" />
</zip>
</target>
@@ -892,79 +981,103 @@ osname=macos,
</subant>
</target>
<target name="deploy" depends="dist,platform-jar" description="deploy snapshot version to Maven snapshot repository">
<artifact:mvn>
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
<!-- NOTE: The 'deploy' target works only if the version (jna.version in build.xml) ends in '-SNAPSHOT'. -->
<target name="deploy" depends="dist" description="deploy snapshot version to Maven snapshot repository">
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/>
<arg value="-Durl=${maven-snapshots-repository-url}"/>
<arg value="-DrepositoryId=${maven-snapshots-repository-id}"/>
<arg value="-DpomFile=${pom}"/>
<arg value="-Dfile=${maven-jar}"/>
<arg value="-Dfile=${dist-jar}"/>
<arg value="-Dfiles=${maven-sources-jar},${maven-javadoc-jar}"/>
<arg value="-Dtypes=jar,jar"/>
<arg value="-Dclassifiers=sources,javadoc"/>
</artifact:mvn>
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/>
<arg value="-Durl=${maven-snapshots-repository-url}"/>
<arg value="-DrepositoryId=${maven-snapshots-repository-id}"/>
<arg value="-DpomFile=${pom-platform}"/>
<arg value="-Dfile=${platform-jar}"/>
<arg value="-Dfiles=${platform-sources-jar},${platform-javadoc-jar}"/>
<arg value="-Dtypes=jar,jar"/>
<arg value="-Dclassifiers=sources,javadoc"/>
</artifact:mvn>
</target>
<!-- before this, update project version (both build.xml and ${pom}) from SNAPSHOT to RELEASE -->
<property name="version-maven-gpg-plugin" value="1.4"/>
<target name="stage" depends="dist" description="deploy release version to Maven staging repository">
<!-- sign and deploy the main artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the jna artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=${pom}"/>
<arg value="-Dfile=${maven-jar}"/>
<arg value="-Pgpg"/>
<arg value="-Dfile=${dist-jar}"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the jna sources artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=${pom}"/>
<arg value="-Dfile=${maven-sources-jar}"/>
<arg value="-Dclassifier=sources"/>
<arg value="-Pgpg"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the jna javadoc artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=${pom}"/>
<arg value="-Dfile=${maven-javadoc-jar}"/>
<arg value="-Dclassifier=javadoc"/>
<arg value="-Pgpg"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the platform artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=pom-platform.xml"/>
<arg value="-DpomFile=${pom-platform}"/>
<arg value="-Dfile=${platform-jar}"/>
<arg value="-Pgpg"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the platform sources artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=pom-platform.xml"/>
<arg value="-DpomFile=${pom-platform}"/>
<arg value="-Dfile=${platform-sources-jar}"/>
<arg value="-Dclassifier=sources"/>
<arg value="-Pgpg"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
<!-- sign and deploy the platform javadoc artifact -->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
<arg value="-Durl=${maven-staging-repository-url}"/>
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
<arg value="-DpomFile=pom-platform.xml"/>
<arg value="-DpomFile=${pom-platform}"/>
<arg value="-Dfile=${platform-javadoc-jar}"/>
<arg value="-Dclassifier=javadoc"/>
<arg value="-Pgpg"/>
<arg value="-Dgpg.useagent=true"/>
</artifact:mvn>
</target>
+7 -14
Ver Arquivo
@@ -8,7 +8,6 @@
<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" />
@@ -37,7 +36,6 @@
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
@@ -45,29 +43,24 @@
<path refid="classpath"/>
</classpath>
</javac>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<!-- Copy all non-java files to classes. -->
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
@@ -154,7 +154,7 @@ public class AlphaMaskDemo implements Runnable {
int w = image.getWidth(null);
int h = image.getHeight(null);
alphaWindow.setSize(w, h);
if (buffer == null || buffer.getSize() != w*h*4) {
if (buffer == null || buffer.size() != w*h*4) {
buffer = new com.sun.jna.Memory(w*h*4);
pixels = new int[w*h];
}
+8 -13
Ver Arquivo
@@ -8,7 +8,6 @@
<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" />
@@ -37,7 +36,6 @@
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
@@ -45,29 +43,26 @@
<path refid="classpath"/>
</classpath>
</javac>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<!-- Copy all non-java files to classes. -->
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
+8 -13
Ver Arquivo
@@ -8,7 +8,6 @@
<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" />
@@ -37,7 +36,6 @@
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
@@ -45,29 +43,26 @@
<path refid="classpath"/>
</classpath>
</javac>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<!-- Copy all non-java files to classes. -->
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
+8 -13
Ver Arquivo
@@ -8,7 +8,6 @@
<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" />
@@ -37,7 +36,6 @@
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
@@ -45,29 +43,26 @@
<path refid="classpath"/>
</classpath>
</javac>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<!-- Copy all non-java files to classes. -->
<copy todir="${classes}/com">
<fileset dir="${src}/com">
<exclude name="**/*.java"/>
</fileset>
<!-- platform -->
<fileset dir="../platform/build/classes/com">
<exclude name="**/*.java"/>
</fileset>
<!-- jna -->
<fileset dir="${file.reference.jna.build}/classes/com">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!-- Create jar-file. -->
<target name="jar" depends="compile">
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
+8
Ver Arquivo
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>msoffice</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//src/com/sun/jna/platform/win32/office/MSWord.java=UTF-8
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -0,0 +1,36 @@
package com.sun.jna.platform.win32.office;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.COMUtils.COMInfo;
public class COMInfoUtil {
public static void main(String[] args) {
try {
String filename = "C:\\TEMP\\CLSIDs.txt";
ArrayList<COMInfo> comInfos = COMUtils.getAllCOMInfoOnSystem();
FileWriter writer = new FileWriter(filename);
for (COMInfo comInfo : comInfos) {
String result = "CLSID: " + comInfo.clsid + "\n";
result += "InprocHandler32: " + comInfo.inprocHandler32 + "\n";
result += "InprocServer32: " + comInfo.inprocServer32 + "\n";
result += "LocalServer32: " + comInfo.localServer32 + "\n";
result += "ProgID: " + comInfo.progID + "\n";
result += "ProgTypeLibID: " + comInfo.typeLib + "\n";
writer.write(result + "\n");
}
System.out.println("file written to: " + filename);
System.out.println("Found CLSID`s on the system: "
+ comInfos.size());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,162 @@
package com.sun.jna.platform.win32.office;
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.Variant;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.COMObject;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.IDispatch;
public class MSExcel extends COMObject {
public MSExcel() throws COMException {
super("Excel.Application", false);
}
public MSExcel(boolean visible) throws COMException {
this();
this.setVisible(Variant.VARIANT_TRUE);
}
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
"Visible", new VARIANT(bVisible));
}
public String getVersion() throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Version");
return result.getValue().toString();
}
public HRESULT newExcelBook() throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
.getIDispatch(), "Add");
return hr;
}
public HRESULT openExcelBook(String filename, boolean bVisible)
throws COMException {
// OpenDocument
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
VARIANT varFilename = new VARIANT(bstrFilename);
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
.getIDispatch(), "Open", varFilename);
return hr;
}
public HRESULT closeActiveWorkbook(VARIANT_BOOL bSave) throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getActiveWorkbook().getIDispatch(), "Close", new VARIANT(bSave));
return hr;
}
public HRESULT quit() throws COMException {
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
this.iDispatch, "Quit");
COMUtils.SUCCEEDED(hr);
return hr;
}
public HRESULT insertValue(String range, String value) throws COMException {
HRESULT hr;
BSTR bstrRange = OleAuto.INSTANCE.SysAllocString(range);
VARIANT varRange = new VARIANT(bstrRange);
VARIANT.ByReference result = new VARIANT.ByReference();
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this
.getActiveSheet().getIDispatch(), "Range", varRange);
Range pRange = new Range((IDispatch) result.getValue());
BSTR bstrValue = OleAuto.INSTANCE.SysAllocString(value);
VARIANT varText = new VARIANT(bstrValue);
hr = oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null,
pRange.getIDispatch(), "Value", varText);
return hr;
}
public Application getApplication() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "Application");
COMUtils.SUCCEEDED(hr);
return new Application((IDispatch) result.getValue());
}
public ActiveWorkbook getActiveWorkbook() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "ActiveWorkbook");
COMUtils.SUCCEEDED(hr);
return new ActiveWorkbook((IDispatch) result.getValue());
}
public Workbooks getWorkbooks() {
// GetDocuments
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "WorkBooks");
COMUtils.SUCCEEDED(hr);
return new Workbooks((IDispatch) result.getValue());
}
public ActiveSheet getActiveSheet() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "ActiveSheet");
COMUtils.SUCCEEDED(hr);
return new ActiveSheet((IDispatch) result.getValue());
}
public class Application extends COMObject {
public Application(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Workbooks extends COMObject {
public Workbooks(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class ActiveWorkbook extends COMObject {
public ActiveWorkbook(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class ActiveSheet extends COMObject {
public ActiveSheet(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Range extends COMObject {
public Range(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
}
@@ -0,0 +1,80 @@
package com.sun.jna.platform.win32.office;
import java.io.File;
import com.sun.jna.platform.win32.Variant;
import com.sun.jna.platform.win32.COM.COMException;
public class MSOfficeDemo {
/**
* @param args
*/
public static void main(String[] args) {
new MSOfficeDemo();
}
private String currentWorkingDir = new File("").getAbsolutePath()
+ File.separator;
public MSOfficeDemo() {
//this.testMSWord();
this.testMSExcel();
}
public void testMSWord() {
MSWord msWord = null;
try {
msWord = new MSWord();
System.out.println("MSWord version: " + msWord.getVersion());
msWord.setVisible(Variant.VARIANT_TRUE);
msWord.newDocument();
//msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
msWord.insertText("Hello from JNA!");
// close and save the document
msWord.closeActiveDocument(Variant.VARIANT_TRUE);
// wait then close word
msWord.quit();
} catch (COMException e) {
if (e.getExcepInfo() != null) {
System.out
.println("bstrSource: " + e.getExcepInfo().bstrSource);
System.out.println("bstrDescription: "
+ e.getExcepInfo().bstrDescription);
} else
e.printStackTrace();
if(msWord != null)
msWord.quit();
}
}
public void testMSExcel() {
MSExcel msExcel = null;
try {
msExcel = new MSExcel();
System.out.println("MSExcel version: " + msExcel.getVersion());
msExcel.setVisible(Variant.VARIANT_TRUE);
//msExcel.newExcelBook();
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
msExcel.insertValue("A1", "Hello from JNA!");
// close and save the active sheet
msExcel.closeActiveWorkbook(Variant.VARIANT_TRUE);
// wait then close excel
msExcel.quit();
} catch (COMException e) {
if (e.getExcepInfo() != null) {
System.out
.println("bstrSource: " + e.getExcepInfo().bstrSource);
System.out.println("bstrDescription: "
+ e.getExcepInfo().bstrDescription);
} else
e.printStackTrace();
if(msExcel != null)
msExcel.quit();
}
}
}
@@ -0,0 +1,145 @@
package com.sun.jna.platform.win32.office;
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.Variant;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.COMObject;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.IDispatch;
public class MSWord extends COMObject {
public MSWord() throws COMException {
super("Word.Application", false);
}
public MSWord(boolean visible) throws COMException {
this();
this.setVisible(Variant.VARIANT_TRUE);
}
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
"Visible", new VARIANT(bVisible));
}
public String getVersion() throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Version");
return result.getValue().toString();
}
public HRESULT newDocument() throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getDocuments().getIDispatch(), "Add");
return hr;
}
public HRESULT openDocument(String filename, boolean bVisible)
throws COMException {
// OpenDocument
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
VARIANT varFilename = new VARIANT(bstrFilename);
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getDocuments().getIDispatch(), "Open", varFilename);
return hr;
}
public HRESULT closeActiveDocument(VARIANT_BOOL bSave)
throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getActiveDocument().getIDispatch(), "Close", new VARIANT(bSave));
return hr;
}
public HRESULT quit() throws COMException {
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
this.iDispatch, "Quit");
COMUtils.SUCCEEDED(hr);
return hr;
}
public HRESULT insertText(String text) throws COMException {
HRESULT hr;
VARIANT.ByReference result = new VARIANT.ByReference();
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "Selection");
Selection pSelection = new Selection((IDispatch) result.getValue());
BSTR bstrText = OleAuto.INSTANCE.SysAllocString(text);
VARIANT varText = new VARIANT(bstrText);
hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
pSelection.getIDispatch(), "TypeText", varText);
return hr;
}
public ActiveDocument getActiveDocument() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"ActiveDocument");
COMUtils.SUCCEEDED(hr);
return new ActiveDocument((IDispatch) result.getValue());
}
public Documents getDocuments() {
// GetDocuments
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Documents");
COMUtils.SUCCEEDED(hr);
return new Documents((IDispatch) result.getValue());
}
public Application getApplication() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Application");
COMUtils.SUCCEEDED(hr);
return new Application((IDispatch) result.getValue());
}
public class Application extends COMObject {
public Application(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Documents extends COMObject {
public Documents(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class ActiveDocument extends COMObject {
public ActiveDocument(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Selection extends COMObject {
public Selection(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
}
+8
Ver Arquivo
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
Ver Arquivo
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>native_window_msg</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,313 @@
/* Copyright (c) 2012 Tobias Wolf, 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.WString;
import com.sun.jna.platform.win32.DBT;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_DEVICEINTERFACE;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef.HMODULE;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.LRESULT;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
import com.sun.jna.platform.win32.WinUser.MSG;
import com.sun.jna.platform.win32.WinUser.WNDCLASSEX;
import com.sun.jna.platform.win32.WinUser.WindowProc;
import com.sun.jna.platform.win32.Wtsapi32;
// TODO: Auto-generated Javadoc
/**
* The Class Win32WindowTest.
*/
public class Win32WindowDemo implements WindowProc {
/**
* Instantiates a new win32 window test.
*/
public Win32WindowDemo() {
// define new window class
WString windowClass = new WString("MyWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Win32WindowDemo.this;
wClass.lpszClassName = windowClass;
// register window class
User32.INSTANCE.RegisterClassEx(wClass);
getLastError();
// create new window
HWND hWnd = User32.INSTANCE
.CreateWindowEx(
User32.WS_EX_TOPMOST,
windowClass,
"My hidden helper window, used only to catch the windows events",
0, 0, 0, 0, 0, WinUser.HWND_MESSAGE, null, hInst, null);
getLastError();
System.out.println("window sucessfully created! window hwnd: "
+ hWnd.getPointer().toString());
Wtsapi32.INSTANCE.WTSRegisterSessionNotification(hWnd,
Wtsapi32.NOTIFY_FOR_THIS_SESSION);
/* this filters for all device classes */
// DEV_BROADCAST_HDR notificationFilter = new DEV_BROADCAST_HDR();
// notificationFilter.dbch_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
/* this filters for all usb device classes */
DEV_BROADCAST_DEVICEINTERFACE notificationFilter = new DEV_BROADCAST_DEVICEINTERFACE();
notificationFilter.dbcc_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
notificationFilter.dbcc_classguid = DBT.GUID_DEVINTERFACE_USB_DEVICE;
/*
* use User32.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES instead of
* DEVICE_NOTIFY_WINDOW_HANDLE to ignore the dbcc_classguid value
*/
HDEVNOTIFY hDevNotify = User32.INSTANCE.RegisterDeviceNotification(
hWnd, notificationFilter, User32.DEVICE_NOTIFY_WINDOW_HANDLE);
getLastError();
if (hDevNotify != null)
System.out.println("RegisterDeviceNotification was sucessfully!");
MSG msg = new MSG();
while (User32.INSTANCE.GetMessage(msg, hWnd, 0, 0) != 0) {
User32.INSTANCE.TranslateMessage(msg);
User32.INSTANCE.DispatchMessage(msg);
}
User32.INSTANCE.UnregisterDeviceNotification(hDevNotify);
Wtsapi32.INSTANCE.WTSUnRegisterSessionNotification(hWnd);
User32.INSTANCE.UnregisterClass(windowClass, hInst);
User32.INSTANCE.DestroyWindow(hWnd);
System.out.println("program exit!");
}
/*
* (non-Javadoc)
*
* @see
* com.sun.jna.platform.win32.User32.WindowProc#callback(com.sun.jna.platform
* .win32.WinDef.HWND, int, com.sun.jna.platform.win32.WinDef.WPARAM,
* com.sun.jna.platform.win32.WinDef.LPARAM)
*/
public LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WinUser.WM_CREATE: {
onCreate(wParam, lParam);
return new LRESULT(0);
}
case WinUser.WM_DESTROY: {
User32.INSTANCE.PostQuitMessage(0);
return new LRESULT(0);
}
case WinUser.WM_SESSION_CHANGE: {
this.onSessionChange(wParam, lParam);
return new LRESULT(0);
}
case WinUser.WM_DEVICECHANGE: {
this.onDeviceChange(wParam, lParam);
return new LRESULT(0);
}
default:
return User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
/**
* Gets the last error.
*
* @return the last error
*/
public int getLastError() {
int rc = Kernel32.INSTANCE.GetLastError();
if (rc != 0)
System.out.println("error: " + rc);
return rc;
}
/**
* On session change.
*
* @param wParam
* the w param
* @param lParam
* the l param
*/
protected void onSessionChange(WPARAM wParam, LPARAM lParam) {
switch (wParam.intValue()) {
case Wtsapi32.WTS_CONSOLE_CONNECT: {
this.onConsoleConnect(lParam.intValue());
break;
}
case Wtsapi32.WTS_CONSOLE_DISCONNECT: {
this.onConsoleDisconnect(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOGON: {
this.onMachineLogon(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOGOFF: {
this.onMachineLogoff(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOCK: {
this.onMachineLocked(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_UNLOCK: {
this.onMachineUnlocked(lParam.intValue());
break;
}
}
}
/**
* On console connect.
*
* @param sessionId
* the session id
*/
protected void onConsoleConnect(int sessionId) {
System.out.println("onConsoleConnect: " + sessionId);
}
/**
* On console disconnect.
*
* @param sessionId
* the session id
*/
protected void onConsoleDisconnect(int sessionId) {
System.out.println("onConsoleDisconnect: " + sessionId);
}
/**
* On machine locked.
*
* @param sessionId
* the session id
*/
protected void onMachineLocked(int sessionId) {
System.out.println("onMachineLocked: " + sessionId);
}
/**
* On machine unlocked.
*
* @param sessionId
* the session id
*/
protected void onMachineUnlocked(int sessionId) {
System.out.println("onMachineUnlocked: " + sessionId);
}
/**
* On machine logon.
*
* @param sessionId
* the session id
*/
protected void onMachineLogon(int sessionId) {
System.out.println("onMachineLogon: " + sessionId);
}
/**
* On machine logoff.
*
* @param sessionId
* the session id
*/
protected void onMachineLogoff(int sessionId) {
System.out.println("onMachineLogoff: " + sessionId);
}
/**
* On device change.
*
* @param wParam
* the w param
* @param lParam
* the l param
*/
protected void onDeviceChange(WPARAM wParam, LPARAM lParam) {
//
// This is the actual message from the interface via Windows messaging.
// This code includes some additional decoding for this particular
// device type
// and some common validation checks.
//
// Note that not all devices utilize these optional parameters in the
// same
// way. Refer to the extended information for your particular device
// type
// specified by your GUID.
//
DEV_BROADCAST_DEVICEINTERFACE bdif = new DEV_BROADCAST_DEVICEINTERFACE(
lParam.longValue());
System.out.println("dbcc_devicetype: " + bdif.dbcc_devicetype);
System.out.println("dbcc_name: " + bdif.getDbcc_name());
System.out.println("dbcc_classguid: "
+ bdif.dbcc_classguid.toGuidString());
// Output some messages to the window.
switch (wParam.intValue()) {
case DBT.DBT_DEVICEARRIVAL:
System.out.println("Message DBT_DEVICEARRIVAL");
break;
case DBT.DBT_DEVICEREMOVECOMPLETE:
System.out.println("Message DBT_DEVICEREMOVECOMPLETE");
break;
case DBT.DBT_DEVNODES_CHANGED:
System.out.println("Message DBT_DEVNODES_CHANGED");
break;
default:
System.out
.println("Message WM_DEVICECHANGE message received, value unhandled.");
}
}
/**
* On create.
*
* @param wParam
* the w param
* @param lParam
* the l param
*/
protected void onCreate(WPARAM wParam, LPARAM lParam) {
System.out.println("onCreate: WM_CREATE");
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String[] args) {
new Win32WindowDemo();
}
}
+175 -191
Ver Arquivo
@@ -9,204 +9,188 @@
package jnacontrib.jna;
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.*;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
*
*
* @author TB
*/
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
W32APIOptions.UNICODE_OPTIONS);
/*
SC_HANDLE WINAPI OpenSCManager(
LPCTSTR lpMachineName,
LPCTSTR lpDatabaseName,
DWORD dwDesiredAccess
);*/
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
/*
BOOL WINAPI CloseServiceHandle(
SC_HANDLE hSCObject
);*/
public boolean CloseServiceHandle(Pointer hSCObject);
/*
SC_HANDLE WINAPI OpenService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
DWORD dwDesiredAccess
);*/
public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
/*
BOOL WINAPI StartService(
SC_HANDLE hService,
DWORD dwNumServiceArgs,
LPCTSTR* lpServiceArgVectors
);*/
public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
/*
BOOL WINAPI ControlService(
SC_HANDLE hService,
DWORD dwControl,
LPSERVICE_STATUS lpServiceStatus
);*/
public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
/*
BOOL WINAPI StartServiceCtrlDispatcher(
const SERVICE_TABLE_ENTRY* lpServiceTable
);*/
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
/*
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
LPCTSTR lpServiceName,
LPHANDLER_FUNCTION lpHandlerProc
);*/
public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
/*
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
LPCTSTR lpServiceName,
LPHANDLER_FUNCTION_EX lpHandlerProc,
LPVOID lpContext
);*/
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
/*
BOOL WINAPI SetServiceStatus(
SERVICE_STATUS_HANDLE hServiceStatus,
LPSERVICE_STATUS lpServiceStatus
);*/
public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
/*
SC_HANDLE WINAPI CreateService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPCTSTR lpDisplayName,
DWORD dwDesiredAccess,
DWORD dwServiceType,
DWORD dwStartType,
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies,
LPCTSTR lpServiceStartName,
LPCTSTR lpPassword
);*/
public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
String lpDependencies, String lpServiceStartName, String lpPassword);
/*
BOOL WINAPI DeleteService(
SC_HANDLE hService
);*/
public boolean DeleteService(Pointer hService);
/*
BOOL WINAPI ChangeServiceConfig2(
SC_HANDLE hService,
DWORD dwInfoLevel,
LPVOID lpInfo
);*/
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
/*
LONG WINAPI RegEnumValue(
HKEY hKey,
DWORD dwIndex,
LPTSTR lpValueName,
LPDWORD lpcchValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);*/
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
/*
VOID WINAPI ServiceMain(
DWORD dwArgc,
LPTSTR* lpszArgv
);*/
public void callback(int dwArgc, Pointer lpszArgv);
}
* SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR
* lpDatabaseName, DWORD dwDesiredAccess );
*/
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName,
int dwDesiredAccess);
interface Handler extends StdCallCallback {
/*
VOID WINAPI Handler(
DWORD fdwControl
);*/
public void callback(int fdwControl);
}
interface HandlerEx extends StdCallCallback {
* BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
*/
public boolean CloseServiceHandle(Pointer hSCObject);
/*
DWORD WINAPI HandlerEx(
DWORD dwControl,
DWORD dwEventType,
LPVOID lpEventData,
LPVOID lpContext
);*/
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
}
/*
typedef struct _SERVICE_STATUS {
DWORD dwServiceType;
DWORD dwCurrentState;
DWORD dwControlsAccepted;
DWORD dwWin32ExitCode;
DWORD dwServiceSpecificExitCode;
DWORD dwCheckPoint;
DWORD dwWaitHint;
} SERVICE_STATUS,
*LPSERVICE_STATUS;*/
public static class SERVICE_STATUS extends Structure {
public int dwServiceType;
public int dwCurrentState;
public int dwControlsAccepted;
public int dwWin32ExitCode;
public int dwServiceSpecificExitCode;
public int dwCheckPoint;
public int dwWaitHint;
}
/*
typedef struct _SERVICE_TABLE_ENTRY {
LPTSTR lpServiceName;
LPSERVICE_MAIN_FUNCTION lpServiceProc;
} SERVICE_TABLE_ENTRY,
*LPSERVICE_TABLE_ENTRY;*/
public static class SERVICE_TABLE_ENTRY extends Structure {
public String lpServiceName;
public SERVICE_MAIN_FUNCTION lpServiceProc;
}
public static class ChangeServiceConfig2Info extends Structure {
}
/*
typedef struct _SERVICE_DESCRIPTION {
LPTSTR lpDescription;
} SERVICE_DESCRIPTION,
*LPSERVICE_DESCRIPTION;*/
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
public String lpDescription;
}
* SC_HANDLE WINAPI OpenService( SC_HANDLE hSCManager, LPCTSTR
* lpServiceName, DWORD dwDesiredAccess );
*/
public Pointer OpenService(Pointer hSCManager, String lpServiceName,
int dwDesiredAccess);
/*
* BOOL WINAPI StartService( SC_HANDLE hService, DWORD dwNumServiceArgs,
* LPCTSTR* lpServiceArgVectors );
*/
public boolean StartService(Pointer hService, int dwNumServiceArgs,
char[] lpServiceArgVectors);
/*
* BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl,
* LPSERVICE_STATUS lpServiceStatus );
*/
public boolean ControlService(Pointer hService, int dwControl,
SERVICE_STATUS lpServiceStatus);
/*
* BOOL WINAPI StartServiceCtrlDispatcher( const SERVICE_TABLE_ENTRY*
* lpServiceTable );
*/
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
/*
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( LPCTSTR
* lpServiceName, LPHANDLER_FUNCTION lpHandlerProc );
*/
public Pointer RegisterServiceCtrlHandler(String lpServiceName,
Handler lpHandlerProc);
/*
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( LPCTSTR
* lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext );
*/
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName,
HandlerEx lpHandlerProc, Pointer lpContext);
/*
* BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus,
* LPSERVICE_STATUS lpServiceStatus );
*/
public boolean SetServiceStatus(Pointer hServiceStatus,
SERVICE_STATUS lpServiceStatus);
/*
* SC_HANDLE WINAPI CreateService( SC_HANDLE hSCManager, LPCTSTR
* lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD
* dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR
* lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR
* lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword );
*/
public Pointer CreateService(Pointer hSCManager, String lpServiceName,
String lpDisplayName, int dwDesiredAccess, int dwServiceType,
int dwStartType, int dwErrorControl, String lpBinaryPathName,
String lpLoadOrderGroup, IntByReference lpdwTagId,
String lpDependencies, String lpServiceStartName, String lpPassword);
/*
* BOOL WINAPI DeleteService( SC_HANDLE hService );
*/
public boolean DeleteService(Pointer hService);
/*
* BOOL WINAPI ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel,
* LPVOID lpInfo );
*/
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel,
ChangeServiceConfig2Info lpInfo);
/*
* LONG WINAPI RegEnumValue( HKEY hKey, DWORD dwIndex, LPTSTR lpValueName,
* LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE
* lpData, LPDWORD lpcbData );
*/
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName,
IntByReference lpcchValueName, IntByReference reserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
/*
* VOID WINAPI ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv );
*/
public void callback(int dwArgc, Pointer lpszArgv);
}
interface Handler extends StdCallCallback {
/*
* VOID WINAPI Handler( DWORD fdwControl );
*/
public void callback(int fdwControl);
}
interface HandlerEx extends StdCallCallback {
/*
* DWORD WINAPI HandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID
* lpEventData, LPVOID lpContext );
*/
public int callback(int dwControl, int dwEventType,
Pointer lpEventData, Pointer lpContext);
}
/*
* typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD
* dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD
* dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; }
* SERVICE_STATUS,LPSERVICE_STATUS;
*/
public static class SERVICE_STATUS extends Structure {
public int dwServiceType;
public int dwCurrentState;
public int dwControlsAccepted;
public int dwWin32ExitCode;
public int dwServiceSpecificExitCode;
public int dwCheckPoint;
public int dwWaitHint;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
}
}
/*
* typedef struct _SERVICE_TABLE_ENTRY { LPTSTR lpServiceName;
* LPSERVICE_MAIN_FUNCTION lpServiceProc; } SERVICE_TABLE_ENTRY,
* LPSERVICE_TABLE_ENTRY;
*/
public static class SERVICE_TABLE_ENTRY extends Structure {
public String lpServiceName;
public SERVICE_MAIN_FUNCTION lpServiceProc;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
}
}
public static abstract class ChangeServiceConfig2Info extends Structure {
}
/*
* typedef struct _SERVICE_DESCRIPTION { LPTSTR lpDescription; }
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
*/
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
public String lpDescription;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lpDescription" });
}
}
}
+19
Ver Arquivo
@@ -69,6 +69,9 @@
<condition property="tests.platform" value="test-osx">
<os family="mac"/>
</condition>
<condition property="tests.platform" value="test-linux">
<os family="unix"/>
</condition>
<target name="test" depends="init,compile-test" description="Run unit tests." if="tests.platform">
<antcall target="${tests.platform}" />
</target>
@@ -86,4 +89,20 @@
<echo>No platform tests yet for OSX</echo>
</target>
<target name="test-win32" depends="-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
<target name="test-linux" depends="-pre-test-run-single" >
<!-- @todo How to ensure sys prop: jna.nosys=true is seen in tests? -->
<!--<property name="test.includes" value="com/sun/jna/platform/**/*.java"/>-->
<property name="test.includes" value="com/sun/jna/platform/StructureFieldOrderTest.java"/>
<property name="javac.includes" value="**/*"/>
<antcall target="test-single"/>
<!--
<antcall target="test-report"/>
<antcall target="-post-test-run"/>
<antcall target="-test-browse"/>
-->
</target>
</project>
+70 -59
Ver Arquivo
@@ -1,59 +1,70 @@
application.args=
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/platform.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=../../build/jna.jar
libs.junit.classpath=../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar};
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.source=1.5
javac.target=1.5
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.junit.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
src.dir=src
test.src.dir=test
application.args=
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/platform.jar
dist.javadoc.dir=${dist.dir}/javadoc
file.reference.jna.jar=../../build/jna.jar
file.reference.jna-d64.jar=../../build-d64/jna.jar
file.reference.jna-test.jar=../../build/jna-test.jar
file.reference.jna-test-d64.jar=../../build-d64/jna-test.jar
libs.junit.classpath=../../lib/junit.jar
jar.compress=false
javac.classpath=\
${file.reference.jna.jar}:\
${file.reference.jna-d64.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.source=1.5
javac.target=1.5
javac.test.classpath=\
${javac.classpath}:\
${file.reference.jna-test.jar}:\
${file.reference.jna-test-d64.jar}:\
${build.classes.dir}:\
${libs.junit.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
../../lib/test/reflections-0.9.8.jar:\
../../lib/test/guava-11.0.2.jar:\
../../lib/test/javassist-3.12.1.GA.jar:\
../../lib/test/slf4j-api-1.6.1.jar:\
../../lib/test/dom4j-1.6.1.jar:\
${build.test.classes.dir}
src.dir=src
test.src.dir=test
+13
Ver Arquivo
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -17,19 +17,22 @@
package com.sun.jna.platform.mac;
import java.nio.IntBuffer;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Library;
import com.sun.jna.Callback;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import java.nio.IntBuffer;
/**
* Author: Denis Tulskiy
* Date: 7/25/11
*/
public interface Carbon {
public interface Carbon extends Library {
public static Carbon INSTANCE = (Carbon) Native.loadLibrary("Carbon", Carbon.class);
public static final int cmdKey = 0x0100;
@@ -70,15 +73,17 @@ public interface Carbon {
public class EventTypeSpec extends Structure {
public int eventClass;
public int eventKind;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "eventClass", "eventKind" }); }
}
public static class EventHotKeyID extends Structure {
public int signature;
public int id;
public static class ByValue extends EventHotKeyID implements Structure.ByValue {
}
public static class ByValue extends EventHotKeyID implements Structure.ByValue { }
protected List getFieldOrder() {
return Arrays.asList(new String[] { "signature", "id" }); }
}
public static interface EventHandlerProcPtr extends Callback {
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007-2013 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
@@ -15,11 +15,15 @@ package com.sun.jna.platform.mac;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.platform.FileUtils;
public class MacFileUtils extends FileUtils {
@@ -27,14 +31,30 @@ public class MacFileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public interface FileManager extends Library {
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
int kFSFileOperationDefaultOptions = 0;
int kFSFileOperationsOverwrite = 0x01;
int kFSFileOperationsSkipSourcePermissionErrors = 0x02;
int kFSFileOperationsDoNotMoveAcrossVolumes = 0x04;
int kFSFileOperationsSkipPreflight = 0x08;
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
int FSPathMoveObjectToTrashSync(String src, PointerByReference target, int options);
int kFSPathDefaultOptions = 0x0;
int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01;
class FSRef extends Structure {
public byte[] hidden = new byte[80];
protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); }
}
// Deprecated; use trashItemAtURL instead:
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize);
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
int FSPathMoveObjectToTrashSync(String source, PointerByReference target, int options);
int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options);
}
public void moveToTrash(File[] files) throws IOException {
@@ -43,11 +63,20 @@ public class MacFileUtils extends FileUtils {
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List<File> failed = new ArrayList<File>();
List<String> failed = new ArrayList<String>();
for (int i=0;i < files.length;i++) {
File src = files[i];
if (FileManager.INSTANCE.FSPathMoveObjectToTrashSync(src.getAbsolutePath(), null, 0) != 0) {
failed.add(src);
FileManager.FSRef fsref = new FileManager.FSRef();
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
FileManager.kFSPathMakeRefDoNotFollowLeafSymlink,
fsref, null);
if (status != 0) {
failed.add(src + " (FSRef: " + status + ")");
continue;
}
status = FileManager.INSTANCE.FSMoveObjectToTrashSync(fsref, null, 0);
if (status != 0) {
failed.add(src + " (" + status + ")");
}
}
if (failed.size() > 0) {
@@ -12,6 +12,9 @@
*/
package com.sun.jna.platform.unix;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Callback;
import com.sun.jna.FromNativeContext;
import com.sun.jna.Library;
@@ -277,9 +280,12 @@ public interface X11 extends Library {
public short green, greenMask;
public short blue, blueMask;
public short alpha, alphaMask;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "red", "redMask", "green", "greenMask", "blue", "blueMask", "alpha", "alphaMask" });
}
}
class PictFormat extends NativeLong {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public PictFormat(long value) { super(value); }
public PictFormat() { }
}
@@ -289,6 +295,9 @@ public interface X11 extends Library {
public int depth;
public XRenderDirectFormat direct;
public Colormap colormap;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "id", "type", "depth", "direct", "colormap" });
}
}
int PictTypeIndexed = 0x0;
int PictTypeDirect = 0x1;
@@ -337,12 +346,18 @@ public interface X11 extends Library {
class XInputClassInfoByReference extends Structure implements Structure.ByReference {
public byte input_class;
public byte event_type_base;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "input_class", "event_type_base" });
}
}
class XDeviceByReference extends Structure implements Structure.ByReference {
public XID device_id;
public int num_classes;
public XInputClassInfoByReference classes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "device_id", "num_classes", "classes" });
}
}
X11 INSTANCE = (X11)Native.loadLibrary("X11", X11.class);
@@ -370,6 +385,9 @@ public interface X11 extends Library {
public int icon_x, icon_y;
public Pixmap icon_mask;
public XID window_group;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "flags", "input", "initial_state", "icon_pixmap", "icon_window", "icon_x", "icon_y", "icon_mask", "window_group" });
}
}
/*
@@ -385,6 +403,9 @@ public interface X11 extends Library {
public Atom encoding;
public int format;
public NativeLong nitems;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "value", "encoding", "format", "nitems" });
}
}
/*
@@ -413,10 +434,14 @@ public interface X11 extends Library {
public static class Aspect extends Structure {
public int x; // numerator
public int y; // denominator
protected List getFieldOrder() {
return Arrays.asList(new String[] { "x", "y" }); }
}
public Aspect min_aspect, max_aspect;
public int base_width, base_height;
public int win_gravity;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "flags", "x", "y", "width", "height", "min_width", "min_height", "max_width", "max_height", "width_inc", "height_inc", "min_aspect", "max_aspect", "base_width", "base_height", "win_gravity" }); }
}
/*
@@ -470,6 +495,9 @@ public interface X11 extends Library {
public NativeLong do_not_propagate_mask;
public boolean override_redirect;
public Screen screen;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "x", "y", "width", "height", "border_width", "depth", "visual", "root", "c_class", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "colormap", "map_installed", "map_state", "all_event_masks", "your_event_mask", "do_not_propagate_mask", "override_redirect", "screen" });
}
}
/*
@@ -507,6 +535,9 @@ public interface X11 extends Library {
public boolean override_redirect;
public Colormap colormap;
public Cursor cursor;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "background_pixmap", "background_pixel", "border_pixmap", "border_pixel", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "event_mask", "do_not_propagate_mask", "override_redirect", "colormap", "cursor" });
}
}
int XK_0 = 0x30;
@@ -549,10 +580,16 @@ public interface X11 extends Library {
public NativeLong blue_mask;
public int colormap_size;
public int bits_per_rgb;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "visual", "visualid", "screen", "depth", "c_class", "red_mask", "green_mask", "blue_mask", "colormap_size", "bits_per_rgb" });
}
}
class XPoint extends Structure {
public short x, y;
public XPoint() { }
protected List getFieldOrder() {
return Arrays.asList(new String[] { "x", "y" });
}
public XPoint() { this((short)0, (short)0); }
public XPoint(short x, short y) {
this.x = x;
this.y = y;
@@ -561,7 +598,10 @@ public interface X11 extends Library {
class XRectangle extends Structure {
public short x, y;
public short width, height;
public XRectangle() { }
protected List getFieldOrder() {
return Arrays.asList(new String[] { "x", "y", "width", "height" });
}
public XRectangle() { this((short)0, (short)0, (short)0, (short)0); }
public XRectangle(short x, short y, short width, short height) {
this.x = x; this.y = y;
this.width = width; this.height = height;
@@ -705,6 +745,9 @@ public interface X11 extends Library {
public Pixmap clip_mask; /* bitmap clipping; other calls for rects */
public int dash_offset; /* patterned/dashed line information */
public byte dashes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "function", "plane_mask", "foreground", "background", "line_width", "line_style", "cap_style", "join_style", "fill_style", "fill_rule", "arc_mode", "tile", "stipple", "ts_x_origin", "ts_y_origin", "font", "subwindow_mode", "graphics_exposures", "clip_x_origin", "clip_y_origin", "clip_mask", "dash_offset", "dashes" });
}
}
GC XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values);
int XSetFillRule(Display display, GC gc, int fill_rule);
@@ -1330,6 +1373,9 @@ public interface X11 extends Library {
public int send_event; // true if this came from a SendEvent request
public Display display; // Display the event was read from
public Window window; // window on which event was requested in event mask
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window" });
}
}
class XKeyEvent extends Structure {
@@ -1346,6 +1392,9 @@ public interface X11 extends Library {
public int state; // key or button mask
public int keycode; // detail
public int same_screen; // same screen flag
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "keycode", "same_screen" });
}
}
class XButtonEvent extends Structure {
@@ -1362,6 +1411,9 @@ public interface X11 extends Library {
public int state; // key or button mask
public int button; // detail
public int same_screen; // same screen flag
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "button", "same_screen" });
}
}
class XButtonPressedEvent extends XButtonEvent {
@@ -1379,6 +1431,9 @@ public interface X11 extends Library {
public Atom message_type;
public int format;
public Data data;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "message_type", "format", "data" });
}
public static class Data extends Union {
public byte b[] = new byte[20];
@@ -1401,6 +1456,9 @@ public interface X11 extends Library {
public int state; // key or button mask
public byte is_hint; // detail
public int same_screen; // same screen flag
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "is_hint", "same_screen" });
}
}
class XPointerMovedEvent extends XMotionEvent {
@@ -1424,8 +1482,11 @@ public interface X11 extends Library {
* NotifyNonlinear,NotifyNonlinearVirtual
*/
public int same_screen; // same screen flag
public int focus; // intean focus
public int focus; // boolean focus
public int state; // key or button mask
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "mode", "detail", "same_screen", "focus", "state" });
}
}
class XEnterWindowEvent extends XCrossingEvent {
@@ -1447,6 +1508,9 @@ public interface X11 extends Library {
* NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
* NotifyPointerRoot, NotifyDetailNone
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "mode", "detail" });
}
}
class XFocusInEvent extends XFocusChangeEvent {
@@ -1464,6 +1528,9 @@ public interface X11 extends Library {
public int x, y;
public int width, height;
public int count; // if non-zero, at least this many more
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "x", "y", "width", "height", "count" });
}
}
class XGraphicsExposeEvent extends Structure {
@@ -1477,6 +1544,9 @@ public interface X11 extends Library {
public int count; // if non-zero, at least this many more
public int major_code; // core is CopyArea or CopyPlane
public int minor_code; // not defined in the core
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "drawable", "x", "y", "width", "height", "count", "major_code", "minor_code" });
}
}
class XNoExposeEvent extends Structure {
@@ -1487,6 +1557,9 @@ public interface X11 extends Library {
public Drawable drawable;
public int major_code; // core is CopyArea or CopyPlane
public int minor_code; // not defined in the core
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "drawable", "major_code", "minor_code" });
}
}
class XVisibilityEvent extends Structure {
@@ -1496,6 +1569,9 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window window;
public int state; // Visibility state
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "state" });
}
}
class XCreateWindowEvent extends Structure {
@@ -1509,6 +1585,9 @@ public interface X11 extends Library {
public int width, height; // size of window
public int border_width; // border width
public int override_redirect; // creation should be overridden
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "override_redirect" });
}
}
class XDestroyWindowEvent extends Structure {
@@ -1518,6 +1597,8 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window event;
public Window window;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window" }); }
}
class XUnmapEvent extends Structure {
@@ -1528,6 +1609,9 @@ public interface X11 extends Library {
public Window event;
public Window window;
public int from_configure;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "from_configure" });
}
}
class XMapEvent extends Structure {
@@ -1537,7 +1621,10 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window event;
public Window window;
public int override_redirect; // intean, is override set...
public int override_redirect; // boolean, is override set...
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "override_redirect" });
}
}
class XMapRequestEvent extends Structure {
@@ -1547,6 +1634,9 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window parent;
public Window window;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window" });
}
}
class XReparentEvent extends Structure {
@@ -1559,6 +1649,9 @@ public interface X11 extends Library {
public Window parent;
public int x, y;
public int override_redirect;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "parent", "x", "y", "override_redirect" });
}
}
class XConfigureEvent extends Structure {
@@ -1573,6 +1666,9 @@ public interface X11 extends Library {
public int border_width;
public Window above;
public int override_redirect;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y", "width", "height", "border_width", "above", "override_redirect" });
}
}
class XGravityEvent extends Structure {
@@ -1583,6 +1679,9 @@ public interface X11 extends Library {
public Window event;
public Window window;
public int x, y;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y" });
}
}
class XResizeRequestEvent extends Structure {
@@ -1592,6 +1691,9 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window window;
public int width, height;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "width", "height" });
}
}
class XConfigureRequestEvent extends Structure {
@@ -1607,6 +1709,9 @@ public interface X11 extends Library {
public Window above;
public int detail; // Above, Below, TopIf, BottomIf, Opposite
public NativeLong value_mask;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "above", "detail", "value_mask" });
}
}
class XCirculateEvent extends Structure {
@@ -1617,6 +1722,9 @@ public interface X11 extends Library {
public Window event;
public Window window;
public int place; // PlaceOnTop, PlaceOnBottom
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "place" });
}
}
class XCirculateRequestEvent extends Structure {
@@ -1627,6 +1735,9 @@ public interface X11 extends Library {
public Window parent;
public Window window;
public int place; // PlaceOnTop, PlaceOnBottom
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "place" });
}
}
class XPropertyEvent extends Structure {
@@ -1638,6 +1749,9 @@ public interface X11 extends Library {
public Atom atom;
public NativeLong time;
public int state; // NewValue, Deleted
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "atom", "time", "state" });
}
}
class XSelectionClearEvent extends Structure {
@@ -1648,6 +1762,9 @@ public interface X11 extends Library {
public Window window;
public Atom selection;
public NativeLong time;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "selection", "time" });
}
}
class XSelectionRequestEvent extends Structure {
@@ -1659,8 +1776,11 @@ public interface X11 extends Library {
public Window requestor;
public Atom selection;
public Atom target;
Atom property;
public Atom property;
public NativeLong time;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "owner", "requestor", "selection", "target", "property", "time" });
}
}
class XSelectionEvent extends Structure {
@@ -1673,6 +1793,9 @@ public interface X11 extends Library {
public Atom target;
public Atom property; // ATOM or None
public NativeLong time;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "requestor", "selection", "target", "property", "time" });
}
}
class XColormapEvent extends Structure {
@@ -1684,6 +1807,9 @@ public interface X11 extends Library {
public Colormap colormap; // COLORMAP or None
public int c_new; // C++
public int state; // ColormapInstalled, ColormapUninstalled
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "colormap", "c_new", "state" });
}
}
class XMappingEvent extends Structure {
@@ -1695,16 +1821,22 @@ public interface X11 extends Library {
public int request; // one of MappingModifier, MappingKeyboard, MappingPointer
public int first_keycode; // first keycode
public int count; // defines range of change w. first_keycode*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "request", "first_keycode", "count" });
}
}
class XErrorEvent extends Structure {
public int type;
public Display display; // Display the event was read from
public XID resourceid; // resource id
public NativeLong serial; // serial number of failed request
public byte error_code; // error code of failed request
public byte request_code; // Major op-code of failed request
public byte minor_code; // Minor op-code of failed request
public XID resourceid; // resource id
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "display", "serial", "error_code", "request_code", "minor_code", "resourceid" });
}
}
// generated on EnterWindow and FocusIn when KeyMapState selected
@@ -1715,6 +1847,9 @@ public interface X11 extends Library {
public Display display; // Display the event was read from
public Window window;
public byte key_vector[] = new byte[32];
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "key_vector" });
}
}
int XSelectInput(Display display, Window window, NativeLong eventMask);
@@ -1859,6 +1994,9 @@ public interface X11 extends Library {
class XModifierKeymapRef extends Structure implements Structure.ByReference{
public int max_keypermod; /* The server's max # of keys per modifier */
public Pointer modifiermap; /* An 8 by max_keypermod array of modifiers */
protected List getFieldOrder() {
return Arrays.asList(new String[] { "max_keypermod", "modifiermap" });
}
}
class XKeyboardControlRef extends Structure implements Structure.ByReference {
@@ -1879,6 +2017,10 @@ public interface X11 extends Library {
/** AutoRepeatModeOff, AutoRepeatModeOn, AutoRepeatModeDefault. */
public int auto_repeat_mode;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led", "led_mode", "key", "auto_repeat_mode" });
}
public String toString() {
return "XKeyboardControlByReference{" +
"key_click_percent=" + key_click_percent +
@@ -1909,6 +2051,10 @@ public interface X11 extends Library {
/** Bit vector. Each bit set to 1 indicates that auto-repeat is enabled for the corresponding key. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. */
public byte auto_repeats[] = new byte[32];
protected List getFieldOrder() {
return Arrays.asList(new String[] { "key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led_mask", "global_auto_repeat", "auto_repeats" });
}
public String toString() {
return "XKeyboardStateByReference{" +
"key_click_percent=" + key_click_percent +
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -35,6 +35,10 @@ public interface BaseTSD extends StdCallLibrary {
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
@@ -59,7 +63,11 @@ public interface BaseTSD extends StdCallLibrary {
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value);
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
@@ -0,0 +1,104 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.ptr.IntByReference;
/**
* Exception class for all COM related classes.
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class COMException extends RuntimeException {
/** The p excep info. */
private EXCEPINFO pExcepInfo;
/** The pu arg err. */
private IntByReference puArgErr;
/**
* Instantiates a new automation exception.
*/
public COMException() {
super();
}
/**
* Instantiates a new automation exception.
*
* @param message
* the message
* @param cause
* the cause
*/
public COMException(String message, Throwable cause) {
super(message, cause);
}
/**
* Instantiates a new automation exception.
*
* @param message
* the message
*/
public COMException(String message) {
super(message);
}
/**
* Instantiates a new automation exception.
*
* @param message
* the message
* @param pExcepInfo
* the excep info
* @param puArgErr
* the pu arg err
*/
public COMException(String message, EXCEPINFO pExcepInfo,
IntByReference puArgErr) {
super(message);
this.pExcepInfo = pExcepInfo;
this.puArgErr = puArgErr;
}
/**
* Instantiates a new automation exception.
*
* @param cause
* the cause
*/
public COMException(Throwable cause) {
super(cause);
}
/**
* Gets the excep info.
*
* @return the excep info
*/
public EXCEPINFO getExcepInfo() {
return pExcepInfo;
}
/**
* Gets the arg err.
*
* @return the arg err
*/
public IntByReference getArgErr() {
return puArgErr;
}
}
@@ -0,0 +1,202 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Native;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.OaIdl;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.Ole32;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.Variant.VariantArg;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Helper class to provide basic COM support.
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class COMObject {
public final static LCID LOCALE_USER_DEFAULT = Kernel32.INSTANCE
.GetUserDefaultLCID();
public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
.GetSystemDefaultLCID();
protected IUnknown iUnknown;
protected IDispatch iDispatch;
private PointerByReference pDispatch = new PointerByReference();
private PointerByReference pUnknown = new PointerByReference();
public COMObject(IDispatch iDispatch) {
this.iDispatch = iDispatch;
}
/**
* Instantiates a new cOM object.
*
* @param progId
* the prog id
* @param useActiveInstance
* the use active instance
* @throws COMException
* the automation exception
*/
public COMObject(String progId, boolean useActiveInstance)
throws COMException {
// enable JNA protected mode
Native.setProtected(true);
// Initialize COM for this thread...
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
if (COMUtils.FAILED(hr)) {
this.release();
throw new COMException("CoInitialize() failed!");
}
// Get CLSID for Word.Application...
CLSID.ByReference clsid = new CLSID.ByReference();
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
if (COMUtils.FAILED(hr)) {
Ole32.INSTANCE.CoUninitialize();
throw new COMException("CLSIDFromProgID() failed!");
}
if (useActiveInstance) {
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
if (COMUtils.SUCCEEDED(hr)) {
this.iUnknown = new IUnknown(this.pUnknown.getValue());
hr = iUnknown.QueryInterface(IDispatch.IID_IDispatch,
this.pDispatch);
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
this.pDispatch);
}
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
this.pDispatch);
}
if (COMUtils.FAILED(hr)) {
throw new COMException("COM object with ProgID '" + progId
+ "' and CLSID " + clsid.toGuidString() + " not registered properly!");
}
this.iDispatch = new IDispatch(this.pDispatch.getValue());
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name, VARIANT[] pArgs) throws COMException {
if (pDisp == null)
throw new COMException("pDisp (IDispatch) parameter is null!");
WString[] ptName = new WString[] { new WString(name) };
DISPPARAMS dp = new DISPPARAMS();
DISPIDbyReference pdispID = new DISPIDbyReference();
VariantArg.ByReference variantArg = new VariantArg.ByReference();
variantArg.variantArg = pArgs;
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
IntByReference puArgErr = new IntByReference();
// Get DISPID for name passed...
HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
LOCALE_USER_DEFAULT, pdispID);
COMUtils.checkAutoRC(hr);
// Handle special-case for property-puts!
if (nType == OleAuto.DISPATCH_PROPERTYPUT) {
dp.cNamedArgs = new UINT(pArgs.length);
dp.rgdispidNamedArgs = new DISPIDbyReference(
OaIdl.DISPID_PROPERTYPUT);
}
// Build DISPPARAMS
if ((pArgs != null) && (pArgs.length > 0)) {
dp.cArgs = new UINT(pArgs.length);
dp.rgvarg = variantArg;
// write 'DISPPARAMS' structure to memory
dp.write();
}
// Make the call!
hr = pDisp.Invoke(pdispID.getValue(), Guid.IID_NULL,
LOCALE_SYSTEM_DEFAULT, new DISPID(nType), dp, pvResult,
pExcepInfo, puArgErr);
COMUtils.checkAutoRC(hr, pExcepInfo, puArgErr);
return hr;
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name, VARIANT pArg) throws COMException {
return this.oleMethod(nType, pvResult, pDisp, name,
new VARIANT[] { pArg });
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name) throws COMException {
return this.oleMethod(nType, pvResult, pDisp, name, (VARIANT[]) null);
}
protected void checkFailed(HRESULT hr) {
COMUtils.checkAutoRC(hr, null, null);
}
public IDispatch getIDispatch() {
return iDispatch;
}
public PointerByReference getIDispatchPointer() {
return pDispatch;
}
public IUnknown getIUnknown() {
return iUnknown;
}
public PointerByReference getIUnknownPointer() {
return pUnknown;
}
public void release() {
if (this.iDispatch != null)
this.iDispatch.Release();
Ole32.INSTANCE.CoUninitialize();
}
}
@@ -0,0 +1,355 @@
package com.sun.jna.platform.win32.COM;
import java.util.ArrayList;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Advapi32;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
import com.sun.jna.platform.win32.Advapi32Util.InfoKey;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.W32Errors;
import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinError;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.WinReg;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
// TODO: Auto-generated Javadoc
/**
* The Class COMUtils.
*/
public abstract class COMUtils {
/** The Constant CO_E_NOTINITIALIZED. */
public static final int S_OK = 0, S_FALSE = 1,
REGDB_E_CLASSNOTREG = 0x80040154,
CLASS_E_NOAGGREGATION = 0x80040110,
CO_E_NOTINITIALIZED = 0x800401F0;
/** The Constant E_UNEXPECTED. */
public static final int E_UNEXPECTED = 0x8000FFFF;
/** The Constant E_NOTIMPL. */
public static final int E_NOTIMPL = 0x80004001;
/** The Constant E_OUTOFMEMORY. */
public static final int E_OUTOFMEMORY = 0x8007000E;
/** The Constant E_INVALIDARG. */
public static final int E_INVALIDARG = 0x80070057;
/** The Constant E_NOINTERFACE. */
public static final int E_NOINTERFACE = 0x80004002;
/** The Constant E_POINTER. */
public static final int E_POINTER = 0x80004003;
/** The Constant E_HANDLE. */
public static final int E_HANDLE = 0x80070006;
/** The Constant E_ABORT. */
public static final int E_ABORT = 0x80004004;
/** The Constant E_FAIL. */
public static final int E_FAIL = 0x80004005;
/** The Constant E_ACCESSDENIED. */
public static final int E_ACCESSDENIED = 0x80070005;
/** The Constant DISP_E_BADVARTYPE. */
public static final int DISP_E_BADVARTYPE = -2147352568;
/** The Constant DISP_E_NOTACOLLECTION. */
public static final int DISP_E_NOTACOLLECTION = -2147352559;
/** The Constant DISP_E_MEMBERNOTFOUND. */
public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
/** The Constant DISP_E_ARRAYISLOCKED. */
public static final int DISP_E_ARRAYISLOCKED = -2147352563;
/** The Constant DISP_E_EXCEPTION. */
public static final int DISP_E_EXCEPTION = -2147352567;
/** The Constant DISP_E_TYPEMISMATCH. */
public static final int DISP_E_TYPEMISMATCH = -2147352571;
/** The Constant DISP_E_BADINDEX. */
public static final int DISP_E_BADINDEX = -2147352565;
/** The Constant DISP_E_BADCALLEE. */
public static final int DISP_E_BADCALLEE = -2147352560;
/** The Constant DISP_E_OVERFLOW. */
public static final int DISP_E_OVERFLOW = -2147352566;
/** The Constant DISP_E_UNKNOWNINTERFACE. */
public static final int DISP_E_UNKNOWNINTERFACE = -2147352575;
/** The Constant DISP_E_DIVBYZERO. */
public static final int DISP_E_DIVBYZERO = -2147352558;
/** The Constant DISP_E_UNKNOWNLCID. */
public static final int DISP_E_UNKNOWNLCID = -2147352564;
/** The Constant DISP_E_PARAMNOTOPTIONAL. */
public static final int DISP_E_PARAMNOTOPTIONAL = -2147352561;
/** The Constant DISP_E_PARAMNOTFOUND. */
public static final int DISP_E_PARAMNOTFOUND = -2147352572;
/** The Constant DISP_E_BADPARAMCOUNT. */
public static final int DISP_E_BADPARAMCOUNT = -2147352562;
/** The Constant DISP_E_BUFFERTOOSMALL. */
public static final int DISP_E_BUFFERTOOSMALL = -2147352557;
/** The Constant DISP_E_UNKNOWNNAME. */
public static final int DISP_E_UNKNOWNNAME = -2147352570;
/** The Constant DISP_E_NONAMEDARGS. */
public static final int DISP_E_NONAMEDARGS = -2147352569;
/** The Constant CO_E_OBJNOTCONNECTED. */
public static final int CO_E_OBJNOTCONNECTED = -2147220995;
/**
* Succeeded.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean SUCCEEDED(HRESULT hr) {
return SUCCEEDED(hr.intValue());
}
/**
* Succeeded.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean SUCCEEDED(int hr) {
if (hr == S_OK)
return true;
else
return false;
}
/**
* Failed.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean FAILED(HRESULT hr) {
return FAILED(hr.intValue());
}
/**
* Failed.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean FAILED(int hr) {
if (hr != S_OK)
return true;
else
return false;
}
/**
* Throw new exception.
*
* @param hr
* the hr
*/
public static void checkAutoRC(HRESULT hr) {
checkAutoRC(hr, null, null);
}
/**
* Throw new exception.
*
* @param hr
* the hr
* @param pExcepInfo
* the excep info
* @param puArgErr
* the pu arg err
*/
public static void checkAutoRC(HRESULT hr, EXCEPINFO pExcepInfo,
IntByReference puArgErr) {
switch (hr.intValue()) {
case S_OK:
return;
case E_NOTIMPL:
throw new COMException("Not implemented!");
case E_INVALIDARG:
throw new COMException("Invalid argument!");
case E_OUTOFMEMORY:
throw new COMException("Out of memory!");
case E_UNEXPECTED:
throw new COMException("Error "
+ Integer.toHexString(hr.intValue()));
case CO_E_NOTINITIALIZED:
throw new COMException("CoInitialized wasn't called!");
case E_NOINTERFACE:
throw new COMException("Interface does not inherit from class!");
case E_POINTER:
throw new COMException("Allocated pointer pointer is null!");
case DISP_E_UNKNOWNNAME:
throw new COMException(
"One or more of the names were not known. The returned array of DISPIDs contains DISPID_UNKNOWN for each entry that corresponds to an unknown name!");
case DISP_E_UNKNOWNLCID:
throw new COMException(
"The locale identifier (LCID) was not recognized!");
case DISP_E_BADPARAMCOUNT:
throw new COMException(
"The number of elements provided to DISPPARAMS is different from the number of arguments accepted by the method or property!");
case DISP_E_BADVARTYPE:
throw new COMException(
"One of the arguments in DISPPARAMS is not a valid variant type!");
case DISP_E_EXCEPTION:
throw new COMException(
"The application needs to raise an exception. In this case, the structure passed in pexcepinfo should be filled in!",
pExcepInfo, puArgErr);
case DISP_E_MEMBERNOTFOUND:
throw new COMException("The requested member does not exist!");
case DISP_E_NONAMEDARGS:
throw new COMException(
"This implementation of IDispatch does not support named arguments!");
case DISP_E_OVERFLOW:
throw new COMException(
"One of the arguments in DISPPARAMS could not be coerced to the specified type!");
case DISP_E_PARAMNOTFOUND:
throw new COMException(
"One of the parameter IDs does not correspond to a parameter on the method. In this case, puArgErr is set to the first argument that contains the error!",
pExcepInfo, puArgErr);
case DISP_E_TYPEMISMATCH:
throw new COMException(
"One or more of the arguments could not be coerced. The index of the first parameter with the incorrect type within rgvarg is returned in puArgErr!",
pExcepInfo, puArgErr);
case DISP_E_UNKNOWNINTERFACE:
throw new COMException(
"The interface identifier passed in riid is not IID_NULL!");
case CO_E_OBJNOTCONNECTED:
throw new COMException(
"The method is not connected to the Dispatch pointer!");
default:
throw new COMException("Unexpected COM error code : "
+ toHexStr(hr));
}
}
public static void checkTypeLibRC(HRESULT hr) {
switch (hr.intValue()) {
case S_OK:
return;
case WinError.E_INVALIDARG:
throw new COMException("One or more of the arguments is not valid.");
case WinError.E_OUTOFMEMORY:
throw new COMException(
"Insufficient memory to complete the operation.");
case WinError.TYPE_E_IOERROR:
throw new COMException("The function could not write to the file.");
case WinError.TYPE_E_INVALIDSTATE:
throw new COMException("The type library could not be opened.");
case WinError.TYPE_E_INVDATAREAD:
throw new COMException(
"The function could not read from the file. ");
case WinError.TYPE_E_UNSUPFORMAT:
throw new COMException("The type library has an older format.");
case WinError.TYPE_E_UNKNOWNLCID:
throw new COMException(
"The LCID could not be found in the OLE-supported DLLs.");
case WinError.TYPE_E_CANTLOADLIBRARY:
throw new COMException(
"The type library or DLL could not be loaded.");
case WinError.TYPE_E_ELEMENTNOTFOUND:
throw new COMException(
"No type description was found in the library with the specified GUID.");
default:
throw new COMException("Unexpected Typelib error code : "
+ toHexStr(hr));
}
}
public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
HKEYByReference phkResult = new HKEYByReference();
HKEYByReference phkResult2 = new HKEYByReference();
String subKey;
ArrayList<COMInfo> comInfos = new ArrayList<COMUtils.COMInfo>();
try {
// open root key
phkResult = Advapi32Util.registryGetKey(WinReg.HKEY_CLASSES_ROOT, "CLSID", WinNT.KEY_ALL_ACCESS);
// open subkey
InfoKey infoKey = Advapi32Util.registryQueryInfoKey(phkResult.getValue(), WinNT.KEY_ALL_ACCESS);
for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
EnumKey enumKey = Advapi32Util.registryRegEnumKey(phkResult.getValue(), i);
subKey = Native.toString(enumKey.lpName);
COMInfo comInfo = new COMInfo(subKey);
phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(), subKey, WinNT.KEY_ALL_ACCESS);
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++)
{
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(phkResult2.getValue(), y);
String subKey2 = Native.toString(enumKey2.lpName);
if(subKey2.equals("InprocHandler32")) {
comInfo.inprocHandler32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("InprocServer32")) {
comInfo.inprocServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("LocalServer32")) {
comInfo.localServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("ProgID")) {
comInfo.progID = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("TypeLib")) {
comInfo.typeLib = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}
}
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
comInfos.add(comInfo);
}
} finally {
Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
}
return comInfos;
}
public static class COMInfo {
public String clsid;
public String inprocHandler32;
public String inprocServer32;
public String localServer32;
public String progID;
public String typeLib;
public COMInfo() {
}
public COMInfo(String clsid) {
this.clsid = clsid;
}
}
private static String toHexStr(HRESULT hr) {
return "0x" + Integer.toHexString(hr.intValue()).toUpperCase();
}
}
@@ -0,0 +1,164 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.IID;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Wrapper class for the IDispatch interface
*
* IDispatch.GetTypeInfoCount 12 IDispatch.GetTypeInfo 16
* IDispatch.GetIDsOfNames 20 IDispatch.Invoke 24
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class IDispatch extends IUnknown {
/**
* The Class ByReference.
*/
public static class ByReference extends IDispatch implements
Structure.ByReference {
}
/** The Constant IID_IDispatch. */
public final static IID IID_IDispatch = new IID(
"00020400-0000-0000-C000-000000000046");
/**
* Instantiates a new i dispatch.
*/
public IDispatch() {
}
/**
* Instantiates a new i dispatch.
*
* @param pvInstance
* the pv instance
*/
public IDispatch(Pointer pvInstance) {
super(pvInstance);
}
/**
* Gets the type info count.
*
* @param pctinfo
* the pctinfo
* @return the hresult
*/
public HRESULT GetTypeInfoCount(IntByReference pctinfo) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(12));
int hr = func.invokeInt(new Object[] { this.getPointer(), pctinfo });
return new HRESULT(hr);
}
/**
* Gets the type info.
*
* @param iTInfo
* the i t info
* @param lcid
* the lcid
* @param ppTInfo
* the pp t info
* @return the hresult
*/
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
PointerByReference ppTInfo) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(16));
int hr = func.invokeInt(new Object[] { this.getPointer(), iTInfo, lcid,
ppTInfo });
return new HRESULT(hr);
}
/**
* Gets the i ds of names.
*
* @param riid
* the riid
* @param rgszNames
* the rgsz names
* @param cNames
* the c names
* @param lcid
* the lcid
* @param rgDispId
* the rg disp id
* @return the hresult
*/
public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
LCID lcid, DISPIDbyReference rgDispId) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(20));
int hr = func.invokeInt(new Object[] { this.getPointer(), riid,
rgszNames, cNames, lcid, rgDispId });
return new HRESULT(hr);
}
/**
* Invoke.
*
* @param dispIdMember
* the disp id member
* @param riid
* the riid
* @param lcid
* the lcid
* @param wFlags
* the w flags
* @param pDispParams
* the disp params
* @param pVarResult
* the var result
* @param pExcepInfo
* the excep info
* @param puArgErr
* the pu arg err
* @return the hresult
*/
public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
DISPID wFlags, DISPPARAMS pDispParams,
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
IntByReference puArgErr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(24));
int hr = func.invokeInt(new Object[] { this.getPointer(), dispIdMember,
riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo,
puArgErr });
return new HRESULT(hr);
}
}
@@ -0,0 +1,282 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.Guid.IID;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinDef.BOOL;
import com.sun.jna.platform.win32.WinDef.PVOID;
import com.sun.jna.platform.win32.WinDef.ULONG;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Wrapper class for the IRecordInfo interface
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class IRecordInfo extends IUnknown {
/** The Constant IID_IRecordInfo. */
public final static IID IID_IRecordInfo = new IID(
"{0000002F-0000-0000-C000-000000000046}");
/**
* Instantiates a new i record info.
*/
public IRecordInfo() {
}
/**
* Instantiates a new i record info.
*
* @param pvInstance
* the pv instance
*/
public IRecordInfo(Pointer pvInstance) {
super(pvInstance);
}
/**
* Record init.
*
* @param pvNew
* the pv new
* @return the hresult
*/
public HRESULT RecordInit(/* [out] */PVOID pvNew) {
return null;
}
/**
* Record clear.
*
* @param pvExisting
* the pv existing
* @return the hresult
*/
public HRESULT RecordClear(
/* [in] */PVOID pvExisting) {
return null;
}
/**
* Record copy.
*
* @param pvExisting
* the pv existing
* @param pvNew
* the pv new
* @return the hresult
*/
public HRESULT RecordCopy(
/* [in] */PVOID pvExisting,
/* [out] */PVOID pvNew) {
return null;
}
/**
* Gets the guid.
*
* @param pguid
* the pguid
* @return the hresult
*/
public HRESULT GetGuid(
/* [out] */GUID pguid) {
return null;
}
/**
* Gets the name.
*
* @param pbstrName
* the pbstr name
* @return the hresult
*/
public HRESULT GetName(
/* [out] */BSTR pbstrName) {
return null;
}
/**
* Gets the size.
*
* @param pcbSize
* the pcb size
* @return the hresult
*/
public HRESULT GetSize(
/* [out] */ULONG pcbSize) {
return null;
}
/**
* Gets the type info.
*
* @param ppTypeInfo
* the pp type info
* @return the hresult
*/
public HRESULT GetTypeInfo(
/* [out] */ITypeInfo ppTypeInfo) {
return null;
}
/**
* Gets the field.
*
* @param pvData
* the pv data
* @param szFieldName
* the sz field name
* @param pvarField
* the pvar field
* @return the hresult
*/
public HRESULT GetField(
/* [in] */PVOID pvData,
/* [in] */WString szFieldName,
/* [out] */VARIANT pvarField) {
return null;
}
/**
* Gets the field no copy.
*
* @param pvData
* the pv data
* @param szFieldName
* the sz field name
* @param pvarField
* the pvar field
* @param ppvDataCArray
* the ppv data c array
* @return the hresult
*/
public HRESULT GetFieldNoCopy(
/* [in] */PVOID pvData,
/* [in] */WString szFieldName,
/* [out] */VARIANT pvarField,
/* [out] */PVOID ppvDataCArray) {
return null;
}
/**
* Put field.
*
* @param wFlags
* the w flags
* @param pvData
* the pv data
* @param szFieldName
* the sz field name
* @param pvarField
* the pvar field
* @return the hresult
*/
public HRESULT PutField(
/* [in] */ULONG wFlags,
/* [out][in] */PVOID pvData,
/* [in] */WString szFieldName,
/* [in] */VARIANT pvarField) {
return null;
}
/**
* Put field no copy.
*
* @param wFlags
* the w flags
* @param pvData
* the pv data
* @param szFieldName
* the sz field name
* @param pvarField
* the pvar field
* @return the hresult
*/
public HRESULT PutFieldNoCopy(
/* [in] */ULONG wFlags,
/* [out][in] */PVOID pvData,
/* [in] */WString szFieldName,
/* [in] */VARIANT pvarField) {
return null;
}
/**
* Gets the field names.
*
* @param pcNames
* the pc names
* @param rgBstrNames
* the rg bstr names
* @return the hresult
*/
public HRESULT GetFieldNames(
/* [out][in] */ULONG pcNames,
/* [length_is][size_is][out] */BSTR rgBstrNames) {
return null;
}
/**
* Checks if is matching type.
*
* @param pRecordInfo
* the record info
* @return the bool
*/
public BOOL IsMatchingType(
/* [in] */IRecordInfo pRecordInfo) {
return null;
}
/**
* Record create.
*
* @return the pvoid
*/
public PVOID RecordCreate() {
return null;
}
/**
* Record create copy.
*
* @param pvSource
* the pv source
* @param ppvDest
* the ppv dest
* @return the hresult
*/
public HRESULT RecordCreateCopy(
/* [in] */PVOID pvSource,
/* [out] */PVOID ppvDest) {
return null;
}
/**
* Record destroy.
*
* @param pvRecord
* the pv record
* @return the hresult
*/
public HRESULT RecordDestroy(
/* [in] */PVOID pvRecord) {
return null;
}
}
@@ -0,0 +1,74 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.OaIdl.BINDPTR;
import com.sun.jna.platform.win32.OaIdl.DESCKIND;
import com.sun.jna.platform.win32.WinDef.ULONG;
import com.sun.jna.platform.win32.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Wrapper class for the ITypeComp interface
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class ITypeComp extends IUnknown {
public static class ByReference extends ITypeComp implements
Structure.ByReference {
}
public ITypeComp() {
}
public ITypeComp(Pointer pvInstance) {
super(pvInstance);
}
public HRESULT Bind(
/* [annotation][in] */
WString szName,
/* [in] */ULONG lHashVal,
/* [in] */WORD wFlags,
/* [out] */ITypeInfo.ByReference ppTInfo,
/* [out] */DESCKIND.ByReference pDescKind,
/* [out] */BINDPTR.ByReference pBindPtr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(12));
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
lHashVal, wFlags, ppTInfo, pDescKind, pBindPtr });
return new HRESULT(hr);
}
public HRESULT BindType(
/* [annotation][in] */
WString szName,
/* [in] */ULONG lHashVal,
/* [out] */ITypeInfo.ByReference ppTInfo,
/* [out] */ITypeComp.ByReference ppTComp) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(16));
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
lHashVal, ppTInfo, ppTComp });
return new HRESULT(hr);
}
}
@@ -0,0 +1,293 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.REFIID;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
import com.sun.jna.platform.win32.OaIdl.HREFTYPEbyReference;
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
import com.sun.jna.platform.win32.OaIdl.VARDESC;
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
import com.sun.jna.platform.win32.WinDef.PVOID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
import com.sun.jna.platform.win32.WinDef.WORD;
import com.sun.jna.platform.win32.WinDef.WORDbyReference;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Wrapper class for the ITypeInfo interface
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class ITypeInfo extends IUnknown {
public static class ByReference extends ITypeInfo implements
Structure.ByReference {
}
public ITypeInfo() {
}
public ITypeInfo(Pointer pvInstance) {
super(pvInstance);
}
public HRESULT GetTypeAttr(
/* [out] */TYPEATTR.ByReference pTypeAttr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(12));
int hr = func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
pTypeAttr.read();
return new HRESULT(hr);
}
public HRESULT GetTypeComp(
/* [out] */ITypeComp.ByReference pTComp) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(16));
PointerByReference ppTComp = new PointerByReference();
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
pTComp.setPointer(ppTComp.getValue());
return new HRESULT(hr);
}
public/* [local] */HRESULT GetFuncDesc(
/* [in] */UINT index,
/* [out] */FUNCDESC.ByReference pFuncDesc) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(20));
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
pFuncDesc });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetVarDesc(
/* [in] */UINT index,
/* [out] */VARDESC.ByReference pVarDesc) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(24));
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
pVarDesc });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetNames(
/* [in] */MEMBERID memid,
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
/* [in] */UINT cMaxNames,
/* [out] */UINTbyReference pcNames) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(28));
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
rgBstrNames, cMaxNames, pcNames });
return new HRESULT(hr);
}
public HRESULT GetRefTypeOfImplType(
/* [in] */UINT index,
/* [out] */HREFTYPEbyReference pRefType) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(32));
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
pRefType });
return new HRESULT(hr);
}
public HRESULT GetImplTypeFlags(
/* [in] */UINT index,
/* [out] */IntByReference pImplTypeFlags) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(36));
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
pImplTypeFlags });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetIDsOfNames(
/* [size_is][in] */WString[] rgszNames,
/* [in] */UINT cNames,
/* [size_is][out] */MEMBERID[] pMemId) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(40));
int hr = func.invokeInt(new Object[] { this.getPointer(), rgszNames,
cNames, pMemId });
return new HRESULT(hr);
}
public/* [local] */HRESULT Invoke(
/* [in] */PVOID pvInstance,
/* [in] */MEMBERID memid,
/* [in] */WORD wFlags,
/* [out][in] */DISPPARAMS.ByReference pDispParams,
/* [out] */VARIANT.ByReference pVarResult,
/* [out] */EXCEPINFO.ByReference pExcepInfo,
/* [out] */UINTbyReference puArgErr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(44));
int hr = func.invokeInt(new Object[] { this.getPointer(), pvInstance,
memid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetDocumentation(
/* [in] */MEMBERID memid,
/* [out] */BSTR pBstrName,
/* [out] */BSTR pBstrDocString,
/* [out] */DWORDbyReference pdwHelpContext,
/* [out] */BSTR pBstrHelpFile) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(48));
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetDllEntry(
/* [in] */MEMBERID memid,
/* [in] */INVOKEKIND invKind,
/* [out] */BSTR pBstrDllName,
/* [out] */BSTR pBstrName,
/* [out] */WORDbyReference pwOrdinal) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(52));
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
invKind, pBstrDllName, pBstrName, pwOrdinal });
return new HRESULT(hr);
}
public HRESULT GetRefTypeInfo(
/* [in] */HREFTYPE hRefType,
/* [out] */ITypeInfo.ByReference ppTInfo) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(56));
int hr = func.invokeInt(new Object[] { this.getPointer(), hRefType,
ppTInfo });
return new HRESULT(hr);
}
public/* [local] */HRESULT AddressOfMember(
/* [in] */MEMBERID memid,
/* [in] */INVOKEKIND invKind,
/* [out] */PointerByReference ppv) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(60));
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
invKind, ppv });
return new HRESULT(hr);
}
public/* [local] */HRESULT CreateInstance(
/* [in] */IUnknown pUnkOuter,
/* [in] */REFIID riid,
/* [iid_is][out] */PointerByReference ppvObj) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(64));
int hr = func.invokeInt(new Object[] { this.getPointer(), pUnkOuter,
riid, ppvObj });
return new HRESULT(hr);
}
public HRESULT GetMops(
/* [in] */MEMBERID memid,
/* [out] */BSTR pBstrMops) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(68));
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
pBstrMops });
return new HRESULT(hr);
}
public/* [local] */HRESULT GetContainingTypeLib(
/* [out] */ITypeLib.ByReference pTLib,
/* [out] */UINTbyReference pIndex) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(72));
PointerByReference ppTLib = new PointerByReference();
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLib,
pIndex });
pTLib.setPointer(ppTLib.getPointer());
return new HRESULT(hr);
}
public/* [local] */void ReleaseTypeAttr(
/* [in] */TYPEATTR pTypeAttr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(76));
func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
}
public/* [local] */void ReleaseFuncDesc(
/* [in] */FUNCDESC pFuncDesc) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(80));
func.invokeInt(new Object[] { this.getPointer(), pFuncDesc });
}
public/* [local] */void ReleaseVarDesc(
/* [in] */VARDESC pVarDesc) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(84));
func.invokeInt(new Object[] { this.getPointer(), pVarDesc });
}
}
@@ -0,0 +1,168 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinDef.BOOLbyReference;
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinDef.ULONG;
import com.sun.jna.platform.win32.WinDef.USHORTbyReference;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Wrapper class for the ITypeLib interface
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class ITypeLib extends IUnknown {
public static class ByReference extends IUnknown implements
Structure.ByReference {
}
public ITypeLib() {
}
public ITypeLib(Pointer pvInstance) {
super(pvInstance);
}
public UINT GetTypeInfoCount() {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(12));
int count = func.invokeInt(new Object[] { this.getPointer() });
return new UINT(count);
}
public HRESULT GetTypeInfo(
/* [in] */UINT index,
/* [out] */ITypeInfo.ByReference pTInfo) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(16));
PointerByReference ppTInfo = new PointerByReference();
int hr = func.invokeInt(new Object[] { this.getPointer(), index, ppTInfo });
pTInfo.setPointer(ppTInfo.getValue());
return new HRESULT(hr);
}
public HRESULT GetTypeInfoType(
/* [in] */UINT index,
/* [out] */IntByReference pTKind) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(20));
int hr = func
.invokeInt(new Object[] { this.getPointer(), index, pTKind });
return new HRESULT(hr);
}
public HRESULT GetTypeInfoOfGuid(
/* [in] */GUID guid,
/* [out] */ITypeInfo.ByReference pTinfo) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(24));
PointerByReference ppTinfo = new PointerByReference();
int hr = func.invokeInt(new Object[] { this.getPointer(), guid, ppTinfo });
pTinfo.setPointer(ppTinfo.getPointer());
return new HRESULT(hr);
}
public HRESULT GetLibAttr(
/* [out] */TLIBATTR.ByReference ppTLibAttr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(28));
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLibAttr });
return new HRESULT(hr);
}
public HRESULT GetTypeComp(
/* [out] */ITypeComp.ByReference pTComp) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(32));
PointerByReference ppTComp = new PointerByReference();
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
pTComp.setPointer(ppTComp.getPointer());
return new HRESULT(hr);
}
public HRESULT GetDocumentation(
/* [in] */int index,
/* [out] */BSTR pBstrName,
/* [out] */BSTR pBstrDocString,
/* [out] */DWORDbyReference pdwHelpContext,
/* [out] */BSTR pBstrHelpFile) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(36));
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
return new HRESULT(hr);
}
public HRESULT IsName(
/* [annotation][out][in] */
WString szNameBuf,
/* [in] */ULONG lHashVal,
/* [out] */BOOLbyReference pfName) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(40));
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
lHashVal, pfName });
return new HRESULT(hr);
}
public HRESULT FindName(
/* [annotation][out][in] */
WString szNameBuf,
/* [in] */ULONG lHashVal,
/* [length_is][size_is][out] */ITypeInfo.ByReference ppTInfo,
/* [length_is][size_is][out] */MEMBERIDbyReference rgMemId,
/* [out][in] */USHORTbyReference pcFound) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(44));
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
lHashVal, ppTInfo, rgMemId, pcFound });
return new HRESULT(hr);
}
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(48));
func.invokeInt(new Object[] { this.getPointer(), pTLibAttr });
}
}
@@ -0,0 +1,101 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.Guid.IID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
/**
* Wrapper class for the ITypeInfo interface
*
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
* IUnknown.Release 8
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class IUnknown extends PointerType {
/**
* The Class ByReference.
*/
public static class ByReference extends IUnknown implements
Structure.ByReference {
}
/** The Constant IID_IDispatch. */
public final static IID IID_IDispatch = new IID(
"{00000000-0000-0000-C000-000000000046}");
/**
* Instantiates a new i unknown.
*/
public IUnknown() {
}
/**
* Instantiates a new i unknown.
*
* @param pvInstance
* the pv instance
*/
public IUnknown(Pointer pvInstance) {
this.setPointer(pvInstance);
}
/**
* Query interface.
*
* @param riid
* the riid
* @param ppvObject
* the ppv object
* @return the hresult
*/
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(0));
int hr = func.invokeInt(new Object[] { this.getPointer(), riid,
ppvObject });
return new HRESULT(hr);
}
/**
* Adds the ref.
*
* @return the ulong
*/
public int AddRef() {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(4));
return func.invokeInt(new Object[] { this.getPointer() });
}
/**
* Release.
*
* @return the ulong
*/
public int Release() {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(8));
return func.invokeInt(new Object[] { this.getPointer() });
}
}
@@ -0,0 +1,530 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinDef.LONG;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on dbt.h (various types)
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
@SuppressWarnings("serial")
public interface DBT extends StdCallLibrary {
/** The dbt no disk space. */
int DBT_NO_DISK_SPACE = 0x0047;
/** The dbt low disk space. */
int DBT_LOW_DISK_SPACE = 0x0048;
/** The dbt configmgprivate. */
int DBT_CONFIGMGPRIVATE = 0x7FFF;
/** The dbt devicearrival. */
int DBT_DEVICEARRIVAL = 0x8000;
/** The dbt devicequeryremove. */
int DBT_DEVICEQUERYREMOVE = 0x8001;
/** The dbt devicequeryremovefailed. */
int DBT_DEVICEQUERYREMOVEFAILED = 0x8002;
/** The dbt deviceremovepending. */
int DBT_DEVICEREMOVEPENDING = 0x8003;
/** The dbt deviceremovecomplete. */
int DBT_DEVICEREMOVECOMPLETE = 0x8004;
/** A device has been added to or removed from the system. */
int DBT_DEVNODES_CHANGED = 0x0007;
/** The dbt devicetypespecific. */
int DBT_DEVICETYPESPECIFIC = 0x8005;
/** The dbt customevent. */
int DBT_CUSTOMEVENT = 0x8006;
/** The guid devinterface usb device. */
public GUID GUID_DEVINTERFACE_USB_DEVICE = new GUID(
"{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
/** The guid devinterface hid. */
public GUID GUID_DEVINTERFACE_HID = new GUID(
"{4D1E55B2-F16F-11CF-88CB-001111000030}");
/** The guid devinterface volume. */
public GUID GUID_DEVINTERFACE_VOLUME = new GUID(
"{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}");
/** The guid devinterface keyboard. */
public GUID GUID_DEVINTERFACE_KEYBOARD = new GUID(
"{884b96c3-56ef-11d1-bc8c-00a0c91405dd}");
/** The guid devinterface mouse. */
public GUID GUID_DEVINTERFACE_MOUSE = new GUID(
"{378DE44C-56EF-11D1-BC8C-00A0C91405DD}");
/**
* The Class DEV_BROADCAST_HDR.
*/
public class DEV_BROADCAST_HDR extends Structure {
/** The dbch_size. */
public int dbch_size = size();
/** The dbch_devicetype. */
public int dbch_devicetype;
/** The dbch_reserved. */
public int dbch_reserved;
/**
* Instantiates a new dev broadcast hdr.
*/
public DEV_BROADCAST_HDR() {
}
/**
* Instantiates a new dev broadcast hdr.
*
* @param pointer
* the pointer
*/
public DEV_BROADCAST_HDR(long pointer) {
this(new Pointer(pointer));
}
/**
* Instantiates a new dev broadcast hdr.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_HDR(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
"dbch_reserved" });
}
}
/** The dbt devtyp oem. */
int DBT_DEVTYP_OEM = 0x00000000;
/** The dbt devtyp devnode. */
int DBT_DEVTYP_DEVNODE = 0x00000001;
/** The dbt devtyp volume. */
int DBT_DEVTYP_VOLUME = 0x00000002;
/** The dbt devtyp port. */
int DBT_DEVTYP_PORT = 0x00000003;
/** The dbt devtyp net. */
int DBT_DEVTYP_NET = 0x00000004;
/** The dbt devtyp deviceinterface. */
int DBT_DEVTYP_DEVICEINTERFACE = 0x00000005;
/** The dbt devtyp handle. */
int DBT_DEVTYP_HANDLE = 0x00000006;
/**
* The Class DEV_BROADCAST_OEM.
*/
public class DEV_BROADCAST_OEM extends Structure {
/** The dbco_size. */
public int dbco_size = size();
/** The dbco_devicetype. */
public int dbco_devicetype;
/** The dbco_reserved. */
public int dbco_reserved;
/** The dbco_identifier. */
public int dbco_identifier;
/** The dbco_suppfunc. */
public int dbco_suppfunc;
/**
* Instantiates a new dev broadcast oem.
*/
public DEV_BROADCAST_OEM() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast oem.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_OEM(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbco_size", "dbco_devicetype",
"dbco_reserved", "dbco_identifier", "dbco_suppfunc" });
}
}
/**
* The Class DEV_BROADCAST_DEVNODE.
*/
public class DEV_BROADCAST_DEVNODE extends Structure {
/** The dbcd_size. */
public int dbcd_size = size();
/** The dbcd_devicetype. */
public int dbcd_devicetype;
/** The dbcd_reserved. */
public int dbcd_reserved;
/** The dbcd_devnode. */
public int dbcd_devnode;
/**
* Instantiates a new dev broadcast devnode.
*/
public DEV_BROADCAST_DEVNODE() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast devnode.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_DEVNODE(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcd_size", "dbcd_devicetype",
"dbcd_reserved", "dbcd_devnode" });
}
}
/**
* The Class DEV_BROADCAST_VOLUME.
*/
public class DEV_BROADCAST_VOLUME extends Structure {
/** The dbcv_size. */
public int dbcv_size = size();
/** The dbcv_devicetype. */
public int dbcv_devicetype;
/** The dbcv_reserved. */
public int dbcv_reserved;
/** The dbcv_unitmask. */
public int dbcv_unitmask;
/** The dbcv_flags. */
public short dbcv_flags;
/**
* Instantiates a new dev broadcast volume.
*/
public DEV_BROADCAST_VOLUME() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast volume.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_VOLUME(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcv_size", "dbcv_devicetype",
"dbcv_reserved", "dbcv_unitmask", "dbcv_flags" });
}
}
/**
* The Class DEV_BROADCAST_PORT.
*/
public class DEV_BROADCAST_PORT extends Structure {
/** The dbcp_size. */
public int dbcp_size = size();
/** The dbcp_devicetype. */
public int dbcp_devicetype;
/** The dbcp_reserved. */
public int dbcp_reserved;
/** The dbcp_name. */
public char[] dbcp_name = new char[1];
/**
* Instantiates a new dev broadcast port.
*/
public DEV_BROADCAST_PORT() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast port.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_PORT(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcp_size", "dbcp_devicetype",
"dbcp_reserved", "dbcp_name" });
}
}
/**
* The Class DEV_BROADCAST_NET.
*/
public class DEV_BROADCAST_NET extends Structure {
/** The dbcn_size. */
public int dbcn_size = size();
/** The dbcn_devicetype. */
public int dbcn_devicetype;
/** The dbcn_reserved. */
public int dbcn_reserved;
/** The dbcn_resource. */
public int dbcn_resource;
/** The dbcn_flags. */
public int dbcn_flags;
/**
* Instantiates a new dev broadcast net.
*/
public DEV_BROADCAST_NET() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast net.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_NET(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcn_size", "dbcn_devicetype",
"dbcn_reserved", "dbcn_resource", "dbcn_flags" });
}
}
/**
* The Class DEV_BROADCAST_DEVICEINTERFACE.
*/
public class DEV_BROADCAST_DEVICEINTERFACE extends Structure {
/** The dbcc_size. */
public int dbcc_size;
/** The dbcc_devicetype. */
public int dbcc_devicetype;
/** The dbcc_reserved. */
public int dbcc_reserved;
/** The dbcc_classguid. */
public GUID dbcc_classguid;
/** The dbcc_name. */
public char[] dbcc_name = new char[1];
/**
* Instantiates a new dev broadcast deviceinterface.
*/
public DEV_BROADCAST_DEVICEINTERFACE() {
// TODO Auto-generated constructor stub
}
/**
* Dev broadcast hdr.
*
* @param pointer
* the pointer
*/
public DEV_BROADCAST_DEVICEINTERFACE(long pointer) {
this(new Pointer(pointer));
}
/**
* Instantiates a new dev broadcast deviceinterface.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_DEVICEINTERFACE(Pointer memory) {
super(memory);
this.dbcc_size = (Integer) this.readField("dbcc_size");
// figure out how long dbcc_name should be based on the size
int len = 1 + this.dbcc_size - size();
this.dbcc_name = new char[len];
read();
}
/**
* Gets the dbcc_name.
*
* @return the dbcc_name
*/
public String getDbcc_name() {
return Native.toString(this.dbcc_name);
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcc_size", "dbcc_devicetype",
"dbcc_reserved", "dbcc_classguid", "dbcc_name" });
}
}
/**
* The Class DEV_BROADCAST_HANDLE.
*/
public class DEV_BROADCAST_HANDLE extends Structure {
/** The dbch_size. */
public int dbch_size = size();
/** The dbch_devicetype. */
public int dbch_devicetype;
/** The dbch_reserved. */
public int dbch_reserved;
/** The dbch_handle. */
public HANDLE dbch_handle;
/** The dbch_hdevnotify. */
public HDEVNOTIFY dbch_hdevnotify;
/** The dbch_eventguid. */
public GUID dbch_eventguid;
/** The dbch_nameoffset. */
public LONG dbch_nameoffset;
/** The dbch_data. */
public byte[] dbch_data;
/**
* Instantiates a new dev broadcast handle.
*/
public DEV_BROADCAST_HANDLE() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast handle.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_HANDLE(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
"dbch_reserved", "dbch_handle", "dbch_hdevnotify",
"dbch_eventguid", "dbch_nameoffset", "dbch_data" });
}
}
}
@@ -12,7 +12,9 @@
*/
package com.sun.jna.platform.win32;
import com.sun.jna.NativeLong;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
@@ -34,14 +36,10 @@ public interface DsGetDC extends StdCallLibrary {
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
public DOMAIN_CONTROLLER_INFO() { }
}
public DOMAIN_CONTROLLER_INFO() {
}
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
super(memory);
read();
@@ -105,6 +103,10 @@ public interface DsGetDC extends StdCallLibrary {
* subnet that the computer is in with a valid site.
*/
public WString ClientSiteName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
}
}
/**
@@ -117,6 +119,10 @@ public interface DsGetDC extends StdCallLibrary {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dci" });
}
}
/**
@@ -161,7 +167,6 @@ public interface DsGetDC extends StdCallLibrary {
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
@@ -175,20 +180,20 @@ public interface DsGetDC extends StdCallLibrary {
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public NativeLong Flags;
public int Flags;
/**
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
* corresponds to the parent domain of the domain represented by this structure.
*/
public NativeLong ParentIndex;
public int ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public NativeLong TrustType;
public int TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public NativeLong TrustAttributes;
public int TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
@@ -199,27 +204,17 @@ public interface DsGetDC extends StdCallLibrary {
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
};
/**
* A pointer to an array of DS_DOMAIN_TRUSTS.
*/
public static class PDS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
protected List getFieldOrder() {
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
}
public DS_DOMAIN_TRUSTS() {
}
public DS_DOMAIN_TRUSTS.ByReference t;
/**
* Returns domain trusts.
* @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);
public DS_DOMAIN_TRUSTS(Pointer p) {
super(p);
read();
}
}
};
}
@@ -1,93 +1,476 @@
/* 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.
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
// TODO: Auto-generated Javadoc
/**
* Ported from Guid.h.
* Microsoft Windows SDK 6.0A.
* Ported from Guid.h. Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface Guid {
public static class GUID extends Structure {
public static class ByReference extends GUID implements Structure.ByReference {
public ByReference() {
}
public final static IID IID_NULL = new IID();
/**
* The Class GUID.
*/
public static class GUID extends Structure {
public ByReference(GUID guid) {
super(guid.getPointer());
/**
* The Class ByReference.
*/
public static class ByReference extends GUID implements
Structure.ByReference {
Data1 = guid.Data1;
Data2 = guid.Data2;
Data3 = guid.Data3;
Data4 = guid.Data4;
}
public ByReference(Pointer memory) {
super(memory);
}
}
public GUID() {
}
public GUID(Pointer memory) {
super(memory);
read();
}
/**
* Instantiates a new by reference.
*/
public ByReference() {
}
public GUID(byte[] data) {
if (data.length != 16) {
throw new IllegalArgumentException("Invalid data length: " + data.length);
}
/**
* Instantiates a new by reference.
*
* @param guid
* the guid
*/
public ByReference(GUID guid) {
super(guid.getPointer());
long data1Temp = data[3] & 0xff;
data1Temp <<= 8;
data1Temp |= data[2] & 0xff;
data1Temp <<= 8;
data1Temp |= data[1] & 0xff;
data1Temp <<= 8;
data1Temp |= data[0] & 0xff;
Data1 = (int) data1Temp;
Data1 = guid.Data1;
Data2 = guid.Data2;
Data3 = guid.Data3;
Data4 = guid.Data4;
}
int data2Temp = data[5] & 0xff;
data2Temp <<= 8;
data2Temp |= data[4] & 0xff;
Data2 = (short) data2Temp;
/**
* Instantiates a new by reference.
*
* @param memory
* the memory
*/
public ByReference(Pointer memory) {
super(memory);
}
}
int data3Temp = data[7] & 0xff;
data3Temp <<= 8;
data3Temp |= data[6] & 0xff;
Data3 = (short) data3Temp;
/** The Data1. */
public int Data1;
Data4[0] = data[8];
Data4[1] = data[9];
Data4[2] = data[10];
Data4[3] = data[11];
Data4[4] = data[12];
Data4[5] = data[13];
Data4[6] = data[14];
Data4[7] = data[15];
}
/** The Data2. */
public short Data2;
public int Data1;
public short Data2;
public short Data3;
public byte[] Data4 = new byte[8];
}
/** The Data3. */
public short Data3;
/** The Data4. */
public byte[] Data4 = new byte[8];
/**
* Instantiates a new guid.
*/
public GUID() {
}
/**
* Instantiates a new guid.
*
* @param guid
* the guid
*/
public GUID(GUID guid) {
this.Data1 = guid.Data1;
this.Data2 = guid.Data2;
this.Data3 = guid.Data3;
this.Data4 = guid.Data4;
this.writeFieldsToMemory();
}
/**
* Instantiates a new guid.
*
* @param guid
* the guid
*/
public GUID(String guid) {
this(fromString(guid));
}
/**
* Instantiates a new guid.
*
* @param data
* the data
*/
public GUID(byte[] data) {
this(fromBinary(data));
}
/**
* Instantiates a new guid.
*
* @param memory
* the memory
*/
public GUID(Pointer memory) {
super(memory);
read();
}
/**
* From binary.
*
* @param data
* the data
* @return the guid
*/
public static GUID fromBinary(byte[] data) {
if (data.length != 16) {
throw new IllegalArgumentException("Invalid data length: "
+ data.length);
}
GUID newGuid = new GUID();
long data1Temp = data[0] & 0xff;
data1Temp <<= 8;
data1Temp |= data[1] & 0xff;
data1Temp <<= 8;
data1Temp |= data[2] & 0xff;
data1Temp <<= 8;
data1Temp |= data[3] & 0xff;
newGuid.Data1 = (int) data1Temp;
int data2Temp = data[4] & 0xff;
data2Temp <<= 8;
data2Temp |= data[5] & 0xff;
newGuid.Data2 = (short) data2Temp;
int data3Temp = data[6] & 0xff;
data3Temp <<= 8;
data3Temp |= data[7] & 0xff;
newGuid.Data3 = (short) data3Temp;
newGuid.Data4[0] = data[8];
newGuid.Data4[1] = data[9];
newGuid.Data4[2] = data[10];
newGuid.Data4[3] = data[11];
newGuid.Data4[4] = data[12];
newGuid.Data4[5] = data[13];
newGuid.Data4[6] = data[14];
newGuid.Data4[7] = data[15];
newGuid.writeFieldsToMemory();
return newGuid;
}
/**
* From string.
*
* @param guid
* the guid
* @return the guid
*/
public static GUID fromString(String guid) {
int y = 0;
char[] _cnewguid = new char[32];
char[] _cguid = guid.toCharArray();
byte[] bdata = new byte[16];
GUID newGuid = new GUID();
// we not accept a string longer than 38 chars
if (guid.length() > 38) {
throw new IllegalArgumentException("Invalid guid length: "
+ guid.length());
}
// remove '{', '}' and '-' from guid string
for (int i = 0; i < _cguid.length; i++) {
if ((_cguid[i] != '{') && (_cguid[i] != '-')
&& (_cguid[i] != '}'))
_cnewguid[y++] = _cguid[i];
}
// convert char to byte
for (int i = 0; i < 32; i += 2) {
bdata[i / 2] = (byte) ((Character.digit(_cnewguid[i], 16) << 4)
+ Character.digit(_cnewguid[i + 1], 16) & 0xff);
}
if (bdata.length != 16) {
throw new IllegalArgumentException("Invalid data length: "
+ bdata.length);
}
long data1Temp = bdata[0] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[1] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[2] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[3] & 0xff;
newGuid.Data1 = (int) data1Temp;
int data2Temp = bdata[4] & 0xff;
data2Temp <<= 8;
data2Temp |= bdata[5] & 0xff;
newGuid.Data2 = (short) data2Temp;
int data3Temp = bdata[6] & 0xff;
data3Temp <<= 8;
data3Temp |= bdata[7] & 0xff;
newGuid.Data3 = (short) data3Temp;
newGuid.Data4[0] = bdata[8];
newGuid.Data4[1] = bdata[9];
newGuid.Data4[2] = bdata[10];
newGuid.Data4[3] = bdata[11];
newGuid.Data4[4] = bdata[12];
newGuid.Data4[5] = bdata[13];
newGuid.Data4[6] = bdata[14];
newGuid.Data4[7] = bdata[15];
newGuid.writeFieldsToMemory();
return newGuid;
}
/**
* Generates a new guid. Code taken from the standard jdk
* implementation (see UUID class).
*
* @return the guid
*/
public static GUID newGuid() {
SecureRandom ng = new SecureRandom();
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f;
randomBytes[6] |= 0x40;
randomBytes[8] &= 0x3f;
randomBytes[8] |= 0x80;
return new GUID(randomBytes);
}
/**
* To byte array.
*
* @return the byte[]
*/
public byte[] toByteArray() {
byte[] guid = new byte[16];
byte[] bytes1 = new byte[4];
bytes1[0] = (byte) (Data1 >> 24);
bytes1[1] = (byte) (Data1 >> 16);
bytes1[2] = (byte) (Data1 >> 8);
bytes1[3] = (byte) (Data1 >> 0);
byte[] bytes2 = new byte[4];
bytes2[0] = (byte) (Data2 >> 24);
bytes2[1] = (byte) (Data2 >> 16);
bytes2[2] = (byte) (Data2 >> 8);
bytes2[3] = (byte) (Data2 >> 0);
byte[] bytes3 = new byte[4];
bytes3[0] = (byte) (Data3 >> 24);
bytes3[1] = (byte) (Data3 >> 16);
bytes3[2] = (byte) (Data3 >> 8);
bytes3[3] = (byte) (Data3 >> 0);
System.arraycopy(bytes1, 0, guid, 0, 4);
System.arraycopy(bytes2, 2, guid, 4, 2);
System.arraycopy(bytes3, 2, guid, 6, 2);
System.arraycopy(Data4, 0, guid, 8, 8);
return guid;
}
/**
* The value of this Guid, formatted as follows:
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
*
* @return the string
*/
public String toGuidString() {
final String HEXES = "0123456789ABCDEF";
byte[] bGuid = toByteArray();
final StringBuilder hexStr = new StringBuilder(2 * bGuid.length);
hexStr.append("{");
for (int i = 0; i < bGuid.length; i++) {
char ch1 = HEXES.charAt((bGuid[i] & 0xF0) >> 4);
char ch2 = HEXES.charAt(bGuid[i] & 0x0F);
hexStr.append(ch1).append(ch2);
if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
hexStr.append("-");
}
hexStr.append("}");
return hexStr.toString();
}
/**
* Write fields to backing memory.
*/
protected void writeFieldsToMemory() {
this.writeField("Data1");
this.writeField("Data2");
this.writeField("Data3");
this.writeField("Data4");
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Data1", "Data2", "Data3",
"Data4" });
}
}
/**
* The Class CLSID.
*/
public static class CLSID extends GUID {
/**
* The Class ByReference.
*/
public static class ByReference extends GUID {
/**
* Instantiates a new by reference.
*/
public ByReference() {
}
/**
* Instantiates a new by reference.
*
* @param guid
* the guid
*/
public ByReference(GUID guid) {
super(guid);
}
/**
* Instantiates a new by reference.
*
* @param memory
* the memory
*/
public ByReference(Pointer memory) {
}
}
/**
* Instantiates a new clsid.
*/
public CLSID() {
}
}
/**
* The Class REFIID.
*/
public class REFIID extends IID {
/**
* Instantiates a new refiid.
*/
public REFIID() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new refiid.
*
* @param memory
* the memory
*/
public REFIID(Pointer memory) {
super(memory);
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new refiid.
*
* @param data
* the data
*/
public REFIID(byte[] data) {
super(data);
// TODO Auto-generated constructor stub
}
}
/**
* The Class IID.
*/
public class IID extends GUID {
/**
* Instantiates a new iid.
*/
public IID() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new iid.
*
* @param memory
* the memory
*/
public IID(Pointer memory) {
super(memory);
// TODO Auto-generated constructor stub
}
public IID(String iid) {
super(iid);
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new iid.
*
* @param data
* the data
*/
public IID(byte[] data) {
super(data);
// TODO Auto-generated constructor stub
}
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,4 +1,4 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, 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
@@ -19,15 +19,16 @@ import java.util.List;
import com.sun.jna.LastErrorException;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Kernel32 utility API.
* @author dblock[at]dblock.org
* @author markus[at]headcrashing[dot]eu
*/
public abstract class Kernel32Util implements WinDef {
@@ -176,7 +177,7 @@ public abstract class Kernel32Util implements WinDef {
case WinNT.FILE_TYPE_UNKNOWN:
int err = Kernel32.INSTANCE.GetLastError();
switch(err) {
case W32Errors.NO_ERROR:
case WinError.NO_ERROR:
break;
default:
throw new Win32Exception(err);
@@ -196,9 +197,95 @@ public abstract class Kernel32Util implements WinDef {
}
/**
* @returns One of the WinBase.DRIVE_* constants.
* @return One of the WinBase.DRIVE_* constants.
*/
public static int getDriveType(String rootName) {
return Kernel32.INSTANCE.GetDriveType(rootName);
}
/**
* Get the value of an environment variable.
* @param name
* Name of the environment variable.
* @return
* Value of an environment variable.
*/
public static String getEnvironmentVariable(String name) {
// obtain the buffer size
int size = Kernel32.INSTANCE.GetEnvironmentVariable(name, null, 0);
if (size == 0) {
return null;
} else if (size < 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
// obtain the value
char[] buffer = new char[size];
size = Kernel32.INSTANCE.GetEnvironmentVariable(name, buffer, buffer.length);
if (size <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Retrieves an integer associated with a key in the specified section of an initialization file.
*
* @param appName
* The name of the section in the initialization file.
* @param keyName
* The name of the key whose value is to be retrieved. This value is in the form of a string; the {@link Kernel32#GetPrivateProfileInt} function converts
* the string into an integer and returns the integer.
* @param defaultValue
* The default value to return if the key name cannot be found in the initialization file.
* @param fileName
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
* Windows directory.
* @return The retrieved integer, or the default if not found.
*/
public static final int getPrivateProfileInt(final String appName, final String keyName, final int defaultValue, final String fileName) {
return Kernel32.INSTANCE.GetPrivateProfileInt(appName, keyName, defaultValue, fileName);
}
/**
* Retrieves a string from the specified section in an initialization file.
*
* @param lpAppName
* The name of the section containing the key name. If this parameter is {@code null}, the {@link Kernel32#GetPrivateProfileString} function copies all
* section names in the file to the supplied buffer.
* @param lpKeyName
* The name of the key whose associated string is to be retrieved. If this parameter is {@code null}, all key names in the section specified by
* the {@code lpAppName} parameter are returned.
* @param lpDefault
* A default string. If the {@code lpKeyName} key cannot be found in the initialization file, {@link Kernel32#GetPrivateProfileString} returns the
* default. If this parameter is {@code null}, the default is an empty string, {@code ""}.
* <p>
* Avoid specifying a default string with trailing blank characters. The function inserts a {@code null} character in the
* {@code lpReturnedString} buffer to strip any trailing blanks.
* </p>
* @param lpFileName
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
* Windows directory.
* @return <p>
* If neither {@code lpAppName} nor {@code lpKeyName} is {@code null} and the destination buffer is too small to hold the requested string, the
* string is truncated.
* </p>
* <p>
* If either {@code lpAppName} or {@code lpKeyName} is {@code null} and the destination buffer is too small to hold all the strings, the last string
* is truncated and followed by two {@code null} characters.
* </p>
* <p>
* In the event the initialization file specified by {@code lpFileName} is not found, or contains invalid values, this function will set errorno
* with a value of '0x2' (File Not Found). To retrieve extended error information, call {@link Kernel32#GetLastError}.
* </p>
*/
public static final String getPrivateProfileString(final String lpAppName, final String lpKeyName, final String lpDefault, final String lpFileName) {
final char buffer[] = new char[1024];
Kernel32.INSTANCE.GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buffer, new DWORD(buffer.length), lpFileName);
return Native.toString(buffer);
}
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) {
if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName))
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
@@ -12,6 +12,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
@@ -36,6 +39,10 @@ public interface LMAccess extends StdCallLibrary {
}
public WString lgrui0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lgrui0_name" });
}
}
public static class LOCALGROUP_INFO_1 extends Structure {
@@ -50,6 +57,9 @@ public interface LMAccess extends StdCallLibrary {
public WString lgrui1_name;
public WString lgrui1_comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lgrui1_name", "lgrui1_comment" });
}
}
//
@@ -80,6 +90,9 @@ public interface LMAccess extends StdCallLibrary {
* Pointer to a Unicode string that specifies the name of the user account.
*/
public WString usri0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "usri0_name" });
}
}
/**
@@ -136,6 +149,10 @@ public interface LMAccess extends StdCallLibrary {
* logon script file.
*/
public WString usri1_script_path;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" });
}
}
/**
@@ -206,7 +223,11 @@ public interface LMAccess extends StdCallLibrary {
* A pointer to a SID structure that contains the security identifier (SID)
* that uniquely identifies the user. The NetUserAdd and NetUserSetInfo functions ignore this member.
*/
public PSID.ByReference usri23_user_sid;
public PSID.ByReference usri23_user_sid;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid" });
}
}
/**
@@ -226,6 +247,10 @@ public interface LMAccess extends StdCallLibrary {
* Pointer to a null-terminated Unicode character string that specifies a name.
*/
public WString grui0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grui0_name" });
}
}
/**
@@ -245,6 +270,10 @@ public interface LMAccess extends StdCallLibrary {
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
*/
public WString lgrui0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lgrui0_name" });
}
}
/**
@@ -267,6 +296,10 @@ public interface LMAccess extends StdCallLibrary {
* the name of the global group.
*/
public WString grpi0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi0_name" });
}
}
/**
@@ -294,6 +327,10 @@ public interface LMAccess extends StdCallLibrary {
* string. The comment can contain MAXCOMMENTSZ characters.
*/
public WString grpi1_comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi1_name", "grpi1_comment" });
}
}
/**
@@ -331,6 +368,10 @@ public interface LMAccess extends StdCallLibrary {
* and SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi2_attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes" });
}
}
/**
@@ -368,6 +409,10 @@ public interface LMAccess extends StdCallLibrary {
* SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi3_attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes" });
}
}
//
@@ -12,8 +12,10 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
@@ -53,6 +55,10 @@ public interface NTSecApi extends StdCallLibrary {
*/
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" });
}
/**
* String representation of the buffer.
* @return
@@ -98,11 +104,18 @@ public interface NTSecApi extends StdCallLibrary {
public PSID.ByReference Sid;
public LSA_UNICODE_STRING DnsName;
public LSA_UNICODE_STRING NetbiosName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" });
}
}
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
public NativeLong Length;
public int Length;
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "Buffer" });
}
}
public static class LSA_FOREST_TRUST_RECORD extends Structure {
@@ -124,7 +137,7 @@ public interface NTSecApi extends StdCallLibrary {
/**
* Flags that control the behavior of the operation.
*/
public NativeLong Flags;
public int Flags;
/**
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
@@ -146,6 +159,10 @@ public interface NTSecApi extends StdCallLibrary {
*/
public UNION u;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" });
}
public void read() {
super.read();
@@ -171,7 +188,11 @@ public interface NTSecApi extends StdCallLibrary {
}
public LSA_FOREST_TRUST_RECORD.ByReference tr;
public LSA_FOREST_TRUST_RECORD.ByReference tr;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "tr" });
}
}
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
@@ -184,20 +205,24 @@ public interface NTSecApi extends StdCallLibrary {
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
* Entries member.
*/
public NativeLong RecordCount;
public int RecordCount;
/**
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
* each of which contains one piece of forest trust information.
*/
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "RecordCount", "Entries" });
}
/**
* 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());
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount);
}
}
/**
@@ -210,6 +235,10 @@ public interface NTSecApi extends StdCallLibrary {
}
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fti" });
}
}
}
@@ -13,15 +13,12 @@
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
@@ -390,7 +387,7 @@ public interface Netapi32 extends StdCallLibrary {
* @param Flags
* Contains a set of flags that determines which domain trusts to enumerate.
* @param Domains
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
* Receives a pointer which points to an array of DS_DOMAIN_TRUSTS structures.
* Each structure in this array contains trust data about a domain. The caller must free this
* memory when it is no longer required by calling NetApiBufferFree.
* @param DomainCount
@@ -398,8 +395,8 @@ public interface Netapi32 extends StdCallLibrary {
* @return
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
*/
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
public int DsEnumerateDomainTrusts(String serverName, int Flags,
PointerByReference Domains, IntByReference DomainCount);
/**
* The NetUserGetInfo function retrieves information about a particular user account on a server.
@@ -14,11 +14,9 @@ package com.sun.jna.platform.win32;
import java.util.ArrayList;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
@@ -27,7 +25,6 @@ import com.sun.jna.platform.win32.LMAccess.USER_INFO_23;
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.ptr.PointerByReference;
/**
@@ -209,8 +206,12 @@ public abstract class Netapi32Util {
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LOCALGROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.lgrui1_name.toString();
lgp.comment = lgpi.lgrui1_comment.toString();;
if (lgpi.lgrui1_name != null) {
lgp.name = lgpi.lgrui1_name.toString();
}
if (lgpi.lgrui1_comment != null) {
lgp.comment = lgpi.lgrui1_comment.toString();
}
result.add(lgp);
}
return result.toArray(new LocalGroup[0]);
@@ -254,8 +255,12 @@ public abstract class Netapi32Util {
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.grpi1_name.toString();
lgp.comment = lgpi.grpi1_comment.toString();;
if (lgpi.grpi1_name != null) {
lgp.name = lgpi.grpi1_name.toString();
}
if (lgpi.grpi1_comment != null) {
lgp.comment = lgpi.grpi1_comment.toString();
}
result.add(lgp);
}
return result.toArray(new LocalGroup[0]);
@@ -287,19 +292,21 @@ public abstract class Netapi32Util {
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
int rc = Netapi32.INSTANCE.NetUserEnum(
serverName, 1, 0, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
ArrayList<User> result = new ArrayList<User>();
for(LMAccess.USER_INFO_1 lu : users) {
User auser = new User();
auser.name = lu.usri1_name.toString();
if (lu.usri1_name != null) {
auser.name = lu.usri1_name.toString();
}
result.add(auser);
}
return result.toArray(new User[0]);
@@ -318,8 +325,7 @@ public abstract class Netapi32Util {
* @return Local groups.
*/
public static Group[] getCurrentUserLocalGroups() {
return getUserLocalGroups(Secur32Util.getUserNameEx(
EXTENDED_NAME_FORMAT.NameSamCompatible));
return getUserLocalGroups(Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible));
}
/**
@@ -342,8 +348,9 @@ public abstract class Netapi32Util {
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(
serverName, userName,
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
@@ -352,7 +359,9 @@ public abstract class Netapi32Util {
ArrayList<Group> result = new ArrayList<Group>();
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
LocalGroup lgp = new LocalGroup();
lgp.name = lgpi.lgrui0_name.toString();
if (lgpi.lgrui0_name != null) {
lgp.name = lgpi.lgrui0_name.toString();
}
result.add(lgp);
}
return result.toArray(new Group[0]);
@@ -386,8 +395,9 @@ public abstract class Netapi32Util {
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
int rc = Netapi32.INSTANCE.NetUserGetGroups(
serverName, userName,
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
@@ -396,7 +406,9 @@ public abstract class Netapi32Util {
ArrayList<Group> result = new ArrayList<Group>();
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
Group lgp = new Group();
lgp.name = lgpi.grui0_name.toString();
if (lgpi.grui0_name != null) {
lgp.name = lgpi.grui0_name.toString();
}
result.add(lgp);
}
return result.toArray(new Group[0]);
@@ -462,14 +474,24 @@ public abstract class Netapi32Util {
throw new Win32Exception(rc);
}
DomainController dc = new DomainController();
dc.address = pdci.dci.DomainControllerAddress.toString();
if (pdci.dci.DomainControllerAddress != null) {
dc.address = pdci.dci.DomainControllerAddress.toString();
}
dc.addressType = pdci.dci.DomainControllerAddressType;
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
dc.dnsForestName = pdci.dci.DnsForestName.toString();
if (pdci.dci.ClientSiteName != null) {
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
}
if (pdci.dci.DnsForestName != null) {
dc.dnsForestName = pdci.dci.DnsForestName.toString();
}
dc.domainGuid = pdci.dci.DomainGuid;
dc.domainName = pdci.dci.DomainName.toString();
if (pdci.dci.DomainName != null) {
dc.domainName = pdci.dci.DomainName.toString();
}
dc.flags = pdci.dci.Flags;
dc.name = pdci.dci.DomainControllerName.toString();
if (pdci.dci.DomainControllerName != null) {
dc.name = pdci.dci.DomainControllerName.toString();
}
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
@@ -594,30 +616,39 @@ public abstract class Netapi32Util {
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts(String serverName) {
NativeLongByReference domainCount = new NativeLongByReference();
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
IntByReference domainTrustCount = new IntByReference();
PointerByReference domainsPointerRef = new PointerByReference();
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(serverName,
DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount);
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
try {
int domainCountValue = domainCount.getValue().intValue();
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainTrustCount.getValue());
for(DS_DOMAIN_TRUSTS domainTrust : domainTrusts) {
DomainTrust t = new DomainTrust();
t.DnsDomainName = trust.DnsDomainName.toString();
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
t.DomainSid = trust.DomainSid;
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
t.DomainGuid = trust.DomainGuid;
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
t.flags = trust.Flags.intValue();
if (domainTrust.DnsDomainName != null) {
t.DnsDomainName = domainTrust.DnsDomainName.toString();
}
if (domainTrust.NetbiosDomainName != null) {
t.NetbiosDomainName = domainTrust.NetbiosDomainName.toString();
}
t.DomainSid = domainTrust.DomainSid;
if (domainTrust.DomainSid != null) {
t.DomainSidString = Advapi32Util.convertSidToStringSid(domainTrust.DomainSid);
}
t.DomainGuid = domainTrust.DomainGuid;
if (domainTrust.DomainGuid != null) {
t.DomainGuidString = Ole32Util.getStringFromGUID(domainTrust.DomainGuid);
}
t.flags = domainTrust.Flags;
trusts.add(t);
}
return trusts.toArray(new DomainTrust[0]);
} finally {
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
rc = Netapi32.INSTANCE.NetApiBufferFree(domainsPointerRef.getValue());
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
@@ -636,11 +667,19 @@ public abstract class Netapi32Util {
if (rc == LMErr.NERR_Success) {
USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue());
UserInfo userInfo = new UserInfo();
userInfo.comment = info_23.usri23_comment.toString();
if (info_23.usri23_comment != null) {
userInfo.comment = info_23.usri23_comment.toString();
}
userInfo.flags = info_23.usri23_flags;
userInfo.fullName = info_23.usri23_full_name.toString();
userInfo.name = info_23.usri23_name.toString();
userInfo.sidString = Advapi32Util.convertSidToStringSid(info_23.usri23_user_sid);
if (info_23.usri23_full_name != null) {
userInfo.fullName = info_23.usri23_full_name.toString();
}
if (info_23.usri23_name != null) {
userInfo.name = info_23.usri23_name.toString();
}
if (info_23.usri23_user_sid != null) {
userInfo.sidString = Advapi32Util.convertSidToStringSid(info_23.usri23_user_sid);
}
userInfo.sid = info_23.usri23_user_sid;
return userInfo;
} else {
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,37 +1,59 @@
/*
* 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 {
int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
// With DCOM, CLSCTX_REMOTE_SERVER should be included
int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_INPROC_HANDLER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
}
/*
* 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;
// TODO: Auto-generated Javadoc
/**
* Definitions from ObjBase.h
* @author scott.palmer
*/
public interface ObjBase {
/** The clsctx inproc. */
int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
// With DCOM, CLSCTX_REMOTE_SERVER should be included
/** The clsctx all. */
int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_INPROC_HANDLER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
/** The clsctx server. */
int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
}
@@ -14,93 +14,196 @@ package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinDef.LPVOID;
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;
// TODO: Auto-generated Javadoc
/**
* Ole32.dll Interface.
*
* @author dblock[at]dblock.org
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public interface Ole32 extends StdCallLibrary {
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
/** The instance. */
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.
* 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.
* 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.
* Converts a globally unique identifier (GUID) into a string of printable
* characters.
*
* @param rguid
* The GUID to be converted.
* The GUID to be converted.
* @param lpsz
* A pointer to a caller-allocated string variable to receive the resulting string.
* 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.
* 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
* 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.
* 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.
* 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();
/**
* Initializes the COM library on the current thread and identifies the
* concurrency model as single-thread apartment (STA).
*
* New applications should call CoInitializeEx instead of CoInitialize.
*
* pvReserved [in, optional] This parameter is reserved and must be NULL.
*
* @param pvReserved
* the pv reserved
* @return S_OK The COM library was initialized successfully on this thread.
*
* S_FALSE The COM library is already initialized on this thread.
*
* RPC_E_CHANGED_MODE A previous call to CoInitializeEx specified
* the concurrency model for this thread as multithread apartment
* (MTA). This could also indicate that a change from
* neutral-threaded apartment to single-threaded apartment has
* occurred.
*/
HRESULT CoInitialize(LPVOID pvReserved);
/**
* 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);
/**
* 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);
/**
* Looks up a CLSID in the registry, given a ProgID.
*
* @param lpszProgID
* [in] A pointer to the ProgID whose CLSID is requested.
* @param lpclsid
* [out] Receives a pointer to the retrieved CLSID on return.
*
* @return S_OK The CLSID was retrieved successfully.
*
* CO_E_CLASSSTRING The registered CLSID for the ProgID is invalid.
*
* REGDB_E_WRITEREGDB An error occurred writing the CLSID to the
* registry. See Remarks below.
*
* Remarks Given a ProgID, CLSIDFromProgID looks up its associated
* CLSID in the registry. If the ProgID cannot be found in the
* registry, CLSIDFromProgID creates an OLE 1 CLSID for the ProgID
* and a CLSID entry in the registry. Because of the restrictions
* placed on OLE 1 CLSID values, CLSIDFromProgID and CLSIDFromString
* are the only two functions that can be used to generate a CLSID
* for an OLE 1 object.
*/
HRESULT CLSIDFromProgID(String lpszProgID, CLSID.ByReference lpclsid);
/**
* Converts a string generated by the StringFromCLSID function back into the
* original CLSID.
*
* @param lpsz
* [in] The string representation of the CLSID.
*
* @param pclsid
* [out] A pointer to the CLSID.
*
* @return Return value
*
* This function can return the standard return value E_INVALIDARG,
* as well as the following values.
*
* NOERROR The CLSID was obtained successfully.
*
* CO_E_CLASSSTRING The class string was improperly formatted.
*
* REGDB_E_CLASSNOTREG The CLSID corresponding to the class string
* was not found in the registry.
*
* REGDB_E_READREGDB The registry could not be opened for reading.
*/
HRESULT CLSIDFromString(WString lpsz, CLSID.ByReference pclsid);
}
@@ -0,0 +1,489 @@
/* copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.Variant.VariantArg;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.PVOID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.ITypeLib;
import com.sun.jna.ptr.DoubleByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
// TODO: Auto-generated Javadoc
/**
* Oleaut32.dll Interface.
*
* @author scott.palmer
*/
public interface OleAuto extends StdCallLibrary {
/* Flags for IDispatch::Invoke */
/** The Constant DISPATCH_METHOD. */
public final static int DISPATCH_METHOD = 0x1;
/** The Constant DISPATCH_PROPERTYGET. */
public final static int DISPATCH_PROPERTYGET = 0x2;
/** The Constant DISPATCH_PROPERTYPUT. */
public final static int DISPATCH_PROPERTYPUT = 0x4;
/** The Constant DISPATCH_PROPERTYPUTREF. */
public final static int DISPATCH_PROPERTYPUTREF = 0x8;
/** An array that is allocated on the stac. */
public final static int FADF_AUTO = 0x0001;
/** An array that is statically allocated. */
public final static int FADF_STATIC = 0x0002;
/** An array that is embedded in a structure. */
public final static int FADF_EMBEDDED = 0x0004;
/** An array that is embedded in a structure. */
public final static int FADF_FIXEDSIZE = 0x0010;
/** An array that is embedded in a structure. */
public final static int FADF_RECORD = 0x0020;
/** An array that is embedded in a structure. */
public final static int FADF_HAVEIID = 0x0040;
/**
* An array that has a variant type. The variant type can be retrieved with
* SafeArrayGetVartype.
*/
public final static int FADF_HAVEVARTYPE = 0x0080;
/** An array of BSTRs. */
public final static int FADF_BSTR = 0x0100;
/** An array of IUnknown*. */
public final static int FADF_UNKNOWN = 0x0200;
/** An array of IDispatch*. */
public final static int FADF_DISPATCH = 0x0400;
/** An array of VARIANTs. */
public final static int FADF_VARIANT = 0x0800;
/** Bits reserved for future use. */
public final static int FADF_RESERVED = 0xF008;
/** The instance. */
OleAuto INSTANCE = (OleAuto) Native.loadLibrary("OleAut32", OleAuto.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.
*/
public BSTR 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.
*/
public void SysFreeString(BSTR bstr);
/**
* The VariantInit function initializes the VARIANTARG by setting the vt
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
* the current contents of the VARIANTARG. Use VariantInit to initialize new
* local variables of type VARIANTARG (or VARIANT).
*
* @param pvarg
* The variant to initialize.
*/
public void VariantInit(VARIANT.ByReference pvarg);
/**
* The VariantInit function initializes the VARIANTARG by setting the vt
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
* the current contents of the VARIANTARG. Use VariantInit to initialize new
* local variables of type VARIANTARG (or VARIANT).
*
* @param pvarg
* The variant to initialize.
*/
public void VariantInit(VARIANT pvarg);
/**
* First, free any memory that is owned by pvargDest, such as VariantClear
* (pvargDest must point to a valid initialized variant, and not simply to
* an uninitialized memory location). Then pvargDest receives an exact copy
* of the contents of pvargSrc.
*
* If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrcis a
* VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or
* VT_UNKNOWN, AddRef is called to increment the object's reference count.
*
* If the variant to be copied is a COM object that is passed by reference,
* the vtfield of the pvargSrcparameter is VT_DISPATCH | VT_BYREF or
* VT_UNKNOWN | VT_BYREF. In this case, VariantCopy does not increment the
* reference count on the referenced object. Because the variant being
* copied is a pointer to a reference to an object, VariantCopy has no way
* to determine if it is necessary to increment the reference count of the
* object. It is therefore the responsibility of the caller to call
* IUnknown::AddRef on the object or not, as appropriate.
*
* Note The VariantCopy method is not threadsafe.
*
* @param pvargDest
* [out] The destination variant.
* @param pvargSrc
* [in] The source variant.
* @return the hresult
*/
public HRESULT VariantCopy(Pointer pvargDest, VARIANT pvargSrc);
/**
* Use this function to clear variables of type VARIANTARG (or VARIANT)
* before the memory containing the VARIANTARG is freed (as when a local
* variable goes out of scope).
*
* The function clears a VARIANTARG by setting the vt field to VT_EMPTY. The
* current contents of the VARIANTARG are released first. If the vtfield is
* VT_BSTR, the string is freed. If the vtfield is VT_DISPATCH, the object
* is released. If the vt field has the VT_ARRAY bit set, the array is
* freed.
*
* If the variant to be cleared is a COM object that is passed by reference,
* the vtfield of the pvargparameter is VT_DISPATCH | VT_BYREF or VT_UNKNOWN
* | VT_BYREF. In this case, VariantClear does not release the object.
* Because the variant being cleared is a pointer to a reference to an
* object, VariantClear has no way to determine if it is necessary to
* release the object. It is therefore the responsibility of the caller to
* release the object or not, as appropriate.
*
* In certain cases, it may be preferable to clear a variant in code without
* calling VariantClear. For example, you can change the type of a VT_I4
* variant to another type without calling this function. Safearrays of BSTR
* will have SysFreeString called on each element not VariantClear. However,
* you must call VariantClear if a VT_type is received but cannot be
* handled. Safearrays of variant will also have VariantClear called on each
* member. Using VariantClear in these cases ensures that code will continue
* to work if Automation adds new variant types in the future.
*
* Do not use VariantClear on unitialized variants; use VariantInit to
* initialize a new VARIANTARG or VARIANT.
*
* Variants containing arrays with outstanding references cannot be cleared.
* Attempts to do so will return an HRESULT containing DISP_E_ARRAYISLOCKED.
*
* @param pvarg
* [in, out] The variant to clear.
* @return the hresult
*/
HRESULT VariantClear(Pointer pvarg);
/**
* Creates a new array descriptor, allocates and initializes the data for
* the array, and returns a pointer to the new array descriptor.
*
* @param vt
* [in] The base type of the array (the VARTYPE of each element
* of the array). The VARTYPE is restricted to a subset of the
* variant types. Neither the VT_ARRAY nor the VT_BYREF flag can
* be set. VT_EMPTY and VT_NULL are not valid base types for the
* array. All other types are legal. cDims
*
* @param cDims
* the c dims
* @param rgsabound
* the rgsabound
*
* @return Return value
*
* A safe array descriptor, or null if the array could not be
* created.
*/
public SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims,
SAFEARRAYBOUND[] rgsabound);
/**
* Stores the data element at the specified location in the array.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
* @param idx
* the idx
* @param pv
* [in] The data to assign to the array. The variant types
* VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not
* require another level of indirection.
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* DISP_E_BADINDEX The specified index is not valid.
*
* E_INVALIDARG One of the arguments is not valid.
*
* E_OUTOFMEMORY Memory could not be allocated for the element.
*/
public HRESULT SafeArrayPutElement(SAFEARRAY psa, long[] idx, VARIANT pv);
/**
* Retrieves a single element of the array.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
* @param rgIndices
* [in] A vector of indexes for each dimension of the array. The
* right-most (least significant) dimension is rgIndices[0]. The
* left-most dimension is stored at rgIndices[psa->cDims - 1].
* @param pv
* [out] The element of the array.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* DISP_E_BADINDEX The specified index is not valid.
*
* E_INVALIDARG One of the arguments is not valid.
*
* E_OUTOFMEMORY Memory could not be allocated for the element.
*/
public HRESULT SafeArrayGetElement(SAFEARRAY psa, long[] rgIndices,
Pointer pv);
/**
* Increments the lock count of an array, and places a pointer to the array
* data in pvData of the array descriptor.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG The argument psa is not valid.
*
* E_UNEXPECTED The array could not be locked.
*/
public HRESULT SafeArrayLock(SAFEARRAY psa);
/**
* Decrements the lock count of an array so it can be freed or resized.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG The argument psa is not valid.
*
* E_UNEXPECTED The array could not be locked.
*/
public HRESULT SafeArrayUnLock(SAFEARRAY psa);
/**
* Retrieves a pointer to a running object that has been registered with
* OLE.
*
* @param rclsid
* [in] The class identifier (CLSID) of the active object from
* the OLE registration database.
* @param pvReserved
* Reserved for future use. Must be null.
* @param ppunk
* [out] The requested active object.
*
* @return Return value
*
* If this function succeeds, it returns S_OK. Otherwise, it returns
* an HRESULT error code.
*/
HRESULT GetActiveObject(GUID rclsid, PVOID pvReserved,
PointerByReference ppunk);
/**
* The Class DISPPARAMS.
*/
public class DISPPARAMS extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends DISPPARAMS implements
Structure.ByReference {
}
/** The rgvarg. */
public VariantArg.ByReference rgvarg;
/** The rgdispid named args. */
public DISPIDbyReference rgdispidNamedArgs;
/** The c args. */
public UINT cArgs;
/** The c named args. */
public UINT cNamedArgs;
/**
* Instantiates a new dispparams.
*/
public DISPPARAMS() {
super();
}
/**
* Instantiates a new dispparams.
*
* @param memory
* the memory
*/
public DISPPARAMS(Pointer memory) {
super(memory);
this.read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "rgvarg", "rgdispidNamedArgs",
"cArgs", "cNamedArgs" });
}
}
/**
* Uses registry information to load a type library.
*
* @param rguid
* The GUID of the library.
* @param wVerMajor
* The major version of the library.
* @param wVerMinor
* The minor version of the library.
* @param lcid
* The national language code of the library.
* @param pptlib
* The loaded type library.
*
* This function can return one of these values: S_OK Success.
*
* E_INVALIDARG One or more of the arguments is not valid.
*
* E_OUTOFMEMORY Insufficient memory to complete the operation.
*
* TYPE_E_IOERROR The function could not write to the file.
*
* TYPE_E_INVALIDSTATE The type library could not be opened.
*
* TYPE_E_INVDATAREAD The function could not read from the file.
*
* TYPE_E_UNSUPFORMAT The type library has an older format.
*
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
* OLE-supported DLLs.
*
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
* loaded.
*/
public HRESULT LoadRegTypeLib(GUID rguid, int wVerMajor, int wVerMinor,
LCID lcid, PointerByReference pptlib);
/**
* Loads and registers a type library.
*
* @param szFile
* The name of the file from which the method should attempt to
* load a type library.
*
* @param pptlib
* The loaded type library. Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG One or more of the arguments is not valid.
*
* E_OUTOFMEMORY Insufficient memory to complete the operation.
*
* TYPE_E_IOERROR The function could not write to the file.
*
* TYPE_E_INVALIDSTATE The type library could not be opened.
*
* TYPE_E_INVDATAREAD The function could not read from the file.
*
* TYPE_E_UNSUPFORMAT The type library has an older format.
*
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
* OLE-supported DLLs.
*
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
* loaded.
*/
HRESULT LoadTypeLib(WString szFile, ITypeLib pptlib);
/**
* Converts a system time to a variant representation.
*
* @param lpSystemTime
* [in] The system time.
*
* @param pvtime
* [out] The variant time.
*
* @return The function returns TRUE on success and FALSE otherwise.
*/
int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime,
DoubleByReference pvtime);
}
@@ -0,0 +1,78 @@
/* Copyright (c) 2012 Tobias Wolf, 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.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMUtils;
// TODO: Auto-generated Javadoc
/**
* The Class OleAut32Util.
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public abstract class OleAutoUtil {
/**
* Creates a new the variant array.
*
* @param size the size
* @return the sAFEARRA y. by reference
*/
public static SAFEARRAY.ByReference createVarArray(int size) {
SAFEARRAY.ByReference psa;
SAFEARRAYBOUND[] rgsabound = new SAFEARRAYBOUND[1];
rgsabound[0] = new SAFEARRAYBOUND(size, 0);
psa = OleAuto.INSTANCE.SafeArrayCreate(
new VARTYPE(Variant.VT_VARIANT), 1, rgsabound);
return psa;
}
/**
* Safe array put element.
*
* @param array the array
* @param index the index
* @param arg the arg
*/
public static void SafeArrayPutElement(SAFEARRAY array, long index,
VARIANT arg) {
long[] idx = new long[1];
idx[0] = index;
HRESULT hr = OleAuto.INSTANCE.SafeArrayPutElement(array, idx, arg);
COMUtils.SUCCEEDED(hr);
}
/**
* Safe array get element.
*
* @param array the array
* @param index the index
* @return the variant
*/
public static VARIANT SafeArrayGetElement(SAFEARRAY array, long index) {
long[] idx = new long[1];
idx[0] = index;
VARIANT result = new VARIANT();
HRESULT hr = OleAuto.INSTANCE.SafeArrayGetElement(array, idx,
result.getPointer());
COMUtils.SUCCEEDED(hr);
return result;
}
}
@@ -1,51 +0,0 @@
/*
* 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);
}
@@ -13,7 +13,6 @@
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Sspi.CredHandle;
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
@@ -23,7 +22,6 @@ 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;
@@ -97,7 +95,7 @@ public interface Secur32 extends StdCallLibrary {
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
NativeLong fCredentialUse, LUID pvLogonID,
int fCredentialUse, LUID pvLogonID,
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
Pointer pvGetKeyArgument, CredHandle phCredential,
TimeStamp ptsExpiry);
@@ -164,9 +162,9 @@ public interface Secur32 extends StdCallLibrary {
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
String pszTargetName, int fContextReq, int Reserved1,
int TargetDataRep, SecBufferDesc pInput, int Reserved2,
CtxtHandle phNewContext, SecBufferDesc pOutput, IntByReference pfContextAttr,
TimeStamp ptsExpiry);
/**
@@ -238,15 +236,15 @@ public interface Secur32 extends StdCallLibrary {
* This function returns one of SEC_* values.
*/
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
SecBufferDesc pInput, int fContextReq, int TargetDataRep,
CtxtHandle phNewContext, SecBufferDesc pOutput, IntByReference pfContextAttr,
TimeStamp ptsTimeStamp);
/**
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
* describe the security packages available to the client.
* @param pcPackages
* A pointer to a ULONG variable that receives the number of packages returned.
* A pointer to a int variable that receives the number of packages returned.
* @param ppPackageInfo
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
* Each structure contains information from the security support provider (SSP) that
@@ -10,6 +10,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
@@ -282,6 +285,10 @@ public interface SetupApi extends StdCallLibrary {
* Reserved. Do not use.
*/
public Pointer Reserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "Flags", "Reserved" });
}
}
/**
@@ -330,5 +337,9 @@ public interface SetupApi extends StdCallLibrary {
* Reserved. For internal use only.
*/
public Pointer Reserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "DevInst", "Reserved" });
}
}
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, 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
@@ -13,9 +13,9 @@
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.WinDef.INT_PTR;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
@@ -128,6 +128,9 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
* that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility
* with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and
* compared to either 32 or the following error codes below.
* <p/>
* NOTE: {@link WinDef.INT_PTR} is used instead of HINSTANCE here, since
* the former fits the reutrn type's actual usage more closely.
*
* 0 The operating system is out of memory or resources.
* ERROR_FILE_NOT_FOUND The specified file was not found.
@@ -146,6 +149,23 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
* SE_ERR_PNF The specified path was not found.
* SE_ERR_SHARE A sharing violation occurred.
*/
WinDef.HINSTANCE ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory,
INT_PTR ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory,
int nShowCmd);
/**
* Retrieves the path of a special folder, identified by its CSIDL.
*
* @param owner
* Reserved.
* @param path
* A pointer to a null-terminated string that receives the drive and path of the specified folder. This buffer must be at least MAX_PATH
* characters in size.
* @param csidl
* A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
* @param create
* Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is
* zero, the folder is not created.
* @return {@code true} if successful; otherwise, {@code false}.
*/
boolean SHGetSpecialFolderPath(HWND owner, char[] path, int csidl, boolean create);
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, 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
@@ -20,6 +20,7 @@ import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Shell32 Utility API.
* @author dblock[at]dblock.org
* @author markus[at]headcrashing[dot]eu
*/
public abstract class Shell32Util {
@@ -55,4 +56,21 @@ public abstract class Shell32Util {
public static String getFolderPath(int nFolder) {
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
}
/**
* Retrieves the path of a special folder, identified by its CSIDL.
*
* @param csidl
* A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
* @param create
* Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is
* zero, the folder is not created.
* @return The drive and path of the specified folder
*/
public static final String getSpecialFolderPath(final int csidl, final boolean create) {
final char[] pszPath = new char[WinDef.MAX_PATH];
if (!Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, csidl, create))
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
return Native.toString(pszPath);
}
}
@@ -12,6 +12,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
@@ -98,6 +101,10 @@ public interface ShellAPI extends StdCallLibrary {
* A pointer to the title of a progress dialog box. This is a null-terminated string.
*/
public WString lpszProgressTitle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" });
}
/** Use this to encode <code>pFrom/pTo</code> paths. */
public String encodePaths(String[] paths) {
@@ -13,7 +13,6 @@
package com.sun.jna.platform.win32;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShlObj.h.
@@ -12,8 +12,10 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
@@ -137,17 +139,18 @@ public interface Sspi extends StdCallLibrary {
public static class SecHandle extends Structure {
public Pointer dwLower;
public Pointer dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
public static class ByReference extends SecHandle implements Structure.ByReference {
}
/**
* An empty SecHandle.
*/
public SecHandle() {
dwLower = null;
dwUpper = null;
}
/**
@@ -166,16 +169,18 @@ public interface Sspi extends StdCallLibrary {
public static class PSecHandle extends Structure {
public static class ByReference extends PSecHandle implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecHandle.ByReference secHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "secHandle" });
}
public PSecHandle() {
}
public PSecHandle(SecHandle h) {
@@ -210,7 +215,6 @@ public interface Sspi extends StdCallLibrary {
* Create a SECBUFFER_EMPTY SecBuffer.
*/
public ByReference() {
}
/**
@@ -241,24 +245,25 @@ public interface Sspi extends StdCallLibrary {
/**
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
*/
public NativeLong cbBuffer;
public int cbBuffer;
/**
* Bit flags that indicate the type of buffer. Must be one of the values of
* the SecBufferType enumeration.
*/
public NativeLong BufferType;
public int BufferType = SECBUFFER_EMPTY;
/**
* A pointer to a buffer.
*/
public Pointer pvBuffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbBuffer", "BufferType", "pvBuffer" });
}
/**
* Create a new SECBUFFER_EMPTY buffer.
*/
public SecBuffer() {
cbBuffer = new NativeLong(0);
pvBuffer = null;
BufferType = new NativeLong(SECBUFFER_EMPTY);
}
/**
@@ -269,10 +274,9 @@ public interface Sspi extends StdCallLibrary {
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public SecBuffer(int type, int size) {
cbBuffer = new NativeLong(size);
cbBuffer = size;
pvBuffer = new Memory(size);
BufferType = new NativeLong(type);
allocateMemory();
BufferType = type;
}
/**
@@ -283,11 +287,10 @@ public interface Sspi extends StdCallLibrary {
* Existing token.
*/
public SecBuffer(int type, byte[] token) {
cbBuffer = new NativeLong(token.length);
cbBuffer = token.length;
pvBuffer = new Memory(token.length);
pvBuffer.write(0, token, 0, token.length);
BufferType = new NativeLong(type);
allocateMemory();
BufferType = type;
}
/**
@@ -296,7 +299,7 @@ public interface Sspi extends StdCallLibrary {
* Raw buffer bytes.
*/
public byte[] getBytes() {
return pvBuffer.getByteArray(0, cbBuffer.intValue());
return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer);
}
}
@@ -305,22 +308,26 @@ public interface Sspi extends StdCallLibrary {
/**
* Version number.
*/
public NativeLong ulVersion;
public int ulVersion;
/**
* Number of buffers.
*/
public NativeLong cBuffers;
public int cBuffers;
/**
* Pointer to array of buffers.
*/
public SecBuffer.ByReference[] pBuffers;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "ulVersion", "cBuffers", "pBuffers" });
}
/**
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
*/
public SecBufferDesc() {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
ulVersion = SECBUFFER_VERSION;
cBuffers = 1;
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
@@ -334,8 +341,8 @@ public interface Sspi extends StdCallLibrary {
* Initial token data.
*/
public SecBufferDesc(int type, byte[] token) {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
ulVersion = SECBUFFER_VERSION;
cBuffers = 1;
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
@@ -347,18 +354,18 @@ public interface Sspi extends StdCallLibrary {
* @param tokenSize
*/
public SecBufferDesc(int type, int tokenSize) {
ulVersion = new NativeLong(SECBUFFER_VERSION);
cBuffers = new NativeLong(1);
ulVersion = SECBUFFER_VERSION;
cBuffers = 1;
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize);
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
public byte[] getBytes() {
if (pBuffers == null || cBuffers == null) {
if (pBuffers == null || cBuffers == 0) {
throw new RuntimeException("pBuffers | cBuffers");
}
if (cBuffers.intValue() == 1) {
if (cBuffers == 1) {
return pBuffers[0].getBytes();
}
throw new RuntimeException("cBuffers > 1");
@@ -369,15 +376,17 @@ public interface Sspi extends StdCallLibrary {
* A security integer.
*/
public static class SECURITY_INTEGER extends Structure {
public NativeLong dwLower;
public NativeLong dwUpper;
public int dwLower;
public int dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
/**
* An security integer of 0.
*/
public SECURITY_INTEGER() {
dwLower = new NativeLong(0);
dwUpper = new NativeLong(0);
}
}
@@ -385,7 +394,6 @@ public interface Sspi extends StdCallLibrary {
* A timestamp.
*/
public static class TimeStamp extends SECURITY_INTEGER {
}
/**
@@ -402,8 +410,11 @@ public interface Sspi extends StdCallLibrary {
*/
public SecPkgInfo.ByReference pPkgInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pPkgInfo" });
}
public PSecPkgInfo() {
}
/**
@@ -424,17 +435,16 @@ public interface Sspi extends StdCallLibrary {
* A reference pointer to a SecPkgInfo structure.
*/
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
}
/**
* Set of bit flags that describes the capabilities of the security package.
*/
public NativeLong fCapabilities;
public int fCapabilities;
/**
* Specifies the version of the package protocol. Must be 1.
*/
public short wVersion;
public short wVersion = 1;
/**
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
@@ -443,7 +453,7 @@ public interface Sspi extends StdCallLibrary {
/**
* Specifies the maximum size, in bytes, of the token.
*/
public NativeLong cbMaxToken;
public int cbMaxToken;
/**
* Pointer to a null-terminated string that contains the name of the security package.
*/
@@ -454,14 +464,14 @@ public interface Sspi extends StdCallLibrary {
*/
public WString Comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" });
}
/**
* Create a new package info.
*/
public SecPkgInfo() {
fCapabilities = new NativeLong(0);
wVersion = 1;
wRPCID = 0;
cbMaxToken = new NativeLong(0);
}
}
}
@@ -10,6 +10,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
@@ -135,5 +138,9 @@ public interface Tlhelp32 extends StdCallLibrary {
* retrieve the full path of the executable file for a 64-bit process.
*/
public char[] szExeFile = new char[WinDef.MAX_PATH];
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile" });
}
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2013 Ralf Hamberger, Markus Karg, 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.WString;
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
import com.sun.jna.platform.win32.WinDef.HMENU;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPVOID;
/**
* Provides convenient usage of functions defined by {@code User32.dll}.
*
* @author Ralf HAMBERGER
* @author Markus KARG (markus[at]headcrashing[dot]eu)
*/
public final class User32Util {
public static final int registerWindowMessage(final String lpString) {
final int messageId = User32.INSTANCE.RegisterWindowMessage(lpString);
if (messageId == 0)
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
return messageId;
}
public static final HWND createWindow(final String className, final String windowName, final int style, final int x, final int y, final int width,
final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) {
return User32Util.createWindowEx(0, className, windowName, style, x, y, width, height, parent, menu, instance, param);
}
public static final HWND createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y,
final int width, final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) {
final HWND hWnd = User32.INSTANCE
.CreateWindowEx(exStyle, new WString(className), windowName, style, x, y, width, height, parent, menu, instance, param);
if (hWnd == null)
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
return hWnd;
}
public static final void destroyWindow(final HWND hWnd) {
if (!User32.INSTANCE.DestroyWindow(hWnd))
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
@@ -0,0 +1,412 @@
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.OaIdl.CURRENCY;
import com.sun.jna.platform.win32.OaIdl.DATE;
import com.sun.jna.platform.win32.OaIdl.DECIMAL;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOLbyReference;
import com.sun.jna.platform.win32.OaIdl._VARIANT_BOOLbyReference;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinDef.BYTE;
import com.sun.jna.platform.win32.WinDef.CHAR;
import com.sun.jna.platform.win32.WinDef.CHARbyReference;
import com.sun.jna.platform.win32.WinDef.LONG;
import com.sun.jna.platform.win32.WinDef.LONGLONG;
import com.sun.jna.platform.win32.WinDef.LONGLONGbyReference;
import com.sun.jna.platform.win32.WinDef.LONGbyReference;
import com.sun.jna.platform.win32.WinDef.PVOID;
import com.sun.jna.platform.win32.WinDef.SCODE;
import com.sun.jna.platform.win32.WinDef.SCODEbyReference;
import com.sun.jna.platform.win32.WinDef.SHORT;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
import com.sun.jna.platform.win32.WinDef.ULONG;
import com.sun.jna.platform.win32.WinDef.ULONGLONG;
import com.sun.jna.platform.win32.WinDef.ULONGLONGbyReference;
import com.sun.jna.platform.win32.WinDef.ULONGbyReference;
import com.sun.jna.platform.win32.WinDef.USHORT;
import com.sun.jna.platform.win32.WinDef.USHORTbyReference;
import com.sun.jna.platform.win32.COM.IDispatch;
import com.sun.jna.platform.win32.COM.IRecordInfo;
import com.sun.jna.platform.win32.COM.IUnknown;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.ptr.DoubleByReference;
import com.sun.jna.ptr.FloatByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.ShortByReference;
public interface Variant {
public static int VT_EMPTY = 0;
public static int VT_NULL = 1;
public static int VT_I2 = 2;
public static int VT_I4 = 3;
public static int VT_R4 = 4;
public static int VT_R8 = 5;
public static int VT_CY = 6;
public static int VT_DATE = 7;
public static int VT_BSTR = 8;
public static int VT_DISPATCH = 9;
public static int VT_ERROR = 10;
public static int VT_BOOL = 11;
public static int VT_VARIANT = 12;
public static int VT_UNKNOWN = 13;
public static int VT_DECIMAL = 14;
public static int VT_I1 = 16;
public static int VT_UI1 = 17;
public static int VT_UI2 = 18;
public static int VT_UI4 = 19;
public static int VT_I8 = 20;
public static int VT_UI8 = 21;
public static int VT_INT = 22;
public static int VT_UINT = 23;
public static int VT_VOID = 24;
public static int VT_HRESULT = 25;
public static int VT_PTR = 26;
public static int VT_SAFEARRAY = 27;
public static int VT_CARRAY = 28;
public static int VT_USERDEFINED = 29;
public static int VT_LPSTR = 30;
public static int VT_LPWSTR = 31;
public static int VT_RECORD = 36;
public static int VT_INT_PTR = 37;
public static int VT_UINT_PTR = 38;
public static int VT_FILETIME = 64;
public static int VT_BLOB = 65;
public static int VT_STREAM = 66;
public static int VT_STORAGE = 67;
public static int VT_STREAMED_OBJECT = 68;
public static int VT_STORED_OBJECT = 69;
public static int VT_BLOB_OBJECT = 70;
public static int VT_CF = 71;
public static int VT_CLSID = 72;
public static int VT_VERSIONED_STREAM = 73;
public static int VT_BSTR_BLOB = 0xfff;
public static int VT_VECTOR = 0x1000;
public static int VT_ARRAY = 0x2000;
public static int VT_BYREF = 0x4000;
public static int VT_RESERVED = 0x8000;
public static int VT_ILLEGAL = 0xffff;
public static int VT_ILLEGALMASKED = 0xfff;
public static int VT_TYPEMASK = 0xfff;
public static VARIANT_BOOL VARIANT_TRUE = new VARIANT_BOOL(0xFFFF);
public static VARIANT_BOOL VARIANT_FALSE = new VARIANT_BOOL(0x0000);
public static class VARIANT extends Union {
public static class ByReference extends VARIANT implements
Structure.ByReference {
}
public _VARIANT _variant;
public DECIMAL decVal;
public VARIANT() {
this.setType("_variant");
this.read();
}
public VARIANT(Pointer pointer) {
super(pointer);
this.setType("_variant");
this.read();
}
public VARIANT(BSTR value) {
this();
this.setValue(VT_BSTR, value);
}
public VARIANT(VARIANT_BOOL value) {
this();
this.setValue(VT_BOOL, value);
}
public VARIANT(LONG value) {
this();
this.setValue(VT_I4, value);
}
public VARIANT(SHORT value) {
this();
this.setValue(VT_I2, value);
}
public VARIANT(DATE value) {
this();
this.setValue(VT_DATE, value);
}
public VARTYPE getVarType() {
this.read();
return _variant.vt;
}
public void setVarType(short vt) {
this._variant.vt = new VARTYPE(vt);
}
public void setValue(int vt, Object value) {
this.setValue(new VARTYPE(vt), value);
}
public void setValue(VARTYPE vt, Object value) {
switch (vt.intValue()) {
case VT_I2:
this._variant.__variant.writeField("iVal", value);
break;
case VT_I4:
this._variant.__variant.writeField("lVal", value);
break;
case VT_I8:
this._variant.__variant.writeField("llVal", value);
break;
case VT_R4:
this._variant.__variant.writeField("fltVal", value);
break;
case VT_R8:
this._variant.__variant.writeField("dblVal", value);
break;
case VT_BOOL:
this._variant.__variant.writeField("boolVal", value);
break;
case VT_ERROR:
this._variant.__variant.writeField("scode", value);
break;
case VT_CY:
this._variant.__variant.writeField("cyVal", value);
break;
case VT_DATE:
this._variant.__variant.writeField("date", value);
break;
case VT_BSTR:
this._variant.__variant.writeField("bstrVal", value);
break;
case VT_DISPATCH:
this._variant.__variant.writeField("pdispVal", value);
break;
case VT_SAFEARRAY:
this._variant.__variant.writeField("parray", value);
break;
case VT_ARRAY:
this._variant.__variant.writeField("parray", value);
break;
}
this._variant.writeField("vt", vt);
this.write();
}
public Object getValue() {
this.read();
switch (this.getVarType().intValue()) {
case VT_I2:
return this._variant.__variant.readField("iVal");
case VT_I4:
return this._variant.__variant.readField("lVal");
case VT_I8:
return this._variant.__variant.readField("llVal");
case VT_R4:
return this._variant.__variant.readField("fltVal");
case VT_R8:
return this._variant.__variant.readField("dblVal");
case VT_BOOL:
return this._variant.__variant.readField("boolVal");
case VT_ERROR:
return this._variant.__variant.readField("scode");
case VT_CY:
return this._variant.__variant.readField("cyVal");
case VT_DATE:
return this._variant.__variant.readField("date");
case VT_BSTR:
return this._variant.__variant.readField("bstrVal");
case VT_DISPATCH:
return this._variant.__variant.readField("pdispVal");
case VT_SAFEARRAY:
return this._variant.__variant.readField("parray");
case VT_ARRAY:
return this._variant.__variant.readField("parray");
default:
return null;
}
}
public static class _VARIANT extends Structure {
public VARTYPE vt;
public short wReserved1;
public short wReserved2;
public short wReserved3;
public __VARIANT __variant;
public _VARIANT() {
}
public _VARIANT(Pointer pointer) {
super(pointer);
this.read();
}
public static class __VARIANT extends Union {
// LONGLONG VT_I8
public LONGLONG llVal;
// LONG VT_I4
public LONG lVal;
// BYTE VT_UI1
public BYTE bVal;
// SHORT VT_I2
public SHORT iVal;
// FLOAT VT_R4
public Float fltVal;
// DOUBLE VT_R8
public Double dblVal;
// VARIANT_BOOL VT_BOOL
public VARIANT_BOOL boolVal;
// SCODE VT_ERROR
public SCODE scode;
// CY VT_CY
public CURRENCY cyVal;
// DATE VT_DATE
public DATE date;
// BSTR VT_BSTR
public BSTR bstrVal;
// IUnknown * VT_UNKNOWN
public IUnknown punkVal;
// IDispatch * VT_DISPATCH
public IDispatch pdispVal;
// SAFEARRAY * VT_ARRAY
public SAFEARRAY.ByReference parray;
// BYTE * VT_BYREF|VT_UI1
public ByteByReference pbVal;
// SHORT * VT_BYREF|VT_I2
public ShortByReference piVal;
// LONG * VT_BYREF|VT_I4
public LONGbyReference plVal;
// LONGLONG * VT_BYREF|VT_I8
public LONGLONGbyReference pllVal;
// FLOAT * VT_BYREF|VT_R4
public FloatByReference pfltVal;
// DOUBLE * VT_BYREF|VT_R8
public DoubleByReference pdblVal;
// VARIANT_BOOL * VT_BYREF|VT_BOOL
public VARIANT_BOOLbyReference pboolVal;
// VARIANT_BOOL * VT_BYREF|VT_BOOL
public _VARIANT_BOOLbyReference pbool;
// SCODE * VT_BYREF|VT_ERROR
public SCODEbyReference pscode;
// CY * VT_BYREF|VT_CY
public CURRENCY.ByReference pcyVal;
// DATE * VT_BYREF|VT_DATE
public DATE.ByReference pdate;
// BSTR * VT_BYREF|VT_BSTR
public BSTR pbstrVal;
// IUnknown ** VT_BYREF|VT_UNKNOWN
public IUnknown.ByReference ppunkVal;
// IDispatch ** VT_BYREF|VT_DISPATCH
public IDispatch.ByReference ppdispVal;
// SAFEARRAY ** VT_BYREF|VT_ARRAY
public SAFEARRAY.ByReference pparray;
// VARIANT * VT_BYREF|VT_VARIANT
public VARIANT.ByReference pvarVal;
// PVOID VT_BYREF (Generic ByRef)
public PVOID byref;
// CHAR VT_I1
public CHAR cVal;
// USHORT VT_UI2
public USHORT uiVal;
// ULONG VT_UI4
public ULONG ulVal;
// ULONGLONG VT_UI8
public ULONGLONG ullVal;
// INT VT_INT
public Integer intVal;
// UINT VT_UINT
public UINT uintVal;
// DECIMAL * VT_BYREF|VT_DECIMAL
public DECIMAL.ByReference pdecVal;
// CHAR * VT_BYREF|VT_I1
public CHARbyReference pcVal;
// USHORT * VT_BYREF|VT_UI2
public USHORTbyReference puiVal;
// ULONG * VT_BYREF|VT_UI4
public ULONGbyReference pulVal;
// ULONGLONG * VT_BYREF|VT_UI8
public ULONGLONGbyReference pullVal;
// INT * VT_BYREF|VT_INT
public IntByReference pintVal;
// UINT * VT_BYREF|VT_UINT
public UINTbyReference puintVal;
public static class BRECORD extends Structure {
public static class ByReference extends BRECORD implements
Structure.ByReference {
}
public PVOID pvRecord;
public IRecordInfo pRecInfo;
public BRECORD() {
}
public BRECORD(Pointer pointer) {
super(pointer);
}
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pvRecord",
"pRecInfo" });
}
}
public __VARIANT() {
super();
this.read();
}
public __VARIANT(Pointer pointer) {
super(pointer);
this.read();
}
}
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "vt", "wReserved1",
"wReserved2", "wReserved3", "__variant" });
}
}
}
public static class VariantArg extends Structure {
public static class ByReference extends VariantArg implements
Structure.ByReference {
}
public VARIANT[] variantArg;
public VariantArg() {
}
public VariantArg(VARIANT[] variantArg) {
this.variantArg = variantArg;
}
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "variantArg" });
}
}
}
@@ -10,6 +10,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
@@ -113,5 +116,9 @@ public interface VerRsrc extends StdCallLibrary {
* The least significant 32 bits of the file's 64-bit binary creation date and time stamp.
*/
public WinDef.DWORD dwFileDateLS;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwSignature", "dwStrucVersion", "dwFileVersionMS", "dwFileVersionLS", "dwProductVersionMS", "dwProductVersionLS", "dwFileFlagsMask", "dwFileFlags", "dwFileOS", "dwFileType", "dwFileSubtype", "dwFileDateMS", "dwFileDateLS" });
}
}
}
@@ -1,105 +1,181 @@
/* Copyright (c) 2010,2011 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.platform.win32.WinNT.HRESULT;
/**
* Utility class for some common error functions.
*/
public abstract class W32Errors implements WinError {
/**
* Generic test for success on any status value (non-negative numbers
* indicate success).
*/
public static final boolean SUCCEEDED(int hr) {
return hr >= 0;
}
/**
* and the inverse
*/
public static final boolean FAILED(int hr) {
return hr < 0;
}
/**
* Extract error code from HRESULT
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
/**
* Extract error code from SCODE
*/
public static final int SCODE_CODE(int sc) {
return sc & 0xFFFF;
}
/**
* Return the facility
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* Return the severity
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* Create an HRESULT value from component pieces
*/
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Map a WIN32 error value into a HRESULT
* Note: This assumes that WIN32 errors fall in the range -32k to=32k.
* @param x original w32 error code
* @return the converted value
*/
public static final HRESULT HRESULT_FROM_WIN32(int x) {
int f = FACILITY_WIN32;
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16) | 0x80000000);
}
/**
* FACILITY_USERMODE_FILTER_MANAGER
*
* Translation macro for converting:
* NTSTATUS --> HRESULT
*/
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
int f = FACILITY_USERMODE_FILTER_MANAGER;
return (((x) & 0x8000FFFF) | (f <<= 16));
}
}
/* Copyright (c) 2010,2011 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.platform.win32.WinNT.HRESULT;
// TODO: Auto-generated Javadoc
/**
* Utility class for some common error functions.
*/
public abstract class W32Errors implements WinError {
/**
* Generic test for success on any status value (non-negative numbers
* indicate success).
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(int hr) {
return hr >= 0;
}
/**
* and the inverse.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(int hr) {
return hr < 0;
}
/**
* Succeeded.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(HRESULT hr) {
if (hr != null)
return SUCCEEDED(hr.intValue());
else
return false;
}
/**
* Failed.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(HRESULT hr) {
if (hr != null)
return FAILED(hr.intValue());
else
return false;
}
/**
* Extract error code from HRESULT.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
/**
* Extract error code from SCODE.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_CODE(int sc) {
return sc & 0xFFFF;
}
/**
* Return the facility.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
/**
* Scode facility.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* Return the severity.
*
* @param hr the hr
* @return the short
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
/**
* Scode severity.
*
* @param sc the sc
* @return the short
*/
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* Create an HRESULT value from component pieces.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Make scode.
*
* @param sev the sev
* @param fac the fac
* @param code the code
* @return the int
*/
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Map a WIN32 error value into a HRESULT Note: This assumes that WIN32
* errors fall in the range -32k to=32k.
*
* @param x
* original w32 error code
* @return the converted value
*/
public static final HRESULT HRESULT_FROM_WIN32(int x) {
int f = FACILITY_WIN32;
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16)
| 0x80000000);
}
/**
* FACILITY_USERMODE_FILTER_MANAGER
*
* Translation macro for converting: NTSTATUS --> HRESULT.
*
* @param x the x
* @return the int
*/
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
int f = FACILITY_USERMODE_FILTER_MANAGER;
return (((x) & 0x8000FFFF) | (f <<= 16));
}
}
@@ -19,11 +19,10 @@ import java.util.HashMap;
import java.util.Map;
import com.sun.jna.platform.FileMonitor;
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTRByReference;
import com.sun.jna.platform.win32.WinBase.OVERLAPPED;
import com.sun.jna.platform.win32.WinNT.FILE_NOTIFY_INFORMATION;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTRByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
@@ -110,14 +109,14 @@ public class W32FileMonitor extends FileMonitor {
}
private FileInfo waitForChange() {
Kernel32 klib = Kernel32.INSTANCE;
IntByReference rcount = new IntByReference();
ULONG_PTRByReference rkey = new ULONG_PTRByReference();
PointerByReference roverlap = new PointerByReference();
klib.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE);
if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) {
return null;
}
synchronized (this) {
return handleMap.get(rkey.getValue());
return handleMap.get(new HANDLE(rkey.getValue().toPointer()));
}
}
@@ -15,29 +15,95 @@
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.platform.win32.WinDef.USHORT;
import com.sun.jna.ptr.ByReference;
/**
* Constant defined in WTypes.h
*
* @author scott.palmer
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public interface WTypes {
int CLSCTX_INPROC_SERVER = 0x1;
int CLSCTX_INPROC_HANDLER = 0x2;
int CLSCTX_LOCAL_SERVER = 0x4;
int CLSCTX_INPROC_SERVER16 = 0x8;
int CLSCTX_REMOTE_SERVER = 0x10;
int CLSCTX_INPROC_HANDLER16 = 0x20;
int CLSCTX_RESERVED1 = 0x40;
int CLSCTX_RESERVED2 = 0x80;
int CLSCTX_RESERVED3 = 0x100;
int CLSCTX_RESERVED4 = 0x200;
int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
int CLSCTX_RESERVED5 = 0x800;
int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
int CLSCTX_NO_FAILURE_LOG = 0x4000;
int CLSCTX_DISABLE_AAA = 0x8000;
int CLSCTX_ENABLE_AAA = 0x10000;
int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
public static int CLSCTX_INPROC_SERVER = 0x1;
public static int CLSCTX_INPROC_HANDLER = 0x2;
public static int CLSCTX_LOCAL_SERVER = 0x4;
public static int CLSCTX_INPROC_SERVER16 = 0x8;
public static int CLSCTX_REMOTE_SERVER = 0x10;
public static int CLSCTX_INPROC_HANDLER16 = 0x20;
public static int CLSCTX_RESERVED1 = 0x40;
public static int CLSCTX_RESERVED2 = 0x80;
public static int CLSCTX_RESERVED3 = 0x100;
public static int CLSCTX_RESERVED4 = 0x200;
public static int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
public static int CLSCTX_RESERVED5 = 0x800;
public static int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
public static int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
public static int CLSCTX_NO_FAILURE_LOG = 0x4000;
public static int CLSCTX_DISABLE_AAA = 0x8000;
public static int CLSCTX_ENABLE_AAA = 0x10000;
public static int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
public static int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
public static int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
public static int CLSCTX_ENABLE_CLOAKING = 0x100000;
public static int CLSCTX_APPCONTAINER = 0x400000;
public static int CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000;
public static int CLSCTX_PS_DLL = 0x80000000;
public static int CLSCTX_SERVER = CLSCTX_INPROC_SERVER
| CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
public static int CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
| CLSCTX_LOCAL_SERVER;
public static class BSTR extends PointerType {
public BSTR() {
super(Pointer.NULL);
}
public void setValue(String value) {
this.getPointer().setString(0, value, true);
}
public String getValue() {
return this.getPointer().getString(0, true);
}
@Override
public String toString() {
return this.getValue();
}
}
public class BSTRByReference extends ByReference {
public BSTRByReference() {
super(Pointer.SIZE);
}
public BSTRByReference(String value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(String value) {
getPointer().setString(0, value);
}
public String getValue() {
return getPointer().getString(0);
}
}
public static class VARTYPE extends USHORT {
public VARTYPE() {
this(0);
}
public VARTYPE(int value) {
super(value);
}
}
}
@@ -12,6 +12,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
@@ -61,6 +64,10 @@ public interface Wdm extends StdCallLibrary {
* The string is not null-terminated.
*/
public char[] Name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "LastWriteTime", "TitleIndex", "NameLength", "Name" });
}
/**
* Name of the key.
* @return String.
@@ -12,20 +12,17 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.platform.win32.BaseTSD.DWORD_PTR;
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.DWORDLONG;
import com.sun.jna.platform.win32.WinDef.WORD;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Winbase.h (kernel32.dll/kernel services).
@@ -174,7 +171,11 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
*/
public static class FILETIME extends Structure {
public int dwLowDateTime;
public int dwHighDateTime;
public int dwHighDateTime;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLowDateTime", "dwHighDateTime" });
}
public static class ByReference extends FILETIME implements Structure.ByReference {
public ByReference() {
@@ -297,6 +298,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
public short wSecond;
// The millisecond. The valid values for this member are 0 through 999.
public short wMilliseconds;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds" });
}
}
/**
@@ -385,6 +390,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
public int Offset;
public int OffsetHigh;
public HANDLE hEvent;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent" });
}
}
int INFINITE = 0xFFFFFFFF;
@@ -417,6 +426,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
* Reserved for future use.
*/
public WORD wReserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "wProcessorArchitecture", "wReserved" });
}
}
/** Unnamed inner union. */
@@ -487,6 +500,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
* Architecture-dependent processor revision.
*/
public WORD wProcessorRevision;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"});
}
}
/**
@@ -536,6 +553,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
*/
public DWORDLONG ullAvailExtendedVirtual;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual" });
}
public MEMORYSTATUSEX() {
dwLength = new DWORD(size());
}
@@ -565,6 +586,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
*/
public boolean bInheritHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLength", "lpSecurityDescriptor", "bInheritHandle" });
}
public SECURITY_ATTRIBUTES() {
dwLength = new DWORD(size());
}
@@ -737,6 +762,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
*/
public HANDLE hStdError;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError" });
}
public STARTUPINFO() {
cb = new DWORD(size());
}
@@ -778,6 +807,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
* identifier may be reused.
*/
public DWORD dwThreadId;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "hProcess", "hThread", "dwProcessId", "dwThreadId" });
}
public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference {
public ByReference() {
@@ -12,6 +12,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
@@ -59,6 +62,9 @@ public interface WinCrypt extends StdCallLibrary {
*/
public Pointer pbData;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbData", "pbData" });
}
/**
* Get byte data.
* @return
@@ -100,6 +106,10 @@ public interface WinCrypt extends StdCallLibrary {
* A string containing the text of a prompt to be displayed.
*/
public String szPrompt;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "dwPromptFlags", "hwndApp", "szPrompt" });
}
}
//
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,97 +1,121 @@
/* 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.Structure;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from WinGDI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinGDI extends StdCallLibrary {
public int RDH_RECTANGLES = 1;
public class RGNDATAHEADER extends Structure {
public int dwSize = size();
public int iType = RDH_RECTANGLES; // required
public int nCount;
public int nRgnSize;
public RECT rcBound;
}
public class RGNDATA extends Structure {
public RGNDATAHEADER rdh;
public byte[] Buffer;
public RGNDATA(int bufferSize) {
Buffer = new byte[bufferSize];
allocateMemory();
}
}
public int RGN_AND = 1;
public int RGN_OR = 2;
public int RGN_XOR = 3;
public int RGN_DIFF = 4;
public int RGN_COPY = 5;
public int ERROR = 0;
public int NULLREGION = 1;
public int SIMPLEREGION = 2;
public int COMPLEXREGION = 3;
public int ALTERNATE = 1;
public int WINDING = 2;
public int BI_RGB = 0;
public int BI_RLE8 = 1;
public int BI_RLE4 = 2;
public int BI_BITFIELDS = 3;
public int BI_JPEG = 4;
public int BI_PNG = 5;
public class BITMAPINFOHEADER extends Structure {
public int biSize = size();
public int biWidth;
public int biHeight;
public short biPlanes;
public short biBitCount;
public int biCompression;
public int biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public int biClrUsed;
public int biClrImportant;
}
public class RGBQUAD extends Structure {
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved = 0;
}
public class BITMAPINFO extends Structure {
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
public RGBQUAD[] bmiColors = new RGBQUAD[1];
public BITMAPINFO() { this(1); }
public BITMAPINFO(int size) {
bmiColors = new RGBQUAD[size];
}
}
public int DIB_RGB_COLORS = 0;
public int DIB_PAL_COLORS = 1;
}
/* 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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from WinGDI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinGDI extends StdCallLibrary {
public int RDH_RECTANGLES = 1;
public class RGNDATAHEADER extends Structure {
public int dwSize = size();
public int iType = RDH_RECTANGLES; // required
public int nCount;
public int nRgnSize;
public RECT rcBound;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwSize", "iType", "nCount", "nRgnSize", "rcBound" });
}
}
public class RGNDATA extends Structure {
public RGNDATAHEADER rdh;
public byte[] Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "rdh", "Buffer" });
}
public RGNDATA() {
this(1);
}
public RGNDATA(int bufferSize) {
Buffer = new byte[bufferSize];
allocateMemory();
}
}
public int RGN_AND = 1;
public int RGN_OR = 2;
public int RGN_XOR = 3;
public int RGN_DIFF = 4;
public int RGN_COPY = 5;
public int ERROR = 0;
public int NULLREGION = 1;
public int SIMPLEREGION = 2;
public int COMPLEXREGION = 3;
public int ALTERNATE = 1;
public int WINDING = 2;
public int BI_RGB = 0;
public int BI_RLE8 = 1;
public int BI_RLE4 = 2;
public int BI_BITFIELDS = 3;
public int BI_JPEG = 4;
public int BI_PNG = 5;
public class BITMAPINFOHEADER extends Structure {
public int biSize = size();
public int biWidth;
public int biHeight;
public short biPlanes;
public short biBitCount;
public int biCompression;
public int biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public int biClrUsed;
public int biClrImportant;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant" });
}
}
public class RGBQUAD extends Structure {
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved = 0;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "rgbBlue", "rgbGreen", "rgbRed", "rgbReserved" });
}
}
public class BITMAPINFO extends Structure {
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
public RGBQUAD[] bmiColors = new RGBQUAD[1];
protected List getFieldOrder() {
return Arrays.asList(new String[] { "bmiHeader", "bmiColors" });
}
public BITMAPINFO() { this(1); }
public BITMAPINFO(int size) {
bmiColors = new RGBQUAD[size];
}
}
public int DIB_RGB_COLORS = 0;
public int DIB_PAL_COLORS = 1;
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -10,6 +10,9 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
@@ -61,5 +64,9 @@ public interface Winioctl extends StdCallLibrary {
* The partition number of the device, if the device can be partitioned. Otherwise, this member is -1.
*/
public int PartitionNumber;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "DeviceType", "DeviceNumber", "PartitionNumber" });
}
}
}
@@ -12,11 +12,13 @@
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
@@ -87,9 +89,12 @@ public interface Winspool extends StdCallLibrary {
public String pDescription;
public String pName;
public String pComment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Flags", "pDescription", "pName", "pComment" });
}
public PRINTER_INFO_1() {
}
public PRINTER_INFO_1(int size) {
@@ -101,9 +106,12 @@ public interface Winspool extends StdCallLibrary {
public String pPrinterName;
public String pServerName;
public DWORD Attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pPrinterName", "pServerName", "Attributes" });
}
public PRINTER_INFO_4() {
}
public PRINTER_INFO_4(int size) {
@@ -13,6 +13,9 @@
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.HANDLE;
@@ -97,6 +100,10 @@ public interface Winsvc extends StdCallLibrary {
*/
public int dwWaitHint;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
}
public SERVICE_STATUS() {
super();
}
@@ -181,6 +188,10 @@ public interface Winsvc extends StdCallLibrary {
*/
public int dwServiceFlags;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint", "dwProcessId", "dwServiceFlags" });
}
public SERVICE_STATUS_PROCESS() {
}
@@ -0,0 +1,107 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wtsapi32 extends StdCallLibrary {
Wtsapi32 INSTANCE = (Wtsapi32) Native.loadLibrary("Wtsapi32",
Wtsapi32.class, W32APIOptions.DEFAULT_OPTIONS);
int NOTIFY_FOR_ALL_SESSIONS = 1;
int NOTIFY_FOR_THIS_SESSION = 0;
/**
* The session identified by lParam was connected to the console terminal or
* RemoteFX session.
*/
public static final int WTS_CONSOLE_CONNECT = 0x1;
/**
* The session identified by lParam was disconnected from the console
* terminal or RemoteFX session.
*/
public static final int WTS_CONSOLE_DISCONNECT = 0x2;
/**
* The session identified by lParam was connected to the remote terminal.
*/
public static final int WTS_REMOTE_CONNECT = 0x3;
/**
* The session identified by lParam was disconnected from the remote
* terminal.
*/
public static final int WTS_REMOTE_DISCONNECT = 0x4;
/**
* A user has logged on to the session identified by lParam.
*/
public static final int WTS_SESSION_LOGON = 0x5;
/**
* A user has logged off the session identified by lParam.
*/
public static final int WTS_SESSION_LOGOFF = 0x6;
/**
* The session identified by lParam has been locked.
*/
public static final int WTS_SESSION_LOCK = 0x7;
/**
* The session identified by lParam has been unlocked.
*/
public static final int WTS_SESSION_UNLOCK = 0x8;
/**
* The session identified by lParam has changed its remote controlled
* status. To determine the status, call GetSystemMetrics and check the
* SM_REMOTECONTROL metric.
*/
public static final int WTS_SESSION_REMOTE_CONTROL = 0x9;
/**
* Registers the specified window to receive session change notifications.
*
* @param hWnd
* [in] Handle of the window to receive session change
* notifications.
*
* @param dwFlags
* [in] Specifies which session notifications are to be received.
* This parameter can be one of the following values.
*
* @return If the function succeeds, the return value is TRUE. Otherwise, it
* is FALSE. To get extended error information, call GetLastError.
*/
public boolean WTSRegisterSessionNotification(HWND hWnd, int dwFlags);
/**
* Unregisters the specified window so that it receives no further session
* change notifications.
*
* @param hWnd
* [in] Handle of the window to be unregistered from receiving
* session notifications.
*
* @return If the function succeeds, the return value is TRUE. Otherwise, it
* is FALSE. To get extended error information, call GetLastError.
*/
public boolean WTSUnRegisterSessionNotification(HWND hWnd);
}
@@ -13,9 +13,8 @@
package com.sun.jna.platform.wince;
import com.sun.jna.Native;
import com.sun.jna.win32.W32APIOptions;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.win32.W32APIOptions;
/** Definition <code>coredll.dll</code>.
Add other win32 interface mappings as needed.
@@ -1,4 +1,4 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
/* Copyright (c) 2007-2013 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
@@ -12,6 +12,7 @@
*/
package com.sun.jna.platform;
import com.sun.jna.Platform;
import java.io.File;
import java.io.IOException;
@@ -24,8 +25,8 @@ public class FileUtilsTest extends TestCase {
if (!utils.hasTrash())
return;
File home = new File(System.getProperty("user.home"));
File file = File.createTempFile(getName(), ".tmp", home);
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
File file = File.createTempFile(getName(), ".tmp", tmpdir);
try {
assertTrue("File should exist", file.exists());
try {
@@ -43,6 +44,39 @@ public class FileUtilsTest extends TestCase {
}
}
public void testMoveSymlinkToTrash() throws Exception {
if (Platform.isWindows()) {
return;
}
FileUtils utils = FileUtils.getInstance();
if (!utils.hasTrash())
return;
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
File file = File.createTempFile(getName(), ".tmp", tmpdir);
File symlink = new File(tmpdir, file.getName() + ".link");
Runtime.getRuntime().exec(new String[] { "ln", "-s", file.getAbsolutePath(), symlink.getAbsolutePath() });
try {
assertTrue("File should exist", symlink.exists());
try {
utils.moveToTrash(new File[] { symlink });
}
catch(IOException e) {
fail(e.toString());
}
assertFalse("Symlink still exists after move to trash: " + symlink, symlink.exists());
assertTrue("Original file should still exist after move to trash: " + file, file.exists());
}
finally {
if (symlink.exists()) {
symlink.delete();
}
if (file.exists()) {
file.delete();
}
}
}
public static void main(String[] args) {
junit.textui.TestRunner.run(FileUtilsTest.class);
}
@@ -0,0 +1,76 @@
/* Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at 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;
import com.sun.jna.Platform;
import com.sun.jna.platform.unix.X11;
import com.sun.jna.platform.win32.DBT;
import junit.framework.TestCase;
import com.sun.jna.StructureFieldOrderInspector;
import java.util.ArrayList;
import java.util.List;
public class StructureFieldOrderTest extends TestCase {
private String origPropJNANoSys;
protected void setUp() {
origPropJNANoSys = System.getProperty("jna.nosys");
System.setProperty("jna.nosys", "true"); // would be set by ant script, set here for IDE usage
}
protected void tearDown() {
if (origPropJNANoSys == null) {
System.getProperties().remove("jna.nosys");
} else {
System.setProperty("jna.nosys", origPropJNANoSys);
}
}
public void testMethodGetFieldOrder() {
final List<String> ignoreConstructorError = new ArrayList<String>();
if (Platform.isWindows()) {
ignoreConstructorError.add(X11.class.getName() + "$");
} else {
ignoreConstructorError.add(com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1.class.getName());
ignoreConstructorError.add(com.sun.jna.platform.win32.Winspool.PRINTER_INFO_4.class.getName());
ignoreConstructorError.add(com.sun.jna.platform.win32.SetupApi.SP_DEVICE_INTERFACE_DATA.class.getName());
ignoreConstructorError.add(com.sun.jna.platform.win32.SetupApi.SP_DEVINFO_DATA.class.getName());
}
ignoreConstructorError.add(DBT.DEV_BROADCAST_HANDLE.class.getName()); // manually validated by wolftobias
ignoreConstructorError.add(DBT.DEV_BROADCAST_PORT.class.getName()); // manually validated by wolftobias
StructureFieldOrderInspector.batchCheckStructureGetFieldOrder(FileUtils.class, ignoreConstructorError);
}
// test below is helpful when investigating failure cause of a specific Structure class, it shows full causes and traces.
/*
public void testMethodGetFieldOrderSingleClass() {
final List<String> ignoreConstructorError = new ArrayList<String>();
if (Platform.isWindows()) {
ignoreConstructorError.add(X11.class.getName() + "$");
}
StructureFieldOrderInspector.checkMethodGetFieldOrder(com.sun.jna.platform.win32.SetupApi.SP_DEVICE_INTERFACE_DATA.class, ignoreConstructorError);
}
//*/
}
@@ -47,8 +47,7 @@ import com.sun.jna.ptr.PointerByReference;
public class Advapi32Test extends TestCase {
private static final String EVERYONE = "S-1-1-0";
private static final String NOBODY = "S-1-0-0";
public static void main(String[] args) {
junit.textui.TestRunner.run(Advapi32Test.class);
}
@@ -274,7 +273,10 @@ public class Advapi32Test extends TestCase {
userInfo.usri1_name = new WString("JNAAdvapi32TestImp");
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null));
// ignore test if not able to add user (need to be administrator to do this).
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
return;
}
try {
HANDLEByReference phUser = new HANDLEByReference();
try {
@@ -517,7 +519,16 @@ public class Advapi32Test extends TestCase {
String applicationEventLog = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application";
String jnaEventSource = "JNADevEventSource";
String jnaEventSourceRegistryPath = applicationEventLog + "\\" + jnaEventSource;
Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
// ignore test if not able to create key (need to be administrator to do this).
try {
final boolean keyCreated = Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
if (!keyCreated) {
return;
}
} catch (Win32Exception e) {
return;
}
HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, jnaEventSource);
IntByReference before = new IntByReference();
assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, before));
@@ -733,7 +744,10 @@ public class Advapi32Test extends TestCase {
assertTrue(Advapi32.INSTANCE.CloseServiceHandle(handle));
assertNull(Advapi32.INSTANCE.OpenSCManager("invalidMachineName", null, Winsvc.SC_MANAGER_CONNECT));
assertEquals(W32Errors.RPC_S_SERVER_UNAVAILABLE, Kernel32.INSTANCE.GetLastError());
int err = Kernel32.INSTANCE.GetLastError();
assertTrue("Unexpected error in OpenSCManager: " + err,
err == W32Errors.RPC_S_SERVER_UNAVAILABLE
|| err == W32Errors.RPC_S_INVALID_NET_ADDR);
assertNull(Advapi32.INSTANCE.OpenSCManager(null, "invalidDatabase", Winsvc.SC_MANAGER_CONNECT));
assertEquals(W32Errors.ERROR_INVALID_NAME, Kernel32.INSTANCE.GetLastError());
@@ -12,7 +12,6 @@
*/
package com.sun.jna.platform.win32;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.TreeMap;
@@ -23,14 +22,12 @@ import com.sun.jna.platform.win32.Advapi32Util.Account;
import com.sun.jna.platform.win32.Advapi32Util.EventLogIterator;
import com.sun.jna.platform.win32.Advapi32Util.EventLogRecord;
import com.sun.jna.platform.win32.LMAccess.USER_INFO_1;
import com.sun.jna.platform.win32.WinNT.ACCESS_ACEStructure;
import com.sun.jna.platform.win32.WinNT.ACCESS_ALLOWED_ACE;
import com.sun.jna.platform.win32.WinNT.ACCESS_DENIED_ACE;
import com.sun.jna.platform.win32.WinNT.ACEStructure;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.platform.win32.WinNT.SID_NAME_USE;
import com.sun.jna.platform.win32.WinNT.WELL_KNOWN_SID_TYPE;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
/**
* @author dblock[at]dblock[dot]org
@@ -112,10 +109,11 @@ public class Advapi32UtilTest extends TestCase {
userInfo.usri1_name = new WString("JNANetapi32TestUser");
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
// ignore test if not able to add user (need to be administrator to do this).
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
return;
}
try {
assertEquals("Error in NetUserAdd",
LMErr.NERR_Success,
Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null));
HANDLEByReference phUser = new HANDLEByReference();
try {
assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
@@ -145,9 +143,11 @@ public class Advapi32UtilTest extends TestCase {
userInfo.usri1_name = new WString("JNANetapi32TestUser");
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
// ignore test if not able to add user (need to be administrator to do this).
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
return;
}
try {
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
null, 1, userInfo, null));
HANDLEByReference phUser = new HANDLEByReference();
try {
assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
@@ -301,8 +301,9 @@ public class Advapi32UtilTest extends TestCase {
Advapi32Util.registrySetStringArray(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringArray", stringsWritten);
String[] emptyArray = new String[0];
Advapi32Util.registrySetStringArray(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyStringArray", emptyArray);
Advapi32Util.registrySetBinaryValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyBinary", new byte[0]);
TreeMap<String, Object> values = Advapi32Util.registryGetValues(WinReg.HKEY_CURRENT_USER, "Software\\JNA");
assertEquals(6, values.keySet().size());
assertEquals(7, values.keySet().size());
assertEquals("FourtyTwo" + uu, values.get("42" + uu));
assertEquals(42, values.get("FourtyTwo" + uu));
assertEquals("%TEMP%", values.get("ExpandableString"));
@@ -320,6 +321,46 @@ public class Advapi32UtilTest extends TestCase {
assertEquals(0, stringsRead.length);
Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA");
}
public void testRegistryGetEmptyValues() {
HKEY root = WinReg.HKEY_CURRENT_USER;
String keyPath = "Software\\JNA";
Advapi32Util.registryCreateKey(root, "Software", "JNA");
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_BINARY);
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_EXPAND_SZ);
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_MULTI_SZ);
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_NONE);
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_SZ);
Advapi32Util.registryDeleteKey(root, "Software", "JNA");
}
private void doTestRegistryGetEmptyValues(HKEY root, String keyPath, int valueType) {
String valueName = "EmptyValue";
registrySetEmptyValue(root, keyPath, valueName, valueType);
Map<String, Object> values = Advapi32Util.registryGetValues(root, keyPath);
assertEquals(1, values.size());
assertTrue(values.containsKey(valueName));
}
private static void registrySetEmptyValue(HKEY root, String keyPath, String name, final int valueType) {
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 {
char[] data = new char[0];
rc = Advapi32.INSTANCE.RegSetValueEx(phkKey.getValue(), name, 0, valueType, data, 0);
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
} finally {
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
if (rc != W32Errors.ERROR_SUCCESS) {
throw new Win32Exception(rc);
}
}
}
public void testIsWellKnownSid() {
String everyoneString = "S-1-1-0";
@@ -410,135 +451,5 @@ public class Advapi32UtilTest extends TestCase {
String block = Advapi32Util.getEnvironmentBlock(mockEnvironment);
assertEquals("Environment block must comprise key=value pairs separated by NUL characters", expected, block);
}
public void testGetFileSecurity() {
//final String userUnderTest = "iFinder";
final String userUnderTest = Advapi32Util.getUserName();
final Account userUnderTestAccount = Advapi32Util.getAccountByName(userUnderTest);
final String userUnderTestSID = userUnderTestAccount.sidString;
//final String groupUnderTest = "Sales";
final String groupUnderTest = "Everybody";
final Account groupUnderTestAccount = Advapi32Util.getAccountByName(groupUnderTest);
final String groupUnderTestSID = groupUnderTestAccount.sidString;
//final String testRootDir = "C:\\Projekte\\JNA-fileAccessRights\\";
final String testRootDir = System.getProperty("java.io.tmpdir");
// User rights "modify" (Um) - includes some others: read, execute, write
// Traverse Folder/Execute File (WinNT.FILE_TRAVERSE, WinNT.FILE_READ_DATA)
// List Folder/Read Data (WinNT.FILE_LIST_DIRECTORY, WinNT.FILE_READ_DATA)
// Read Attributes (WinNT.FILE_READ_ATTRIBUTES)
// Read Extended Attributes (WinNT.FILE_READ_EA)
// Create Files/Write Data (WinNT.FILE_ADD_FILE, WinNT.FILE_WRITE_DATA)
// Create Folders/Append Data (WinNT.FILE_ADD_SUBDIRECTORY, WinNT.FILE_APPEND_DATA)
// Write Attributes (WinNT.FILE_WRITE_ATTRIBUTES)
// Write Extended Attributes (WinNT.FILE_WRITE_EA)
// Delete (WinNT.DELETE)
// Read Permissions (WinNT.FILE_READ_ATTRIBUTES)
// Synchronize (WinNT.SYNCHRONIZE)
// Group rights allowed:"read" denied:"write" (Gr-w)
// List Folder/Read Data (WinNT.FILE_LIST_DIRECTORY, WinNT.FILE_READ_DATA)
// Read Attributes (WinNT.FILE_READ_ATTRIBUTES)
// Read Extended Attributes (WinNT.FILE_READ_EA)
// Read Permissions (WinNT.FILE_READ_ATTRIBUTES)
ACCESS_ACEStructure[] fileSecurity_UmGr = Advapi32Util.getFileSecurity(testRootDir + "/UmGr-w.txt", false);
System.out.println("UmGr-w.txt");
checkFileSecurity(fileSecurity_UmGr,
userUnderTestSID,
new String[] {
"0 0 DELETE READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_READ_EA FILE_WRITE_EA FILE_EXECUTE FILE_TRAVERSE FILE_READ_ATTRIBUTES FILE_WRITE_ATTRIBUTES"
},
groupUnderTestSID,
new String[] {
"0 1 FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_WRITE_EA FILE_WRITE_ATTRIBUTES"
, "0 0 READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_READ_EA FILE_READ_ATTRIBUTES"
});
// User full access
ACCESS_ACEStructure[] fileSecurity_Uf = Advapi32Util.getFileSecurity(testRootDir + "/Uf.txt", false);
//System.out.println("Uf.txt");
checkFileSecurity(fileSecurity_Uf, userUnderTestSID,
new String[] {"0 0 DELETE READ_CONTROL WRITE_DAC WRITE_OWNER SYNCHRONIZE STANDARD_RIGHTS_REQUIRED STANDARD_RIGHTS_ALL FILE_READ_DATA FILE_LIST_DIRECTORY FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_READ_EA FILE_WRITE_EA FILE_EXECUTE FILE_TRAVERSE FILE_DELETE_CHILD FILE_READ_ATTRIBUTES FILE_WRITE_ATTRIBUTES"}, null, null);
// file in directory - access rights copied
ACCESS_ACEStructure[] fileSecurity_Grw_Cp = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/Grw.txt", false);
//System.out.println("UrwGr.dir/Grw.txt");
checkFileSecurity(fileSecurity_Grw_Cp, null, null,
groupUnderTestSID,
new String[]{"16 0 READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_READ_EA FILE_READ_ATTRIBUTES"}
);
/*
// User rights: read, execute, list folder, write
// Group rights: read
ACCESS_ACEStructure[] fileSecurity_UrwGr_Dir = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/", false);
System.out.println("UrwGr.dir/");
// file in directory - access rights inherited
// User rights: read, execute, write
ACCESS_ACEStructure[] fileSecurity_UrI_Inh = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/UrI.txt", false);
System.out.println("UrwGr.dir/UrI.txt");
*/
}
private void checkFileSecurity(ACCESS_ACEStructure[] fileSecurity, String userUnderTestSID, String[] expectedUsrMasks, String groupUnderTestSID, String[] expectedGrpMasks) {
int remainingUsr = userUnderTestSID == null ? 0 : expectedUsrMasks.length;
int remainingGrp = groupUnderTestSID == null ? 0 : expectedGrpMasks.length;
for (ACCESS_ACEStructure aces : fileSecurity) {
if (userUnderTestSID != null && aces.getSidString().equals(userUnderTestSID)) {
String start = (aces.AceFlags & WinNT.VALID_INHERIT_FLAGS) + " " + aces.AceType + " ";
for (String expected : expectedUsrMasks) {
if (expected.startsWith(start)) {
String gotMask = start + getFileSecurityAsString(aces.Mask);
System.out.println(expected);
remainingUsr--;
assertEquals(expected, gotMask);
}
}
}
if (groupUnderTestSID != null && aces.getSidString().equals(groupUnderTestSID)) {
String start = (aces.AceFlags & WinNT.VALID_INHERIT_FLAGS) + " " + aces.AceType + " ";
for (String expected : expectedGrpMasks) {
if (expected.startsWith(start)) {
String gotMask = start + getFileSecurityAsString(aces.Mask);
System.out.println(expected);
remainingGrp--;
assertEquals(expected, gotMask);
}
}
}
}
assertEquals("Not all ACLs found for user ", 0, remainingUsr);
assertEquals("Not all ACLs found for group ", 0, remainingGrp);
}
private String getFileSecurityAsString(int accessMask) {
final String[] FLAGS = {"DELETE", "READ_CONTROL", "WRITE_DAC", "WRITE_OWNER", "SYNCHRONIZE",
"STANDARD_RIGHTS_REQUIRED", "STANDARD_RIGHTS_ALL", "SPECIFIC_RIGHTS_ALL",
"GENERIC_ALL", "GENERIC_EXECUTE", "GENERIC_WRITE", "GENERIC_READ",
"FILE_READ_DATA", "FILE_LIST_DIRECTORY", "FILE_WRITE_DATA", "FILE_ADD_FILE",
"FILE_APPEND_DATA", "FILE_ADD_SUBDIRECTORY", "FILE_CREATE_PIPE_INSTANCE",
"FILE_READ_EA", "FILE_WRITE_EA", "FILE_EXECUTE", "FILE_TRAVERSE",
"FILE_DELETE_CHILD", "FILE_READ_ATTRIBUTES", "FILE_WRITE_ATTRIBUTES"};
String asString = "";
for (String flag : FLAGS) {
try {
Field field = WinNT.class.getDeclaredField(flag);
int int1 = field.getInt(null);
if ((int1 & accessMask) == int1) {
asString += flag + " ";
}
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (SecurityException e) {
} catch (NoSuchFieldException e) {
}
}
return asString.trim();
}
}
@@ -0,0 +1,103 @@
/* Copyright (c) 2012 Tobias Wolf, 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.COM;
import junit.framework.TestCase;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Ole32;
import com.sun.jna.platform.win32.W32Errors;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.IDispatch;
import com.sun.jna.ptr.PointerByReference;
public class IUnknownTest extends TestCase {
private IDispatch iDispatch = new IDispatch();
private PointerByReference pDispatch = new PointerByReference();
@Override
protected void setUp() throws Exception {
super.setUp();
Native.setProtected(true);
System.out.println("JNA protected mode: " + Native.isProtected());
// Initialize COM for this thread...
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
if (W32Errors.FAILED(hr)) {
this.tearDown();
throw new COMException("CoInitialize() failed");
}
// Get CLSID for Word.Application...
CLSID.ByReference clsid = new CLSID.ByReference();
hr = Ole32.INSTANCE.CLSIDFromProgID("InternetExplorer.Application",
clsid);
if (W32Errors.FAILED(hr)) {
Ole32.INSTANCE.CoUninitialize();
throw new COMException("CLSIDFromProgID() failed!");
}
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
WTypes.CLSCTX_LOCAL_SERVER, IDispatch.IID_IDispatch,
this.pDispatch);
if (W32Errors.FAILED(hr)) {
throw new COMException("Internet Explorer not registered properly!");
}
this.iDispatch = new IDispatch(pDispatch.getPointer());
}
public void testQueryInterface() {
System.out.println("start 'testQueryInterface'");
PointerByReference ppvObject = new PointerByReference();
this.iDispatch.QueryInterface(IDispatch.IID_IDispatch, ppvObject);
System.out.println("ppvObject:" + ppvObject.toString());
System.out.println("end 'testQueryInterface'");
}
public void testAddRef() {
System.out.println("start 'testAddRef'");
int addRef = this.iDispatch.AddRef();
System.out.println("addRef:" + addRef);
System.out.println("end 'testAddRef'");
}
public void testRelease() {
System.out.println("start 'testQueryInterface'");
int release = this.iDispatch.Release();
System.out.println("release:" + release);
System.out.println("end 'testRelease'");
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
Ole32.INSTANCE.CoUninitialize();
}
public static void main(String[] args) {
junit.textui.TestRunner.run(IUnknownTest.class);
}
}
@@ -0,0 +1,129 @@
package com.sun.jna.platform.win32;
import junit.framework.TestCase;
import com.sun.jna.platform.win32.Guid.GUID;
// TODO: Auto-generated Javadoc
/**
* The Class GuidTest.
*/
public class GuidTest extends TestCase {
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String[] args) {
junit.textui.TestRunner.run(GuidTest.class);
}
/**
* Instantiates a new guid test.
*/
public GuidTest() {
}
/**
* Loads a GUID from string and verify that the guid returned has the
* expected values in each byte.
*/
public void testGUIDFromString() {
String sourceGuidStr = "{A5DCBF10-6530-11D2-901F-00C04FB951ED}";
// test loading via static method
GUID targetGuid = GUID.fromString(sourceGuidStr);
assertEquals(targetGuid.toGuidString(), sourceGuidStr);
}
/**
* Loads a GUID from string via the constructor and verify that the guid
* returned has the expected values in each byte.
*/
public void testGUIDFromString2() {
String sourceGuidStr = "{A5DCBF10-6530-11D2-901F-00C04FB951ED}";
// test loading via constructor
GUID targetGuid = new GUID(sourceGuidStr);
assertEquals(targetGuid.toGuidString(), sourceGuidStr);
}
/**
* Loads a GUID from a byte array and verify that the guid returned has the
* expected values in each byte.
*/
public void testGUIDFromBinary() {
byte[] sourceGuidBArr = new byte[] { (byte) 0xA5, (byte) 0xDC,
(byte) 0xBF, (byte) 0x10, (byte) 0x65, (byte) 0x30,
(byte) 0x11, (byte) 0xD2, (byte) 0x90, (byte) 0x1F,
(byte) 0x00, (byte) 0xC0, (byte) 0x4F, (byte) 0xB9,
(byte) 0x51, (byte) 0xED };
// test loading via static method
GUID targetGuid = GUID.fromBinary(sourceGuidBArr);
byte[] targetGuidBArr = targetGuid.toByteArray();
for (int i = 0; i < sourceGuidBArr.length; i++) {
assertEquals(targetGuidBArr[i], sourceGuidBArr[i]);
}
}
/**
* Loads a GUID from a byte array via the constructor and verify that the
* guid returned has the expected values in each byte.
*/
public void testGUIDFromBinary2() {
byte[] sourceGuidBArr = new byte[] { (byte) 0xA5, (byte) 0xDC,
(byte) 0xBF, (byte) 0x10, (byte) 0x65, (byte) 0x30,
(byte) 0x11, (byte) 0xD2, (byte) 0x90, (byte) 0x1F,
(byte) 0x00, (byte) 0xC0, (byte) 0x4F, (byte) 0xB9,
(byte) 0x51, (byte) 0xED };
// test loading via constructor
GUID targetGuid = new GUID(sourceGuidBArr);
byte[] targetGuidBArr = targetGuid.toByteArray();
for (int i = 0; i < sourceGuidBArr.length; i++) {
assertEquals(targetGuidBArr[i], sourceGuidBArr[i]);
}
}
/**
* Instantiates two guids, one with windows build-in function and one via
* jna and compares it.
*/
public void testBehaviourWithOle32() {
GUID ole32Guid = Ole32Util.getGUIDFromString("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
GUID jnaGuid = new GUID("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
assertEquals(ole32Guid, jnaGuid);
}
/**
* Test with the windows build-in function, compares the result of the
* methods.
*/
public void testBehaviourWithOle32_2() {
GUID ole32Guid = Ole32Util
.getGUIDFromString("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
GUID jnaGuid = new GUID("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
String ole32Guidstr = Ole32Util.getStringFromGUID(ole32Guid);
String jnaGuidStr = jnaGuid.toGuidString();
assertEquals(ole32Guidstr, jnaGuidStr);
}
/**
* Tests the new guid with the build-in function coming with windows.
*/
public void testNewGuid() {
GUID newGuid = GUID.newGuid();
String guidString = newGuid.toGuidString();
GUID guidFromString = Ole32Util.getGUIDFromString(guidString);
assertEquals(guidFromString.toGuidString(), guidString);
}
}
@@ -0,0 +1,271 @@
/* 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 junit.framework.TestCase;
import com.sun.jna.Native;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
import com.sun.jna.platform.win32.OaIdl.HREFTYPEbyReference;
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
import com.sun.jna.platform.win32.OaIdl.VARDESC;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
import com.sun.jna.platform.win32.WinDef.WORDbyReference;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMObject;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.ITypeComp;
import com.sun.jna.platform.win32.COM.ITypeInfo;
import com.sun.jna.platform.win32.COM.ITypeLib;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* @author dblock[at]dblock[dot]org
*/
public class ITypeInfoTest extends TestCase {
private COMObject comObj = null;
public static void main(String[] args) {
junit.textui.TestRunner.run(ITypeInfoTest.class);
}
public ITypeInfoTest() {
Native.setProtected(true);
}
@Override
protected void setUp() throws Exception {
if (this.comObj == null) {
// create a shell COM object
this.comObj = new COMObject("Shell.Application", false);
}
}
@Override
protected void tearDown() throws Exception {
if (this.comObj != null) {
this.comObj.release();
}
}
public ITypeInfo getTypeInfo() {
// get user default lcid
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
// create a IUnknown pointer
PointerByReference ppTInfo = new PointerByReference();
comObj.getIDispatch().GetTypeInfo(new UINT(0), lcid, ppTInfo);
return new ITypeInfo(ppTInfo.getValue());
}
public void testGetTypeAttr() {
ITypeInfo typeInfo = getTypeInfo();
TYPEATTR.ByReference pTypeAttr = new TYPEATTR.ByReference();
HRESULT hr = typeInfo.GetTypeAttr(pTypeAttr);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetTypeAttr: " + pTypeAttr.toString(true));
}
public void testGetTypeComp() {
ITypeInfo typeInfo = getTypeInfo();
ITypeComp.ByReference pTComp = new ITypeComp.ByReference();
HRESULT hr = typeInfo.GetTypeComp(pTComp);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetTypeComp: " + pTComp.toString());
}
public void testGetFuncDesc() {
ITypeInfo typeInfo = getTypeInfo();
FUNCDESC.ByReference pFuncDesc = new FUNCDESC.ByReference();
HRESULT hr = typeInfo.GetFuncDesc(new UINT(1), pFuncDesc);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetFuncDesc: " + pFuncDesc.toString(true));
}
public void testGetVarDesc() {
ITypeInfo typeInfo = getTypeInfo();
VARDESC.ByReference pVarDesc = new VARDESC.ByReference();
HRESULT hr = typeInfo.GetVarDesc(new UINT(0), pVarDesc);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetVarDesc: " + pVarDesc.toString());
}
public void testGetNames() {
ITypeInfo typeInfo = getTypeInfo();
MEMBERID memid = new MEMBERID(1);
BSTR[] rgBstrNames = new BSTR[1];
UINT cMaxNames = new UINT(1);
UINTbyReference pcNames = new UINTbyReference();
HRESULT hr = typeInfo.GetNames(memid, rgBstrNames, cMaxNames, pcNames);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("rgBstrNames: " + rgBstrNames[0].getValue());
System.out.println("pcNames: " + pcNames.getValue().intValue());
}
public void testGetRefTypeOfImplType() {
ITypeInfo typeInfo = getTypeInfo();
HREFTYPEbyReference pRefType = new HREFTYPEbyReference();
HRESULT hr = typeInfo.GetRefTypeOfImplType(new UINT(0), pRefType);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetRefTypeOfImplType: " + pRefType.toString());
}
public void testGetImplTypeFlags() {
ITypeInfo typeInfo = getTypeInfo();
IntByReference pImplTypeFlags = new IntByReference();
HRESULT hr = typeInfo.GetImplTypeFlags(new UINT(0), pImplTypeFlags);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetImplTypeFlags: " + pImplTypeFlags.toString());
}
public void testGetIDsOfNames() {
ITypeInfo typeInfo = getTypeInfo();
WString[] rgszNames = { new WString("Visible") };
UINT cNames = new UINT(1);
MEMBERID[] pMemId = new MEMBERID[1];
HRESULT hr = typeInfo.GetIDsOfNames(rgszNames, cNames, pMemId);
COMUtils.checkAutoRC(hr);
assertEquals(0, hr.intValue());
System.out.println("pMemId: " + pMemId.toString());
}
public void testInvoke() {
fail("not implemented due complexity.");
}
public void testGetDocumentation() {
ITypeInfo typeInfo = getTypeInfo();
MEMBERID memid = new MEMBERID(0);
BSTR pBstrName = new BSTR();
BSTR pBstrDocString = new BSTR();
DWORDbyReference pdwHelpContext = new DWORDbyReference();
BSTR pBstrHelpFile = new BSTR();
HRESULT hr = typeInfo.GetDocumentation(memid, pBstrName,
pBstrDocString, pdwHelpContext, pBstrHelpFile);
COMUtils.checkAutoRC(hr);
assertEquals(0, hr.intValue());
System.out.println("memid: " + memid.intValue());
System.out.println("pBstrName: " + pBstrName.getValue());
System.out.println("pBstrDocString: " + pBstrDocString.getValue());
System.out.println("pdwHelpContext: " + pdwHelpContext.getValue());
System.out.println("pBstrHelpFile: " + pBstrHelpFile.getValue());
}
public void testGetDllEntry() {
ITypeInfo typeInfo = getTypeInfo();
MEMBERID memid = new MEMBERID(0);
BSTR pBstrDllName = new BSTR();
BSTR pBstrName = new BSTR();
WORDbyReference pwOrdinal = new WORDbyReference();
HRESULT hr = typeInfo.GetDllEntry(memid, INVOKEKIND.INVOKE_FUNC,
pBstrDllName, pBstrName, pwOrdinal);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("memid: " + memid.intValue());
System.out.println("pBstrDllName: " + pBstrDllName.getValue());
System.out.println("pBstrName: " + pBstrName.getValue());
System.out.println("pwOrdinal: " + pwOrdinal.getValue());
}
public void testGetRefTypeInfo() {
ITypeInfo typeInfo = getTypeInfo();
HREFTYPE hRefType = new HREFTYPE();
ITypeInfo.ByReference ppTInfo = new ITypeInfo.ByReference();
HRESULT hr = typeInfo.GetRefTypeInfo(hRefType, ppTInfo);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("GetRefTypeInfo: " + ppTInfo.toString());
}
public void testAddressOfMember() {
ITypeInfo typeInfo = getTypeInfo();
MEMBERID memid = new MEMBERID();
PointerByReference ppv = new PointerByReference();
HRESULT hr = typeInfo.AddressOfMember(memid, INVOKEKIND.INVOKE_FUNC,
ppv);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("AddressOfMember: " + ppv.toString());
}
public void testCreateInstance() {
fail("not implemented due complexity.");
}
public void testGetMops() {
ITypeInfo typeInfo = getTypeInfo();
MEMBERID memid = new MEMBERID(0);
BSTR pBstrMops = new BSTR();
HRESULT hr = typeInfo.GetMops(memid, pBstrMops);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("pBstrMops: " + pBstrMops.toString());
}
public void testGetContainingTypeLib() {
ITypeInfo typeInfo = getTypeInfo();
ITypeLib.ByReference pTLib = new ITypeLib.ByReference();
UINTbyReference pIndex = new UINTbyReference();
HRESULT hr = typeInfo.GetContainingTypeLib(pTLib, pIndex);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("pTLib: " + pTLib.toString());
System.out.println("pTLib: " + pIndex.toString());
}
public void testReleaseTypeAttr() {
fail("not implemented due complexity.");
}
public void testReleaseFuncDesc() {
fail("not implemented due complexity.");
}
public void testReleaseVarDesc() {
fail("not implemented due complexity.");
}
}
@@ -0,0 +1,127 @@
/* 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 junit.framework.TestCase;
import com.sun.jna.Native;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.ITypeComp;
import com.sun.jna.platform.win32.COM.ITypeInfo;
import com.sun.jna.platform.win32.COM.ITypeLib;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* @author dblock[at]dblock[dot]org
*/
public class ITypeLibTest extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(ITypeLibTest.class);
}
public ITypeLibTest() {
Native.setProtected(true);
}
public ITypeLib loadShellTypeLib() {
// Microsoft Shell Controls And Automation
CLSID.ByReference clsid = new CLSID.ByReference();
// get CLSID from string
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(
"{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}"), clsid);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
// get user default lcid
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
// create a IUnknown pointer
PointerByReference pShellTypeLib = new PointerByReference();
// load typelib
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 1, 0, lcid, pShellTypeLib);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
return new ITypeLib(pShellTypeLib.getValue());
}
public void testGetTypeInfoCount() {
ITypeLib shellTypeLib = loadShellTypeLib();
UINT typeInfoCount = shellTypeLib.GetTypeInfoCount();
System.out.println("GetTypeInfoCount: " + typeInfoCount);
}
public void testGetTypeInfo() {
ITypeLib shellTypeLib = loadShellTypeLib();
ITypeInfo.ByReference pTInfo = new ITypeInfo.ByReference();
HRESULT hr = shellTypeLib.GetTypeInfo(new UINT(0), pTInfo);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("ITypeInfo: " + pTInfo.toString());
}
public void testGetTypeInfoType() {
ITypeLib shellTypeLib = loadShellTypeLib();
IntByReference pTKind = new IntByReference();
HRESULT hr = shellTypeLib.GetTypeInfoType(new UINT(0), pTKind);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("TYPEKIND: " + pTKind);
}
public void testGetTypeInfoOfGuid() {
ITypeLib shellTypeLib = loadShellTypeLib();
GUID shellGuid = new GUID("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}");
ITypeInfo.ByReference pTInfo = new ITypeInfo.ByReference();
HRESULT hr = shellTypeLib.GetTypeInfoOfGuid(shellGuid, pTInfo);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("ITypeInfo: " + pTInfo.toString());
}
public void testGetLibAttr() {
ITypeLib shellTypeLib = loadShellTypeLib();
TLIBATTR.ByReference ppTLibAttr = new TLIBATTR.ByReference();
HRESULT hr = shellTypeLib.GetLibAttr(ppTLibAttr);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("ppTLibAttr: " + ppTLibAttr.toString());
}
public void testGetTypeComp() {
ITypeLib shellTypeLib = loadShellTypeLib();
ITypeComp.ByReference pTComp = new ITypeComp.ByReference();
HRESULT hr = shellTypeLib.GetTypeComp(pTComp);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
System.out.println("pTComp: " + pTComp.toString());
}
}
@@ -1,20 +1,24 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -24,11 +28,11 @@ import java.util.TimeZone;
import junit.framework.TestCase;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.NativeMappedConverter;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Memory;
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;
@@ -41,24 +45,24 @@ import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
import com.sun.jna.ptr.IntByReference;
public class Kernel32Test extends TestCase {
public static void main(String[] args) {
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
System.out.println("Operating system: "
System.out.println("Operating system: "
+ lpVersionInfo.dwMajorVersion.longValue() + "." + lpVersionInfo.dwMinorVersion.longValue()
+ " (" + lpVersionInfo.dwBuildNumber + ")"
+ " [" + Native.toString(lpVersionInfo.szCSDVersion) + "]");
junit.textui.TestRunner.run(Kernel32Test.class);
}
public void testGetDriveType() {
if (!Platform.isWindows()) return;
Kernel32 kernel = Kernel32.INSTANCE;
assertEquals("Wrong drive type.", WinBase.DRIVE_FIXED, kernel.GetDriveType("c:"));
}
public void testStructureOutArgument() {
Kernel32 kernel = Kernel32.INSTANCE;
WinBase.SYSTEMTIME time = new WinBase.SYSTEMTIME();
@@ -69,18 +73,18 @@ public class Kernel32Test extends TestCase {
assertEquals("Day not properly set",
cal.get(Calendar.DAY_OF_WEEK)-1,
time.wDayOfWeek);
assertEquals("Year not properly set",
assertEquals("Year not properly set",
cal.get(Calendar.YEAR), time.wYear);
}
public void testGetLastError() {
Kernel32 kernel = Kernel32.INSTANCE;
int ERRCODE = 8;
kernel.SetLastError(ERRCODE);
int code = kernel.GetLastError();
assertEquals("Wrong error value after SetLastError", ERRCODE, code);
if (kernel.GetProcessVersion(-1) == 0) {
final int INVALID_PARAMETER = 87;
code = kernel.GetLastError();
@@ -90,16 +94,16 @@ public class Kernel32Test extends TestCase {
fail("GetProcessId(NULL) should fail");
}
}
public void testConvertHWND_BROADCAST() {
HWND hwnd = WinUser.HWND_BROADCAST;
NativeMappedConverter.getInstance(hwnd.getClass()).toNative(hwnd, null);
}
public void testGetComputerName() {
IntByReference lpnSize = new IntByReference(0);
assertFalse(Kernel32.INSTANCE.GetComputerName(null, lpnSize));
assertEquals(W32Errors.ERROR_BUFFER_OVERFLOW, Kernel32.INSTANCE.GetLastError());
assertEquals(WinError.ERROR_BUFFER_OVERFLOW, Kernel32.INSTANCE.GetLastError());
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
lpnSize.setValue(buffer.length);
assertTrue(Kernel32.INSTANCE.GetComputerName(buffer, lpnSize));
@@ -107,87 +111,87 @@ public class Kernel32Test extends TestCase {
public void testWaitForSingleObject() {
HANDLE handle = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
// handle runs into timeout since it is not triggered
// WAIT_TIMEOUT = 0x00000102
assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForSingleObject(
handle, 1000));
Kernel32.INSTANCE.CloseHandle(handle);
}
public void testWaitForMultipleObjects(){
HANDLE[] handles = new HANDLE[2];
handles[0] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
// handle runs into timeout since it is not triggered
// WAIT_TIMEOUT = 0x00000102
assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForMultipleObjects(
assertEquals(WinError.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForSingleObject(
handle, 1000));
Kernel32.INSTANCE.CloseHandle(handle);
}
public void testWaitForMultipleObjects(){
HANDLE[] handles = new HANDLE[2];
handles[0] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
// handle runs into timeout since it is not triggered
// WAIT_TIMEOUT = 0x00000102
assertEquals(WinError.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForMultipleObjects(
handles.length, handles, false, 1000));
Kernel32.INSTANCE.CloseHandle(handles[0]);
Kernel32.INSTANCE.CloseHandle(handles[1]);
// invalid Handle
handles[0] = WinBase.INVALID_HANDLE_VALUE;
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
// returns WAIT_FAILED since handle is invalid
assertEquals(WinBase.WAIT_FAILED, Kernel32.INSTANCE.WaitForMultipleObjects(
handles.length, handles, false, 5000));
Kernel32.INSTANCE.CloseHandle(handles[1]);
}
}
public void testGetCurrentThreadId() {
assertTrue(Kernel32.INSTANCE.GetCurrentThreadId() > 0);
}
public void testGetCurrentThread() {
HANDLE h = Kernel32.INSTANCE.GetCurrentThread();
assertNotNull(h);
assertFalse(h.equals(0));
// CloseHandle does not need to be called for a thread handle
assertFalse(Kernel32.INSTANCE.CloseHandle(h));
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
}
public void testOpenThread() {
HANDLE h = Kernel32.INSTANCE.OpenThread(WinNT.THREAD_ALL_ACCESS, false,
HANDLE h = Kernel32.INSTANCE.OpenThread(WinNT.THREAD_ALL_ACCESS, false,
Kernel32.INSTANCE.GetCurrentThreadId());
assertNotNull(h);
assertFalse(h.equals(0));
assertTrue(Kernel32.INSTANCE.CloseHandle(h));
}
public void testGetCurrentProcessId() {
assertTrue(Kernel32.INSTANCE.GetCurrentProcessId() > 0);
}
public void testGetCurrentProcess() {
HANDLE h = Kernel32.INSTANCE.GetCurrentProcess();
assertNotNull(h);
assertFalse(h.equals(0));
// CloseHandle does not need to be called for a process handle
assertFalse(Kernel32.INSTANCE.CloseHandle(h));
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
}
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
}
public void testOpenProcess() {
HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false,
HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false,
Kernel32.INSTANCE.GetCurrentProcessId());
assertNull(h);
// opening your own process fails with access denied
assertEquals(W32Errors.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
assertEquals(WinError.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
}
public void testGetTempPath() {
char[] buffer = new char[WinDef.MAX_PATH];
assertTrue(Kernel32.INSTANCE.GetTempPath(new DWORD(WinDef.MAX_PATH), buffer).intValue() > 0);
char[] buffer = new char[WinDef.MAX_PATH];
assertTrue(Kernel32.INSTANCE.GetTempPath(new DWORD(WinDef.MAX_PATH), buffer).intValue() > 0);
}
public void testGetTickCount() throws InterruptedException {
// Tick count rolls over every 49.7 days, so to safeguard from
// roll-over, we will get two time spans. At least one should
@@ -200,15 +204,15 @@ public class Kernel32Test extends TestCase {
assertTrue(tick2 > tick1 || tick3 > tick2);
}
public void testGetVersion() {
DWORD version = Kernel32.INSTANCE.GetVersion();
assertTrue("Version high should be non-zero: 0x" + Integer.toHexString(version.getHigh().intValue()), version.getHigh().intValue() != 0);
assertTrue("Version low should be >= 0: 0x" + Integer.toHexString(version.getLow().intValue()), version.getLow().intValue() >= 0);
}
public void testGetVersionEx_OSVERSIONINFO() {
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0);
@@ -216,11 +220,11 @@ public class Kernel32Test extends TestCase {
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0);
assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0);
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
}
public void testGetVersionEx_OSVERSIONINFOEX() {
OSVERSIONINFOEX lpVersionInfo = new OSVERSIONINFOEX();
OSVERSIONINFOEX lpVersionInfo = new OSVERSIONINFOEX();
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0);
@@ -228,16 +232,16 @@ public class Kernel32Test extends TestCase {
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0);
assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0);
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
assertTrue(lpVersionInfo.wProductType >= 0);
}
public void testGetSystemInfo() {
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
Kernel32.INSTANCE.GetSystemInfo(lpSystemInfo);
assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0);
}
public void testIsWow64Process() {
try {
IntByReference isWow64 = new IntByReference(42);
@@ -248,7 +252,7 @@ public class Kernel32Test extends TestCase {
// IsWow64Process is not available on this OS
}
}
public void testGetNativeSystemInfo() {
try {
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
@@ -258,7 +262,7 @@ public class Kernel32Test extends TestCase {
// only available under WOW64
}
}
public void testGlobalMemoryStatusEx() {
MEMORYSTATUSEX lpBuffer = new MEMORYSTATUSEX();
assertTrue(Kernel32.INSTANCE.GlobalMemoryStatusEx(lpBuffer));
@@ -273,45 +277,46 @@ public class Kernel32Test extends TestCase {
char buf[] = new char[dwSize.intValue()];
assertTrue(Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf).intValue() > 0);
}
public void testGetDiskFreeSpaceEx() {
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference();
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference();
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference();
assertTrue(Kernel32.INSTANCE.GetDiskFreeSpaceEx(null,
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference();
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference();
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference();
assertTrue(Kernel32.INSTANCE.GetDiskFreeSpaceEx(null,
lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes));
assertTrue(lpTotalNumberOfFreeBytes.getValue() > 0);
assertTrue(lpTotalNumberOfFreeBytes.getValue() < lpTotalNumberOfBytes.getValue());
}
public void testDeleteFile() {
String filename = Kernel32Util.getTempPath() + "\\FileDoesNotExist.jna";
assertFalse(Kernel32.INSTANCE.DeleteFile(filename));
assertEquals(W32Errors.ERROR_FILE_NOT_FOUND, Kernel32.INSTANCE.GetLastError());
assertEquals(WinError.ERROR_FILE_NOT_FOUND, Kernel32.INSTANCE.GetLastError());
}
public void testReadFile() throws IOException {
String expected = "jna - testReadFile";
File tmp = File.createTempFile("testReadFile", "jna");
tmp.deleteOnExit();
FileWriter fw = new FileWriter(tmp);
fw.append(expected);
fw.close();
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
assertFalse(hFile == WinBase.INVALID_HANDLE_VALUE);
Memory m = new Memory(2048);
IntByReference lpNumberOfBytesRead = new IntByReference(0);
assertTrue(Kernel32.INSTANCE.ReadFile(hFile, m, (int)m.size(), lpNumberOfBytesRead, null));
assertEquals(expected.length(), lpNumberOfBytesRead.getValue());
assertEquals(expected, m.getString(0));
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
assertTrue(Kernel32.INSTANCE.ReadFile(hFile, m, (int) m.size(), lpNumberOfBytesRead, null));
int read = lpNumberOfBytesRead.getValue();
assertEquals(expected.length(), read);
assertEquals(expected, new String(m.getByteArray(0, read)));
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
}
public void testSetHandleInformation() throws IOException {
File tmp = File.createTempFile("testSetHandleInformation", "jna");
tmp.deleteOnExit();
@@ -319,39 +324,39 @@ public class Kernel32Test extends TestCase {
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
assertFalse(hFile == WinBase.INVALID_HANDLE_VALUE);
assertTrue(Kernel32.INSTANCE.SetHandleInformation(hFile, WinBase.HANDLE_FLAG_PROTECT_FROM_CLOSE, 0));
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
}
public void testCreatePipe() {
HANDLEByReference hReadPipe = new HANDLEByReference();
HANDLEByReference hWritePipe = new HANDLEByReference();
assertTrue(Kernel32.INSTANCE.CreatePipe(hReadPipe, hWritePipe, null, 0));
assertTrue(Kernel32.INSTANCE.CloseHandle(hReadPipe.getValue()));
assertTrue(Kernel32.INSTANCE.CloseHandle(hWritePipe.getValue()));
}
public void testGetExitCodeProcess() {
IntByReference lpExitCode = new IntByReference(0);
assertTrue(Kernel32.INSTANCE.GetExitCodeProcess(Kernel32.INSTANCE.GetCurrentProcess(), lpExitCode));
assertEquals(WinBase.STILL_ACTIVE, lpExitCode.getValue());
}
public void testTerminateProcess() throws IOException {
File tmp = File.createTempFile("testTerminateProcess", "jna");
tmp.deleteOnExit();
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
assertFalse(Kernel32.INSTANCE.TerminateProcess(hFile, 1));
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
}
public void testGetFileAttributes() {
assertTrue(WinBase.INVALID_FILE_ATTRIBUTES != Kernel32.INSTANCE.GetFileAttributes("."));
assertTrue(WinBase.INVALID_FILE_ATTRIBUTES != Kernel32.INSTANCE.GetFileAttributes("."));
}
public void testCopyFile() throws IOException {
@@ -406,11 +411,19 @@ public class Kernel32Test extends TestCase {
assertTrue(processInformation.dwProcessId.longValue() > 0);
}
public void testGetEnvironmentVariable() {
assertTrue(Kernel32.INSTANCE.SetEnvironmentVariable("jna-getenvironment-test", "42"));
int size = Kernel32.INSTANCE.GetEnvironmentVariable("jna-getenvironment-test", null, 0);
assertTrue(size == 3);
char[] data = new char[size];
assertEquals(size - 1, Kernel32.INSTANCE.GetEnvironmentVariable("jna-getenvironment-test", data, size));
assertEquals(size - 1, Native.toString(data).length());
}
public void testSetEnvironmentVariable() {
int value = new Random().nextInt();
Kernel32.INSTANCE.SetEnvironmentVariable("jna-setenvironment-test", Integer.toString(value));
assertEquals(System.getenv("jna-setenvironment-test"), Integer.toString(value));
assertEquals(Integer.toString(value), Kernel32Util.getEnvironmentVariable("jna-setenvironment-test"));
}
public void testGetSetFileTime() throws IOException {
@@ -466,4 +479,50 @@ public class Kernel32Test extends TestCase {
assertTrue(Kernel32.INSTANCE.CloseHandle(processEnumHandle));
assertTrue(processIdList.size() > 4);
}
public final void testGetPrivateProfileInt() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileInt", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = 123");
writer.close();
assertEquals(123, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "existingKey", 456, tmp.getCanonicalPath()));
assertEquals(456, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "missingKey", 456, tmp.getCanonicalPath()));
}
public final void testGetPrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileString", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = ABC");
writer.close();
final char[] buffer = new char[8];
assertEquals("ABC", Kernel32.INSTANCE.GetPrivateProfileString("Section", "existingKey", "DEF", buffer, new DWORD(buffer.length), tmp.getCanonicalPath()));
assertEquals("DEF", Kernel32.INSTANCE.GetPrivateProfileString("Section", "missingKey", "DEF", buffer, new DWORD(buffer.length), tmp.getCanonicalPath()));
}
public final void testWritePrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testWritePrivateProfileString", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = ABC");
writer.println("removedKey = JKL");
writer.close();
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath()));
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "addedKey", "GHI", tmp.getCanonicalPath()));
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "removedKey", null, tmp.getCanonicalPath()));
final BufferedReader reader = new BufferedReader(new FileReader(tmp));
assertEquals(reader.readLine(), "[Section]");
assertTrue(reader.readLine().matches("existingKey\\s*=\\s*DEF"));
assertTrue(reader.readLine().matches("addedKey\\s*=\\s*GHI"));
assertEquals(reader.readLine(), null);
reader.close();
}
}
@@ -1,4 +1,4 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, 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,15 +12,21 @@
*/
package com.sun.jna.platform.win32;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import java.io.PrintWriter;
import junit.framework.TestCase;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
/**
* @author dblock[at]dblock[dot]org
* @author markus[at]headcrashing[dot]eu
*/
public class Kernel32UtilTest extends TestCase {
@@ -123,4 +129,55 @@ public class Kernel32UtilTest extends TestCase {
tempFile.delete();
assertEquals(0, fileAttributes2 & WinNT.FILE_ATTRIBUTE_DIRECTORY);
}
public void testGetEnvironmentVariable() {
assertEquals(null, Kernel32Util.getEnvironmentVariable("jna-getenvironment-test"));
Kernel32.INSTANCE.SetEnvironmentVariable("jna-getenvironment-test", "42");
assertEquals("42", Kernel32Util.getEnvironmentVariable("jna-getenvironment-test"));
}
public final void testGetPrivateProfileInt() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileInt", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = 123");
writer.close();
assertEquals(123, Kernel32Util.getPrivateProfileInt("Section", "existingKey", 456, tmp.getCanonicalPath()));
assertEquals(456, Kernel32Util.getPrivateProfileInt("Section", "missingKey", 456, tmp.getCanonicalPath()));
}
public final void testGetPrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testGetPrivateProfileString", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = ABC");
writer.close();
assertEquals("ABC", Kernel32Util.getPrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath()));
assertEquals("DEF", Kernel32Util.getPrivateProfileString("Section", "missingKey", "DEF", tmp.getCanonicalPath()));
}
public final void testWritePrivateProfileString() throws IOException {
final File tmp = File.createTempFile("testWritePrivateProfileString", "ini");
tmp.deleteOnExit();
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
writer.println("[Section]");
writer.println("existingKey = ABC");
writer.println("removedKey = JKL");
writer.close();
Kernel32Util.writePrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath());
Kernel32Util.writePrivateProfileString("Section", "addedKey", "GHI", tmp.getCanonicalPath());
Kernel32Util.writePrivateProfileString("Section", "removedKey", null, tmp.getCanonicalPath());
final BufferedReader reader = new BufferedReader(new FileReader(tmp));
assertEquals(reader.readLine(), "[Section]");
assertTrue(reader.readLine().matches("existingKey\\s*=\\s*DEF"));
assertTrue(reader.readLine().matches("addedKey\\s*=\\s*GHI"));
assertEquals(reader.readLine(), null);
reader.close();
}
}
@@ -10,15 +10,13 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
package com.sun.jna.platform.win32;
import junit.framework.TestCase;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
import com.sun.jna.platform.win32.LMAccess.GROUP_INFO_2;
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
@@ -29,7 +27,6 @@ import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_RECORD;
import com.sun.jna.platform.win32.Netapi32Util.User;
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.ptr.PointerByReference;
/**
@@ -152,8 +149,10 @@ public class Netapi32Test extends TestCase {
userInfo.usri1_name = new WString("JNANetapi32TestUser");
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
Kernel32Util.getComputerName(), 1, userInfo, null));
// ignore test if not able to add user (need to be administrator to do this).
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) {
return;
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel(
Kernel32Util.getComputerName(), userInfo.usri1_name.toString()));
}
@@ -163,8 +162,10 @@ public class Netapi32Test extends TestCase {
userInfo.usri1_name = new WString("JNANetapi32TestUser");
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
Kernel32Util.getComputerName(), 1, userInfo, null));
// ignore test if not able to add user (need to be administrator to do this).
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) {
return;
}
try {
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserChangePassword(
Kernel32Util.getComputerName(), userInfo.usri1_name.toString(), userInfo.usri1_password.toString(),
@@ -200,7 +201,7 @@ public class Netapi32Test extends TestCase {
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsGetForestTrustInformation(
domainController, null, 0, pfti));
assertTrue(pfti.fti.RecordCount.intValue() >= 0);
assertTrue(pfti.fti.RecordCount >= 0);
for (PLSA_FOREST_TRUST_RECORD precord : pfti.fti.getEntries()) {
LSA_FOREST_TRUST_RECORD.UNION data = precord.tr.u;
@@ -236,23 +237,24 @@ public class Netapi32Test extends TestCase {
if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
return;
NativeLongByReference domainCount = new NativeLongByReference();
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(
null, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount));
IntByReference domainTrustCount = new IntByReference();
PointerByReference domainsPointerRef = new PointerByReference();
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(null,
DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount));
assertTrue(domainTrustCount.getValue() >= 0);
assertTrue(domainCount.getValue().intValue() >= 0);
DS_DOMAIN_TRUSTS[] trusts = domains.getTrusts(domainCount.getValue().intValue());
for(DS_DOMAIN_TRUSTS trust : trusts) {
assertTrue(trust.NetbiosDomainName.length() > 0);
DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
for(DS_DOMAIN_TRUSTS trust : domainTrusts) {
assertTrue(trust.DnsDomainName.length() > 0);
assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid));
assertTrue(Advapi32Util.convertSidToStringSid(trust.DomainSid).startsWith("S-"));
assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{"));
}
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(
domains.getPointer()));
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer()));
}
}
@@ -17,7 +17,6 @@ import junit.framework.TestCase;
import com.sun.jna.platform.win32.Netapi32Util.DomainController;
import com.sun.jna.platform.win32.Netapi32Util.DomainTrust;
import com.sun.jna.platform.win32.Netapi32Util.UserInfo;
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
/**
* @author dblock[at]dblock[dot]org
@@ -1,4 +1,4 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, 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
@@ -22,78 +22,89 @@ import com.sun.jna.ptr.PointerByReference;
/**
* @author dblock[at]dblock[dot]org
* @author markus[at]headcrashing[dot]eu
*/
public class Ole32Test extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(Ole32Test.class);
}
public void testCoCreateGUID() {
GUID.ByReference pguid = new GUID.ByReference();
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.CoCreateGuid(pguid));
assertTrue(pguid.Data1 != 0 || pguid.Data2 != 0 || pguid.Data3 != 0 && pguid.Data4 != null);
}
public void testIIDFromString() {
GUID.ByReference lpiid = new GUID.ByReference();
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.IIDFromString(
"{13709620-C279-11CE-A49E-444553540000}", lpiid)); // Shell.Application.1
assertEquals(0x13709620, lpiid.Data1);
assertEquals(0xFFFFC279, lpiid.Data2);
assertEquals(0x11CE, lpiid.Data3);
assertEquals(0xFFFFFFA4, lpiid.Data4[0]);
assertEquals(0xFFFFFF9E, lpiid.Data4[1]);
assertEquals(0x44, lpiid.Data4[2]);
assertEquals(0x45, lpiid.Data4[3]);
assertEquals(0x53, lpiid.Data4[4]);
assertEquals(0x54, lpiid.Data4[5]);
assertEquals(0, lpiid.Data4[6]);
assertEquals(0, lpiid.Data4[7]);
}
public void testStringFromGUID2() {
GUID.ByReference pguid = new GUID.ByReference();
pguid.Data1 = 0;
pguid.Data2 = 0;
pguid.Data3 = 0;
for (int i = 0; i < pguid.Data4.length; i++) {
pguid.Data4[i] = 0;
}
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
assertTrue(len > 1);
lpsz[len - 1] = 0;
assertEquals("{00000000-0000-0000-0000-000000000000}", Native.toString(lpsz));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(Ole32Test.class);
}
public void testCoInitializeEx() {
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
assertTrue(W32Errors.SUCCEEDED(hr.intValue()) || hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
if (W32Errors.SUCCEEDED(hr.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
public void testCoCreateGUID() {
GUID.ByReference pguid = new GUID.ByReference();
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.CoCreateGuid(pguid));
assertTrue(pguid.Data1 != 0 || pguid.Data2 != 0 || pguid.Data3 != 0
&& pguid.Data4 != null);
}
public void testCoCreateInstance() {
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
public void testIIDFromString() {
GUID.ByReference lpiid = new GUID.ByReference();
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.IIDFromString(
"{13709620-C279-11CE-A49E-444553540000}", lpiid)); // Shell.Application.1
assertEquals(0x13709620, lpiid.Data1);
assertEquals(0xFFFFC279, lpiid.Data2);
assertEquals(0x11CE, lpiid.Data3);
assertEquals(0xFFFFFFA4, lpiid.Data4[0]);
assertEquals(0xFFFFFF9E, lpiid.Data4[1]);
assertEquals(0x44, lpiid.Data4[2]);
assertEquals(0x45, lpiid.Data4[3]);
assertEquals(0x53, lpiid.Data4[4]);
assertEquals(0x54, lpiid.Data4[5]);
assertEquals(0, lpiid.Data4[6]);
assertEquals(0, lpiid.Data4[7]);
}
GUID guid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); //Shell object
GUID riid = Ole32Util.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); //IShellDispatch
public void testStringFromGUID2() {
GUID.ByReference pguid = new GUID.ByReference();
pguid.Data1 = 0;
pguid.Data2 = 0;
pguid.Data3 = 0;
for (int i = 0; i < pguid.Data4.length; i++) {
pguid.Data4[i] = 0;
}
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
assertTrue(len > 1);
lpsz[len - 1] = 0;
assertEquals("{00000000-0000-0000-0000-000000000000}",
Native.toString(lpsz));
}
PointerByReference iUnknown = new PointerByReference();
public void testCoInitializeEx() {
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
assertTrue(W32Errors.SUCCEEDED(hr.intValue())
|| hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
if (W32Errors.SUCCEEDED(hr.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(
guid,
null, // pOuter = null, no aggregation
ObjBase.CLSCTX_ALL,
riid,
iUnknown);
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
assertTrue(!iUnknown.getValue().equals(Pointer.NULL));
// We leak this iUnknown reference because we don't have the JNACOM lib
// here to wrap the native iUnknown pointer and call iUnknown.release()
if (W32Errors.SUCCEEDED(hrCI.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
public void testCoCreateInstance() {
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
GUID guid = Ole32Util
.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); // Shell
// object
GUID riid = Ole32Util
.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); // IShellDispatch
PointerByReference pDispatch = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(guid, null, // pOuter =
// null, no
// aggregation
WTypes.CLSCTX_LOCAL_SERVER, riid, pDispatch);
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
assertTrue(!pDispatch.equals(Pointer.NULL));
// We leak this iUnknown reference because we don't have the JNACOM lib
// here to wrap the native iUnknown pointer and call iUnknown.release()
if (W32Errors.SUCCEEDED(hrCI.intValue()))
Ole32.INSTANCE.CoUninitialize();
}
public final void testCLSIDFromProgID() {
final Guid.CLSID.ByReference clsid = new Guid.CLSID.ByReference();
assertEquals(WinError.S_OK, Ole32.INSTANCE.CLSIDFromProgID("jpegfile", clsid));
assertEquals("{25336920-03F9-11CF-8FD0-00AA00686F13}", clsid.toGuidString());
}
}
@@ -0,0 +1,79 @@
/* 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 junit.framework.TestCase;
import com.sun.jna.Native;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.ptr.PointerByReference;
/**
* @author dblock[at]dblock[dot]org
*/
public class OleAutoTest extends TestCase {
public static void main(String[] args) {
Native.setProtected(true);
junit.textui.TestRunner.run(OleAutoTest.class);
}
public OleAutoTest() {
Native.setProtected(true);
}
public void testSysAllocString() {
assertEquals(null, OleAuto.INSTANCE.SysAllocString(null));
BSTR p = OleAuto.INSTANCE.SysAllocString("hello world");
assertEquals("hello world", p.getValue());
OleAuto.INSTANCE.SysFreeString(p);
}
public void testSysFreeString() {
OleAuto.INSTANCE.SysFreeString(null);
}
public void testDISPPARAMS() {
// Build DISPPARAMS
SAFEARRAY.ByReference safeArg = OleAutoUtil.createVarArray(1);
OleAutoUtil.SafeArrayPutElement(safeArg, 0, new VARIANT(
Variant.VARIANT_TRUE));
System.out.println(safeArg.toString(true));
}
public void testLoadRegTypeLib() {
// MS Word typelib guid
CLSID.ByReference clsid = new CLSID.ByReference();
// get CLSID from string
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(
"{00020905-0000-0000-C000-000000000046}"), clsid);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
// get user default lcid
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
PointerByReference pWordTypeLib = new PointerByReference();
// get typelib based on Word 8.3 (v11)
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 8, 3, lcid, pWordTypeLib);
COMUtils.checkTypeLibRC(hr);
assertEquals(0, hr.intValue());
}
}
@@ -0,0 +1,67 @@
/* Copyright (c) 2013 Tobias Wolf, 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 junit.framework.TestCase;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WinDef.SHORT;
import com.sun.jna.platform.win32.COM.COMException;
/**
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class OleAutoUtilTest extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(OleAutoUtilTest.class);
}
public void testCreateVarArray() {
SAFEARRAY varArray = OleAutoUtil.createVarArray(1);
assertTrue(varArray != null);
}
public void testSafeArrayPutGetElement() {
SAFEARRAY varArray = OleAutoUtil.createVarArray(10);
for (int i = 0; i < 10; i++) {
try {
VARIANT variant = new VARIANT(new SHORT(i + i*100));
System.out.println(variant.toString(true));
OleAutoUtil.SafeArrayPutElement(varArray, i, variant);
} catch (COMException e) {
e.printStackTrace();
}
}
assertTrue(varArray != null);
System.out
.println("\n\n\n-------------------------------------------------------------");
System.out
.println("-------------------------------------------------------------\n\n\n");
for (int i = 0; i < 10; i++) {
try {
VARIANT element = OleAutoUtil.SafeArrayGetElement(varArray, i);
System.out.println(element.toString(true));
System.out.println("variant type: " + element.getVarType());
System.out.println("value: " + element.getValue());
} catch (COMException e) {
e.printStackTrace();
}
}
}
}
@@ -1,38 +0,0 @@
/* 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 junit.framework.TestCase;
import com.sun.jna.Pointer;
/**
* @author dblock[at]dblock[dot]org
*/
public class Oleaut32Test extends TestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(Oleaut32Test.class);
}
public void testSysAllocString() {
assertEquals(null, Oleaut32.INSTANCE.SysAllocString(null));
Pointer p = Oleaut32.INSTANCE.SysAllocString("hello world");
assertEquals("hello world", p.getString(0, true));
Oleaut32.INSTANCE.SysFreeString(p);
}
public void testSysFreeString() {
Oleaut32.INSTANCE.SysFreeString(null);
}
}

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