Comparar commits

..

497 Commits

Autor SHA1 Mensagem Data
Timothy Wall 2239bdfdfd improve library load debugging 2013-06-02 08:44:32 -04:00
Timothy Wall c6151c3775 ensure native library found in jar 2013-06-02 08:34:03 -04:00
Timothy Wall 0387196f85 fix library load error w/unicode 2013-06-02 14:18:32 +02:00
Timothy Wall c7e7798979 fix amd64 native thread cleanup test 2013-05-30 10:42:09 -04:00
Timothy Wall aa80c8d19f Merge branch 'amd64-pthread-cleanup' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-30 08:03:06 -04:00
Timothy Wall 02d5f47380 Merge branch 'master' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-30 07:42:21 -04:00
Timothy Wall 75f3ed2d5a revise thread termination flag logic 2013-05-30 07:41:24 -04:00
Timothy Wall 85793114d4 fix #237, LastErrorException/getLastError thread-safe errno on AIX 2013-05-30 07:00:30 -04:00
Timothy Wall 708e76473a Merge branch 'master' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-30 06:57:43 -04:00
Timothy Wall 2b8773a8f0 fix padding on ppc 2013-05-29 23:55:12 -04:00
Timothy Wall 962ae7998e fix broken test 2013-05-29 23:24:45 -04:00
Timothy Wall 8f199788a5 force gcc to 32-bit mode for i386 builds on amd64 2013-05-29 21:24:43 -04:00
Timothy Wall caaddd1179 add thread termination flags and checking 2013-05-29 20:43:26 -04:00
Timothy Wall 3704b23a71 auto-strip profiler prefix set in jna.profiler.prefix 2013-05-28 22:49:20 -04:00
Timothy Wall c596f9f7d5 add explicit test for direct mapping use of supplied function mapper 2013-05-28 22:18:21 -04:00
Timothy Wall f6208e71f4 Merge branch 'master' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-28 07:00:30 -04:00
Timothy Wall 85a3cda5c8 update win32-x86 natives 2013-05-27 23:09:32 -04:00
Timothy Wall 6c591c38d9 fix failing test on XP 2013-05-27 23:08:18 -04:00
Timothy Wall 15aac21e2b restore gcc as default win32 32-bit build 2013-05-27 22:22:17 -04:00
Timothy Wall e0441a356d fix failing test 2013-05-27 16:20:58 -04:00
Timothy Wall f3da8161aa verify proper module handle for dll callbacks 2013-05-27 16:14:38 -04:00
Timothy Wall 609e3e459b fix dll callbacks inline asm with msvc 2013-05-27 15:11:55 -04:00
Timothy Wall 8638bb57f9 fix 32-bit build under MSVC 10 2013-05-27 07:56:05 -04:00
Timothy Wall d11084ce0d Merge branch 'master' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-27 07:16:08 -04:00
Timothy Wall 1ae335c7da update win64 natives 2013-05-26 17:56:55 -04:00
Timothy Wall 99529821b4 Merge branch 'master' of github.com:twall/jna 2013-05-26 17:52:52 -04:00
Timothy Wall d551e656cb fix win64 compile warnings 2013-05-26 09:57:45 -04:00
Timothy Wall ba49b166fb add test for GetLastError interception 2013-05-26 09:57:28 -04:00
Timothy Wall a3e002c1db fix w32 test 2013-05-26 09:20:32 -04:00
Timothy Wall 02601e4f7c Merge branch 'master' of github.com:twall/jna 2013-05-25 20:23:51 -04:00
Timothy Wall e2349e4bf6 expand test coverage 2013-05-25 20:11:43 -04:00
Timothy Wall 87afaf44f7 fix javadoc warnings 2013-05-25 19:29:26 -04:00
Timothy Wall bb913b171d add missing methods on opaque pointer
fix NPE
2013-05-25 19:07:07 -04:00
Daniel Doubrovkine (dB.) 975063a28f Fixed links, consistent tense. 2013-05-25 14:29:03 -03:00
Daniel Doubrovkine 8e44c82096 Merged from master. 2013-05-25 13:17:17 -04:00
Daniel Doubrovkine (dB.) 7a33f0b43e Added a note on \r. 2013-05-25 13:53:53 -03:00
Daniel Doubrovkine (dB.) cfdf20f4b7 Clarified Win64 64-bit builds. 2013-05-25 13:48:22 -03:00
Timothy Wall 13207caab6 update clover 2013-05-24 23:31:37 -04:00
Timothy Wall 980b86e2c5 fix test 2013-05-24 23:31:20 -04:00
Timothy Wall c6afe5f73d check for options caching 2013-05-24 08:17:57 -04:00
Timothy Wall 5c48942bda clean up synchronization around options loading 2013-05-24 00:08:57 -04:00
Timothy Wall 82c032329a Merge pull request #234 from dblock/eclipse-build
Fix: Eclipse project build.
2013-05-23 15:06:57 -07:00
Timothy Wall 2a2bdbe60c merge from upstream 2013-05-22 22:36:55 -04:00
Timothy Wall 9414757638 update linux-arm natives 2013-05-22 22:29:56 -04:00
Timothy Wall 253dc5abae work around linux-arm class incompatibility bug in StructureTest 2013-05-22 22:27:56 -04:00
Timothy Wall 296185c0ba fix FP callback args on ARM 2013-05-22 21:12:56 -04:00
Daniel Doubrovkine 70cff3e17a Fix: Eclipse project build. 2013-05-22 18:02:54 -04:00
Timothy Wall 78969b8050 avoid static field initialization bug 2013-05-21 15:19:13 -04:00
Timothy Wall d90f6e3346 fix typo 2013-05-21 14:02:48 -04:00
Timothy Wall 8f99db35dd fix struct padding test on linux-arm 2013-05-21 13:45:38 -04:00
Timothy Wall b5759955d5 bump versions 2013-05-21 13:26:40 -04:00
Timothy Wall adafa3b2c4 last error now always preserved 2013-05-20 23:33:24 -04:00
Timothy Wall 979f43da07 more cleanup 2013-05-20 23:28:06 -04:00
Timothy Wall 39aebf1d0b fix WORDByReference definition 2013-05-20 19:59:42 -04:00
Timothy Wall 45df2eb8f5 correct test to fix failure 2013-05-20 19:55:03 -04:00
Timothy Wall 92aa443023 fix file mods 2013-05-19 22:54:56 -04:00
Timothy Wall 1492546150 revise string encoding 2013-05-19 22:53:38 -04:00
Timothy Wall 95c7be884f clean up platform tests and error handling on windows 2013-05-18 12:39:27 -04:00
Timothy Wall 00acbd664e fix javadoc warning 2013-05-17 13:56:49 -04:00
Timothy Wall e7b4a2d5ec add CoInit constants
fix last error formatting
2013-05-17 13:41:03 -04:00
Timothy Wall d7448ad16c remove dummy files 2013-05-16 23:04:11 -07:00
Timothy Wall 7d8afba0f4 clean up some platform win32 junk 2013-05-16 23:03:28 -07:00
Timothy Wall 0f1bdc87d4 enable android-x86 cross-builds 2013-05-16 23:01:14 -07:00
Timothy Wall d4ed7ea34f remove superfluous Structure.ByReference usage 2013-05-15 10:05:07 -04:00
Timothy Wall daf8d5ef89 fix up VM arch flags 2013-05-15 10:04:40 -04:00
Timothy Wall 7a0ec5b1df fix vm arch property def 2013-05-13 23:37:16 -04:00
Timothy Wall 8e99313ea4 update changelog 2013-05-13 08:42:10 -04:00
Timothy Wall 8e8aba6ffb getContextClassLoader() may return null 2013-05-13 08:32:15 -04:00
Timothy Wall f903aa926d use a single build directory, multiple build/native-(prefix) directories 2013-05-13 08:01:14 -04:00
Timothy Wall 3848e55813 update license information 2013-05-12 09:18:48 -04:00
Timothy Wall 55778824f3 Merge branch 'master' of github.com:twall/jna into amd64-pthread-cleanup 2013-05-12 09:03:59 -04:00
Timothy Wall 5b240371d9 Merge branch 'master' of github.com:twall/jna 2013-05-12 00:05:30 -04:00
Timothy Wall d65432a014 update w32 natives
fix stdcall stack in libffi
auto-update version resource
2013-05-11 23:55:54 -04:00
Timothy Wall 107d7fa43e report correct javaws error on win64 2013-05-11 21:44:11 -04:00
Timothy Wall bf19830d66 fix padding for windows 2013-05-11 19:16:16 -04:00
Timothy Wall 090b248708 update linux/x86 natives 2013-05-11 15:33:51 -04:00
Timothy Wall e5855c2fa1 fix web start test timeout 2013-05-11 15:33:37 -04:00
Timothy Wall 064785b985 Merge branch 'master' of github.com:twall/jna 2013-05-11 12:21:03 -04:00
Timothy Wall 757446c64e update android natives 2013-05-11 12:20:55 -04:00
Timothy Wall 14e69d1501 update solaris/x86 natives 2013-05-11 12:19:13 -04:00
Timothy Wall 874caccc53 make arch handling more consistent; don't load Native class from Platform 2013-05-11 12:15:39 -04:00
Timothy Wall 295aaa4c31 work around solaris/x86 JVM bug 2013-05-11 11:49:28 -04:00
Timothy Wall dbd45ddf90 update osx natives 2013-05-11 09:27:02 -04:00
Timothy Wall 2f2289c9df Merge branch 'master' of github.com:twall/jna 2013-05-11 15:15:53 +02:00
Timothy Wall 9b7dddfe0c update sunos natives, fix struct padding test expected results 2013-05-11 15:15:18 +02:00
Timothy Wall 21a468a125 consolidate BSD targets test 2013-05-11 01:14:39 -04:00
Timothy Wall de82d964ca update bsd64 native 2013-05-10 20:57:30 -04:00
Timothy Wall d843968432 consolidate BSD targets 2013-05-10 20:54:57 -04:00
Timothy Wall f4958ee8f9 fix broken callback test on BSD 2013-05-10 20:53:02 -04:00
twalljava@java.net 1ed65484e0 fix test on 32-bit 2013-05-10 17:10:25 -04:00
Timothy Wall 8c1e1c2d2e remove invalid character from javadoc 2013-05-10 08:44:38 -04:00
Timothy Wall c888d6e86a fix README typos 2013-05-10 08:32:03 -04:00
Timothy Wall a9ef0e6aca use current java version for compatibility if less than 1.6 2013-05-10 08:24:16 -04:00
Timothy Wall 35b409dce8 Merge branch 'master' of github.com:twall/jna 2013-05-10 08:03:01 -04:00
Timothy Wall 16f3f9310e fix javadoc warning 2013-05-10 08:02:33 -04:00
Timothy Wall 5206982e48 add ASL
set compatibility to 1.6 by default
tweak CreateProcessW definition
avoid unicode errors in username on win32 (temp files)
2013-05-10 08:00:53 -04:00
Timothy Wall 8e9e3b45b6 add symlink creation timeout 2013-05-09 09:14:19 -04:00
Timothy Wall f96eddc6ca update android native 2013-05-08 23:55:27 -04:00
Timothy Wall b2dc918313 update osx natives 2013-05-08 08:01:23 -04:00
Timothy Wall d511e9f0e5 update win32 native 2013-05-08 07:46:36 -04:00
Timothy Wall ed93f9833e Merge branch 'master' of github.com:twall/jna 2013-05-08 07:21:29 -04:00
Timothy Wall 4b34601dc3 update win64 nattttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttive 2013-05-08 07:17:23 -04:00
Timothy Wall c7142dc82c update sparc natives 2013-05-08 13:09:45 +02:00
Timothy Wall 9914826b57 fix line terminators 2013-05-07 08:37:20 -04:00
Trejkaz d2159d70e3 Fixing compilation issues in Kernel32UtilTest 2013-05-07 20:41:20 +10:00
Trejkaz 6a06656c16 Merge branch 'master' of https://github.com/twall/jna
Pulling master back to get compilation fixes.
2013-05-07 20:39:27 +10:00
Timothy Wall b1aa24d911 add test for loading from path with unicode characters (fails on XP, at least) 2013-05-06 09:04:02 -04:00
Timothy Wall 198cb1f9df fix file permissions 2013-05-06 08:25:36 -04:00
Timothy Wall 4b9632c4ee update linux/amd64 natives 2013-05-04 11:43:17 -04:00
Timothy Wall 6c9708070c update linux/x86 natives 2013-05-11 01:32:46 -04:00
Timothy Wall b7a299f42a amd64/linux pthread investigations 2013-05-04 11:38:12 -04:00
Timothy Wall e35977776d symlink creation now broken on osx 10.8.3 2013-05-01 15:29:50 -04:00
Timothy Wall 25d1b110a3 Merge branch 'master' of github.com:twall/jna 2013-05-01 00:12:04 -04:00
Timothy Wall 38b796a516 fix #223, union sizing/layout issue 2013-05-01 00:11:19 -04:00
Trejkaz 136653a644 GetLogicalProcessorInformation and associated structs 2013-05-01 13:24:31 +10:00
Timothy Wall 1af1000139 Add prominent links for mailing list and stackoverflow 2013-04-30 07:41:56 -03:00
Timothy Wall 5db3b42770 consolidate compiler pragmas 2013-04-25 08:22:37 -04:00
Timothy Wall 6b552cc03d fix framework loading on OSX 2013-04-25 08:22:16 -04:00
Timothy Wall 19d7775e91 windows won't load libraries w/truncated name 2013-04-24 08:33:53 -04:00
Timothy Wall 299b0a9517 catch attempts to run 64-bit tests on 32-bit javaws 2013-04-24 08:11:49 -04:00
Timothy Wall 075efa649d use a different error code on windows, fixes broken test 2013-04-24 06:57:16 -04:00
Timothy Wall b4f0f21421 fixes for oracle openjdk 2013-04-22 08:48:27 -04:00
Timothy Wall dbeda7f67d fix some tests under clover 2013-04-21 22:37:47 -04:00
Timothy Wall ea56252d2f fix javadoc warnings 2013-04-21 09:46:56 -04:00
Timothy Wall 8d376755dc clean up some function naming
fix typo
2013-04-21 09:39:10 -04:00
Timothy Wall 5d8243ec3b revise resource extraction to use explicit class loaders 2013-04-21 09:33:05 -04:00
Timothy Wall 85e962c124 fix #218 2013-04-17 21:02:53 -04:00
Timothy Wall 97403354a2 add tests for library loading from resource path 2013-04-17 20:53:09 -04:00
Timothy Wall 605dfcbd33 update CHANGES.md 2013-04-17 07:32:04 -04:00
Timothy Wall 3f6441c420 Merge branch 'master' of github.com:twall/jna 2013-04-17 07:29:12 -04:00
Timothy Wall 885586188c clean up platform test runner, run on all platforms 2013-04-17 07:28:28 -04:00
Timothy Wall a517ca68e9 fix libjsig path 2013-04-16 19:39:58 -04:00
Timothy Wall 5857cf7c49 fix load/unload tests 2013-04-14 22:06:38 -04:00
Timothy Wall 52bec37a5b remove extraneous endif 2013-04-14 10:33:02 -04:00
Timothy Wall 48b584d979 reinstate option for xcode 4 only 2013-04-14 10:30:13 -04:00
Dan Rollo 6d2658d888 Revert back to 'failifexecutionfails' for git call. 2013-04-11 03:32:16 -04:00
Dan Rollo 48df3d3cd2 Try 'searchpath' in clean-exec target on OSX. 2013-04-11 03:20:35 -04:00
Dan Rollo d58add66d4 Fix compile error on MacOSX introduced in a676e3acaa. 2013-04-11 01:40:44 -04:00
Timothy Wall 5ac33562cf trim some fat 2013-04-10 07:28:14 -04:00
Timothy Wall 483223546b update from libffi 3.0.13 2013-04-10 07:24:45 -04:00
Dan Rollo 3a795a4483 add 'failifexecutionfails' to ignore problems reverting version stamped files. Was causing build problem on OSX build agent. 2013-04-10 00:21:57 -04:00
Timothy Wall 3e0ee7eced always create errno, detach TLS 2013-04-09 06:20:20 -04:00
Timothy Wall 721a080af9 clean up nounpack handling 2013-04-09 05:57:06 -04:00
Timothy Wall e8dd1564d5 tweak build notes 2013-04-09 05:21:19 -04:00
Timothy Wall 6b923bcf0c avoid superfluous rebuilds on windows, fix md5 checksum with newer ant 2013-04-09 05:19:46 -04:00
Timothy Wall 889d2bbb11 avoid spurious rebuilds 2013-04-09 04:55:06 -04:00
Timothy Wall d53bbd32a9 fix win32 build 2013-04-09 04:08:33 -04:00
Timothy Wall 467ab4ec17 reapply changes 2013-04-08 16:44:50 -04:00
Timothy Wall 900a68eb63 Merge pull request #213 from tomohiron/fix_dump_memory
fix dump memory problem
2013-04-08 13:44:14 -07:00
Timothy Wall 638135f309 pre-merge 2013-04-08 16:43:47 -04:00
Timothy Wall 3a94cbf242 pre-merge 2013-04-08 16:42:43 -04:00
Timothy Wall 8326d791bf fix web start deployment path under oracle 2013-04-08 16:36:57 -04:00
Timothy Wall a676e3acaa fix building under newer xcode, fix compiler warning 2013-04-08 16:32:29 -04:00
Timothy Wall 8a5265c1dd invalidate native jars 2013-04-08 09:58:25 -04:00
Timothy Wall cab106167c update CHANGES.md 2013-04-08 09:57:55 -04:00
Timothy Wall 6fc42f59e1 use tls for callback detach indication, avoid potential conflict with last error 2013-04-08 09:56:42 -04:00
Timothy Wall d0995f3bc2 update natives 2013-04-08 08:00:19 -04:00
Timothy Wall 8ed4def1f3 Merge branch 'master' of github.com:twall/jna 2013-04-08 01:37:48 +02:00
Timothy Wall bf0ab0ea55 update natives 2013-04-08 01:34:57 +02:00
Timothy Wall d4a33cbc58 update native 2013-04-07 19:31:51 -04:00
tomohiro 18cd75b130 modified CHANGES.md 2013-04-08 04:40:38 +09:00
Timothy Wall 4b2c411a2e reorganize tests, ensure by value arguments always use their own memory 2013-04-07 10:09:58 -04:00
tomohiro b33ac764b4 fix Structure.toString because it dumped memory when jna.dump_memory was false 2013-04-07 14:23:23 +09:00
Timothy Wall 0edd935144 fix direct buffer args tests 2013-04-06 18:09:47 -04:00
Timothy Wall 839be7862e use snapshot versions for maven 2013-04-06 17:19:59 -04:00
Timothy Wall 3cfb7df151 enable canonical processor designations on other platforms 2013-04-06 17:19:14 -04:00
Timothy Wall 3364dfcc2a fix compiler warnings on win64 2013-04-06 17:18:50 -04:00
Timothy Wall 818f7fa5d6 obsolete native libs 2013-04-06 17:15:27 -04:00
Timothy Wall 8bb128062a Merge pull request #212 from twall/native-struct-ptr-creation
Native struct ptr creation
2013-04-06 13:23:03 -07:00
Timothy Wall f576184c13 Merge branch 'master' of github.com:twall/jna into native-struct-ptr-creation 2013-04-06 16:14:19 -04:00
Timothy Wall 7d57612d7d Merge pull request #211 from twall/improved_last_error
Improved last error
2013-04-06 13:12:09 -07:00
Timothy Wall c94e9ff4b7 reset read flag when base pointer is altered 2013-04-06 09:40:58 -04:00
Timothy Wall 0a8a67ca5f Merge branch 'improved_last_error' of github.com:twall/jna into native-struct-ptr-creation 2013-04-06 09:36:48 -04:00
Timothy Wall dac9dc4742 Merge branch 'improved_last_error' of github.com:twall/jna into native-struct-ptr-creation 2013-04-06 09:35:07 -04:00
Timothy Wall bf91b32d25 rename with consistent processor names 2013-04-06 09:33:33 -04:00
Timothy Wall 16e6031999 use consistent processor arch names, bump version number 2013-04-06 09:30:13 -04:00
Timothy Wall a4ee620aaf merge from upstream 2013-04-06 08:49:44 -04:00
Timothy Wall 2c18ec2b75 update links 2013-04-06 07:24:18 -04:00
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 b26402bd57 use ptr-based structure creation 2013-03-30 07:58:14 -04:00
Timothy Wall bf1579a5dc use distinct maps for direct vs non-direct callbacks (performance) 2013-03-26 21:58:22 -04:00
Timothy Wall d8e8889d92 improve performance saving last error (per thread) 2013-03-26 11:28:27 -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
Anthony Green f22ab3c687 Merge branch 'master' of github.com:/atgreen/libffi 2013-03-17 18:37:50 -04:00
Anthony Green 12b1886d7b cygwin fix & updates for 3.0.13 2013-03-17 18:33:59 -04:00
Anthony Green d08124bedf cygwin fix & updates for 3.0.13 2013-03-17 18:32:12 -04:00
Anthony Green cb32c812d0 Fix lib install dir 2013-03-17 09:27:55 -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
Anthony Green efd7866a36 2.0.13rc1 2013-03-16 08:35:57 -04:00
Anthony Green ff647ad4df Merge branch 'master' of github.com:/atgreen/libffi
Conflicts:
	ChangeLog
2013-03-16 08:20:40 -04:00
Anthony Green 4acf0056f5 Build fix for soft-float power targets 2013-03-16 08:18:45 -04:00
Anthony Green 675c983922 Documentation fix 2013-03-16 08:12:38 -04:00
Anthony Green 8a286f570c Fix for m68000 systems 2013-03-16 08:12:19 -04:00
Anthony Green d9dd417b09 Fix for m68000 systems 2013-03-16 08:01:19 -04:00
Anthony Green 215763d012 Update configury. 2013-03-16 07:57:35 -04:00
Anthony Green 9180d8f39c Merge branch 'master' of github.com:/atgreen/libffi 2013-03-16 07:46:55 -04:00
Anthony Green 2fb527a017 Add Meta processor support 2013-03-16 07:46:38 -04:00
Anthony Green 211a9ebf4d Merge pull request #32 from alex/patch-1
Fix for a crasher due to misaligned stack on x86-32.
2013-03-16 07:28:20 -04:00
Anthony Green 7e1b32649e Merge pull request #32 from alex/patch-1
Fix for a crasher due to misaligned stack on x86-32.
2013-03-16 04:24:40 -07: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
Alex Gaynor ee18766b16 Fix for a crasher due to misaligned stack on x86-32.
Full information on reproduction (using Python's ctypes available here: http://bugs.python.org/issue17423)
2013-03-14 15:00:33 -07: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
Anthony Green f308faf1ea Add moxie support. Release 3.0.12. 2013-02-11 14:25:13 -05:00
Anthony Green 4ea22e54e3 Update README 2013-02-10 08:48:38 -05:00
Anthony Green 10e77227b6 mend 2013-02-10 08:47:26 -05:00
Tobias e69d7fa485 some changes 2013-02-09 16:57:35 +01:00
Anthony Green a9521411a5 sparc v8 and testsuite fixes 2013-02-09 06:54:40 -05:00
Anthony Green 70b11b47ee Fix small struct passing on ppc 2013-02-08 16:12:19 -05:00
Anthony Green 63ba1fa79f Remove xfail for arm*-*-*. 2013-02-08 15:18:19 -05:00
Anthony Green 24fbca4c1d Fix typo 2013-02-08 14:19:56 -05:00
Anthony Green b0fa11cb0a More man page cleanup 2013-02-08 14:17:13 -05:00
Anthony Green 8bd15d139a Fix many.c testcase for ppc 2013-02-08 13:56:37 -05:00
Anthony Green 7aab825cf1 Add missing files to dist 2013-02-08 13:26:21 -05:00
Anthony Green cb03ea8f4e sparc v9 fixes for sun tools 2013-02-08 12:25:18 -05:00
Anthony Green 35ee8d44f3 Fix microblaze big-endian struct issue 2013-02-08 07:12:41 -05:00
Anthony Green 9db7e1a958 Fix botched sparc patch. Update version. 2013-02-07 21:06:08 -05: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
Anthony Green ce0138e614 Update bug report address. rc2. 2013-02-07 18:04:01 -05:00
Anthony Green fd07c9e404 Add cache flushing routine for sun compiler on sparc solaris 2.8 2013-02-07 18:00:36 -05:00
Anthony Green ed6ae9501b Add libtool-ldflags. Define toolexeclibdir for non-GCC builds. 2013-02-07 16:43:36 -05:00
Anthony Green ffef2e046a x32 and libtool fixes 2013-02-07 15:47:01 -05:00
Anthony Green 95eecebb28 Remove a.out cruft from dist 2013-02-07 15:32:46 -05:00
Anthony Green 176aa9d2e2 Fix GCC usage test and update README 2013-02-07 15:29:22 -05:00
Anthony Green f3a4f3fdde Fixes for AIX xlc compiler. 2013-02-07 09:57:20 -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
Anthony Green 522f8fef49 Fix man page. Clean out junk. 2013-02-06 20:31:31 -05:00
Anthony Green c4dfa259eb Bump soversion 2013-02-06 17:43:24 -05:00
Anthony Green f62bd63fe6 Release candidate 1 2013-02-06 17:38:32 -05:00
Anthony Green f7cd61e9e6 Fix pkgconfig install bits 2013-02-06 17:38:04 -05:00
Anthony Green 6a79012942 Work around LLVM ABI problem on x86-64 2013-02-06 17:37:15 -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
Anthony Green 370112938e Merge pull request #28 from jralls/master
Reorder x86_64 checks
2013-01-27 05:09:04 -08:00
John Ralls bcc0c28001 Reorder x86_64 tests
So that darwin and cygwin/mingw are tested before the generic check --
which allows them to actually be set.
2013-01-26 15:26:01 -08: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
Anthony Green bada2e326d Update README 2013-01-21 08:02:07 -05:00
Anthony Green 655bb8f369 Merge branch 'master' of github.com:/atgreen/libffi 2013-01-21 08:01:24 -05:00
Anthony Green 1035ffb2f4 Update README 2013-01-21 08:01:13 -05:00
Anthony Green 840f975866 Merge branch 'master' of github.com:/atgreen/libffi 2013-01-21 07:55:53 -05:00
Anthony Green aeb8719a34 New microblaze support 2013-01-21 07:55:37 -05:00
Anthony Green 40860245a4 New microblaze support 2013-01-21 07:37:30 -05:00
Anthony Green 20cae32b15 Xtensa support 2013-01-21 07:07:38 -05:00
Anthony Green 9742f91782 Mention IBM XL compiler support on AIX. 2013-01-21 07:03:41 -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
Anthony Green f03eab0824 Remove obsolete inline test functions 2013-01-11 17:14:11 -05:00
Anthony Green 05fbe1faed xlc compiler support 2013-01-11 16:54:40 -05:00
Anthony Green 0b4986a788 [travis] install dejagnu with sudo 2013-01-11 11:19:52 -05:00
Anthony Green 3c337eef51 [travis] install dejagnu 2013-01-11 11:18:14 -05:00
Anthony Green 90720962ce Add first travis config file 2013-01-11 10:57:30 -05:00
Tobias ad442d822d some changes 2013-01-11 16:28:49 +01:00
Anthony Green bff052d9cd 32-bit x86 fix and more 2013-01-11 10:24:32 -05: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
Anthony Green cd41aeab61 Add compiler column to table 2013-01-10 17:25:45 -05:00
Anthony Green 8bf987d4df Fix for sunpro compiler on Solaris 2013-01-10 17:24:51 -05:00
Anthony Green 3ee74fd6dc Update documentation version. 2013-01-10 17:15:03 -05:00
Anthony Green 13e2d7b925 Handle both 32 and 64-bit x86 builds regardless of target triple 2013-01-10 10:52:02 -05:00
Tobias b6215a24b5 some changes in the Variant structure 2013-01-10 14:34:44 +01:00
Anthony Green 5141543000 Don't run EH tests with non-GNU compiler 2013-01-10 07:35:53 -05:00
Anthony Green 56ba8d86f4 Don't use warning checking macro with sun compiler 2013-01-10 07:25:10 -05:00
Anthony Green 6a028caec1 Don't use GCCisms to define types when
+       building with the SUNPRO compiler.
2013-01-10 01:19:43 -05:00
Anthony Green 2d9b393975 Fix for closures with sunpro compiler 2013-01-09 21:14:54 -05:00
Tobias Wolf c62b73bdf5 some changes 2013-01-09 14:48:10 +01:00
Anthony Green 8308984e47 Make sure we're running dejagnu tests with the right compiler. 2013-01-08 15:14:21 -05:00
Anthony Green f26c7ca671 Make compiler options in dejagnu runs compiler specific 2013-01-08 14:47:05 -05:00
Anthony Green 74c776e219 Switch x86 Solaris to X86 from X86_64 2013-01-08 12:25:54 -05:00
Anthony Green 8962c8c8d0 Fix read-only eh_frame test 2013-01-08 12:22:24 -05:00
Anthony Green 35ddb69c2b Only emit DWARF unwind info when building with GCC 2013-01-08 07:53:37 -05:00
Anthony Green f7879bc3f3 Testsuite fix for Solaris vendor compiler 2013-01-08 07:30:28 -05:00
Anthony Green 67cea90fc0 mend 2013-01-07 06:30:24 -05:00
Thorsten Glaser 0de3277b18 Testsuite fixes (was Re: [PATCH] Fix libffi on m68k-linux-gnu, completely)
Dixi quod…

>although I believe some 3.0.11 checks to be broken:

And indeed, with a few minor changes on top of git master,
I still get a full run of PASS plus one XPASS on amd64-linux!

With the other patches (from this message’s parent) and
these applied, I get a full PASS on m68k-linux as well.

So, please git am these three diffs ☺

bye,
//mirabilos
--
FWIW, I'm quite impressed with mksh interactively. I thought it was much
*much* more bare bones. But it turns out it beats the living hell out of
ksh93 in that respect. I'd even consider it for my daily use if I hadn't
wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh
From 5cb15a3bad1f0fb360520dd48bfc938c821cdcca Mon Sep 17 00:00:00 2001
From: Thorsten Glaser <tg@mirbsd.org>
Date: Sun, 2 Dec 2012 23:20:56 +0000
Subject: [PATCH 1/2] Fix tests writing to a closure retval via pointer casts

As explained in <Pine.BSM.4.64L.1212022014490.23442@herc.mirbsd.org>
all other tests that do the same cast to an ffi_arg pointer instead.

PASS on amd64-linux (Xen domU) and m68k-linux (ARAnyM)

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
2013-01-07 06:22:51 -05:00
Anthony Green 8f4772f383 m68k fixes for signed 8 and 16-bit calls. 2013-01-07 06:14:53 -05:00
Anthony Green ea7f8440d5 remove gcc-ism 2013-01-04 09:09:32 -05:00
Tobias Wolf 2832feaa8e Additional changes to the com implementation 2013-01-03 19:37:31 +01:00
Anthony Green f06c0f1037 Add missing ChangeLog entry and generated files. 2013-01-02 09:39:17 -05:00
Anthony Green 1f8675d4c1 Merge pull request #26 from rofl0r/master
fix build error on ppc when long double == double
2013-01-02 06:34:38 -08:00
Anthony Green 335f419a86 Merge pull request #23 from rurban/master
cygwin/mingw shared libs need libtool LDFLAGS = -no-undefined
2013-01-02 06:30:03 -08:00
Anthony Green 53236d5061 Regenerate files 2013-01-02 09:24:55 -05:00
Anthony Green 72222ca3fb Update texinfo.tex 2013-01-02 09:06:38 -05:00
Anthony Green 1e326c9543 Update config.guess and config.sub 2013-01-02 09:05:02 -05:00
Anthony Green cb6671f5b8 Missing .gitignore changes for xcode support 2013-01-02 08:56:07 -05:00
Anthony Green ebbe779668 missed x32 libtool patch. 2013-01-02 08:54:05 -05:00
Anthony Green 4394096da0 missed trampoline_table patch. Move to GCC. 2013-01-02 08:51:35 -05:00
Anthony Green ed7a59c3ff Windows symbol export fix. Move to GCC. 2013-01-02 08:48:01 -05:00
Anthony Green ccee09a4ff +2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+       * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
+       (set_ld_library_path_env_vars): Add the library search dir to PATH
+       (and save PATH for later).
+       (restore_ld_library_path_env_vars): Restore PATH.
2013-01-02 08:41:55 -05:00
Anthony Green 089dbce7cc med 2013-01-02 08:37:35 -05:00
Anthony Green 980a334c42 Test GCC update 2013-01-02 08:34:01 -05:00
Anthony Green 8bad679ade New stand-alone patch 2013-01-02 08:28:35 -05:00
Anthony Green 981c32ee11 Merge with GCC. Eliminate quilt bits. 2013-01-02 07:34:03 -05: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
Anthony Green 61a0549295 Refresh config.guess and config.sub 2012-11-28 06:07:41 -05:00
rofl0r f6b58d2bdc fix build on ppc when long double == double 2012-11-22 16:26:21 +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
Anthony Green 69da33a076 Pull in config.sub for aarch64 support and more 2012-11-12 15:25:47 -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
Anthony Green f680b598b7 Add missing aarch64 configury bits 2012-11-06 16:00:40 -05:00
Timothy Wall 3b2fd06dc0 compile against GNU C Library 2.3.6 2012-10-31 20:50:38 -04:00
Anthony Green dfadfb1985 Rebase for ppc64 fix 2012-10-31 06:46:41 -04:00
Anthony Green e944b8c7eb Add PaX work-around 2012-10-30 14:06:40 -04:00
Anthony Green 9ccd51be1f Fix commit conflicts 2012-10-30 13:37:37 -04:00
Anthony Green f342996cb5 Darwin12 fix 2012-10-30 07:42:27 -04:00
Anthony Green 58e8b66f70 AArch64 port 2012-10-30 07:36:49 -04:00
Anthony Green fa5d747905 AArch64 port 2012-10-30 07:07:19 -04:00
Anthony Green 6993a6686f Fix autoconf macros 2012-10-30 06:59:32 -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
Anthony Green 70084e70dd Update Tile* port info 2012-10-12 23:55:06 -04:00
Anthony Green 9c00a3f674 TILE-Gx/TILEPro support 2012-10-12 16:46:06 -04:00
Anthony Green 048d2f41c3 Rebase 2012-10-11 10:55:25 -04:00
Reini Urban 6d6f711080 cygwin/mingw shared libs need libtool LDFLAGS = -no-undefined
otherwise only static libs are created.
2012-07-07 12:52:02 -05:00
640 arquivos alterados com 47426 adições e 290600 exclusões
Arquivo executável → Arquivo normal
+11 -10
Ver Arquivo
@@ -1,10 +1,11 @@
<?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="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="lib/test/reflections-0.9.8.jar"/>
<classpathentry kind="output" path="build.eclipse/classes"/>
</classpath>
+3
Ver Arquivo
@@ -2,6 +2,7 @@ build
build-d64
build.eclipse
build.number
build.clover
.metadata
.DS_Store
bin
@@ -15,3 +16,5 @@ dist/*-sources.jar
dist/*-javadoc.jar
dist/src-mvn.zip
dist/out-of-date.jar
perf*.txt
native/libffi/doc/libffi.info
Arquivo executável → Arquivo normal
Ver Arquivo
+202
Ver Arquivo
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Arquivo executável → Arquivo normal
+74 -5
Ver Arquivo
@@ -1,17 +1,86 @@
Release 3.5.1
====================
Next Release (4.0)
==================
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE).
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.
Features
--------
* Added ASL licensing to facilitate distribution - [@twall](https://github.com/twall).
* [#109](https://github.com/twall/jna/issues/109): Set default Java compatibility level to 1.6 - [@twall](https://github.com/twall).
* [#209](https://github.com/twall/jna/issues/209): Improved default performance saving last error results - [@twall](https://github.com/twall).
* Use predictable names for CPU architecture prefix (namely x86, x86-64); names correspond to OSGI processor values - [@twall](https://github.com/twall).
* Avoid superfluous Structure memory allocation from native - [@twall](https://github.com/twall).
* Added `Library.OPTION_CLASSLOADER`, which enables loading native libraries from any class loader (including JNA's native library). This enables parallel dependencies on JNA (e.g. within a tomcat deployment without having to include JNA in the app server environment) - [@twall](https://github.com/twall).
* Use per-library String encoding settings (see `Native.getDefaultStringEncoding()` and `Structure.getStringEncoding()`) - [@twall](https://github.com/twall).
* Added memory dump for debugging (see `com.sun.jna.Memory`) - [@twall](https://github.com/twall).
* Improved caching of Structure alignment, type mapping, and encoding information - [@twall](https://github.com/twall).
* [#225](https://github.com/twall/jna/pull/225): Added `platform.win32.Kernel32.GetLogicalProcessorInformation` and `platform.win32.Kernel32Util.getLogicalProcessorInformation` - [@trejkaz](https://github.com/trejkaz).
* [#236](https://github.com/twall/jna/issues/236): Auto-strip profiler native method prefix specified by `jna.profiler.prefix`, which defaults to $$YJP$$ - [@twall](https://github.com/twall).
* Added `jna.debug_load` property to diagnose library loading issues - [@twall](https://github.com/twall).
Bug Fixes
---------
* [#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
* [#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
* [#151] 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
* [#213](https://github.com/twall/jna/pull/213): Fixed `Structure.toString()` not to dump memory when `jna.dump_memory` is false - [@tomohiron](https://github.com/tomohiron).
* Use dedicated TLS to indicate callback detach state, to avoid any potential conflicts with last error storage - [@twall](https://github.com/twall).
* [#173](https://github.com/twall/jna/issues/173): Fixed OSX 10.8/Xcode 4+ builds, web start path with Oracle 1.7 JDK - [@mkjellman](https://github.com/mkjellman).
* [#215](https://github.com/twall/jna/issues/215): Forced use of XSI `strerror_r` on linux - [LionelCons](https://github.com/LionelCons).
* [#214](https://github.com/twall/jna/issues/214): Don't map library names when an absolute path is provided - [@twall](https://github.com/twall).
* [#218](https://github.com/twall/jna/issues/218): Explicitly handled broken Android `SecurityManager` implementation - [@twall](https://github.com/twall).
* [#223](https://github.com/twall/jna/issues/223): Fixed layout/size derivation for unions - [@twall](https://github.com/twall).
* [#229](https://github.com/twall/jna/issues/229): Added `CreateProcessW` (Unicode version) - [@twall](https://github.com/twall).
* Avoid solaris/x86 JVM bug w/library open flags - [@twall](https://github.com/twall).
* Fixed NPE returning wide string from a direct-mapped function - [@twall](https://github.com/twall).
* [#237](https://github.com/twall/jna/issues/237): Fix LastErrorException/getLastError on AIX - [@skissane](https://github.com/skissane).
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#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).
* 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).
* [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).
* [#206](https://github.com/twall/jna/issues/206): Fix `moveToTrash()` on OSX to work with symlinks - [@twall](https://github.com/twall).
* Fix NPE if `Thread.getContextClassLoader()` returns `null` - [@twall](https://github.com/twall).
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).
+504
Ver Arquivo
@@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
Arquivo executável → Arquivo normal
+25 -504
Ver Arquivo
@@ -1,504 +1,25 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
JNA is dual-licensed under 2 alternative Open Source/Free
licenses: LGPL 2.1 and Apache License 2.0. (starting with
JNA version 4.0.0).
What this means is that one can choose either one of these
licenses (for purposes of re-distributing JNA; usually by
including it as one of jars another application or
library uses) by downloading corresponding jar file,
using it, and living happily everafter.
You may obtain a copy of the LGPL License at:
http://www.gnu.org/licenses/licenses.html
A copy is also included in the downloadable source code package
containing JNA, in file "LGPL2.1", under the same directory
as this file.
You may obtain a copy of the ASL License at:
http://www.apache.org/licenses/
A copy is also included in the downloadable source code package
containing JNA, in file "ASL2.0", under the same directory
as this file.
Arquivo executável → Arquivo normal
Ver Arquivo
+12 -9
Ver Arquivo
@@ -3,9 +3,9 @@
Java Native Access (JNA)
========================
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).
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.5.2/javadoc/). Please read the [overview](http://twall.github.com/jna/3.5.2/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java codeno JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.
@@ -18,10 +18,10 @@ JNA includes a platform library with many native functions already mapped as wel
Download
========
Version 3.5.1
Version 3.5.2
* [jna.jar](jna/blob/3.5.1/dist/jna.jar?raw=true)
* [platform.jar](jna/blob/3.5.1/dist/platform.jar?raw=true)
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.2/jna-3.5.2.jar)
* [platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/3.5.2/platform-3.5.2.jar)
Features
========
@@ -79,17 +79,17 @@ Using the Library
* [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)
* [Avoiding Crashes](http://twall.github.com/jna/3.5.2/javadoc/overview-summary.html#crash-protection)
Primary Documentation (JavaDoc)
===============================
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/).
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.5.2/javadoc/).
Developers
==========
* [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
* [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)
@@ -107,6 +107,9 @@ If you are interested in paid support, feel free to say so on the [jna-users mai
License
=======
This library is provided under the LGPL, version 2.1 or later. Alternative license arrangements are negotiable.
This library is licensed under the LGPL, version 2.1 or later, and (from
version 4.0 onward) the Apache Software License, version 2.0. Commercial
license arrangements are negotiable.
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
+63 -51
Ver Arquivo
@@ -10,19 +10,51 @@
o arrays are treated as pointers, except within a struct
- in structure (inline; otherwise pointer-to-X should be used)
- as function argument (auto-convert to pointer via Memory)
o pointer to type in struct should use Pointer or ByReference
o pointer to type in struct should use PointerType or Structure.ByReference
o "free" should be invisible wherever possible
# FUTURE DEMOS:
* test keyboard keys' state (needs OSX)
* test keyboard keys' state (needs OSX impl)
* get system process information, basic process control
* additional file utilities (meta info, free space, etc)
* enforce window minimum/maximum size (workaround java bug)
# TODO
* make native dll extraction from jar public, to use with user dlls packaged
in a jar
* annotations/generics:
o GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
o per-arg/return type marshalling
o avoid casts in loadLibrary
o wrap global variables w/type (set/get)
o support annotations of parameters and return values w/o breaking
1.4 compatibility (retroweaver?), e.g.
-- retroweaver (requires retroweaver runtime classes to provide annotation
features) not yet worth doing
void my_function(@MarshalAs(off_t)long arg);
trading off cruft in the interface def to avoid cruft in the usage:
my_function(0) versus my_function(new off_t(0))
this only really applies to NativeLong/IntegerType types that want to use a
primitive value instead of creating an object instance.
o flag string(/wstring)-returning methods which need to free their result
to avoid leaking memory whan auto-creating strings from the result
(since normally we don't take explicit ownership of any returned pointers)
this is a special case for returned strings only, since other returned
pointers are available to the user for later "freeing"
Use a map on library creation, an iface for the library, or annotation
NOTE: how many methods actually do this? strdup...
Maybe make function return "Memory", which can then be converted to a
Structure or some other type. Then memory will free itself when no longer
referenced. (not really common)
* auto-generate direct mappings/bindings on a per-method basis (perform a
method register on first call to an interface-mapped function) with
sufficient pre-processing to convert to primitives.
* dispose memory/callbacks in Native finalizer to ensure they run first
(use referencequeue to run them when they become unreachable)
@@ -32,59 +64,13 @@
and forth multiple times). This also makes it easer to perform conversions
(no native changes required).
* use libffi java raw?
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
* ppc64 direct/raw failures (multiple)
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
now
* combine direct and interface mapping calling code where possible
* Callback.PostCallWrite.write() cf PostCallRead
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
Can use annotations as shorthand to initialize a map, but basically set up a
per-NativeLibrary (or per-Function?) map of methods to mappers.
* eliminate type conversion contexts; these are almost entirely unused
Requires separate compilation of annotation handling.
* ditch type conversion context (?)
* packaging: 'types', 'convert/marshal' subpackages?
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
explicit, since marshal/unmarshal doesn't indicate src/dst.
o moving conversion contexts to subpackage cleans up top level
substantially, but we probably don't want to move things like Structure and
Pointer into a types subpackage (which would leave just a few top-level
classes). Javadoc is cluttered by example classes anyway.
* support annotations of parameters and return values w/o breaking
1.4 compatibility (retroweaver?), e.g.
-- retroweaver (requires retroweaver runtime classes to provide annotation
features) not yet worth doing
void my_function(@MarshalAs(off_t)long arg);
trading off cruft in the interface def to avoid cruft in the usage:
my_function(0) versus my_function(new off_t(0))
this only really applies to NativeLong/IntegerType types that want to use a
primitive value instead of creating an object instance.
* flag string(/wstring)-returning methods which need to free their result
to avoid leaking memory whan auto-creating strings from the result
(since normally we don't take explicit ownership of any returned pointers)
this is a special case for returned strings only, since other returned
pointers are available to the user for later "freeing"
Use a map on library creation, an iface for the library, or annotation
NOTE: how many methods actually do this? strdup...
Maybe make function return "Memory", which can then be converted to a
Structure or some other type. Then memory will free itself when no longer
referenced.
* make Pointer free-able (system allocates memory, client frees it); actually,
this should probably be automatic so the user doesn't have to think about it.
Maybe a custom type representing "function-allocated-pointer" or
"pointer-requiring-free" (which is just Memory). For now, leave it up to
the user to manage the pointer, since they have to define the free method
anyway. use could always put a finalizer on a PointerType-derived type.
* universal GCC build w/cross-compile (needs cross compilers...)
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
Long.SIZE, Integer.SIZE, et al.
@@ -94,6 +80,32 @@
# DONE
* combine direct and interface mapping calling code where possible
* DOCS: how to properly use W32API_DEFAULT_OPTIONS (A/W, String/WString)
* make native dll extraction from jar public, to use with user dlls packaged
in a jar
* use consistent cpu references (x86->i386, x86_64->amd64)
* osgi for osx
* NO: make Pointer free-able (system allocates memory, client frees it); actually,
this should probably be automatic so the user doesn't have to think about it.
Maybe a custom type representing "function-allocated-pointer" or
"pointer-requiring-free" (which is just Memory). For now, leave it up to
the user to manage the pointer, since they have to define the free method
anyway. use could always put a finalizer on a PointerType-derived type.
- user can do this explicitly if needed
* NO: use libffi java raw? (deprecated)
* NO: MethodArgument/ReturnMapper: per method mapping of arguments/return type.
Can use annotations as shorthand to initialize a map, but basically set up a
per-NativeLibrary (or per-Function?) map of methods to mappers.
Requires separate compilation of annotation handling.
* NO: packaging: 'types', 'convert/marshal' subpackages?
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
explicit, since marshal/unmarshal doesn't indicate src/dst.
o moving conversion contexts to subpackage cleans up top level
substantially, but we probably don't want to move things like Structure and
Pointer into a types subpackage (which would leave just a few top-level
classes). Javadoc is cluttered by example classes anyway.
* cache structure information per-class
* fix setFieldOrder to *always* apply if used
* Make a separate jar file for all OS-specific headers
+165 -129
Ver Arquivo
@@ -10,10 +10,11 @@
Cross-compile by specifying -Dos.prefix={name-arch} to ant
(cross-compile currently only configured/tested on w32ce-arm and
android-arm)
android-arm/-x86)
Use -Dskip-native to skip building native parts.
Use -Dheadless to run tests headless
Use ANT_OPTS=-Dskip-native to skip building native parts.
Use ANT_OPTS=-Dheadless to run tests headless
Use ANT_OPTS=-Drelease to stage a final, non-snapshot version
-->
<!--
@@ -46,39 +47,63 @@
<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="5"/>
<property name="jna.revision" value="1"/>
<property name="jna.major" value="4"/>
<property name="jna.minor" value="0"/>
<property name="jna.revision" value="0"/>
<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">
<or>
<isset property="release"/>
<isset property="maven-release"/>
</or>
</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="5"/>
<property name="jni.major" value="4"/>
<property name="jni.minor" value="0"/>
<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="60417f69d77e4d8d693b43391a4a5b91"/>
<property name="jni.md5" value="1a6047467b59e8748f975e03016ce3d9"/>
<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"/>
<property name="platform.compatibility" value="1.5"/>
<condition property="compatibility" value="1.4">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="test.compatibility" value="1.4">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<!-- Default compatibility, 1.6, or whatever version is running -->
<condition property="compatibility" value="${ant.java.version}" else="1.6">
<matches pattern="^1.[345]$" string="${ant.java.version}"/>
</condition>
<!-- Platform default compatibility, 1.5+ -->
<condition property="platform.compatibility" value="1.5" else="${compatibility}">
<equals arg1="${compatibility}" arg2="1.4"/>
</condition>
<!-- Test default compatibility, 1.5+ -->
<condition property="test.compatibility" value="1.5" else="${compatibility}">
<equals arg1="${compatibility}" arg2="1.4"/>
</condition>
<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 -->
@@ -119,14 +144,15 @@
<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"/>
file="src/com/sun/jna/Version.java"/>
<replaceregexp match='VERSION_NATIVE = ".*";'
replace='VERSION_NATIVE = "${jni.version}";'
file="src/com/sun/jna/Native.java"/>
file="src/com/sun/jna/Version.java"/>
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
<isset property="omit-jnilib"/>
@@ -134,18 +160,23 @@
<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"/>
<!-- Sun 1.6 VM for windows doesn't support -d32/-d64 switch -->
<condition property="vm.64" value="-d64" else="-Ddummy">
<not><os family="windows"/></not>
</condition>
<condition property="vm.arch" value="-d64" else="">
<condition property="vm.32" value="-d32" else="-Ddummy">
<not><os family="windows"/></not>
</condition>
<condition property="vmopt.arch" value="${vm.64}" else="${vm.32}">
<and>
<not><equals arg1="${os.prefix}" arg2="android-arm" trim="true"/></not>
<not><equals arg1="${os.prefix}" arg2="android-x86" 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="em64t"/>
<os arch="sparcv9"/>
<os arch="ppc64"/>
<os arch="ia64"/>
@@ -155,21 +186,27 @@
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
<and>
<os name="SunOS"/>
<equals arg1="${vm.arch}" arg2="-d64"/>
<equals arg1="${vmopt.arch}" arg2="${vm.64}"/>
</and>
</condition>
<property name="build" value="build${vm.arch}"/>
<property name="build" value="build"/>
<property name="classes" location="${build}/classes"/>
<property name="eclipse.classes" location="build.eclipse/classes"/>
<property name="test.classes" location="${build}/test-classes"/>
<property name="reports" value="${build}/reports"/>
<!-- Add other supported platforms here -->
<condition property="jre.arch" value="i386">
<equals arg1="x86" arg2="${os.arch}"/>
<condition property="jre.arch" value="x86">
<matches pattern="(i[3456]86|pentium)" string="${os.arch}"/>
</condition>
<condition property="jre.arch" value="amd64">
<equals arg1="x86_64" arg2="${os.arch}"/>
<condition property="jre.arch" value="x86-64">
<matches pattern="(x86_64|amd64|em64t)" string="${os.arch}"/>
</condition>
<condition property="jre.arch" value="ppc">
<matches pattern="(powerpc|power)" string="${os.arch}"/>
</condition>
<condition property="jre.arch" value="ppc64">
<matches pattern="(powerpc64|power64)" string="${os.arch}"/>
</condition>
<property name="jre.arch" value="${os.arch}"/>
<condition property="os.prefix" value="linux-${jre.arch}">
@@ -178,23 +215,26 @@
<condition property="os.prefix" value="aix-${jre.arch}">
<os name="AIX"/>
</condition>
<condition property="os.prefix" value="win32-${os.arch}">
<condition property="os.prefix" value="win32-${jre.arch}">
<os family="windows"/>
</condition>
<!-- Darwin builds are universal, no arch required -->
<condition property="os.prefix" value="darwin">
<os family="mac"/>
</condition>
<condition property="os.prefix" value="sunos-${os.arch}">
<condition property="os.prefix" value="sunos-${jre.arch}">
<os name="SunOS"/>
</condition>
<condition property="os.prefix" value="freebsd-${os.arch}">
<os name="FreeBSD"/>
<condition property="os.prefix" value="bsd-${jre.arch}">
<or>
<os name="FreeBSD"/>
<os name="OpenBSD"/>
<os name="NetBSD"/>
</or>
</condition>
<condition property="os.prefix" value="openbsd-${os.arch}">
<os name="OpenBSD"/>
</condition>
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${jre.arch}), edit build.xml and native/Makefile to add it."/>
<!-- Keep all natives separate -->
<property name="native.subdir" value="native-${os.prefix}"/>
<condition property="jdk.home" value="${java.home}">
<available file="${java.home}/include"/>
</condition>
@@ -205,9 +245,10 @@
<available file="/System/Library/Frameworks/JavaVM.framework/Headers"/>
</condition>
<fail unless="jdk.home" message="Can't find JNI headers (java.home=${java.home})"/>
<property name="libarch" value="${os.arch}"/>
<condition property="libjsig"
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
value="${java.home}/lib/${libarch}/libjsig.so" else="">
<available file="${java.home}/lib/${libarch}/libjsig.so"/>
</condition>
<condition property="ld.preload.name" value="${ld.preload}" else="IGNORE">
<not><equals arg1="${libjsig}" arg2=""/></not>
@@ -242,6 +283,7 @@
<fileset dir="lib">
<include name="junit.jar"/>
</fileset>
<fileset dir="lib/test"/>
<pathelement path="${classes}"/>
</path>
</path>
@@ -252,6 +294,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>
@@ -273,7 +316,6 @@
<uptodate property="-jar" targetfile="${build}/${jar}">
<srcfiles dir="${classes}">
<patternset id="jar-compiled">
<include name="lib/armeabi/*"/>
<include name="com/sun/jna/*"/>
<include name="com/sun/jna/**/*"/>
</patternset>
@@ -316,14 +358,14 @@
value="
com/sun/jna/win32-x86/jnidispatch.dll;
processor=x86;osname=win32,
com/sun/jna/win32-amd64/jnidispatch.dll;
com/sun/jna/win32-x86-64/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;
com/sun/jna/sunos-x86-64/libjnidispatch.so;
processor=x86-64;osname=sunos,
com/sun/jna/sunos-sparc/libjnidispatch.so;
processor=sparc;osname=sunos,
@@ -339,24 +381,22 @@ 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;
com/sun/jna/linux-x86/libjnidispatch.so;
processor=x86;osname=linux,
com/sun/jna/linux-amd64/libjnidispatch.so;
com/sun/jna/linux-x86-64/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/bsd-x86/libjnidispatch.so;
processor=x86;osname=openbsd;osname=freebsd;osname=netbsd,
com/sun/jna/bsd-x86-64/libjnidispatch.so;
processor=x86-64;osname=openbsd;osname=freebsd;osname=netbsd,
com/sun/jna/darwin/libjnidispatch.jnilib;
osname=macos
osname=macosx;processor=x86;processor=x86-64;processor=ppc
"/>
</manifest>
<fileset dir="${classes}" excludes="${jar.omitted}">
@@ -374,12 +414,12 @@ osname=macos
<zipfileset src="${lib.native}/darwin.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/darwin"/>
<zipfileset src="${lib.native}/linux-i386.jar"
<zipfileset src="${lib.native}/linux-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-i386"/>
<zipfileset src="${lib.native}/linux-amd64.jar"
prefix="com/sun/jna/linux-x86"/>
<zipfileset src="${lib.native}/linux-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-amd64"/>
prefix="com/sun/jna/linux-x86-64"/>
<zipfileset src="${lib.native}/linux-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/linux-arm"/>
@@ -395,27 +435,24 @@ osname=macos
<zipfileset src="${lib.native}/sunos-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-x86"/>
<zipfileset src="${lib.native}/sunos-amd64.jar"
<zipfileset src="${lib.native}/sunos-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/sunos-amd64"/>
prefix="com/sun/jna/sunos-x86-64"/>
<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"
<zipfileset src="${lib.native}/bsd-x86.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-i386"/>
<zipfileset src="${lib.native}/freebsd-amd64.jar"
prefix="com/sun/jna/bsd-x86"/>
<zipfileset src="${lib.native}/bsd-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/freebsd-amd64"/>
<zipfileset src="${lib.native}/openbsd-i386.jar"
prefix="com/sun/jna/bsd-x86-64"/>
<zipfileset src="${lib.native}/win32-x86-64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/openbsd-i386"/>
<zipfileset src="${lib.native}/win32-amd64.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/win32-amd64"/>
prefix="com/sun/jna/win32-x86-64"/>
<zipfileset src="${lib.native}/w32ce-arm.jar"
includes="*jnidispatch*"
prefix="com/sun/jna/w32ce-arm"/>
@@ -438,9 +475,6 @@ osname=macos
<zip zipfile="${platform-sources-jar}">
<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">
@@ -452,7 +486,7 @@ osname=macos
</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"/>
@@ -474,6 +508,7 @@ osname=macos
<fileset dir="${build.native}" includes="*.h"/>
</apply>
<!-- Clean up gcj javah output to match that of Sun's javah -->
<fixcrlf file="${md5.file}" eol="unix"/>
<replaceregexp match="^((.*\.h):JNIEXPORT[^(]+)( +\(.*)"
replace="\1&#xa;\2- \3&#xa;--"
byline="true"
@@ -486,7 +521,6 @@ osname=macos
replace=""
flags="m"
file="${md5.file}"/>
<fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
<checksum property="md5" file="${md5.file}" />
<condition property="jni.valid" value="true">
<or>
@@ -501,22 +535,22 @@ osname=macos
<echo>Invalidating native code, new checksum is ${md5}</echo>
<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}/win32-x86-64.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-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-x86-64.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}/bsd-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/bsd-x86-64.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-x86-64.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"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-x86.jar" overwrite="true"/>
<delete failOnError="false" includeEmptyDirs="true">
<fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
</delete>
@@ -537,18 +571,27 @@ osname=macos
<copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
<replaceregexp match="FILEVERSION.*"
replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
<replaceregexp match="PRODUCTVERSION.*"
replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
<replaceregexp match="FileVersion.*"
replace="FileVersion&quot;,&quot;${jni.version}&quot;"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
<replaceregexp match="Full Version.*"
replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
<replaceregexp match="ProductVersion.*"
replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
<replaceregexp match="(Copyright.*-)2..."
replace="\1${year}"
preserveLastModified="true"
file="${rsrc}" byline="true"/>
</target>
@@ -566,7 +609,10 @@ osname=macos
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="make.OS" value="OS=android">
<equals arg1="${os.prefix}" arg2="android-arm"/>
<or>
<equals arg1="${os.prefix}" arg2="android-arm"/>
<equals arg1="${os.prefix}" arg2="android-x86"/>
</or>
</condition>
<property name="make.OS" value="IGNORE="/>
<!-- Ensure Makefile ARCH property properly set -->
@@ -576,6 +622,9 @@ osname=macos
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="android-arm"/>
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
</condition>
<condition property="ARCH" value="ppc">
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
</condition>
@@ -583,7 +632,7 @@ osname=macos
<equals arg1="${os.prefix}" arg2="aix-ppc64"/>
</condition>
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
<!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
<!-- use ANT_OPTS=-d64/-d32 to build 64-bit/32-bit if not the platform default -->
<property name="ARCH" value="${os.arch}"/>
<condition property="make.CC" value="CC=${CC}" else="IGNORE=">
<isset property="CC"/>
@@ -633,6 +682,7 @@ osname=macos
<or>
<os name="FreeBSD"/>
<os name="OpenBSD"/>
<os name="NetBSD"/>
<os name="SunOS"/>
<os name="AIX"/>
</or>
@@ -642,9 +692,7 @@ osname=macos
<isset property="EXTRA_MAKE_OPTS"/>
</condition>
<!-- Native resource path within jna.jar -->
<condition property="native.path" value="lib/armeabi" else="com/sun/jna/${os.prefix}">
<equals arg1="${os.prefix}" arg2="android-arm"/>
</condition>
<property name="native.path" value="com/sun/jna/${os.prefix}"/>
<!-- Default make program -->
<property name="make" value="make"/>
@@ -702,12 +750,31 @@ osname=macos
<src path="${test.src}"/>
<exclude name="${tests.exclude}"/>
</javac>
<!-- Create a jar for easy movement of tests -->
<!-- Embed testlib-jar at root and at default resource path -->
<mkdir dir="${test.classes}/${os.prefix}"/>
<copy todir="${test.classes}">
<fileset dir="${build.native}">
<include name="*testlib-jar*"/>
</fileset>
</copy>
<copy todir="${test.classes}/${os.prefix}">
<fileset dir="${build.native}">
<include name="*testlib-jar*"/>
</fileset>
</copy>
<!-- Create a jar for easy movement of tests, and jar load test -->
<jar jarfile="${build}/${testjar}">
<fileset dir="${test.classes}">
<patternset refid="jar-compiled"/>
<include name="**/*testlib-jar*"/>
</fileset>
</jar>
<!-- Ensure jar-based library is unavailable on FS-based class path -->
<delete>
<fileset dir="${build}">
<include name="**/*testlib-jar*"/>
</fileset>
</delete>
<mkdir dir="${build}/jws"/>
<copy todir="${build}/jws" file="${build}/${jar}"/>
<copy todir="${build}/jws" file="${build}/${testjar}"/>
@@ -742,6 +809,8 @@ osname=macos
<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.native}/test-path.dll"/>
<copy todir="${shared}" file="${build.native}/testlib-truncated"/>
<copy todir="${shared}" file="w32ce-test.lnk"/>
<chmod file="${shared}/*.dll" perm="+x"/>
</target>
@@ -759,7 +828,7 @@ osname=macos
<condition property="tests.platform" value="**/win32/**/*Test.java">
<os family="windows"/>
</condition>
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
<condition property="tests.exclude" value="${tests.stdcall}">
<and><os family="windows"/><not><os arch="x86"/></not></and>
</condition>
<condition property="tests.platform" value="**/unix/*Test.java">
@@ -768,13 +837,6 @@ osname=macos
<not><os family="mac"/></not>
</and>
</condition>
<condition property="vmopt.arch" value="-d64" else="-Dignore">
<and>
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
<not><os family="windows"/></not>
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</and>
</condition>
<property name="tests.platform" value=""/>
<property name="tests.exclude" value=""/>
<property name="tests.exclude-patterns" value=""/>
@@ -795,6 +857,7 @@ osname=macos
<!-- Avoid VM crashes, if possible -->
<sysproperty key="jna.protected" value="true"/>
<sysproperty key="jna.builddir" file="${build}"/>
<sysproperty key="jna.nativedir" file="${build.native}"/>
<jvmarg value="${vmopt.arch}"/>
<classpath><path refid="test.runpath"/></classpath>
<formatter type="brief" usefile="false"/>
@@ -817,8 +880,8 @@ osname=macos
<fail if="testfailure" unless="clover">One or more tests failed</fail>
</target>
<target name="contrib-test" depends="contrib-jars,compile-tests">
<subant target="test" failonerror="true">
<target name="test-platform" depends="compile-tests,platform-jar">
<subant target="test" failonerror="true" inheritall="true" inheritrefs="true">
<property name="file.reference.jna.build" location="${build}"/>
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
<property name="libs.junit.classpath" location="lib/junit.jar"/>
@@ -895,6 +958,9 @@ osname=macos
<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"
@@ -922,7 +988,7 @@ osname=macos
<!-- 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"/>
<zipfileset dir="." includes="build.xml,${pom},LICENSE,LGPL2.1,ASL2.0"/>
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
<zipfileset dir="${native}" excludes="libffi,libffi/**/*,build,build/**/*" prefix="native"/>
@@ -948,7 +1014,7 @@ osname=macos
<delete quiet="true" includeEmptyDirs="true">
<fileset dir=".clover"/>
<fileset dir="${javadoc}"/>
<fileset dir="." includes="*~,**/*~"/>
<fileset dir="." includes="*~,**/*~,build.number"/>
</delete>
<subant target="clean" failonerror="true">
<fileset dir="${contrib}" includes="*/build.xml"/>
@@ -969,25 +1035,10 @@ osname=macos
<arg value="-DrepositoryId=${maven-snapshots-repository-id}"/>
<arg value="-DpomFile=${pom}"/>
<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>
<!-- @todo only one file at a time is working with maven-deploy-plugin, find way to deploy sources and javadoc too.
<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-sources-jar}"/>
<arg value="-Dclassifier=sources"/>
</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}"/>
<arg value="-Dfile=${maven-javadoc-jar}"/>
<arg value="-Dclassifier=javadoc"/>
</artifact:mvn>
-->
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/>
@@ -995,25 +1046,10 @@ osname=macos
<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>
<!-- @todo only one file at a time is working with maven-deploy-plugin, find way to deploy sources and javadoc too.
<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-sources-jar}"/>
<arg value="-Dclassifier=sources"/>
</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-javadoc-jar}"/>
<arg value="-Dclassifier=javadoc"/>
</artifact:mvn>
-->
</target>
Arquivo executável → Arquivo normal
Ver Arquivo
@@ -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];
}
Arquivo executável → Arquivo normal
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,424 +1,424 @@
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.Popup;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
//TODO: FilteredTextField - Comment this class.
/**
* The FilteredTextField class is a JTextField that only allows specified
* characters to be entered into it. The allowed characters can be added to
* the text field, and entry validation is performed as each character is
* typed. In addition, complete string validation is tested against a
* configurable regular expression when leaving the field. If the string is
* invalid the text field is bordered with a red line, and the user is notified
* of the error upon returning to the text field. The text field can also be
* configured to accept a limited number of characters.
*/
@SuppressWarnings("serial")
public class FilteredTextField extends JTextField {
public static final Character[] UPPERCASE_CHARS = {'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z'};
public static final Character[] LOWERCASE_CHARS = {'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'};
public static final Character[] NUMERIC_CHARS = {'1', '2', '3', '4', '5',
'6', '7', '8', '9', '0'};
private static final Integer ENTRY_BALLOON = 0;
private static final Integer VALID_BALLOON = 1;
private static final Integer LENGTH_BALLOON = 2;
private static final Border RED_BORDER =
BorderFactory.createLineBorder(Color.RED, 2);
private ArrayList<Character> allowable = new ArrayList<Character>();
private int maximumLength = String.valueOf(Long.MAX_VALUE).length();
private Border defaultBorder = null;
private boolean isValid = true;
private Popup balloon = null;
private String entryError = null;
private String validRegex = null;
private String validError = null;
private Color balloonBorderColor = null;
private Color balloonBackgroundColor = null;
private Color balloonTextColor = null;
private Integer balloonDuration = null;
private Integer balloonType = null;
/**
* Create a FilteredTextField.
*/
public FilteredTextField () {
super();
init();
}
/**
* Create a FilteredTextField.
* @param columns the number of columns to use to calculate the preferred
* width
*/
public FilteredTextField (int columns) {
super(columns);
init();
}
/*
* Initialize the FilteredTextField.
*/
private void init () {
defaultBorder = getBorder();
entryError = "";
validRegex = "";
validError = "";
balloonBorderColor = BalloonTipManager.DEFAULT_BORDER_COLOR;
balloonBackgroundColor = BalloonTipManager.DEFAULT_BACKGROUND_COLOR;
balloonTextColor = BalloonTipManager.DEFAULT_TEXT_COLOR;
balloonDuration = 10000;
balloonType = ENTRY_BALLOON;
addFocusListener(new ValidationEar());
}
/**
* Sets the allowable character used for entry validation.
* @param characters the allowable characters
*/
public void setCharacters (Character[] characters) {
clearCharacters();
for (int i = 0; i < characters.length; i++) {
addCharacter(characters[i]);
}
}
/**
* Adds the character array to the list used for entry validation.
* @param characters the character array
*/
public void addCharacters (Character[] characters) {
for (int i = 0; i < characters.length; i++) {
addCharacter(characters[i]);
}
}
/**
* Adds the character to the list used for entry validation.
* @param characters the character
*/
public void addCharacter (Character character) {
if (!allowable.contains(character)) {
allowable.add(character);
}
}
/**
* Clears the list of allowable characters for entry validation.
*/
public void clearCharacters () {
allowable.clear();
}
/**
* Removes the character array from the list used for entry validation.
* @param characters the character array
*/
public void removeCharacters (Character[] characters) {
for (int i = 0; i < characters.length; i++) {
removeCharacter(characters[i]);
}
}
/**
* Removes the character from the list used for entry validation.
* @param character the character
*/
public void removeCharacter (Character character) {
if (allowable.contains(character)) {
allowable.remove(character);
}
}
/**
* Sets the maximum number of characters for the length of the entry string.
* @param maximumLength the number of characters
*/
public void setMaximumLength (int maximumLength) {
this.maximumLength = maximumLength;
}
/**
* Sets the message that is displayed when there is an entry error.
* @param entryError the entry error message
*/
public void setEntryError (String entryError) {
this.entryError = entryError;
}
/**
* Sets the regular expression that is used for string validation. String
* validation is checked when exiting the text field.
* @param validRegex the validation regular expression
*/
public void setValidRegex (String validRegex) {
this.validRegex = validRegex;
}
/**
* Sets the message that is displayed when there is a validation error.
* @param validError the validation error message
*/
public void setValidError (String validError) {
this.validError = validError;
}
/**
* Sets the color to use for the balloon border.
* @param borderColor the balloon border color
*/
public void setBalloonBorderColor (Color borderColor) {
balloonBorderColor = borderColor;
}
/**
* Sets the color to use for the balloon background.
* @param backgroundColor the balloon background color
*/
public void setBalloonBackgroundColor (Color backgroundColor) {
balloonBackgroundColor = backgroundColor;
}
/**
* Sets the color to use for the balloon text.
* @param textColor the balloon text color
*/
public void setBalloonTextColor (Color textColor) {
balloonTextColor = textColor;
}
/**
* Sets the time in milliseconds that the balloon is visible before
* disappearing. This is the maximum time that the balloon will be visible,
* as other events can also make the balloon disappear.
* @param duration the time in milliseconds
*/
public void setBalloonDuration (Integer duration) {
balloonDuration = duration;
}
/*
* (non-Javadoc)
* @see javax.swing.JTextField#createDefaultModel()
*/
protected Document createDefaultModel () {
return new FilteredTextFieldDocument();
}
/*
* This class defines the document used for the FilteredTextField.
*/
private class FilteredTextFieldDocument extends PlainDocument {
/*
* Create a FilteredTextFieldDocument.
*/
public FilteredTextFieldDocument () {
addDocumentListener(new FilteredTextFieldEar());
}
/*
* (non-Javadoc)
* @see javax.swing.text.PlainDocument#insertString(
* int, java.lang.String, javax.swing.text.AttributeSet)
*/
public void insertString (int offset, String str, AttributeSet a)
throws BadLocationException
{
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == VALID_BALLOON) {
balloon.hide();
}
}
StringBuffer buffer =
new StringBuffer(FilteredTextField.this.getText());
if (offset >= 0 && offset <= buffer.length()) {
buffer.insert(offset, str);
String strBuf = buffer.toString();
if (buffer.length() > maximumLength) {
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == LENGTH_BALLOON) {
BalloonTipManager.restartTimer();
return;
}
else {
balloon.hide();
}
}
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
"The number of characters must be less than or equal to " +
maximumLength, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = LENGTH_BALLOON;
return;
}
if (strBuf == null || strBuf.equals("")) {
remove(0, getLength());
super.insertString(0, "", null);
if (balloon != null && BalloonTipManager.isShowing()) {
balloon.hide();
}
return;
}
if (allowable.contains(str.charAt(0))) {
super.insertString(offset, str, a);
if (balloon != null && BalloonTipManager.isShowing()) {
balloon.hide();
}
}
else {
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == ENTRY_BALLOON) {
BalloonTipManager.restartTimer();
return;
}
else {
balloon.hide();
}
}
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
entryError, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = ENTRY_BALLOON;
}
}
}
/*
* This listener class is needed to catch character removal events.
*/
private class FilteredTextFieldEar implements DocumentListener {
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(
* javax.swing.event.DocumentEvent)
*/
public void insertUpdate (DocumentEvent e) {/* N/A */}
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(
* javax.swing.event.DocumentEvent)
*/
public void removeUpdate (DocumentEvent e) {
if (balloon != null && BalloonTipManager.isShowing())
{
balloon.hide();
}
}
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(
* javax.swing.event.DocumentEvent)
*/
public void changedUpdate (DocumentEvent e) {/* N/A */}
}
}
/*
* This listener class is used to determine whether the string is valid based
* on a regular expression. The validation is tested when leaving the text
* field, and notification is performed when returning to the text field.
*/
private class ValidationEar extends FocusAdapter {
/*
* (non-Javadoc)
* @see java.awt.event.FocusAdapter#focusLost(java.awt.event.FocusEvent)
*/
public void focusLost (FocusEvent e) {
String entered = getText().trim();
if (!entered.matches(validRegex)) {
if (balloon != null) {
balloon.hide();
}
setBorder(
BorderFactory.createCompoundBorder(RED_BORDER, defaultBorder));
isValid = false;
}
else {
setBorder(defaultBorder);
isValid = true;
}
}
/*
* (non-Javadoc)
* @see java.awt.event.FocusAdapter#focusGained(java.awt.event.FocusEvent)
*/
public void focusGained (FocusEvent e) {
if (!isValid) {
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
validError, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = VALID_BALLOON;
}
}
}
/*
* A main entry point to test the FilteredTextField.
* @param args application arguments
*/
public static void main (String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
JFrame jframe = new JFrame("Balloon Tips on FilteredTextField");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setSize(400, 75);
jframe.setLocation(400, 400);
JPanel jpanel = new JPanel();
jpanel.setLayout(new BorderLayout());
FilteredTextField ftfield = new FilteredTextField(10);
ftfield.setCharacters(LOWERCASE_CHARS);
ftfield.addCharacter('-');
ftfield.addCharacter('_');
ftfield.addCharacter(' ');
ftfield.setMaximumLength(10);
ftfield.setEntryError(
"Only lower case letters, hyphens, underscores, and spaces allowed.");
ftfield.setValidRegex("^a+[a-z-_ ]*");
ftfield.setValidError("The string must begin with the letter 'a'.");
jpanel.add(new JLabel("Type some text into either field"), BorderLayout.NORTH);
jpanel.add(ftfield, BorderLayout.CENTER);
jpanel.add(new FilteredTextField(10), BorderLayout.SOUTH);
jframe.getContentPane().add(jpanel);
jframe.setVisible(true);
}
}
package com.sun.jna.contrib.demo;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.Popup;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
//TODO: FilteredTextField - Comment this class.
/**
* The FilteredTextField class is a JTextField that only allows specified
* characters to be entered into it. The allowed characters can be added to
* the text field, and entry validation is performed as each character is
* typed. In addition, complete string validation is tested against a
* configurable regular expression when leaving the field. If the string is
* invalid the text field is bordered with a red line, and the user is notified
* of the error upon returning to the text field. The text field can also be
* configured to accept a limited number of characters.
*/
@SuppressWarnings("serial")
public class FilteredTextField extends JTextField {
public static final Character[] UPPERCASE_CHARS = {'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z'};
public static final Character[] LOWERCASE_CHARS = {'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'};
public static final Character[] NUMERIC_CHARS = {'1', '2', '3', '4', '5',
'6', '7', '8', '9', '0'};
private static final Integer ENTRY_BALLOON = 0;
private static final Integer VALID_BALLOON = 1;
private static final Integer LENGTH_BALLOON = 2;
private static final Border RED_BORDER =
BorderFactory.createLineBorder(Color.RED, 2);
private ArrayList<Character> allowable = new ArrayList<Character>();
private int maximumLength = String.valueOf(Long.MAX_VALUE).length();
private Border defaultBorder = null;
private boolean isValid = true;
private Popup balloon = null;
private String entryError = null;
private String validRegex = null;
private String validError = null;
private Color balloonBorderColor = null;
private Color balloonBackgroundColor = null;
private Color balloonTextColor = null;
private Integer balloonDuration = null;
private Integer balloonType = null;
/**
* Create a FilteredTextField.
*/
public FilteredTextField () {
super();
init();
}
/**
* Create a FilteredTextField.
* @param columns the number of columns to use to calculate the preferred
* width
*/
public FilteredTextField (int columns) {
super(columns);
init();
}
/*
* Initialize the FilteredTextField.
*/
private void init () {
defaultBorder = getBorder();
entryError = "";
validRegex = "";
validError = "";
balloonBorderColor = BalloonTipManager.DEFAULT_BORDER_COLOR;
balloonBackgroundColor = BalloonTipManager.DEFAULT_BACKGROUND_COLOR;
balloonTextColor = BalloonTipManager.DEFAULT_TEXT_COLOR;
balloonDuration = 10000;
balloonType = ENTRY_BALLOON;
addFocusListener(new ValidationEar());
}
/**
* Sets the allowable character used for entry validation.
* @param characters the allowable characters
*/
public void setCharacters (Character[] characters) {
clearCharacters();
for (int i = 0; i < characters.length; i++) {
addCharacter(characters[i]);
}
}
/**
* Adds the character array to the list used for entry validation.
* @param characters the character array
*/
public void addCharacters (Character[] characters) {
for (int i = 0; i < characters.length; i++) {
addCharacter(characters[i]);
}
}
/**
* Adds the character to the list used for entry validation.
* @param characters the character
*/
public void addCharacter (Character character) {
if (!allowable.contains(character)) {
allowable.add(character);
}
}
/**
* Clears the list of allowable characters for entry validation.
*/
public void clearCharacters () {
allowable.clear();
}
/**
* Removes the character array from the list used for entry validation.
* @param characters the character array
*/
public void removeCharacters (Character[] characters) {
for (int i = 0; i < characters.length; i++) {
removeCharacter(characters[i]);
}
}
/**
* Removes the character from the list used for entry validation.
* @param character the character
*/
public void removeCharacter (Character character) {
if (allowable.contains(character)) {
allowable.remove(character);
}
}
/**
* Sets the maximum number of characters for the length of the entry string.
* @param maximumLength the number of characters
*/
public void setMaximumLength (int maximumLength) {
this.maximumLength = maximumLength;
}
/**
* Sets the message that is displayed when there is an entry error.
* @param entryError the entry error message
*/
public void setEntryError (String entryError) {
this.entryError = entryError;
}
/**
* Sets the regular expression that is used for string validation. String
* validation is checked when exiting the text field.
* @param validRegex the validation regular expression
*/
public void setValidRegex (String validRegex) {
this.validRegex = validRegex;
}
/**
* Sets the message that is displayed when there is a validation error.
* @param validError the validation error message
*/
public void setValidError (String validError) {
this.validError = validError;
}
/**
* Sets the color to use for the balloon border.
* @param borderColor the balloon border color
*/
public void setBalloonBorderColor (Color borderColor) {
balloonBorderColor = borderColor;
}
/**
* Sets the color to use for the balloon background.
* @param backgroundColor the balloon background color
*/
public void setBalloonBackgroundColor (Color backgroundColor) {
balloonBackgroundColor = backgroundColor;
}
/**
* Sets the color to use for the balloon text.
* @param textColor the balloon text color
*/
public void setBalloonTextColor (Color textColor) {
balloonTextColor = textColor;
}
/**
* Sets the time in milliseconds that the balloon is visible before
* disappearing. This is the maximum time that the balloon will be visible,
* as other events can also make the balloon disappear.
* @param duration the time in milliseconds
*/
public void setBalloonDuration (Integer duration) {
balloonDuration = duration;
}
/*
* (non-Javadoc)
* @see javax.swing.JTextField#createDefaultModel()
*/
protected Document createDefaultModel () {
return new FilteredTextFieldDocument();
}
/*
* This class defines the document used for the FilteredTextField.
*/
private class FilteredTextFieldDocument extends PlainDocument {
/*
* Create a FilteredTextFieldDocument.
*/
public FilteredTextFieldDocument () {
addDocumentListener(new FilteredTextFieldEar());
}
/*
* (non-Javadoc)
* @see javax.swing.text.PlainDocument#insertString(
* int, java.lang.String, javax.swing.text.AttributeSet)
*/
public void insertString (int offset, String str, AttributeSet a)
throws BadLocationException
{
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == VALID_BALLOON) {
balloon.hide();
}
}
StringBuffer buffer =
new StringBuffer(FilteredTextField.this.getText());
if (offset >= 0 && offset <= buffer.length()) {
buffer.insert(offset, str);
String strBuf = buffer.toString();
if (buffer.length() > maximumLength) {
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == LENGTH_BALLOON) {
BalloonTipManager.restartTimer();
return;
}
else {
balloon.hide();
}
}
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
"The number of characters must be less than or equal to " +
maximumLength, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = LENGTH_BALLOON;
return;
}
if (strBuf == null || strBuf.equals("")) {
remove(0, getLength());
super.insertString(0, "", null);
if (balloon != null && BalloonTipManager.isShowing()) {
balloon.hide();
}
return;
}
if (allowable.contains(str.charAt(0))) {
super.insertString(offset, str, a);
if (balloon != null && BalloonTipManager.isShowing()) {
balloon.hide();
}
}
else {
if (balloon != null && BalloonTipManager.isShowing()) {
if (balloonType == ENTRY_BALLOON) {
BalloonTipManager.restartTimer();
return;
}
else {
balloon.hide();
}
}
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
entryError, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = ENTRY_BALLOON;
}
}
}
/*
* This listener class is needed to catch character removal events.
*/
private class FilteredTextFieldEar implements DocumentListener {
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(
* javax.swing.event.DocumentEvent)
*/
public void insertUpdate (DocumentEvent e) {/* N/A */}
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(
* javax.swing.event.DocumentEvent)
*/
public void removeUpdate (DocumentEvent e) {
if (balloon != null && BalloonTipManager.isShowing())
{
balloon.hide();
}
}
/*
* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(
* javax.swing.event.DocumentEvent)
*/
public void changedUpdate (DocumentEvent e) {/* N/A */}
}
}
/*
* This listener class is used to determine whether the string is valid based
* on a regular expression. The validation is tested when leaving the text
* field, and notification is performed when returning to the text field.
*/
private class ValidationEar extends FocusAdapter {
/*
* (non-Javadoc)
* @see java.awt.event.FocusAdapter#focusLost(java.awt.event.FocusEvent)
*/
public void focusLost (FocusEvent e) {
String entered = getText().trim();
if (!entered.matches(validRegex)) {
if (balloon != null) {
balloon.hide();
}
setBorder(
BorderFactory.createCompoundBorder(RED_BORDER, defaultBorder));
isValid = false;
}
else {
setBorder(defaultBorder);
isValid = true;
}
}
/*
* (non-Javadoc)
* @see java.awt.event.FocusAdapter#focusGained(java.awt.event.FocusEvent)
*/
public void focusGained (FocusEvent e) {
if (!isValid) {
balloon = BalloonTipManager.getBalloonTip(FilteredTextField.this,
validError, 0, 0, balloonDuration, balloonBorderColor,
balloonBackgroundColor, balloonTextColor);
balloon.show();
balloonType = VALID_BALLOON;
}
}
}
/*
* A main entry point to test the FilteredTextField.
* @param args application arguments
*/
public static void main (String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
JFrame jframe = new JFrame("Balloon Tips on FilteredTextField");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setSize(400, 75);
jframe.setLocation(400, 400);
JPanel jpanel = new JPanel();
jpanel.setLayout(new BorderLayout());
FilteredTextField ftfield = new FilteredTextField(10);
ftfield.setCharacters(LOWERCASE_CHARS);
ftfield.addCharacter('-');
ftfield.addCharacter('_');
ftfield.addCharacter(' ');
ftfield.setMaximumLength(10);
ftfield.setEntryError(
"Only lower case letters, hyphens, underscores, and spaces allowed.");
ftfield.setValidRegex("^a+[a-z-_ ]*");
ftfield.setValidError("The string must begin with the letter 'a'.");
jpanel.add(new JLabel("Type some text into either field"), BorderLayout.NORTH);
jpanel.add(ftfield, BorderLayout.CENTER);
jpanel.add(new FilteredTextField(10), BorderLayout.SOUTH);
jframe.getContentPane().add(jpanel);
jframe.setVisible(true);
}
}
+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();
}
}
+196 -196
Ver Arquivo
@@ -1,196 +1,196 @@
/*
* Advapi32.java
*
* Created on 6. August 2007, 11:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
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);
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" });
}
}
}
/*
* Advapi32.java
*
* Created on 6. August 2007, 11:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
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);
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" });
}
}
}
+22 -22
Ver Arquivo
@@ -1,22 +1,22 @@
/*
* WINERROR.java
*
* Created on 7. August 2007, 08:09
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINERROR {
public final static int ERROR_SUCCESS = 0;
public final static int NO_ERROR = 0;
public final static int ERROR_FILE_NOT_FOUND = 2;
public final static int ERROR_MORE_DATA = 234;
}
/*
* WINERROR.java
*
* Created on 7. August 2007, 08:09
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINERROR {
public final static int ERROR_SUCCESS = 0;
public final static int NO_ERROR = 0;
public final static int ERROR_FILE_NOT_FOUND = 2;
public final static int ERROR_MORE_DATA = 234;
}
+36 -36
Ver Arquivo
@@ -1,36 +1,36 @@
/*
* WINNT.java
*
* Created on 8. August 2007, 13:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINNT {
public final static int DELETE = 0x00010000;
public final static int READ_CONTROL = 0x00020000;
public final static int WRITE_DAC = 0x00040000;
public final static int WRITE_OWNER = 0x00080000;
public final static int SYNCHRONIZE = 0x00100000;
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
public final static int GENERIC_EXECUTE = 0x20000000;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
}
/*
* WINNT.java
*
* Created on 8. August 2007, 13:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINNT {
public final static int DELETE = 0x00010000;
public final static int READ_CONTROL = 0x00020000;
public final static int WRITE_DAC = 0x00040000;
public final static int WRITE_OWNER = 0x00080000;
public final static int SYNCHRONIZE = 0x00100000;
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
public final static int GENERIC_EXECUTE = 0x20000000;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
}
+104 -104
Ver Arquivo
@@ -1,104 +1,104 @@
/*
* WINSVC.java
*
* Created on 8. August 2007, 15:07
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINSVC {
public final static int SERVICE_CONTROL_STOP = 0x00000001;
public final static int SERVICE_CONTROL_SHUTDOWN = 0x00000005;
public final static int SERVICE_STOPPED = 0x00000001;
public final static int SERVICE_START_PENDING = 0x00000002;
public final static int SERVICE_STOP_PENDING = 0x00000003;
public final static int SERVICE_RUNNING = 0x00000004;
public final static int SERVICE_CONTINUE_PENDING = 0x00000005;
public final static int SERVICE_PAUSE_PENDING = 0x00000006;
public final static int SERVICE_PAUSED = 0x00000007;
public final static int SERVICE_ACCEPT_STOP = 0x00000001;
public final static int SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002;
public final static int SERVICE_ACCEPT_SHUTDOWN = 0x00000004;
public final static int SERVICE_ACCEPT_PARAMCHANGE = 0x00000008;
public final static int SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010;
public final static int SC_MANAGER_CONNECT = 0x0001;
public final static int SC_MANAGER_CREATE_SERVICE = 0x0002;
public final static int SC_MANAGER_ENUMERATE_SERVICE = 0x0004;
public final static int SC_MANAGER_LOCK = 0x0008;
public final static int SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;
public final static int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020;
public final static int SC_MANAGER_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
SC_MANAGER_CONNECT |
SC_MANAGER_CREATE_SERVICE |
SC_MANAGER_ENUMERATE_SERVICE |
SC_MANAGER_LOCK |
SC_MANAGER_QUERY_LOCK_STATUS |
SC_MANAGER_MODIFY_BOOT_CONFIG;
public final static int SERVICE_QUERY_CONFIG = 0x0001;
public final static int SERVICE_CHANGE_CONFIG = 0x0002;
public final static int SERVICE_QUERY_STATUS = 0x0004;
public final static int SERVICE_ENUMERATE_DEPENDENTS = 0x0008;
public final static int SERVICE_START = 0x0010;
public final static int SERVICE_STOP = 0x0020;
public final static int SERVICE_PAUSE_CONTINUE = 0x0040;
public final static int SERVICE_INTERROGATE = 0x0080;
public final static int SERVICE_USER_DEFINED_CONTROL = 0x0100;
public final static int SERVICE_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
SERVICE_QUERY_CONFIG |
SERVICE_CHANGE_CONFIG |
SERVICE_QUERY_STATUS |
SERVICE_ENUMERATE_DEPENDENTS |
SERVICE_START |
SERVICE_STOP |
SERVICE_PAUSE_CONTINUE |
SERVICE_INTERROGATE |
SERVICE_USER_DEFINED_CONTROL;
public final static int SERVICE_CONFIG_DESCRIPTION = 1;
public final static int SERVICE_CONFIG_FAILURE_ACTIONS = 2;
public final static int SERVICE_KERNEL_DRIVER = 0x00000001;
public final static int SERVICE_FILE_SYSTEM_DRIVER = 0x00000002;
public final static int SERVICE_ADAPTER = 0x00000004;
public final static int SERVICE_RECOGNIZER_DRIVER = 0x00000008;
public final static int SERVICE_DRIVER = SERVICE_KERNEL_DRIVER |
SERVICE_FILE_SYSTEM_DRIVER |
SERVICE_RECOGNIZER_DRIVER;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
public final static int SERVICE_WIN32_SHARE_PROCESS = 0x00000020;
public final static int SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS;
public final static int SERVICE_INTERACTIVE_PROCESS = 0x00000100;
public final static int SERVICE_TYPE_ALL = SERVICE_WIN32 |
SERVICE_ADAPTER |
SERVICE_DRIVER |
SERVICE_INTERACTIVE_PROCESS;
public final static int SERVICE_BOOT_START = 0x00000000;
public final static int SERVICE_SYSTEM_START = 0x00000001;
public final static int SERVICE_AUTO_START = 0x00000002;
public final static int SERVICE_DEMAND_START = 0x00000003;
public final static int SERVICE_DISABLED = 0x00000004;
public final static int SERVICE_ERROR_IGNORE = 0x00000000;
public final static int SERVICE_ERROR_NORMAL = 0x00000001;
public final static int SERVICE_ERROR_SEVERE = 0x00000002;
public final static int SERVICE_ERROR_CRITICAL = 0x00000003;
}
/*
* WINSVC.java
*
* Created on 8. August 2007, 15:07
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINSVC {
public final static int SERVICE_CONTROL_STOP = 0x00000001;
public final static int SERVICE_CONTROL_SHUTDOWN = 0x00000005;
public final static int SERVICE_STOPPED = 0x00000001;
public final static int SERVICE_START_PENDING = 0x00000002;
public final static int SERVICE_STOP_PENDING = 0x00000003;
public final static int SERVICE_RUNNING = 0x00000004;
public final static int SERVICE_CONTINUE_PENDING = 0x00000005;
public final static int SERVICE_PAUSE_PENDING = 0x00000006;
public final static int SERVICE_PAUSED = 0x00000007;
public final static int SERVICE_ACCEPT_STOP = 0x00000001;
public final static int SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002;
public final static int SERVICE_ACCEPT_SHUTDOWN = 0x00000004;
public final static int SERVICE_ACCEPT_PARAMCHANGE = 0x00000008;
public final static int SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010;
public final static int SC_MANAGER_CONNECT = 0x0001;
public final static int SC_MANAGER_CREATE_SERVICE = 0x0002;
public final static int SC_MANAGER_ENUMERATE_SERVICE = 0x0004;
public final static int SC_MANAGER_LOCK = 0x0008;
public final static int SC_MANAGER_QUERY_LOCK_STATUS = 0x0010;
public final static int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020;
public final static int SC_MANAGER_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
SC_MANAGER_CONNECT |
SC_MANAGER_CREATE_SERVICE |
SC_MANAGER_ENUMERATE_SERVICE |
SC_MANAGER_LOCK |
SC_MANAGER_QUERY_LOCK_STATUS |
SC_MANAGER_MODIFY_BOOT_CONFIG;
public final static int SERVICE_QUERY_CONFIG = 0x0001;
public final static int SERVICE_CHANGE_CONFIG = 0x0002;
public final static int SERVICE_QUERY_STATUS = 0x0004;
public final static int SERVICE_ENUMERATE_DEPENDENTS = 0x0008;
public final static int SERVICE_START = 0x0010;
public final static int SERVICE_STOP = 0x0020;
public final static int SERVICE_PAUSE_CONTINUE = 0x0040;
public final static int SERVICE_INTERROGATE = 0x0080;
public final static int SERVICE_USER_DEFINED_CONTROL = 0x0100;
public final static int SERVICE_ALL_ACCESS = WINNT.STANDARD_RIGHTS_REQUIRED |
SERVICE_QUERY_CONFIG |
SERVICE_CHANGE_CONFIG |
SERVICE_QUERY_STATUS |
SERVICE_ENUMERATE_DEPENDENTS |
SERVICE_START |
SERVICE_STOP |
SERVICE_PAUSE_CONTINUE |
SERVICE_INTERROGATE |
SERVICE_USER_DEFINED_CONTROL;
public final static int SERVICE_CONFIG_DESCRIPTION = 1;
public final static int SERVICE_CONFIG_FAILURE_ACTIONS = 2;
public final static int SERVICE_KERNEL_DRIVER = 0x00000001;
public final static int SERVICE_FILE_SYSTEM_DRIVER = 0x00000002;
public final static int SERVICE_ADAPTER = 0x00000004;
public final static int SERVICE_RECOGNIZER_DRIVER = 0x00000008;
public final static int SERVICE_DRIVER = SERVICE_KERNEL_DRIVER |
SERVICE_FILE_SYSTEM_DRIVER |
SERVICE_RECOGNIZER_DRIVER;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
public final static int SERVICE_WIN32_SHARE_PROCESS = 0x00000020;
public final static int SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS;
public final static int SERVICE_INTERACTIVE_PROCESS = 0x00000100;
public final static int SERVICE_TYPE_ALL = SERVICE_WIN32 |
SERVICE_ADAPTER |
SERVICE_DRIVER |
SERVICE_INTERACTIVE_PROCESS;
public final static int SERVICE_BOOT_START = 0x00000000;
public final static int SERVICE_SYSTEM_START = 0x00000001;
public final static int SERVICE_AUTO_START = 0x00000002;
public final static int SERVICE_DEMAND_START = 0x00000003;
public final static int SERVICE_DISABLED = 0x00000004;
public final static int SERVICE_ERROR_IGNORE = 0x00000000;
public final static int SERVICE_ERROR_NORMAL = 0x00000001;
public final static int SERVICE_ERROR_SEVERE = 0x00000002;
public final static int SERVICE_ERROR_CRITICAL = 0x00000003;
}
@@ -1,66 +1,66 @@
/*
* TestService.java
*
* Created on 12. September 2007, 12:49
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.win32;
/**
* TestService.
*/
public class TestService extends Win32Service {
/**
* main.
* @param args arguments
*/
public static void main(String[] args) {
TestService service = new TestService();
if(args.length == 1) {
if(args[0].equalsIgnoreCase("install")) {
System.out.println(service.install("TestService DisplayName", "TestService Description",
null, null, null));
} else if(args[0].equalsIgnoreCase("uninstall")) {
System.out.println(service.uninstall());
} else {
System.out.println("Arguments:");
System.out.println("install = install service");
System.out.println("uninstall = uninstall service");
System.out.println("<none> = run service");
System.exit(0);
}
} else {
service.init();
}
}
/**
* Creates a new instance of TestService.
*/
public TestService() {
super("TestService");
}
/**
* Will be called on start.
*/
public void onStart() {
}
/**
* Will be called on stop.
*/
public void onStop() {
}
}
/*
* TestService.java
*
* Created on 12. September 2007, 12:49
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.win32;
/**
* TestService.
*/
public class TestService extends Win32Service {
/**
* main.
* @param args arguments
*/
public static void main(String[] args) {
TestService service = new TestService();
if(args.length == 1) {
if(args[0].equalsIgnoreCase("install")) {
System.out.println(service.install("TestService DisplayName", "TestService Description",
null, null, null));
} else if(args[0].equalsIgnoreCase("uninstall")) {
System.out.println(service.uninstall());
} else {
System.out.println("Arguments:");
System.out.println("install = install service");
System.out.println("uninstall = uninstall service");
System.out.println("<none> = run service");
System.exit(0);
}
} else {
service.init();
}
}
/**
* Creates a new instance of TestService.
*/
public TestService() {
super("TestService");
}
/**
* Will be called on start.
*/
public void onStart() {
}
/**
* Will be called on stop.
*/
public void onStop() {
}
}
@@ -1,310 +1,310 @@
/*
* Win32Service.java
*
* Created on 12. September 2007, 12:05
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.win32;
import jnacontrib.jna.*;
import com.sun.jna.Pointer;
/**
* Baseclass for a Win32 service.
*/
public abstract class Win32Service {
protected String serviceName;
private ServiceMain serviceMain;
private ServiceControl serviceControl;
private Pointer serviceStatusHandle;
private Object waitObject = new Object();
/**
* Creates a new instance of Win32Service.
*
* @param serviceName internal name of the service
*/
public Win32Service(String serviceName) {
this.serviceName = serviceName;
}
/**
* Install the service.
*
* @param displayName visible name
* @param description description
* @param dependencies array of other services to depend on or null
* @param account service account or null for LocalSystem
* @param password password for service account or null
* @throws java.lang.Exception
* @return true on success
*/
public boolean install(String displayName, String description, String[] dependencies, String account, String password) {
return(install(displayName, description, dependencies, account, password, "java.exe -cp \"" +
System.getProperty("java.class.path") + "\" -Xrs " + this.getClass().getName()));
}
/**
* Install the service.
*
* @return true on success
* @param displayName visible name
* @param description description
* @param dependencies array of other services to depend on or null
* @param account service account or null for LocalSystem
* @param password password for service account or null
* @param command command line to start the service
* @throws java.lang.Exception
*/
public boolean install(String displayName, String description, String[] dependencies, String account, String password, String command) {
Advapi32 advapi32;
Advapi32.SERVICE_DESCRIPTION desc;
Pointer serviceManager, service;
boolean success = false;
String dep = "";
if(dependencies != null) {
for(String s : dependencies) {
dep += s + "\0";
}
}
dep += "\0";
desc = new Advapi32.SERVICE_DESCRIPTION();
desc.lpDescription = description;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
if(serviceManager != null) {
service = advapi32.CreateService(serviceManager, serviceName, displayName,
WINSVC.SERVICE_ALL_ACCESS, WINSVC.SERVICE_WIN32_OWN_PROCESS, WINSVC.SERVICE_DEMAND_START,
WINSVC.SERVICE_ERROR_NORMAL,
command,
null, null, dep, account, password);
if(service != null) {
success = advapi32.ChangeServiceConfig2(service, WINSVC.SERVICE_CONFIG_DESCRIPTION, desc);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Uninstall the service.
*
* @throws java.lang.Exception
* @return true on success
*/
public boolean uninstall() {
Advapi32 advapi32;
Pointer serviceManager, service;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINSVC.SERVICE_ALL_ACCESS);
if(service != null) {
success = advapi32.DeleteService(service);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Ask the ServiceControlManager to start the service.
* @return true on success
*/
public boolean start() {
Advapi32 advapi32;
Pointer serviceManager, service;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
if(service != null) {
success = advapi32.StartService(service, 0, null);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Ask the ServiceControlManager to stop the service.
* @return true on success
*/
public boolean stop() throws Exception {
Advapi32 advapi32;
Pointer serviceManager, service;
Advapi32.SERVICE_STATUS serviceStatus;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
if(service != null) {
serviceStatus = new Advapi32.SERVICE_STATUS();
success = advapi32.ControlService(service, WINSVC.SERVICE_CONTROL_STOP, serviceStatus);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Initialize the service, connect to the ServiceControlManager.
*/
public void init() {
Advapi32 advapi32;
Advapi32.SERVICE_TABLE_ENTRY entry;
serviceMain = new ServiceMain();
advapi32 = Advapi32.INSTANCE;
entry = new Advapi32.SERVICE_TABLE_ENTRY();
entry.lpServiceName = serviceName;
entry.lpServiceProc = serviceMain;
advapi32.StartServiceCtrlDispatcher(entry.toArray(2));
}
/**
* Get a handle to the ServiceControlManager.
*
* @param machine name of the machine or null for localhost
* @param access access flags
* @return handle to ServiceControlManager or null when failed
*/
private Pointer openServiceControlManager(String machine, int access) {
Pointer handle = null;
Advapi32 advapi32;
advapi32 = Advapi32.INSTANCE;
handle = advapi32.OpenSCManager(machine, null, access);
return(handle);
}
/**
* Report service status to the ServiceControlManager.
*
* @param status status
* @param win32ExitCode exit code
* @param waitHint time to wait
*/
private void reportStatus(int status, int win32ExitCode, int waitHint) {
Advapi32 advapi32;
Advapi32.SERVICE_STATUS serviceStatus;
advapi32 = Advapi32.INSTANCE;
serviceStatus = new Advapi32.SERVICE_STATUS();
serviceStatus.dwServiceType = WINNT.SERVICE_WIN32_OWN_PROCESS;
serviceStatus.dwControlsAccepted = WINSVC.SERVICE_ACCEPT_STOP | WINSVC.SERVICE_ACCEPT_SHUTDOWN;
serviceStatus.dwWin32ExitCode = win32ExitCode;
serviceStatus.dwWaitHint = waitHint;
serviceStatus.dwCurrentState = status;
advapi32.SetServiceStatus(serviceStatusHandle, serviceStatus);
}
/**
* Called when service is starting.
*/
public abstract void onStart();
/*
* Called when service should stop.
*/
public abstract void onStop();
/**
* Implementation of the service main function.
*/
private class ServiceMain implements Advapi32.SERVICE_MAIN_FUNCTION {
/**
* Called when the service is starting.
*
* @param dwArgc number of arguments
* @param lpszArgv pointer to arguments
*/
public void callback(int dwArgc, Pointer lpszArgv) {
Advapi32 advapi32;
advapi32 = Advapi32.INSTANCE;
serviceControl = new ServiceControl();
serviceStatusHandle = advapi32.RegisterServiceCtrlHandlerEx(serviceName, serviceControl, null);
reportStatus(WINSVC.SERVICE_START_PENDING, WINERROR.NO_ERROR, 3000);
reportStatus(WINSVC.SERVICE_RUNNING, WINERROR.NO_ERROR, 0);
onStart();
try {
synchronized(waitObject) {
waitObject.wait();
}
} catch (InterruptedException ex) {
}
reportStatus(WINSVC.SERVICE_STOPPED, WINERROR.NO_ERROR, 0);
// Avoid returning from ServiceMain, which will cause a crash
// See http://support.microsoft.com/kb/201349, which recommends
// having init() wait for this thread.
// Waiting on this thread in init() won't fix the crash, though.
//System.exit(0);
}
}
/**
* Implementation of the service control function.
*/
private class ServiceControl implements Advapi32.HandlerEx {
/**
* Called when the service get a control code.
*
* @param dwControl
* @param dwEventType
* @param lpEventData
* @param lpContext
*/
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext) {
switch(dwControl) {
case WINSVC.SERVICE_CONTROL_STOP:
case WINSVC.SERVICE_CONTROL_SHUTDOWN:
reportStatus(WINSVC.SERVICE_STOP_PENDING, WINERROR.NO_ERROR, 5000);
onStop();
synchronized(waitObject) {
waitObject.notifyAll();
}
}
return WINERROR.NO_ERROR;
}
}
}
/*
* Win32Service.java
*
* Created on 12. September 2007, 12:05
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.win32;
import jnacontrib.jna.*;
import com.sun.jna.Pointer;
/**
* Baseclass for a Win32 service.
*/
public abstract class Win32Service {
protected String serviceName;
private ServiceMain serviceMain;
private ServiceControl serviceControl;
private Pointer serviceStatusHandle;
private Object waitObject = new Object();
/**
* Creates a new instance of Win32Service.
*
* @param serviceName internal name of the service
*/
public Win32Service(String serviceName) {
this.serviceName = serviceName;
}
/**
* Install the service.
*
* @param displayName visible name
* @param description description
* @param dependencies array of other services to depend on or null
* @param account service account or null for LocalSystem
* @param password password for service account or null
* @throws java.lang.Exception
* @return true on success
*/
public boolean install(String displayName, String description, String[] dependencies, String account, String password) {
return(install(displayName, description, dependencies, account, password, "java.exe -cp \"" +
System.getProperty("java.class.path") + "\" -Xrs " + this.getClass().getName()));
}
/**
* Install the service.
*
* @return true on success
* @param displayName visible name
* @param description description
* @param dependencies array of other services to depend on or null
* @param account service account or null for LocalSystem
* @param password password for service account or null
* @param command command line to start the service
* @throws java.lang.Exception
*/
public boolean install(String displayName, String description, String[] dependencies, String account, String password, String command) {
Advapi32 advapi32;
Advapi32.SERVICE_DESCRIPTION desc;
Pointer serviceManager, service;
boolean success = false;
String dep = "";
if(dependencies != null) {
for(String s : dependencies) {
dep += s + "\0";
}
}
dep += "\0";
desc = new Advapi32.SERVICE_DESCRIPTION();
desc.lpDescription = description;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
if(serviceManager != null) {
service = advapi32.CreateService(serviceManager, serviceName, displayName,
WINSVC.SERVICE_ALL_ACCESS, WINSVC.SERVICE_WIN32_OWN_PROCESS, WINSVC.SERVICE_DEMAND_START,
WINSVC.SERVICE_ERROR_NORMAL,
command,
null, null, dep, account, password);
if(service != null) {
success = advapi32.ChangeServiceConfig2(service, WINSVC.SERVICE_CONFIG_DESCRIPTION, desc);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Uninstall the service.
*
* @throws java.lang.Exception
* @return true on success
*/
public boolean uninstall() {
Advapi32 advapi32;
Pointer serviceManager, service;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINSVC.SC_MANAGER_ALL_ACCESS);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINSVC.SERVICE_ALL_ACCESS);
if(service != null) {
success = advapi32.DeleteService(service);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Ask the ServiceControlManager to start the service.
* @return true on success
*/
public boolean start() {
Advapi32 advapi32;
Pointer serviceManager, service;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
if(service != null) {
success = advapi32.StartService(service, 0, null);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Ask the ServiceControlManager to stop the service.
* @return true on success
*/
public boolean stop() throws Exception {
Advapi32 advapi32;
Pointer serviceManager, service;
Advapi32.SERVICE_STATUS serviceStatus;
boolean success = false;
advapi32 = Advapi32.INSTANCE;
serviceManager = openServiceControlManager(null, WINNT.GENERIC_EXECUTE);
if(serviceManager != null) {
service = advapi32.OpenService(serviceManager, serviceName, WINNT.GENERIC_EXECUTE);
if(service != null) {
serviceStatus = new Advapi32.SERVICE_STATUS();
success = advapi32.ControlService(service, WINSVC.SERVICE_CONTROL_STOP, serviceStatus);
advapi32.CloseServiceHandle(service);
}
advapi32.CloseServiceHandle(serviceManager);
}
return(success);
}
/**
* Initialize the service, connect to the ServiceControlManager.
*/
public void init() {
Advapi32 advapi32;
Advapi32.SERVICE_TABLE_ENTRY entry;
serviceMain = new ServiceMain();
advapi32 = Advapi32.INSTANCE;
entry = new Advapi32.SERVICE_TABLE_ENTRY();
entry.lpServiceName = serviceName;
entry.lpServiceProc = serviceMain;
advapi32.StartServiceCtrlDispatcher(entry.toArray(2));
}
/**
* Get a handle to the ServiceControlManager.
*
* @param machine name of the machine or null for localhost
* @param access access flags
* @return handle to ServiceControlManager or null when failed
*/
private Pointer openServiceControlManager(String machine, int access) {
Pointer handle = null;
Advapi32 advapi32;
advapi32 = Advapi32.INSTANCE;
handle = advapi32.OpenSCManager(machine, null, access);
return(handle);
}
/**
* Report service status to the ServiceControlManager.
*
* @param status status
* @param win32ExitCode exit code
* @param waitHint time to wait
*/
private void reportStatus(int status, int win32ExitCode, int waitHint) {
Advapi32 advapi32;
Advapi32.SERVICE_STATUS serviceStatus;
advapi32 = Advapi32.INSTANCE;
serviceStatus = new Advapi32.SERVICE_STATUS();
serviceStatus.dwServiceType = WINNT.SERVICE_WIN32_OWN_PROCESS;
serviceStatus.dwControlsAccepted = WINSVC.SERVICE_ACCEPT_STOP | WINSVC.SERVICE_ACCEPT_SHUTDOWN;
serviceStatus.dwWin32ExitCode = win32ExitCode;
serviceStatus.dwWaitHint = waitHint;
serviceStatus.dwCurrentState = status;
advapi32.SetServiceStatus(serviceStatusHandle, serviceStatus);
}
/**
* Called when service is starting.
*/
public abstract void onStart();
/*
* Called when service should stop.
*/
public abstract void onStop();
/**
* Implementation of the service main function.
*/
private class ServiceMain implements Advapi32.SERVICE_MAIN_FUNCTION {
/**
* Called when the service is starting.
*
* @param dwArgc number of arguments
* @param lpszArgv pointer to arguments
*/
public void callback(int dwArgc, Pointer lpszArgv) {
Advapi32 advapi32;
advapi32 = Advapi32.INSTANCE;
serviceControl = new ServiceControl();
serviceStatusHandle = advapi32.RegisterServiceCtrlHandlerEx(serviceName, serviceControl, null);
reportStatus(WINSVC.SERVICE_START_PENDING, WINERROR.NO_ERROR, 3000);
reportStatus(WINSVC.SERVICE_RUNNING, WINERROR.NO_ERROR, 0);
onStart();
try {
synchronized(waitObject) {
waitObject.wait();
}
} catch (InterruptedException ex) {
}
reportStatus(WINSVC.SERVICE_STOPPED, WINERROR.NO_ERROR, 0);
// Avoid returning from ServiceMain, which will cause a crash
// See http://support.microsoft.com/kb/201349, which recommends
// having init() wait for this thread.
// Waiting on this thread in init() won't fix the crash, though.
//System.exit(0);
}
}
/**
* Implementation of the service control function.
*/
private class ServiceControl implements Advapi32.HandlerEx {
/**
* Called when the service get a control code.
*
* @param dwControl
* @param dwEventType
* @param lpEventData
* @param lpContext
*/
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext) {
switch(dwControl) {
case WINSVC.SERVICE_CONTROL_STOP:
case WINSVC.SERVICE_CONTROL_SHUTDOWN:
reportStatus(WINSVC.SERVICE_STOP_PENDING, WINERROR.NO_ERROR, 5000);
onStop();
synchronized(waitObject) {
waitObject.notifyAll();
}
}
return WINERROR.NO_ERROR;
}
}
}
+140 -89
Ver Arquivo
@@ -1,89 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="default" basedir=".">
<description>Builds, tests, and runs the project platform.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JnaContrib-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<condition property="tests.platform" value="test-win32">
<os family="windows"/>
</condition>
<condition property="tests.platform" value="test-osx">
<os family="mac"/>
</condition>
<target name="test" depends="init,compile-test" description="Run unit tests." if="tests.platform">
<antcall target="${tests.platform}" />
</target>
<target name="test-report">
<junitreport todir="${build.test.results.dir}">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${build.test.results.dir}"/>
</junitreport>
<property name="build.test.results.dir.abs" location="${build.test.results.dir}"/>
<echo message="View test report in file://${build.test.results.dir.abs}/index.html" />
</target>
<target name="test-osx">
<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" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="default" basedir=".">
<description>Builds and tests platform-specific code.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JnaContrib-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<target name="test" depends="init,compile,compile-test,-pre-test-run" description="Run platform unit tests.">
<echo>Running platform tests: ${test.src.dir}</echo>
<property name="test.fork" value="yes"/>
<property name="build.test.results.dir.abs" location="${build.test.results.dir}"/>
<mkdir dir="${build.test.results.dir.abs}"/>
<echo>Saving test results in ${build.test.results.dir.abs}</echo>
<condition property="tests.platform" value="**/mac/**">
<os family="mac"/>
</condition>
<condition property="tests.platform" value="**/win32/**">
<os family="windows"/>
</condition>
<condition property="tests.platform" value="**/unix/**">
<os family="unix"/>
</condition>
<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>
<condition property="vmopt.arch" value="-d64" else="-Dignore">
<and>
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
<not><os family="windows"/></not>
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</and>
</condition>
<propertyset id="headless">
<propertyref prefix="java.awt.headless"/>
</propertyset>
<echo>tests.platform=${tests.platform}</echo>
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build.dir}">
<!-- optionally run headless -->
<syspropertyset refid="headless"/>
<!-- avoid VM conflicts with JNA protected mode -->
<env key="${ld.preload.name}" file="${libjsig}"/>
<!-- Ignore any system install of JNA -->
<sysproperty key="jna.nosys" value="true"/>
<!-- Avoid VM crashes, if possible -->
<sysproperty key="jna.protected" value="true"/>
<sysproperty key="jna.builddir" file="${file.reference.jna.build}"/>
<jvmarg value="${vmopt.arch}"/>
<classpath><path path="${run.test.classpath}"/></classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" excludes="${tests.exclude-patterns}">
<!-- Until StructureFieldOrderTest gets fixed up a little -->
<exclude name="**/StructureFieldOrderTest.java"/>
<include name="com/sun/jna/platform/*Test.java"/>
<include name="${tests.platform}"/>
<exclude name="${tests.exclude}"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${build.test.results.dir}">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${build.test.results.dir}"/>
</junitreport>
<echo message="View test report in file://${build.test.results.dir.abs}/index.html" />
<fail if="testfailure">One or more tests failed</fail>
</target>
<!-- One-off test to check field order definitions -->
<target name="test-field-order" 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"/>
</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>
@@ -21,6 +21,7 @@ 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;
@@ -31,7 +32,7 @@ import com.sun.jna.ptr.PointerByReference;
* 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;
@@ -1,57 +1,86 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.mac;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.platform.FileUtils;
public class MacFileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public interface FileManager extends Library {
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);
}
public void moveToTrash(File[] files) throws IOException {
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List<File> failed = new ArrayList<File>();
for (int i=0;i < files.length;i++) {
File src = files[i];
if (FileManager.INSTANCE.FSPathMoveObjectToTrashSync(src.getAbsolutePath(), null, 0) != 0) {
failed.add(src);
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
}
}
/* 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.mac;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.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 {
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;
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 {
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List<String> failed = new ArrayList<String>();
for (int i=0;i < files.length;i++) {
File src = files[i];
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) {
throw new IOException("The following files could not be trashed: " + failed);
}
}
}
@@ -1598,7 +1598,7 @@ public interface X11 extends Library {
public Window event;
public Window window;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window" }); }
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window" }); }
}
class XUnmapEvent extends Structure {
@@ -1610,7 +1610,7 @@ public interface X11 extends Library {
public Window window;
public int from_configure;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "from_configure" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "from_configure" });
}
}
@@ -1623,7 +1623,7 @@ public interface X11 extends Library {
public Window window;
public int override_redirect; // boolean, is override set...
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "override_redirect" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "override_redirect" });
}
}
@@ -1635,7 +1635,7 @@ public interface X11 extends Library {
public Window parent;
public Window window;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window" });
}
}
@@ -1650,7 +1650,7 @@ public interface X11 extends Library {
public int x, y;
public int override_redirect;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "x", "y", "override_redirect" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "parent", "x", "y", "override_redirect" });
}
}
@@ -1667,7 +1667,7 @@ public interface X11 extends Library {
public Window above;
public int override_redirect;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "x", "y", "width", "height", "border_width", "above", "override_redirect" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y", "width", "height", "border_width", "above", "override_redirect" });
}
}
@@ -1680,7 +1680,7 @@ public interface X11 extends Library {
public Window window;
public int x, y;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "x", "y" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y" });
}
}
@@ -1710,7 +1710,7 @@ public interface X11 extends Library {
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", "window", "x", "y", "width", "height", "above", "detail", "value_mask" });
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "above", "detail", "value_mask" });
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,127 +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 com.sun.jna.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on basetsd.h (various types)
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision.
* Use when casting a pointer to a long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* PULONG_PTR
*/
public static class ULONG_PTRByReference extends ByReference {
public ULONG_PTRByReference() {
this(new ULONG_PTR(0));
}
public ULONG_PTRByReference(ULONG_PTR value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(ULONG_PTR value) {
if (Pointer.SIZE == 4) {
getPointer().setInt(0, value.intValue());
}
else {
getPointer().setLong(0, value.longValue());
}
}
public ULONG_PTR getValue() {
return new ULONG_PTR(Pointer.SIZE == 4
? getPointer().getInt(0)
: getPointer().getLong(0));
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point.
* Use for a count that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on basetsd.h (various types)
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision.
* Use when casting a pointer to a long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* PULONG_PTR
*/
public static class ULONG_PTRByReference extends ByReference {
public ULONG_PTRByReference() {
this(new ULONG_PTR(0));
}
public ULONG_PTRByReference(ULONG_PTR value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(ULONG_PTR value) {
if (Pointer.SIZE == 4) {
getPointer().setInt(0, value.intValue());
}
else {
getPointer().setLong(0, value.longValue());
}
}
public ULONG_PTR getValue() {
return new ULONG_PTR(Pointer.SIZE == 4
? getPointer().getInt(0)
: getPointer().getLong(0));
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point.
* Use for a count that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
@@ -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,200 @@
/* 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.Kernel32Util;
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 {
// Initialize COM for this thread...
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED);
if (COMUtils.FAILED(hr)) {
this.release();
throw new COMException("CoInitializeEx() failed: " + Kernel32Util.formatMessage(hr));
}
CLSID clsid = new CLSID();
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
if (COMUtils.FAILED(hr)) {
Ole32.INSTANCE.CoUninitialize();
throw new COMException("CLSIDFromProgID() failed: " + Kernel32Util.formatMessage(hr));
}
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,354 @@
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;
/**
* 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) {
super(pvInstance);
}
/**
* Query interface.
*
* @param riid
* the riid
* @param ppvObject
* the ppv object
* @return the hresult
*/
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
Pointer base = this.getPointer();
Pointer vptr = base.getPointer(0);
Pointer root = vptr.getPointer(0);
Function func = Function.getFunction(root);
int hr = func.invokeInt(new Object[] { base, 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() });
}
}
@@ -1,112 +1,112 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Crypt32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
* structure. Typically, only a user with the same logon credential as the encrypter
* can decrypt the data. In addition, the encryption and decryption usually must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
* @param szDataDescr
* String with a readable description of the data to be encrypted. This description
* string is included with the encrypted data. This parameter is optional and can
* be set to NULL, except on Windows 2000.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
* phase must also be used in the decryption phase. This parameter can be set to NULL
* for no additional entropy.
* @param pvReserved
* Reserved for future use and must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL in both the encryption and decryption
* phases.
* @param dwFlags
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
* CRYPTPROTECT_VERIFY_PROTECTION.
* @param pDataOut
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
* finished using the DATA_BLOB structure, free its pbData member by calling the
* LocalFree function.
* @return
* If the function succeeds, the function returns TRUE. If the function fails,
* it returns FALSE. For extended error information, call GetLastError.
*/
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
/**
* The CryptUnprotectData function decrypts and does an integrity check of the data in
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
* encrypter can decrypt the data. In addition, the encryption and decryption must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
* structure's cbData member holds the length of the pbData member's byte string that
* contains the text to be encrypted.
* @param szDataDescr
* Pointer to a string-readable description of the encrypted data included with the
* encrypted data. This parameter can be set to NULL. When you have finished using
* ppszDataDescr, free it by calling the LocalFree function.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used when the data was encrypted. This parameter can be set to NULL;
* however, if an optional entropy DATA_BLOB structure was used in the encryption
* phase, that same DATA_BLOB structure must be used for the decryption phase.
* @param pvReserved
* Reserved for future use; must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL.
* @param dwFlags
* DWORD value that specifies options for this function. This parameter can be zero,
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
* @param pDataOut
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
* When you have finished using the DATA_BLOB structure, free its pbData member by
* calling the LocalFree function.
* @return
* If the function succeeds, the return value is TRUE. If the function fails, the
* return value is FALSE.
*/
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
}
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Crypt32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
* structure. Typically, only a user with the same logon credential as the encrypter
* can decrypt the data. In addition, the encryption and decryption usually must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
* @param szDataDescr
* String with a readable description of the data to be encrypted. This description
* string is included with the encrypted data. This parameter is optional and can
* be set to NULL, except on Windows 2000.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
* phase must also be used in the decryption phase. This parameter can be set to NULL
* for no additional entropy.
* @param pvReserved
* Reserved for future use and must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL in both the encryption and decryption
* phases.
* @param dwFlags
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
* CRYPTPROTECT_VERIFY_PROTECTION.
* @param pDataOut
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
* finished using the DATA_BLOB structure, free its pbData member by calling the
* LocalFree function.
* @return
* If the function succeeds, the function returns TRUE. If the function fails,
* it returns FALSE. For extended error information, call GetLastError.
*/
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
/**
* The CryptUnprotectData function decrypts and does an integrity check of the data in
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
* encrypter can decrypt the data. In addition, the encryption and decryption must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
* structure's cbData member holds the length of the pbData member's byte string that
* contains the text to be encrypted.
* @param szDataDescr
* Pointer to a string-readable description of the encrypted data included with the
* encrypted data. This parameter can be set to NULL. When you have finished using
* ppszDataDescr, free it by calling the LocalFree function.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used when the data was encrypted. This parameter can be set to NULL;
* however, if an optional entropy DATA_BLOB structure was used in the encryption
* phase, that same DATA_BLOB structure must be used for the decryption phase.
* @param pvReserved
* Reserved for future use; must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL.
* @param dwFlags
* DWORD value that specifies options for this function. This parameter can be zero,
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
* @param pDataOut
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
* When you have finished using the DATA_BLOB structure, free its pbData member by
* calling the LocalFree function.
* @return
* If the function succeeds, the return value is TRUE. If the function fails, the
* return value is FALSE.
*/
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
}
@@ -1,140 +1,140 @@
/* 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.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
/**
* Crypt32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Crypt32Util {
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data) {
return cryptProtectData(data, 0);
}
/**
* Protect a blob of data with optional flags.
* @param data
* Data to protect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data, int flags) {
return cryptProtectData(data, null, flags, "", null);
}
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param description
* Optional description.
* @param prompt
* Prompt structure.
* @return
* Protected bytes.
*/
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataProtected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
try {
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
pEntropy, null, prompt, flags, pDataProtected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataProtected.getData();
} finally {
if (pDataProtected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
}
}
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data) {
return cryptUnprotectData(data, 0);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, int flags) {
return cryptUnprotectData(data, null, flags, null);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param prompt
* Optional prompt structure.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataUnprotected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
PointerByReference pDescription = new PointerByReference();
try {
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
pEntropy, null, prompt, flags, pDataUnprotected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataUnprotected.getData();
} finally {
if (pDataUnprotected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
}
if (pDescription.getValue() != null) {
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
}
}
}
/* 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.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
/**
* Crypt32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Crypt32Util {
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data) {
return cryptProtectData(data, 0);
}
/**
* Protect a blob of data with optional flags.
* @param data
* Data to protect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data, int flags) {
return cryptProtectData(data, null, flags, "", null);
}
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param description
* Optional description.
* @param prompt
* Prompt structure.
* @return
* Protected bytes.
*/
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataProtected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
try {
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
pEntropy, null, prompt, flags, pDataProtected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataProtected.getData();
} finally {
if (pDataProtected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
}
}
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data) {
return cryptUnprotectData(data, 0);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, int flags) {
return cryptUnprotectData(data, null, flags, null);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param prompt
* Optional prompt structure.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataUnprotected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
PointerByReference pDescription = new PointerByReference();
try {
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
pEntropy, null, prompt, flags, pDataUnprotected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataUnprotected.getData();
} finally {
if (pDataUnprotected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
}
if (pDescription.getValue() != null) {
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
}
}
}
}
@@ -0,0 +1,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" });
}
}
}
@@ -1,220 +1,220 @@
/* 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.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from DsGetDC.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface DsGetDC extends StdCallLibrary {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
* function to receive data about a domain controller.
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
public DOMAIN_CONTROLLER_INFO() { }
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated WString that specifies the computer name
* of the discovered domain controller. The returned computer name is
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
* is returned, if available. If the DNS-style name is not available, the
* flat-style name (for example, "\\phoenix") is returned. This example would apply
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
* IP family of protocols.
*/
public WString DomainControllerName;
/**
* Pointer to a null-terminated WString that specifies the address of the discovered
* domain controller. The address is prefixed with "\\". This WString is one of the
* types defined by the DomainControllerAddressType member.
*/
public WString DomainControllerAddress;
/**
* Indicates the type of WString that is contained in the DomainControllerAddress member.
*/
public int DomainControllerAddressType;
/**
* The GUID of the domain. This member is zero if the domain controller does not have
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
* controller.
*/
public GUID DomainGuid;
/**
* Pointer to a null-terminated WString that specifies the name of the domain. The
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
* the flat-style name, for example, "fabrikam", is returned. This name may be different
* than the requested domain name if the domain has been renamed.
*/
public WString DomainName;
/**
* Pointer to a null-terminated WString that specifies the name of the domain at the root
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
*/
public WString DnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int Flags;
/**
* Pointer to a null-terminated WString that specifies the name of the site where the
* domain controller is located. This member may be NULL if the domain controller is
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
* controller.
*/
public WString DcSiteName;
/**
* Pointer to a null-terminated WString that specifies the name of the site that the
* computer belongs to. The computer is specified in the ComputerName parameter passed
* to DsGetDcName. This member may be NULL if the site that contains the computer
* cannot be found; for example, if the DS administrator has not associated the
* subnet that the computer is in with a valid site.
*/
public WString ClientSiteName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
}
}
/**
* Pointer to DOMAIN_CONTROLLER_INFO.
*/
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dci" });
}
}
/**
* Domain is a member of the forest.
*/
int DS_DOMAIN_IN_FOREST = 0x0001;
/**
* Domain is directly trusted.
*/
int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
/**
* Domain is root of a tree in the forest.
*/
int DS_DOMAIN_TREE_ROOT = 0x0004;
/**
* Domain is the primary domain of queried server.
*/
int DS_DOMAIN_PRIMARY = 0x0008;
/**
* Primary domain is running in native mode.
*/
int DS_DOMAIN_NATIVE_MODE = 0x0010;
/**
* Domain is directly trusting.
*/
int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
/**
* Valid domain flags.
*/
int DS_DOMAIN_VALID_FLAGS =
DS_DOMAIN_IN_FOREST |
DS_DOMAIN_DIRECT_OUTBOUND |
DS_DOMAIN_TREE_ROOT |
DS_DOMAIN_PRIMARY |
DS_DOMAIN_NATIVE_MODE |
DS_DOMAIN_DIRECT_INBOUND;
/**
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
* contain trust data for a domain.
*/
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
*/
public WString NetbiosDomainName;
/**
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
*/
public WString DnsDomainName;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public 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 int ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public int TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public int TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID.ByReference DomainSid;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
}
public DS_DOMAIN_TRUSTS() {
}
public DS_DOMAIN_TRUSTS(Pointer p) {
super(p);
read();
}
};
}
/* 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.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from DsGetDC.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface DsGetDC extends StdCallLibrary {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
* function to receive data about a domain controller.
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
public DOMAIN_CONTROLLER_INFO() { }
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated WString that specifies the computer name
* of the discovered domain controller. The returned computer name is
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
* is returned, if available. If the DNS-style name is not available, the
* flat-style name (for example, "\\phoenix") is returned. This example would apply
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
* IP family of protocols.
*/
public WString DomainControllerName;
/**
* Pointer to a null-terminated WString that specifies the address of the discovered
* domain controller. The address is prefixed with "\\". This WString is one of the
* types defined by the DomainControllerAddressType member.
*/
public WString DomainControllerAddress;
/**
* Indicates the type of WString that is contained in the DomainControllerAddress member.
*/
public int DomainControllerAddressType;
/**
* The GUID of the domain. This member is zero if the domain controller does not have
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
* controller.
*/
public GUID DomainGuid;
/**
* Pointer to a null-terminated WString that specifies the name of the domain. The
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
* the flat-style name, for example, "fabrikam", is returned. This name may be different
* than the requested domain name if the domain has been renamed.
*/
public WString DomainName;
/**
* Pointer to a null-terminated WString that specifies the name of the domain at the root
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
*/
public WString DnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int Flags;
/**
* Pointer to a null-terminated WString that specifies the name of the site where the
* domain controller is located. This member may be NULL if the domain controller is
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
* controller.
*/
public WString DcSiteName;
/**
* Pointer to a null-terminated WString that specifies the name of the site that the
* computer belongs to. The computer is specified in the ComputerName parameter passed
* to DsGetDcName. This member may be NULL if the site that contains the computer
* cannot be found; for example, if the DS administrator has not associated the
* subnet that the computer is in with a valid site.
*/
public WString ClientSiteName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
}
}
/**
* Pointer to DOMAIN_CONTROLLER_INFO.
*/
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dci" });
}
}
/**
* Domain is a member of the forest.
*/
int DS_DOMAIN_IN_FOREST = 0x0001;
/**
* Domain is directly trusted.
*/
int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
/**
* Domain is root of a tree in the forest.
*/
int DS_DOMAIN_TREE_ROOT = 0x0004;
/**
* Domain is the primary domain of queried server.
*/
int DS_DOMAIN_PRIMARY = 0x0008;
/**
* Primary domain is running in native mode.
*/
int DS_DOMAIN_NATIVE_MODE = 0x0010;
/**
* Domain is directly trusting.
*/
int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
/**
* Valid domain flags.
*/
int DS_DOMAIN_VALID_FLAGS =
DS_DOMAIN_IN_FOREST |
DS_DOMAIN_DIRECT_OUTBOUND |
DS_DOMAIN_TREE_ROOT |
DS_DOMAIN_PRIMARY |
DS_DOMAIN_NATIVE_MODE |
DS_DOMAIN_DIRECT_INBOUND;
/**
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
* contain trust data for a domain.
*/
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
*/
public WString NetbiosDomainName;
/**
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
*/
public WString DnsDomainName;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public 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 int ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public int TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public int TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID.ByReference DomainSid;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
}
public DS_DOMAIN_TRUSTS() {
}
public DS_DOMAIN_TRUSTS(Pointer p) {
super(p);
read();
}
};
}
@@ -1,100 +1,475 @@
/* 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.Pointer;
import com.sun.jna.Structure;
/**
* 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 ByReference(GUID guid) {
super(guid.getPointer());
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();
}
public GUID(byte[] data) {
if (data.length != 16) {
throw new IllegalArgumentException("Invalid data length: " + data.length);
}
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;
int data2Temp = data[5] & 0xff;
data2Temp <<= 8;
data2Temp |= data[4] & 0xff;
Data2 = (short) data2Temp;
int data3Temp = data[7] & 0xff;
data3Temp <<= 8;
data3Temp |= data[6] & 0xff;
Data3 = (short) data3Temp;
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];
}
public int Data1;
public short Data2;
public short Data3;
public byte[] Data4 = new byte[8];
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Data1", "Data2", "Data3", "Data4" });
}
}
}
/* 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.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
* Ported from Guid.h. Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface Guid {
public final static IID IID_NULL = new IID();
/**
* The Class GUID.
*/
public static class GUID extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends GUID implements
Structure.ByReference {
/**
* Instantiates a new by reference.
*/
public ByReference() {
}
/**
* Instantiates a new by reference.
*
* @param guid
* the guid
*/
public ByReference(GUID guid) {
super(guid.getPointer());
Data1 = guid.Data1;
Data2 = guid.Data2;
Data3 = guid.Data3;
Data4 = guid.Data4;
}
/**
* Instantiates a new by reference.
*
* @param memory
* the memory
*/
public ByReference(Pointer memory) {
super(memory);
}
}
/** The Data1. */
public int Data1;
/** The Data2. */
public short Data2;
/** 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,228 +1,338 @@
/* 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.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.LastErrorException;
import com.sun.jna.Native;
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
*/
public abstract class Kernel32Util implements WinDef {
/**
* Get current computer NetBIOS name.
* @return
* Netbios name.
*/
public static String getComputerName() {
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
IntByReference lpnSize = new IntByReference(buffer.length);
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Format a message from an HRESULT.
* @param code
* HRESULT
* @return
* Formatted message.
*/
public static String formatMessageFromHR(HRESULT code) {
PointerByReference buffer = new PointerByReference();
if (0 == Kernel32.INSTANCE.FormatMessage(
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
null,
code.intValue(),
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
buffer,
0,
null)) {
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
}
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
Kernel32.INSTANCE.LocalFree(buffer.getValue());
return s.trim();
}
/**
* Format a system message from an error code.
* @param code
* Error code, typically a result of GetLastError.
* @return
* Formatted message.
*/
public static String formatMessageFromLastErrorCode(int code) {
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
}
/**
* Return the path designated for temporary files.
* @return
* Path.
*/
public static String getTempPath() {
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
char[] buffer = new char[nBufferLength.intValue()];
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
public static void deleteFile(String filename) {
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Returns valid drives in the system.
* @return
* An array of valid drives.
*/
public static String[] getLogicalDriveStrings() {
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
char buf[] = new char[dwSize.intValue()];
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
List<String> drives = new ArrayList<String>();
String drive = "";
// the buffer is double-null-terminated
for(int i = 0; i < buf.length - 1; i++) {
if (buf[i] == 0) {
drives.add(drive);
drive = "";
} else {
drive += buf[i];
}
}
return drives.toArray(new String[0]);
}
/**
* Retrieves file system attributes for a specified file or directory.
* @param fileName
* The name of the file or directory.
* @return
* The attributes of the specified file or directory.
*/
public static int getFileAttributes(String fileName) {
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return fileAttributes;
}
/**
* Retrieves the result of GetFileType, provided the file exists.
*/
public static int getFileType(String fileName) throws FileNotFoundException {
File f = new File(fileName);
if (!f.exists()) {
throw new FileNotFoundException(fileName);
}
HANDLE hFile = null;
try {
hFile = Kernel32.INSTANCE.CreateFile(fileName,
WinNT.GENERIC_READ,
WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(),
WinNT.OPEN_EXISTING,
WinNT.FILE_ATTRIBUTE_NORMAL,
new HANDLEByReference().getValue());
if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
int type = Kernel32.INSTANCE.GetFileType(hFile);
switch(type) {
case WinNT.FILE_TYPE_UNKNOWN:
int err = Kernel32.INSTANCE.GetLastError();
switch(err) {
case W32Errors.NO_ERROR:
break;
default:
throw new Win32Exception(err);
}
// fall-thru
default:
return type;
}
} finally {
if (hFile != null) {
if (! Kernel32.INSTANCE.CloseHandle(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
}
/**
* @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);
}
}
/* 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.LastErrorException;
import com.sun.jna.Memory;
import com.sun.jna.Native;
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 {
/**
* Get current computer NetBIOS name.
* @return
* Netbios name.
*/
public static String getComputerName() {
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
IntByReference lpnSize = new IntByReference(buffer.length);
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Format a message from the value obtained from {@link
* Kernel32#GetLastError} or {@link Native#getLastError}.
* @param code
* int
* @return
* Formatted message.
*/
public static String formatMessage(int code) {
PointerByReference buffer = new PointerByReference();
if (0 == Kernel32.INSTANCE.FormatMessage(
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
null,
code,
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
buffer,
0,
null)) {
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
}
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
Kernel32.INSTANCE.LocalFree(buffer.getValue());
return s.trim();
}
/**
* Format a message from an HRESULT.
* @param code
* HRESULT
* @return
* Formatted message.
*/
public static String formatMessage(HRESULT code) {
return formatMessage(code.intValue());
}
/** @deprecated use {@link #formatMessage(WinNT.HRESULT)} instead. */
public static String formatMessageFromHR(HRESULT code) {
return formatMessage(code.intValue());
}
/**
* Format a system message from an error code.
* @param code
* Error code, typically a result of GetLastError.
* @return
* Formatted message.
*/
public static String formatMessageFromLastErrorCode(int code) {
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
}
/**
* Return the path designated for temporary files.
* @return
* Path.
*/
public static String getTempPath() {
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
char[] buffer = new char[nBufferLength.intValue()];
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
public static void deleteFile(String filename) {
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Returns valid drives in the system.
* @return
* An array of valid drives.
*/
public static String[] getLogicalDriveStrings() {
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
char buf[] = new char[dwSize.intValue()];
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
List<String> drives = new ArrayList<String>();
String drive = "";
// the buffer is double-null-terminated
for(int i = 0; i < buf.length - 1; i++) {
if (buf[i] == 0) {
drives.add(drive);
drive = "";
} else {
drive += buf[i];
}
}
return drives.toArray(new String[0]);
}
/**
* Retrieves file system attributes for a specified file or directory.
* @param fileName
* The name of the file or directory.
* @return
* The attributes of the specified file or directory.
*/
public static int getFileAttributes(String fileName) {
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return fileAttributes;
}
/**
* Retrieves the result of GetFileType, provided the file exists.
*/
public static int getFileType(String fileName) throws FileNotFoundException {
File f = new File(fileName);
if (!f.exists()) {
throw new FileNotFoundException(fileName);
}
HANDLE hFile = null;
try {
hFile = Kernel32.INSTANCE.CreateFile(fileName,
WinNT.GENERIC_READ,
WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(),
WinNT.OPEN_EXISTING,
WinNT.FILE_ATTRIBUTE_NORMAL,
new HANDLEByReference().getValue());
if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
int type = Kernel32.INSTANCE.GetFileType(hFile);
switch(type) {
case WinNT.FILE_TYPE_UNKNOWN:
int err = Kernel32.INSTANCE.GetLastError();
switch(err) {
case WinError.NO_ERROR:
break;
default:
throw new Win32Exception(err);
}
// fall-thru
default:
return type;
}
} finally {
if (hFile != null) {
if (! Kernel32.INSTANCE.CloseHandle(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
}
/**
* @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());
}
/**
* Convenience method to get the processor information. Takes care of auto-growing the array.
*
* @return the array of processor information.
*/
public static final WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] getLogicalProcessorInformation()
{
int sizePerStruct = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION().size();
WinDef.DWORDByReference bufferSize = new WinDef.DWORDByReference(new WinDef.DWORD(sizePerStruct));
Memory memory;
while (true)
{
memory = new Memory(bufferSize.getValue().intValue());
if (! Kernel32.INSTANCE.GetLogicalProcessorInformation(memory, bufferSize))
{
int err = Kernel32.INSTANCE.GetLastError();
if (err != WinError.ERROR_INSUFFICIENT_BUFFER)
throw new Win32Exception(err);
}
else
{
break;
}
}
WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION firstInformation = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION(memory);
int returnedStructCount = bufferSize.getValue().intValue() / sizePerStruct;
return (WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]) firstInformation.toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[returnedStructCount]);
}
}
@@ -411,7 +411,7 @@ public interface LMAccess extends StdCallLibrary {
public int grpi3_attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_id", "grpi3_attributes" });
return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes" });
}
}
@@ -1,244 +1,244 @@
/* 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.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from NTSecApi.h
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface NTSecApi extends StdCallLibrary {
/**
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
* functions to specify a Unicode string.
*/
public static class LSA_UNICODE_STRING extends Structure {
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
}
/**
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
* not including the terminating null character, if any.
*/
public short Length;
/**
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
* MaximumLength bytes can be written into the buffer without trampling memory.
*/
public short MaximumLength;
/**
* Pointer to a wide character string. Note that the strings returned by the
* various LSA functions might not be null terminated.
*/
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" });
}
/**
* String representation of the buffer.
* @return
* Unicode string.
*/
public String getString() {
byte[] data = Buffer.getByteArray(0, Length);
if (data.length < 2 || data[data.length - 1] != 0) {
Memory newdata = new Memory(data.length + 2);
newdata.write(0, data, 0, data.length);
return newdata.getString(0, true);
}
return Buffer.getString(0, true);
}
}
/**
* Pointer to an LSA_UNICODE_STRING.
*/
public static class PLSA_UNICODE_STRING {
public static class ByReference extends PLSA_UNICODE_STRING
implements Structure.ByReference {
}
public LSA_UNICODE_STRING.ByReference s;
}
/**
* Record contains an included top-level name.
*/
int ForestTrustTopLevelName = 0;
/**
* Record contains an excluded top-level name.
*/
int ForestTrustTopLevelNameEx = 1;
/**
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
*/
int ForestTrustDomainInfo = 2;
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
public PSID.ByReference Sid;
public LSA_UNICODE_STRING DnsName;
public LSA_UNICODE_STRING NetbiosName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" });
}
}
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
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 {
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
public LSA_UNICODE_STRING TopLevelName;
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
public LSA_FOREST_TRUST_BINARY_DATA Data;
}
/**
* Flags that control the behavior of the operation.
*/
public int Flags;
/**
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
* The following table shows the possible values.
* ForestTrustTopLevelName
* Record contains an included top-level name.
* ForestTrustTopLevelNameEx
* Record contains an excluded top-level name.
* ForestTrustDomainInfo
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
* ForestTrustRecordTypeLast
* Marks the end of an enumeration.
*/
public int ForestTrustType;
public LARGE_INTEGER Time;
/**
* Data type depending on ForestTrustType.
*/
public UNION u;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" });
}
public void read() {
super.read();
switch(ForestTrustType) {
case NTSecApi.ForestTrustTopLevelName:
case NTSecApi.ForestTrustTopLevelNameEx:
u.setType(LSA_UNICODE_STRING.class);
break;
case NTSecApi.ForestTrustDomainInfo:
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
break;
default:
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
break;
}
u.read();
}
}
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public LSA_FOREST_TRUST_RECORD.ByReference tr;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "tr" });
}
}
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
/**
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
* Entries member.
*/
public 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);
}
}
/**
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
* forest trust information.
*/
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fti" });
}
}
}
/* 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.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from NTSecApi.h
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface NTSecApi extends StdCallLibrary {
/**
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
* functions to specify a Unicode string.
*/
public static class LSA_UNICODE_STRING extends Structure {
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
}
/**
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
* not including the terminating null character, if any.
*/
public short Length;
/**
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
* MaximumLength bytes can be written into the buffer without trampling memory.
*/
public short MaximumLength;
/**
* Pointer to a wide character string. Note that the strings returned by the
* various LSA functions might not be null terminated.
*/
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" });
}
/**
* String representation of the buffer.
* @return
* Unicode string.
*/
public String getString() {
byte[] data = Buffer.getByteArray(0, Length);
if (data.length < 2 || data[data.length - 1] != 0) {
Memory newdata = new Memory(data.length + 2);
newdata.write(0, data, 0, data.length);
return newdata.getString(0, true);
}
return Buffer.getString(0, true);
}
}
/**
* Pointer to an LSA_UNICODE_STRING.
*/
public static class PLSA_UNICODE_STRING {
public static class ByReference extends PLSA_UNICODE_STRING
implements Structure.ByReference {
}
public LSA_UNICODE_STRING.ByReference s;
}
/**
* Record contains an included top-level name.
*/
int ForestTrustTopLevelName = 0;
/**
* Record contains an excluded top-level name.
*/
int ForestTrustTopLevelNameEx = 1;
/**
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
*/
int ForestTrustDomainInfo = 2;
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
public PSID.ByReference Sid;
public LSA_UNICODE_STRING DnsName;
public LSA_UNICODE_STRING NetbiosName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" });
}
}
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
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 {
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
public LSA_UNICODE_STRING TopLevelName;
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
public LSA_FOREST_TRUST_BINARY_DATA Data;
}
/**
* Flags that control the behavior of the operation.
*/
public int Flags;
/**
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
* The following table shows the possible values.
* ForestTrustTopLevelName
* Record contains an included top-level name.
* ForestTrustTopLevelNameEx
* Record contains an excluded top-level name.
* ForestTrustDomainInfo
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
* ForestTrustRecordTypeLast
* Marks the end of an enumeration.
*/
public int ForestTrustType;
public LARGE_INTEGER Time;
/**
* Data type depending on ForestTrustType.
*/
public UNION u;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" });
}
public void read() {
super.read();
switch(ForestTrustType) {
case NTSecApi.ForestTrustTopLevelName:
case NTSecApi.ForestTrustTopLevelNameEx:
u.setType(LSA_UNICODE_STRING.class);
break;
case NTSecApi.ForestTrustDomainInfo:
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
break;
default:
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
break;
}
u.read();
}
}
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public LSA_FOREST_TRUST_RECORD.ByReference tr;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "tr" });
}
}
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
/**
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
* Entries member.
*/
public 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);
}
}
/**
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
* forest trust information.
*/
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fti" });
}
}
}
@@ -1,431 +1,431 @@
/* 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.
*/
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Netapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves join status information for the specified computer.
*
* @param lpServer
* Specifies the DNS or NetBIOS name of the computer on which to
* call the function.
* @param lpNameBuffer
* Receives the NetBIOS name of the domain or workgroup to which
* the computer is joined.
* @param BufferType
* Join status of the specified computer.
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetGetJoinInformation(String lpServer,
PointerByReference lpNameBuffer, IntByReference BufferType);
/**
* Frees the memory that the NetApiBufferAllocate function allocates.
*
* @param buffer
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetApiBufferFree(Pointer buffer);
/**
* Returns information about each local group account on the specified
* server.
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the address of the buffer that receives the
* information structure.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in
* bytes.
* @param entriesread
* Pointer to a value that receives the count of elements
* actually enumerated.
* @param totalentries
* Pointer to a value that receives the approximate total number
* of entries that could have been enumerated from the current
* resume position.
* @param resume_handle
* Pointer to a value that contains a resume handle that is used
* to continue an existing local group search.
* @return If the function succeeds, the return value is NERR_Success.
*/
public int NetLocalGroupEnum(String serverName, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* Returns the name of the primary domain controller (PDC).
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute. If this parameter is NULL, the local computer is used.
* @param domainName
* Specifies the name of the domain.
* @param bufptr
* Receives a string that specifies the server name of the PDC of the domain.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGetDCName(String serverName, String domainName,
PointerByReference bufptr);
/**
* The NetGroupEnum function retrieves information about each global group
* in the security database, which is the security accounts manager (SAM) database or,
* in the case of domain controllers, the Active Directory.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer to receive the global group information structure.
* The format of this data depends on the value of the level parameter.
* @param prefmaxlen
* Specifies the preferred maximum length of the returned data, in bytes.
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
* memory required to hold the data. If you specify another value in this
* parameter, it can restrict the number of bytes that the function returns.
* If the buffer size is insufficient to hold all entries, the function
* returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. The total number of entries
* is only a hint.
* @param resume_handle
* Pointer to a variable that contains a resume handle that is used to continue
* the global group enumeration. The handle should be zero on the first call and
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
* is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserEnum function provides information about all user accounts on a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param filter
* Specifies a value that filters the account types for enumeration.
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends
* on the value of the level parameter. This buffer is allocated by the system and
* must be freed using the NetApiBufferFree function. Note that you must free the
* buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
* required for the data. If you specify another value in this parameter, it can
* restrict the number of bytes that the function returns. If the buffer size is
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. Note that applications should
* consider this value only as a hint.
* @param resume_handle
* Pointer to a value that contains a resume handle which is used to continue an
* existing user search. The handle should be zero on the first call and left
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
* handle is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserGetGroups function retrieves a list of global groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user to search for
* in each group account. For more information, see the following Remarks section.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer that receives the data. This buffer is allocated by the
* system and must be freed using the NetApiBufferFree function. Note that you must
* free the buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number
* of bytes that the function returns. If the buffer size is insufficient to hold
* all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually retrieved.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been retrieved.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetGroups(String servername, String username, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user for which to return
* local group membership information. If the string is of the form DomainName\UserName
* the user name is expected to be found on that domain. If the string is of the form
* UserName, the user name is expected to be found on the server specified by the
* servername parameter.
* @param level
* Specifies the information level of the data.
* @param flags
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
* defined. If this bit is set, the function also returns the names of the local
* groups in which the user is indirectly a member (that is, the user has membership
* in a global group that is itself a member of one or more local groups).
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends on
* the value of the level parameter. This buffer is allocated by the system and must
* be freed using the NetApiBufferFree function. Note that you must free the buffer
* even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number of
* bytes that the function returns. If the buffer size is insufficient to hold all
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
* Management Function Buffers and Network Management Function Buffer Lengths.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been enumerated.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetLocalGroups(String servername, String username, int level,
int flags, PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserAdd function adds a user account and assigns a password and privilege level.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
* on which the function is to execute.
* @param level
* Specifies the information level of the data.
* @param buf
* Pointer to the buffer that specifies the data. The format of this data depends on the
* value of the level parameter.
* @param parm_err
* Pointer to a value that receives the index of the first member of the user information
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
* not returned on error.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserAdd(String servername, int level,
Structure buf, IntByReference parm_err);
/**
* The NetUserDel function deletes a user account from a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user account to delete.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserDel(String servername, String username);
/**
* The NetUserChangePassword function changes a user's password for a specified
* network server or domain.
* @param domainname
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
* server or domain on which the function is to execute. If this parameter is NULL,
* the logon domain of the caller is used.
* @param username
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
* function changes the password for the specified user. If this parameter is NULL,
* the logon name of the caller is used.
* @param oldpassword
* Pointer to a constant string that specifies the user's old password.
* @param newpassword
* Pointer to a constant string that specifies the user's new password.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserChangePassword(String domainname, String username,
String oldpassword, String newpassword);
/**
* The DsGetDcName function returns the name of a domain controller in a specified domain.
* This function accepts additional domain controller selection criteria to indicate
* preference for a domain controller with particular characteristics.
* @param ComputerName
* Pointer to a null-terminated string that specifies the name of the server to process
* this function. Typically, this parameter is NULL, which indicates that the local
* computer is used.
* @param DomainName
* Pointer to a null-terminated string that specifies the name of the domain or application
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
* may be specified with or without a trailing period.
* @param DomainGuid
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
* by DomainGuid.
* @param SiteName
* Pointer to a null-terminated string that specifies the name of the site where the returned
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
* to return a domain controller in the site closest to the site of the computer specified by
* ComputerName. This parameter should be NULL, by default.
* @param Flags
* Contains a set of flags that provide additional data used to process the request.
* @param DomainControllerInfo
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
* This structure is allocated by DsGetDcName. The caller must free the structure using
* the NetApiBufferFree function when it is no longer required.
* @return
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
* If the function fails, the return code is one of ERROR_* values.
*/
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO.ByReference DomainControllerInfo);
/**
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
* @param serverName
* Contains the name of the domain controller that DsGetForestTrustInformationW
* is connected to remotely. The caller must be an authenticated user on this server.
* If this parameter is NULL, the local server is used.
* @param trustedDomainName
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
* trust attribute. If this parameter is NULL, the forest trust data for the domain
* hosted by ServerName is retrieved.
* @param Flags
* Contains a set of flags that modify the behavior of this function.
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
* @param ForestTrustInfo
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
* trust data that describes the namespaces claimed by the domain specified by
* TrustedDomainName. The Time member of all returned records will be zero.
* @return
* Returns NO_ERROR if successful or a Win32 error code otherwise.
*/
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
PLSA_FOREST_TRUST_INFORMATION.ByReference ForestTrustInfo);
/**
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
* @param serverName
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
* obtain the trust information for. This computer must be running the Windows 2000 or later
* operating system. If this parameter is NULL, the name of the local computer is used.
* The caller must be an authenticated user in this domain.
* @param Flags
* Contains a set of flags that determines which domain trusts to enumerate.
* @param Domains
* 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
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
* @return
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
*/
public int DsEnumerateDomainTrusts(String serverName, int Flags,
PointerByReference Domains, IntByReference DomainCount);
/**
* The NetUserGetInfo function retrieves information about a particular user account on a server.
* @param servername
* A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL, the local computer is used.
* @param username
* A pointer to a constant string that specifies the name of the user account for which to return information.
* For more information, see the following Remarks section.
* @param level
* The information level of the data. This parameter can be one of the following values.
* Value Meaning
* 0 Return the user account name. The bufptr parameter points to a USER_INFO_0 structure.
* 1 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure.
* 2 Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure.
* 3 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead.
* 4 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_4 structure. Windows 2000: This level is not supported.
* 10 Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure.
* 11 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure.
* 20 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_20 structure. Note that on Windows XP and later, it is recommended that you use USER_INFO_23 instead.
* 23 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_23 structure. Windows 2000: This level is not supported.
* @param bufptr
* A pointer to the buffer that receives the data.
* The format of this data depends on the value of the level parameter.
* This buffer is allocated by the system and must be freed using the NetApiBufferFree function.
* For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetInfo( String servername, String username, int level, PointerByReference bufptr );
}
import com.sun.jna.Native;
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.Guid.GUID;
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Netapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves join status information for the specified computer.
*
* @param lpServer
* Specifies the DNS or NetBIOS name of the computer on which to
* call the function.
* @param lpNameBuffer
* Receives the NetBIOS name of the domain or workgroup to which
* the computer is joined.
* @param BufferType
* Join status of the specified computer.
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetGetJoinInformation(String lpServer,
PointerByReference lpNameBuffer, IntByReference BufferType);
/**
* Frees the memory that the NetApiBufferAllocate function allocates.
*
* @param buffer
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetApiBufferFree(Pointer buffer);
/**
* Returns information about each local group account on the specified
* server.
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the address of the buffer that receives the
* information structure.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in
* bytes.
* @param entriesread
* Pointer to a value that receives the count of elements
* actually enumerated.
* @param totalentries
* Pointer to a value that receives the approximate total number
* of entries that could have been enumerated from the current
* resume position.
* @param resume_handle
* Pointer to a value that contains a resume handle that is used
* to continue an existing local group search.
* @return If the function succeeds, the return value is NERR_Success.
*/
public int NetLocalGroupEnum(String serverName, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* Returns the name of the primary domain controller (PDC).
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute. If this parameter is NULL, the local computer is used.
* @param domainName
* Specifies the name of the domain.
* @param bufptr
* Receives a string that specifies the server name of the PDC of the domain.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGetDCName(String serverName, String domainName,
PointerByReference bufptr);
/**
* The NetGroupEnum function retrieves information about each global group
* in the security database, which is the security accounts manager (SAM) database or,
* in the case of domain controllers, the Active Directory.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer to receive the global group information structure.
* The format of this data depends on the value of the level parameter.
* @param prefmaxlen
* Specifies the preferred maximum length of the returned data, in bytes.
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
* memory required to hold the data. If you specify another value in this
* parameter, it can restrict the number of bytes that the function returns.
* If the buffer size is insufficient to hold all entries, the function
* returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. The total number of entries
* is only a hint.
* @param resume_handle
* Pointer to a variable that contains a resume handle that is used to continue
* the global group enumeration. The handle should be zero on the first call and
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
* is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserEnum function provides information about all user accounts on a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param filter
* Specifies a value that filters the account types for enumeration.
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends
* on the value of the level parameter. This buffer is allocated by the system and
* must be freed using the NetApiBufferFree function. Note that you must free the
* buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
* required for the data. If you specify another value in this parameter, it can
* restrict the number of bytes that the function returns. If the buffer size is
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. Note that applications should
* consider this value only as a hint.
* @param resume_handle
* Pointer to a value that contains a resume handle which is used to continue an
* existing user search. The handle should be zero on the first call and left
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
* handle is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserGetGroups function retrieves a list of global groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user to search for
* in each group account. For more information, see the following Remarks section.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer that receives the data. This buffer is allocated by the
* system and must be freed using the NetApiBufferFree function. Note that you must
* free the buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number
* of bytes that the function returns. If the buffer size is insufficient to hold
* all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually retrieved.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been retrieved.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetGroups(String servername, String username, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user for which to return
* local group membership information. If the string is of the form DomainName\UserName
* the user name is expected to be found on that domain. If the string is of the form
* UserName, the user name is expected to be found on the server specified by the
* servername parameter.
* @param level
* Specifies the information level of the data.
* @param flags
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
* defined. If this bit is set, the function also returns the names of the local
* groups in which the user is indirectly a member (that is, the user has membership
* in a global group that is itself a member of one or more local groups).
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends on
* the value of the level parameter. This buffer is allocated by the system and must
* be freed using the NetApiBufferFree function. Note that you must free the buffer
* even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number of
* bytes that the function returns. If the buffer size is insufficient to hold all
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
* Management Function Buffers and Network Management Function Buffer Lengths.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been enumerated.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetLocalGroups(String servername, String username, int level,
int flags, PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserAdd function adds a user account and assigns a password and privilege level.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
* on which the function is to execute.
* @param level
* Specifies the information level of the data.
* @param buf
* Pointer to the buffer that specifies the data. The format of this data depends on the
* value of the level parameter.
* @param parm_err
* Pointer to a value that receives the index of the first member of the user information
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
* not returned on error.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserAdd(String servername, int level,
Structure buf, IntByReference parm_err);
/**
* The NetUserDel function deletes a user account from a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user account to delete.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserDel(String servername, String username);
/**
* The NetUserChangePassword function changes a user's password for a specified
* network server or domain.
* @param domainname
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
* server or domain on which the function is to execute. If this parameter is NULL,
* the logon domain of the caller is used.
* @param username
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
* function changes the password for the specified user. If this parameter is NULL,
* the logon name of the caller is used.
* @param oldpassword
* Pointer to a constant string that specifies the user's old password.
* @param newpassword
* Pointer to a constant string that specifies the user's new password.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserChangePassword(String domainname, String username,
String oldpassword, String newpassword);
/**
* The DsGetDcName function returns the name of a domain controller in a specified domain.
* This function accepts additional domain controller selection criteria to indicate
* preference for a domain controller with particular characteristics.
* @param ComputerName
* Pointer to a null-terminated string that specifies the name of the server to process
* this function. Typically, this parameter is NULL, which indicates that the local
* computer is used.
* @param DomainName
* Pointer to a null-terminated string that specifies the name of the domain or application
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
* may be specified with or without a trailing period.
* @param DomainGuid
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
* by DomainGuid.
* @param SiteName
* Pointer to a null-terminated string that specifies the name of the site where the returned
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
* to return a domain controller in the site closest to the site of the computer specified by
* ComputerName. This parameter should be NULL, by default.
* @param Flags
* Contains a set of flags that provide additional data used to process the request.
* @param DomainControllerInfo
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
* This structure is allocated by DsGetDcName. The caller must free the structure using
* the NetApiBufferFree function when it is no longer required.
* @return
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
* If the function fails, the return code is one of ERROR_* values.
*/
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO DomainControllerInfo);
/**
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
* @param serverName
* Contains the name of the domain controller that DsGetForestTrustInformationW
* is connected to remotely. The caller must be an authenticated user on this server.
* If this parameter is NULL, the local server is used.
* @param trustedDomainName
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
* trust attribute. If this parameter is NULL, the forest trust data for the domain
* hosted by ServerName is retrieved.
* @param Flags
* Contains a set of flags that modify the behavior of this function.
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
* @param ForestTrustInfo
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
* trust data that describes the namespaces claimed by the domain specified by
* TrustedDomainName. The Time member of all returned records will be zero.
* @return
* Returns NO_ERROR if successful or a Win32 error code otherwise.
*/
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo);
/**
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
* @param serverName
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
* obtain the trust information for. This computer must be running the Windows 2000 or later
* operating system. If this parameter is NULL, the name of the local computer is used.
* The caller must be an authenticated user in this domain.
* @param Flags
* Contains a set of flags that determines which domain trusts to enumerate.
* @param Domains
* 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
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
* @return
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
*/
public int DsEnumerateDomainTrusts(String serverName, int Flags,
PointerByReference Domains, IntByReference DomainCount);
/**
* The NetUserGetInfo function retrieves information about a particular user account on a server.
* @param servername
* A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL, the local computer is used.
* @param username
* A pointer to a constant string that specifies the name of the user account for which to return information.
* For more information, see the following Remarks section.
* @param level
* The information level of the data. This parameter can be one of the following values.
* Value Meaning
* 0 Return the user account name. The bufptr parameter points to a USER_INFO_0 structure.
* 1 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure.
* 2 Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure.
* 3 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead.
* 4 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_4 structure. Windows 2000: This level is not supported.
* 10 Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure.
* 11 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure.
* 20 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_20 structure. Note that on Windows XP and later, it is recommended that you use USER_INFO_23 instead.
* 23 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_23 structure. Windows 2000: This level is not supported.
* @param bufptr
* A pointer to the buffer that receives the data.
* The format of this data depends on the value of the level parameter.
* This buffer is allocated by the system and must be freed using the NetApiBufferFree function.
* For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetInfo( String servername, String username, int level, PointerByReference bufptr );
}
@@ -468,7 +468,7 @@ public abstract class Netapi32Util {
* Domain controller information.
*/
public static DomainController getDC() {
PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
PDOMAIN_CONTROLLER_INFO pdci = new PDOMAIN_CONTROLLER_INFO();
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
if (W32Errors.ERROR_SUCCESS != rc) {
throw new Win32Exception(rc);
@@ -1,55 +1,55 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* ntdll.dll Interface.
* @author dblock[at]dblock.org
*/
public interface NtDll extends StdCallLibrary {
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The ZwQueryKey routine provides information about the class of a registry key,
* and the number and sizes of its subkeys.
* @param KeyHandle
* Handle to the registry key to obtain information about. This handle is created by
* a successful call to ZwCreateKey or ZwOpenKey.
* @param KeyInformationClass
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
* returned in the KeyInformation buffer.
* @param KeyInformation
* Pointer to a caller-allocated buffer that receives the requested information.
* @param Length
* Specifies the size, in bytes, of the KeyInformation buffer.
* @param ResultLength
* Pointer to a variable that receives the size, in bytes, of the requested key
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
* required buffer size.
* @return
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
*/
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
Structure KeyInformation, int Length, IntByReference ResultLength);
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* ntdll.dll Interface.
* @author dblock[at]dblock.org
*/
public interface NtDll extends StdCallLibrary {
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The ZwQueryKey routine provides information about the class of a registry key,
* and the number and sizes of its subkeys.
* @param KeyHandle
* Handle to the registry key to obtain information about. This handle is created by
* a successful call to ZwCreateKey or ZwOpenKey.
* @param KeyInformationClass
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
* returned in the KeyInformation buffer.
* @param KeyInformation
* Pointer to a caller-allocated buffer that receives the requested information.
* @param Length
* Specifies the size, in bytes, of the KeyInformation buffer.
* @param ResultLength
* Pointer to a variable that receives the size, in bytes, of the requested key
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
* required buffer size.
* @return
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
*/
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
Structure KeyInformation, int Length, IntByReference ResultLength);
}
@@ -1,47 +1,47 @@
/* 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.platform.win32.Wdm.KEY_BASIC_INFORMATION;
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.ptr.IntByReference;
/**
* NtDll Utility API.
* @author dblock[at]dblock.org
*/
public abstract class NtDllUtil {
/**
* Retrieve the name of an opened registry key.
* @param hkey Opened registry key.
* @return Basic key name, not including node information.
*/
public static String getKeyName(HKEY hkey) {
IntByReference resultLength = new IntByReference();
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
null, 0, resultLength);
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
throw new Win32Exception(rc);
}
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
resultLength.getValue());
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
keyInformation, resultLength.getValue(), resultLength);
if (rc != NTStatus.STATUS_SUCCESS) {
throw new Win32Exception(rc);
}
return keyInformation.getName();
}
}
/* 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.platform.win32.Wdm.KEY_BASIC_INFORMATION;
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.ptr.IntByReference;
/**
* NtDll Utility API.
* @author dblock[at]dblock.org
*/
public abstract class NtDllUtil {
/**
* Retrieve the name of an opened registry key.
* @param hkey Opened registry key.
* @return Basic key name, not including node information.
*/
public static String getKeyName(HKEY hkey) {
IntByReference resultLength = new IntByReference();
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
null, 0, resultLength);
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
throw new Win32Exception(rc);
}
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
resultLength.getValue());
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
keyInformation, resultLength.getValue(), resultLength);
if (rc != NTStatus.STATUS_SUCCESS) {
throw new Win32Exception(rc);
}
return keyInformation.getName();
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,7 +1,10 @@
/*
* 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
@@ -15,23 +18,41 @@
*/
package com.sun.jna.platform.win32;
import com.sun.jna.platform.win32.WTypes;
/**
* 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);
}
@@ -1,106 +1,217 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Ole32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Ole32 extends StdCallLibrary {
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
* @param pguid
* A pointer to the requested GUID.
* @return
* S_OK if the GUID was successfully created.
*/
HRESULT CoCreateGuid(GUID.ByReference pguid);
/**
* Converts a globally unique identifier (GUID) into a string of printable characters.
* @param rguid
* The GUID to be converted.
* @param lpsz
* A pointer to a caller-allocated string variable to receive the resulting string.
* @param cchMax
* The number of characters available in the lpsz buffer.
* @return
* If the function succeeds, the return value is the number of characters in the
* returned string, including the null terminator. If the buffer is too small to contain
* the string, the return value is 0.
*/
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
/**
* Converts a string generated by the StringFromIID function back into the
* original interface identifier (IID).
* @param lpsz
* A pointer to the string representation of the IID.
* @param lpiid
* A pointer to the requested IID on return.
* @return
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
* and S_OK.
*/
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
/**
* Initializes the COM library for use by the calling thread, sets the thread's
* concurrency model, and creates a new apartment for the thread if one is required.
* @param reserved This parameter is reserved and must be NULL.
* @param dwCoInit The concurrency model and initialization options for the
* thread. Values for this parameter are taken from the COINIT enumeration.
* Any combination of values from COINIT can be used, except that the
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
*/
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
/**
* Closes the COM library on the current thread, unloads all DLLs loaded by
* the thread, frees any other resources that the thread maintains, and
* forces all RPC connections on the thread to close.
*
*/
void CoUninitialize();
/**
* Creates a single uninitialized object of the class associated with a specified CLSID.
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
* @return an HRESULT
*/
HRESULT CoCreateInstance(
GUID rclsid,
Pointer pUnkOuter,
int dwClsContext,
GUID riid,
PointerByReference ppv);
}
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.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;
/**
* Ole32.dll Interface.
*
* @author dblock[at]dblock.org
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public interface Ole32 extends StdCallLibrary {
/** 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.
*
* @param pguid
* A pointer to the requested GUID.
* @return S_OK if the GUID was successfully created.
*/
HRESULT CoCreateGuid(GUID pguid);
/** @deprecated use {@link #CoCreateGuid(Guid.GUID)}. */
HRESULT CoCreateGuid(GUID.ByReference pguid);
/**
* Converts a globally unique identifier (GUID) into a string of printable
* characters.
*
* @param rguid
* The GUID to be converted.
* @param lpsz
* A pointer to a caller-allocated string variable to receive the
* resulting string.
* @param cchMax
* The number of characters available in the lpsz buffer.
* @return If the function succeeds, the return value is the number of
* characters in the returned string, including the null terminator.
* If the buffer is too small to contain the string, the return
* value is 0.
*/
int StringFromGUID2(GUID rguid, char[] lpsz, int cchMax);
/**
* Converts a string generated by the StringFromIID function back into the
* original interface identifier (IID).
*
* @param lpsz
* A pointer to the string representation of the IID.
* @param lpiid
* A pointer to the requested IID on return.
* @return This function can return the standard return values E_INVALIDARG,
* E_OUTOFMEMORY, and S_OK.
*/
HRESULT IIDFromString(String lpsz, GUID lpiid);
/**
* 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);
int COINIT_APARTMENTTHREADED = 0x2;
int COINIT_MULTITHREADED = 0x0;
int COINIT_DISABLE_OLE1DDE = 0x4;
int COINIT_SPEED_OVER_MEMORY = 0x8;
/**
* 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 {@link #COINIT_APARTMENTTHREADED} and
* {@link #COINIT_MULTITHREADED} flags cannot both be set. The
* default (and only sane choice) is
* {@link #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 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 pclsid);
}
@@ -1,73 +1,73 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Ole32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Ole32Util {
/**
* Convert a string to a GUID.
* @param guidString
* String representation of a GUID, including { }.
* @return
* A GUID.
*/
public static GUID getGUIDFromString(String guidString) {
GUID.ByReference lpiid = new GUID.ByReference();
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return lpiid;
}
/**
* Convert a GUID into a string.
* @param guid
* GUID.
* @return
* String representation of a GUID.
*/
public static String getStringFromGUID(GUID guid) {
GUID.ByReference pguid = new GUID.ByReference(guid.getPointer());
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
if (len == 0) {
throw new RuntimeException("StringFromGUID2");
}
lpsz[len - 1] = 0;
return Native.toString(lpsz);
}
/**
* Generate a new GUID.
* @return
* New GUID.
*/
public static GUID generateGUID() {
GUID.ByReference pguid = new GUID.ByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return pguid;
}
}
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Ole32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Ole32Util {
/**
* Convert a string to a GUID.
* @param guidString
* String representation of a GUID, including { }.
* @return
* A GUID.
*/
public static GUID getGUIDFromString(String guidString) {
GUID lpiid = new GUID();
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return lpiid;
}
/**
* Convert a GUID into a string.
* @param guid
* GUID.
* @return
* String representation of a GUID.
*/
public static String getStringFromGUID(GUID guid) {
GUID pguid = new GUID(guid.getPointer());
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
if (len == 0) {
throw new RuntimeException("StringFromGUID2");
}
lpsz[len - 1] = 0;
return Native.toString(lpsz);
}
/**
* Generate a new GUID.
* @return
* New GUID.
*/
public static GUID generateGUID() {
GUID pguid = new GUID();
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return pguid;
}
}
@@ -0,0 +1,477 @@
/* 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;
/**
* 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 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 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,77 @@
/* 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;
/**
* 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 createVarArray(int size) {
SAFEARRAY 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);
}
@@ -254,7 +254,7 @@ public interface Secur32 extends StdCallLibrary {
* If the function fails, it returns a nonzero error code.
*/
public int EnumerateSecurityPackages(IntByReference pcPackages,
PSecPkgInfo.ByReference ppPackageInfo);
PSecPkgInfo ppPackageInfo);
/**
* The FreeContextBuffer function enables callers of security package functions to free a memory
@@ -11,19 +11,19 @@
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.ArrayList;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
import com.sun.jna.ptr.IntByReference;
/**
* Secur32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Secur32Util {
/**
* Secur32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Secur32Util {
/**
* An SSPI package.
@@ -38,39 +38,39 @@ public abstract class Secur32Util {
*/
public String comment;
}
/**
* Retrieves the name of the user or other security principal associated
* with the calling thread.
*
* @param format User name format.
* @return User name in a given format.
*/
public static String getUserNameEx(int format) {
char[] buffer = new char[128];
IntByReference len = new IntByReference(buffer.length);
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
if (! result) {
int rc = Kernel32.INSTANCE.GetLastError();
switch(rc) {
case W32Errors.ERROR_MORE_DATA:
buffer = new char[len.getValue() + 1];
break;
default:
throw new Win32Exception(Native.getLastError());
}
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
}
if (! result) {
throw new Win32Exception(Native.getLastError());
}
return Native.toString(buffer);
/**
* Retrieves the name of the user or other security principal associated
* with the calling thread.
*
* @param format User name format.
* @return User name in a given format.
*/
public static String getUserNameEx(int format) {
char[] buffer = new char[128];
IntByReference len = new IntByReference(buffer.length);
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
if (! result) {
int rc = Kernel32.INSTANCE.GetLastError();
switch(rc) {
case W32Errors.ERROR_MORE_DATA:
buffer = new char[len.getValue() + 1];
break;
default:
throw new Win32Exception(Native.getLastError());
}
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
}
if (! result) {
throw new Win32Exception(Native.getLastError());
}
return Native.toString(buffer);
}
/**
@@ -80,7 +80,7 @@ public abstract class Secur32Util {
*/
public static SecurityPackage[] getSecurityPackages() {
IntByReference pcPackages = new IntByReference();
PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference();
PSecPkgInfo pPackageInfo = new PSecPkgInfo();
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
@@ -98,5 +98,5 @@ public abstract class Secur32Util {
throw new Win32Exception(rc);
}
return packages.toArray(new SecurityPackage[0]);
}
}
}
}
@@ -109,7 +109,7 @@ public interface SetupApi extends StdCallLibrary {
* installed devices that matched the supplied parameters. If the operation fails, the function returns
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
*/
WinNT.HANDLE SetupDiGetClassDevs(Guid.GUID.ByReference classGuid, Pointer enumerator, Pointer hwndParent, int flags);
WinNT.HANDLE SetupDiGetClassDevs(Guid.GUID classGuid, Pointer enumerator, Pointer hwndParent, int flags);
/**
* The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory.
@@ -157,8 +157,8 @@ public interface SetupApi extends StdCallLibrary {
* with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
*/
boolean SetupDiEnumDeviceInterfaces(WinNT.HANDLE hDevInfo, Pointer devInfo,
Guid.GUID.ByReference interfaceClassGuid, int memberIndex,
SP_DEVICE_INTERFACE_DATA.ByReference deviceInterfaceData);
Guid.GUID interfaceClassGuid, int memberIndex,
SP_DEVICE_INTERFACE_DATA deviceInterfaceData);
/**
* The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
@@ -199,8 +199,8 @@ public interface SetupApi extends StdCallLibrary {
* with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
*/
boolean SetupDiGetDeviceInterfaceDetail(WinNT.HANDLE hDevInfo,
SP_DEVICE_INTERFACE_DATA.ByReference deviceInterfaceData, Pointer deviceInterfaceDetailData,
int deviceInterfaceDetailDataSize, IntByReference requiredSize, SP_DEVINFO_DATA.ByReference deviceInfoData);
SP_DEVICE_INTERFACE_DATA deviceInterfaceData, Pointer deviceInterfaceDetailData,
int deviceInterfaceDetailDataSize, IntByReference requiredSize, SP_DEVINFO_DATA deviceInfoData);
/**
* The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
@@ -236,7 +236,7 @@ public interface SetupApi extends StdCallLibrary {
* ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is
* not valid.
*/
boolean SetupDiGetDeviceRegistryProperty(WinNT.HANDLE DeviceInfoSet, SP_DEVINFO_DATA.ByReference DeviceInfoData,
boolean SetupDiGetDeviceRegistryProperty(WinNT.HANDLE DeviceInfoSet, SP_DEVINFO_DATA DeviceInfoData,
int Property, IntByReference PropertyRegDataType, Pointer PropertyBuffer, int PropertyBufferSize,
IntByReference RequiredSize);
@@ -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
@@ -151,4 +151,21 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
*/
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,58 +1,76 @@
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Shell32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Shell32Util {
/**
* Get a special folder path.
* @param hwnd
* Parent window.
* @param nFolder
* Folder CSLID.
* @param dwFlags
* Flags.
* @return
* Special folder.
*/
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
nFolder, null, dwFlags,
pszPath);
if (! hr.equals(W32Errors.S_OK)) {
throw new Win32Exception(hr);
}
return Native.toString(pszPath);
}
/**
* Get a special folder path.
* @param nFolder
* Folder CSLID.
* @return
* Special folder path.
*/
public static String getFolderPath(int nFolder) {
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
}
/* 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
* 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.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
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 {
/**
* Get a special folder path.
* @param hwnd
* Parent window.
* @param nFolder
* Folder CSLID.
* @param dwFlags
* Flags.
* @return
* Special folder.
*/
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
nFolder, null, dwFlags,
pszPath);
if (! hr.equals(W32Errors.S_OK)) {
throw new Win32Exception(hr);
}
return Native.toString(pszPath);
}
/**
* Get a special folder path.
* @param nFolder
* Folder CSLID.
* @return
* Special folder path.
*/
public static String getFolderPath(int nFolder) {
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
}
/**
* 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);
}
}
@@ -1,119 +1,119 @@
/* 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.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShellAPI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShellAPI extends StdCallLibrary {
int STRUCTURE_ALIGNMENT = Platform.is64Bit() ? Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
int FO_MOVE = 0x0001;
int FO_COPY = 0x0002;
int FO_DELETE = 0x0003;
int FO_RENAME = 0x0004;
int FOF_MULTIDESTFILES = 0x0001;
int FOF_CONFIRMMOUSE = 0x0002;
int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
int PO_DELETE = 0x0013; // printer is being deleted
int PO_RENAME = 0x0014; // printer is being renamed
int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
/**
* Contains information that the SHFileOperation function uses to perform file operations.
*/
public static class SHFILEOPSTRUCT extends Structure {
/**
* A window handle to the dialog box to display information about
* the status of the file operation.
*/
public HANDLE hwnd;
/**
* An FO_* value that indicates which operation to perform.
*/
public int wFunc;
/**
* A pointer to one or more source file names, double null-terminated.
*/
public WString pFrom;
/**
* A pointer to the destination file or directory name.
*/
public WString pTo;
/**
* Flags that control the file operation.
*/
public short fFlags;
/**
* When the function returns, this member contains TRUE if any file operations
* were aborted before they were completed; otherwise, FALSE. An operation can
* be manually aborted by the user through UI or it can be silently aborted by
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
*/
public boolean fAnyOperationsAborted;
/**
* When the function returns, this member contains a handle to a name mapping
* object that contains the old and new names of the renamed files. This member
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
*/
public Pointer pNameMappings;
/**
* A pointer to the title of a progress dialog box. This is a null-terminated string.
*/
public WString lpszProgressTitle;
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) {
String encoded = "";
for (int i=0; i < paths.length;i++) {
encoded += paths[i];
encoded += "\0";
}
return encoded + "\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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShellAPI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShellAPI extends StdCallLibrary {
int STRUCTURE_ALIGNMENT = Platform.is64Bit() ? Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
int FO_MOVE = 0x0001;
int FO_COPY = 0x0002;
int FO_DELETE = 0x0003;
int FO_RENAME = 0x0004;
int FOF_MULTIDESTFILES = 0x0001;
int FOF_CONFIRMMOUSE = 0x0002;
int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
int PO_DELETE = 0x0013; // printer is being deleted
int PO_RENAME = 0x0014; // printer is being renamed
int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
/**
* Contains information that the SHFileOperation function uses to perform file operations.
*/
public static class SHFILEOPSTRUCT extends Structure {
/**
* A window handle to the dialog box to display information about
* the status of the file operation.
*/
public HANDLE hwnd;
/**
* An FO_* value that indicates which operation to perform.
*/
public int wFunc;
/**
* A pointer to one or more source file names, double null-terminated.
*/
public WString pFrom;
/**
* A pointer to the destination file or directory name.
*/
public WString pTo;
/**
* Flags that control the file operation.
*/
public short fFlags;
/**
* When the function returns, this member contains TRUE if any file operations
* were aborted before they were completed; otherwise, FALSE. An operation can
* be manually aborted by the user through UI or it can be silently aborted by
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
*/
public boolean fAnyOperationsAborted;
/**
* When the function returns, this member contains a handle to a name mapping
* object that contains the old and new names of the renamed files. This member
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
*/
public Pointer pNameMappings;
/**
* A pointer to the title of a progress dialog box. This is a null-terminated string.
*/
public WString lpszProgressTitle;
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) {
String encoded = "";
for (int i=0; i < paths.length;i++) {
encoded += paths[i];
encoded += "\0";
}
return encoded + "\0";
}
}
}
@@ -1,84 +1,84 @@
/* 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.platform.win32.WinDef.DWORD;
/**
* Ported from ShlObj.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShlObj {
DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
int CSIDL_DESKTOP = 0x0000; // <desktop>
int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
int CSIDL_PERSONAL = 0x0005; // My Documents
int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
int CSIDL_RECENT = 0x0008; // <user name>\Recent
int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
int CSIDL_DRIVES = 0x0011; // My Computer
int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
int CSIDL_FONTS = 0x0014; // windows\fonts
int CSIDL_TEMPLATES = 0x0015;
int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
int CSIDL_COMMON_FAVORITES = 0x001f;
int CSIDL_INTERNET_CACHE = 0x0020;
int CSIDL_COOKIES = 0x0021;
int CSIDL_HISTORY = 0x0022;
int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
int CSIDL_PROFILE = 0x0028; // USERPROFILE
int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
}
/* 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.platform.win32.WinDef.DWORD;
/**
* Ported from ShlObj.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShlObj {
DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
int CSIDL_DESKTOP = 0x0000; // <desktop>
int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
int CSIDL_PERSONAL = 0x0005; // My Documents
int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
int CSIDL_RECENT = 0x0008; // <user name>\Recent
int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
int CSIDL_DRIVES = 0x0011; // My Computer
int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
int CSIDL_FONTS = 0x0014; // windows\fonts
int CSIDL_TEMPLATES = 0x0015;
int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
int CSIDL_COMMON_FAVORITES = 0x001f;
int CSIDL_INTERNET_CACHE = 0x0020;
int CSIDL_COOKIES = 0x0021;
int CSIDL_HISTORY = 0x0022;
int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
int CSIDL_PROFILE = 0x0028; // USERPROFILE
int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
}
@@ -1,477 +1,451 @@
/* 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.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Sspi.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface Sspi extends StdCallLibrary {
/**
* Maximum size in bytes of a security token.
*/
int MAX_TOKEN_SIZE = 12288;
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
/**
* Validate an incoming server credential. Inbound credentials might be validated
* by using an authenticating authority when InitializeSecurityContext or
* AcceptSecurityContext is called. If such an authority is not available, the function will
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
*/
int SECPKG_CRED_INBOUND = 1;
/**
* Allow a local client credential to prepare an outgoing token.
*/
int SECPKG_CRED_OUTBOUND = 2;
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
/**
* Specifies Native data representation.
*/
int SECURITY_NATIVE_DREP = 0x10;
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
/**
* The security package allocates output buffers for you.
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
*/
int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
/**
* Encrypt messages by using the EncryptMessage function.
*/
int ISC_REQ_CONFIDENTIALITY = 0x00000010;
/**
* The security context will not handle formatting messages. This value is the default.
*/
int ISC_REQ_CONNECTION = 0x00000800;
/**
* The server can use the context to authenticate to other servers as the client.
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
* Ignore this flag for constrained delegation.
*/
int ISC_REQ_DELEGATE = 0x00000001;
/**
* When errors occur, the remote party will be notified.
*/
int ISC_REQ_EXTENDED_ERROR = 0x00004000;
/**
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
*/
int ISC_REQ_INTEGRITY = 0x00010000;
/**
* The mutual authentication policy of the service will be satisfied.
*/
int ISC_REQ_MUTUAL_AUTH = 0x00000002;
/**
* Detect replayed messages that have been encoded by using the
* EncryptMessage or MakeSignature functions.
*/
int ISC_REQ_REPLAY_DETECT = 0x00000004;
/**
* Detect messages received out of sequence.
*/
int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
/**
* Support a stream-oriented connection.
*/
int ISC_REQ_STREAM = 0x00008000;
/**
* Version of the SecBuffer struct.
*/
int SECBUFFER_VERSION = 0;
/**
* This is a placeholder in the buffer array.
*/
int SECBUFFER_EMPTY = 0;
/**
* This buffer type is used for common data. The security package can read
* and write this data.
*/
int SECBUFFER_DATA = 1;
/**
* This buffer type is used to indicate the security token portion of the message.
* This is read-only for input parameters or read/write for output parameters.
*/
int SECBUFFER_TOKEN = 2;
/**
* Security handle.
*/
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() {
}
/**
* Returns true if the handle is NULL.
* @return
* True if NULL, False otherwise.
*/
public boolean isNull() {
return dwLower == null && dwUpper == null;
}
}
/**
* A pointer to a SecHandle
*/
public static class PSecHandle extends Structure {
public static class ByReference extends PSecHandle implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecHandle.ByReference secHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "secHandle" });
}
public PSecHandle() {
}
public PSecHandle(SecHandle h) {
super(h.getPointer());
read();
}
}
/**
* Credentials handle.
*/
public static class CredHandle extends SecHandle {
}
/**
* Security context handle.
*/
public static class CtxtHandle extends SecHandle {
}
/**
* The SecBuffer structure describes a buffer allocated by a transport application
* to pass to a security package.
*/
public static class SecBuffer extends Structure {
/**
* A ByReference SecBuffer.
*/
public static class ByReference extends SecBuffer implements Structure.ByReference {
/**
* Create a SECBUFFER_EMPTY SecBuffer.
*/
public ByReference() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public ByReference(int type, int size) {
super(type, size);
}
public ByReference(int type, byte[] token) {
super(type, token);
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return super.getBytes();
}
}
/**
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
*/
public int cbBuffer;
/**
* Bit flags that indicate the type of buffer. Must be one of the values of
* the SecBufferType enumeration.
*/
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() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public SecBuffer(int type, int size) {
cbBuffer = size;
pvBuffer = new Memory(size);
BufferType = type;
}
/**
* Create a SecBuffer of a given type with initial data.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param token
* Existing token.
*/
public SecBuffer(int type, byte[] token) {
cbBuffer = token.length;
pvBuffer = new Memory(token.length);
pvBuffer.write(0, token, 0, token.length);
BufferType = type;
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer);
}
}
public static class SecBufferDesc extends Structure {
/**
* Version number.
*/
public int ulVersion;
/**
* Number of buffers.
*/
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 = SECBUFFER_VERSION;
cBuffers = 1;
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
/**
* Create a new SecBufferDesc with initial data.
* @param type
* Token type.
* @param token
* Initial token data.
*/
public SecBufferDesc(int type, byte[] token) {
ulVersion = SECBUFFER_VERSION;
cBuffers = 1;
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
allocateMemory();
}
/**
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
* @param type
* @param tokenSize
*/
public SecBufferDesc(int type, int tokenSize) {
ulVersion = 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 == 0) {
throw new RuntimeException("pBuffers | cBuffers");
}
if (cBuffers == 1) {
return pBuffers[0].getBytes();
}
throw new RuntimeException("cBuffers > 1");
}
}
/**
* A security integer.
*/
public static class SECURITY_INTEGER extends Structure {
public int dwLower;
public int dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
/**
* An security integer of 0.
*/
public SECURITY_INTEGER() {
}
}
/**
* A timestamp.
*/
public static class TimeStamp extends SECURITY_INTEGER {
}
/**
* A pointer to an array of SecPkgInfo structures.
*/
public static class PSecPkgInfo extends Structure {
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference pPkgInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pPkgInfo" });
}
public PSecPkgInfo() {
}
/**
* An array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference[] toArray(int size) {
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
}
}
/**
* The SecPkgInfo structure provides general information about a security package,
* such as its name and capabilities.
*/
public static class SecPkgInfo extends Structure {
/**
* A reference pointer to a SecPkgInfo structure.
*/
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
}
/**
* Set of bit flags that describes the capabilities of the security package.
*/
public int fCapabilities;
/**
* Specifies the version of the package protocol. Must be 1.
*/
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.
*/
public short wRPCID;
/**
* Specifies the maximum size, in bytes, of the token.
*/
public int cbMaxToken;
/**
* Pointer to a null-terminated string that contains the name of the security package.
*/
public WString Name;
/**
* Pointer to a null-terminated string. This can be any additional string passed
* back by the package.
*/
public WString Comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" });
}
/**
* Create a new package info.
*/
public SecPkgInfo() {
}
}
}
/* 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.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Sspi.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface Sspi extends StdCallLibrary {
/**
* Maximum size in bytes of a security token.
*/
int MAX_TOKEN_SIZE = 12288;
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
/**
* Validate an incoming server credential. Inbound credentials might be validated
* by using an authenticating authority when InitializeSecurityContext or
* AcceptSecurityContext is called. If such an authority is not available, the function will
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
*/
int SECPKG_CRED_INBOUND = 1;
/**
* Allow a local client credential to prepare an outgoing token.
*/
int SECPKG_CRED_OUTBOUND = 2;
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
/**
* Specifies Native data representation.
*/
int SECURITY_NATIVE_DREP = 0x10;
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
/**
* The security package allocates output buffers for you.
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
*/
int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
/**
* Encrypt messages by using the EncryptMessage function.
*/
int ISC_REQ_CONFIDENTIALITY = 0x00000010;
/**
* The security context will not handle formatting messages. This value is the default.
*/
int ISC_REQ_CONNECTION = 0x00000800;
/**
* The server can use the context to authenticate to other servers as the client.
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
* Ignore this flag for constrained delegation.
*/
int ISC_REQ_DELEGATE = 0x00000001;
/**
* When errors occur, the remote party will be notified.
*/
int ISC_REQ_EXTENDED_ERROR = 0x00004000;
/**
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
*/
int ISC_REQ_INTEGRITY = 0x00010000;
/**
* The mutual authentication policy of the service will be satisfied.
*/
int ISC_REQ_MUTUAL_AUTH = 0x00000002;
/**
* Detect replayed messages that have been encoded by using the
* EncryptMessage or MakeSignature functions.
*/
int ISC_REQ_REPLAY_DETECT = 0x00000004;
/**
* Detect messages received out of sequence.
*/
int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
/**
* Support a stream-oriented connection.
*/
int ISC_REQ_STREAM = 0x00008000;
/**
* Version of the SecBuffer struct.
*/
int SECBUFFER_VERSION = 0;
/**
* This is a placeholder in the buffer array.
*/
int SECBUFFER_EMPTY = 0;
/**
* This buffer type is used for common data. The security package can read
* and write this data.
*/
int SECBUFFER_DATA = 1;
/**
* This buffer type is used to indicate the security token portion of the message.
* This is read-only for input parameters or read/write for output parameters.
*/
int SECBUFFER_TOKEN = 2;
/**
* Security handle.
*/
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() {
}
/**
* Returns true if the handle is NULL.
* @return
* True if NULL, False otherwise.
*/
public boolean isNull() {
return dwLower == null && dwUpper == null;
}
}
/**
* A pointer to a SecHandle
*/
public static class PSecHandle extends Structure {
public static class ByReference extends PSecHandle implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecHandle.ByReference secHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "secHandle" });
}
public PSecHandle() {
}
public PSecHandle(SecHandle h) {
super(h.getPointer());
read();
}
}
/**
* Credentials handle.
*/
public static class CredHandle extends SecHandle {
}
/**
* Security context handle.
*/
public static class CtxtHandle extends SecHandle {
}
/**
* The SecBuffer structure describes a buffer allocated by a transport application
* to pass to a security package.
*/
public static class SecBuffer extends Structure {
/**
* A ByReference SecBuffer.
*/
public static class ByReference extends SecBuffer implements Structure.ByReference {
/**
* Create a SECBUFFER_EMPTY SecBuffer.
*/
public ByReference() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public ByReference(int type, int size) {
super(type, size);
}
public ByReference(int type, byte[] token) {
super(type, token);
}
}
/**
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
*/
public int cbBuffer;
/**
* Bit flags that indicate the type of buffer. Must be one of the values of
* the SecBufferType enumeration.
*/
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() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public SecBuffer(int type, int size) {
cbBuffer = size;
pvBuffer = new Memory(size);
BufferType = type;
}
/**
* Create a SecBuffer of a given type with initial data.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param token
* Existing token.
*/
public SecBuffer(int type, byte[] token) {
cbBuffer = token.length;
pvBuffer = new Memory(token.length);
pvBuffer.write(0, token, 0, token.length);
BufferType = type;
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer);
}
}
public static class SecBufferDesc extends Structure {
/**
* Version number.
*/
public int ulVersion = SECBUFFER_VERSION;
/**
* Number of buffers.
*/
public int cBuffers = 1;
/**
* Pointer to array of buffers.
*/
public SecBuffer.ByReference[] pBuffers = new SecBuffer.ByReference[] {
new SecBuffer.ByReference()
};
protected List getFieldOrder() {
return Arrays.asList(new String[] { "ulVersion", "cBuffers", "pBuffers" });
}
/**
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
*/
public SecBufferDesc() {
}
/**
* Create a new SecBufferDesc with initial data.
* @param type
* Token type.
* @param token
* Initial token data.
*/
public SecBufferDesc(int type, byte[] token) {
pBuffers[0] = new SecBuffer.ByReference(type, token);
}
/**
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
* @param type
* @param tokenSize
*/
public SecBufferDesc(int type, int tokenSize) {
pBuffers[0] = new SecBuffer.ByReference(type, tokenSize);
}
public byte[] getBytes() {
return pBuffers[0].getBytes();
}
}
/**
* A security integer.
*/
public static class SECURITY_INTEGER extends Structure {
public int dwLower;
public int dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
/**
* An security integer of 0.
*/
public SECURITY_INTEGER() {
}
}
/**
* A timestamp.
*/
public static class TimeStamp extends SECURITY_INTEGER {
}
/**
* A pointer to an array of SecPkgInfo structures.
*/
public static class PSecPkgInfo extends Structure {
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference pPkgInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pPkgInfo" });
}
public PSecPkgInfo() {
}
/**
* An array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference[] toArray(int size) {
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
}
}
/**
* The SecPkgInfo structure provides general information about a security package,
* such as its name and capabilities.
*/
public static class SecPkgInfo extends Structure {
/**
* A reference pointer to a SecPkgInfo structure.
*/
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
}
/**
* Set of bit flags that describes the capabilities of the security package.
*/
public int fCapabilities;
/**
* Specifies the version of the package protocol. Must be 1.
*/
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.
*/
public short wRPCID;
/**
* Specifies the maximum size, in bytes, of the token.
*/
public int cbMaxToken;
/**
* Pointer to a null-terminated string that contains the name of the security package.
*/
public WString Name;
/**
* Pointer to a null-terminated string. This can be any additional string passed
* back by the package.
*/
public WString Comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" });
}
/**
* Create a new package info.
*/
public SecPkgInfo() {
}
}
}
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" });
}
}
}
@@ -18,88 +18,157 @@ 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;
}
/**
* 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
*/
public static final boolean FAILED(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;
}
/**
* Extract error code from HRESULT
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
/**
* Succeeded.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean SUCCEEDED(HRESULT hr) {
return hr == null || SUCCEEDED(hr.intValue());
}
/**
* Extract error code from SCODE
*/
public static final int SCODE_CODE(int sc) {
return sc & 0xFFFF;
}
/**
* Failed.
*
* @param hr the hr
* @return true, if successful
*/
public static final boolean FAILED(HRESULT hr) {
return hr != null && FAILED(hr.intValue());
}
/**
* Return the facility
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
/**
* Extract error code from HRESULT.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_CODE(int hr) {
return hr & 0xFFFF;
}
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* 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 severity
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
/**
* Return the facility.
*
* @param hr the hr
* @return the int
*/
public static final int HRESULT_FACILITY(int hr) {
return (hr >>= 16) & 0x1fff;
}
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* Scode facility.
*
* @param sc the sc
* @return the int
*/
public static final int SCODE_FACILITY(short sc) {
return (sc >>= 16) & 0x1fff;
}
/**
* Create an HRESULT value from component pieces
*/
public static int MAKE_HRESULT(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Return the severity.
*
* @param hr the hr
* @return the short
*/
public static short HRESULT_SEVERITY(int hr) {
return (short) ((hr >>= 31) & 0x1);
}
public static final int MAKE_SCODE(short sev, short fac, short code) {
return ((sev << 31) | (fac << 16) | code);
}
/**
* Scode severity.
*
* @param sc the sc
* @return the short
*/
public static short SCODE_SEVERITY(short sc) {
return (short) ((sc >>= 31) & 0x1);
}
/**
* 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);
}
/**
* 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);
}
/**
* 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));
}
/**
* 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));
}
}
@@ -1,258 +1,258 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
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.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
public class W32FileMonitor extends FileMonitor {
private static final int BUFFER_SIZE = 4096;
private class FileInfo {
public final File file;
public final HANDLE handle;
public final int notifyMask;
public final boolean recursive;
public final FILE_NOTIFY_INFORMATION info = new FILE_NOTIFY_INFORMATION(BUFFER_SIZE);
public final IntByReference infoLength = new IntByReference();
public final OVERLAPPED overlapped = new OVERLAPPED();
public FileInfo(File f, HANDLE h, int mask, boolean recurse) {
this.file = f;
this.handle = h;
this.notifyMask = mask;
this.recursive = recurse;
}
}
private Thread watcher;
private HANDLE port;
private final Map<File, FileInfo> fileMap = new HashMap<File, FileInfo>();
private final Map<HANDLE, FileInfo> handleMap = new HashMap<HANDLE, FileInfo>();
private boolean disposing = false;
private void handleChanges(FileInfo finfo) throws IOException {
Kernel32 klib = Kernel32.INSTANCE;
FILE_NOTIFY_INFORMATION fni = finfo.info;
// Need an explicit read, since data was filled in asynchronously
fni.read();
do {
FileEvent event = null;
File file = new File(finfo.file, fni.getFilename());
switch(fni.Action) {
case 0:
break;
case WinNT.FILE_ACTION_MODIFIED:
event = new FileEvent(file, FILE_MODIFIED);
break;
case WinNT.FILE_ACTION_ADDED:
event = new FileEvent(file, FILE_CREATED);
break;
case WinNT.FILE_ACTION_REMOVED:
event = new FileEvent(file, FILE_DELETED);
break;
case WinNT.FILE_ACTION_RENAMED_OLD_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_OLD);
break;
case WinNT.FILE_ACTION_RENAMED_NEW_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_NEW);
break;
default:
// TODO: other actions...
System.err.println("Unrecognized file action '" + fni.Action + "'");
}
if (event != null) {
notify(event);
}
fni = fni.next();
} while (fni != null);
// trigger the next read
if (!finfo.file.exists()) {
unwatch(finfo.file);
return;
}
if (!klib.ReadDirectoryChangesW(finfo.handle, finfo.info,
finfo.info.size(), finfo.recursive, finfo.notifyMask,
finfo.infoLength, finfo.overlapped, null)) {
if (! disposing) {
int err = klib.GetLastError();
throw new IOException("ReadDirectoryChangesW failed on "
+ finfo.file + ": '"
+ Kernel32Util.formatMessageFromLastErrorCode(err)
+ "' (" + err + ")");
}
}
}
private FileInfo waitForChange() {
IntByReference rcount = new IntByReference();
ULONG_PTRByReference rkey = new ULONG_PTRByReference();
PointerByReference roverlap = new PointerByReference();
if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) {
return null;
}
synchronized (this) {
return handleMap.get(new HANDLE(rkey.getValue().toPointer()));
}
}
private int convertMask(int mask) {
int result = 0;
if ((mask & FILE_CREATED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_CREATION;
}
if ((mask & FILE_DELETED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_NAME;
}
if ((mask & FILE_MODIFIED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_LAST_WRITE;
}
if ((mask & FILE_RENAMED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_NAME;
}
if ((mask & FILE_SIZE_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_SIZE;
}
if ((mask & FILE_ACCESSED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_LAST_ACCESS;
}
if ((mask & FILE_ATTRIBUTES_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_ATTRIBUTES;
}
if ((mask & FILE_SECURITY_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_SECURITY;
}
return result;
}
private static int watcherThreadID;
protected synchronized void watch(File file, int eventMask, boolean recursive) throws IOException {
File dir = file;
if (!dir.isDirectory()) {
recursive = false;
dir = file.getParentFile();
}
while (dir != null && !dir.exists()) {
recursive = true;
dir = dir.getParentFile();
}
if (dir == null) {
throw new FileNotFoundException("No ancestor found for " + file);
}
Kernel32 klib = Kernel32.INSTANCE;
int mask = WinNT.FILE_SHARE_READ
| WinNT.FILE_SHARE_WRITE | WinNT.FILE_SHARE_DELETE;
int flags = WinNT.FILE_FLAG_BACKUP_SEMANTICS
| WinNT.FILE_FLAG_OVERLAPPED;
HANDLE handle = klib.CreateFile(file.getAbsolutePath(),
WinNT.FILE_LIST_DIRECTORY,
mask, null, WinNT.OPEN_EXISTING,
flags, null);
if (WinBase.INVALID_HANDLE_VALUE.equals(handle)) {
throw new IOException("Unable to open " + file + " ("
+ klib.GetLastError() + ")");
}
int notifyMask = convertMask(eventMask);
FileInfo finfo = new FileInfo(file, handle, notifyMask, recursive);
fileMap.put(file, finfo);
handleMap.put(handle, finfo);
// Existing port is returned
port = klib.CreateIoCompletionPort(handle, port, handle.getPointer(), 0);
if (WinBase.INVALID_HANDLE_VALUE.equals(port)) {
throw new IOException("Unable to create/use I/O Completion port "
+ "for " + file + " ("
+ klib.GetLastError() + ")");
}
// TODO: use FileIOCompletionRoutine callback method instead of a
// dedicated thread
if (!klib.ReadDirectoryChangesW(handle, finfo.info, finfo.info.size(),
recursive, notifyMask, finfo.infoLength,
finfo.overlapped, null)) {
int err = klib.GetLastError();
throw new IOException("ReadDirectoryChangesW failed on "
+ finfo.file + ", handle " + handle
+ ": '" + Kernel32Util.formatMessageFromLastErrorCode(err)
+ "' (" + err + ")");
}
if (watcher == null) {
watcher = new Thread("W32 File Monitor-" + (watcherThreadID++)) {
public void run() {
FileInfo finfo;
while (true) {
finfo = waitForChange();
if (finfo == null) {
synchronized(W32FileMonitor.this) {
if (fileMap.isEmpty()) {
watcher = null;
break;
}
}
continue;
}
try {
handleChanges(finfo);
}
catch(IOException e) {
// TODO: how is this best handled?
e.printStackTrace();
}
}
}
};
watcher.setDaemon(true);
watcher.start();
}
}
protected synchronized void unwatch(File file) {
FileInfo finfo = fileMap.remove(file);
if (finfo != null) {
handleMap.remove(finfo.handle);
Kernel32 klib = Kernel32.INSTANCE;
// bug: the watcher may still be processing this file
klib.CloseHandle(finfo.handle);
}
}
public synchronized void dispose() {
disposing = true;
// unwatch any remaining files in map, allows watcher thread to exit
int i = 0;
for (Object[] keys = fileMap.keySet().toArray(); !fileMap.isEmpty();) {
unwatch((File)keys[i++]);
}
Kernel32 klib = Kernel32.INSTANCE;
klib.PostQueuedCompletionStatus(port, 0, null, null);
klib.CloseHandle(port);
port = null;
watcher = null;
}
}
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
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.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
public class W32FileMonitor extends FileMonitor {
private static final int BUFFER_SIZE = 4096;
private class FileInfo {
public final File file;
public final HANDLE handle;
public final int notifyMask;
public final boolean recursive;
public final FILE_NOTIFY_INFORMATION info = new FILE_NOTIFY_INFORMATION(BUFFER_SIZE);
public final IntByReference infoLength = new IntByReference();
public final OVERLAPPED overlapped = new OVERLAPPED();
public FileInfo(File f, HANDLE h, int mask, boolean recurse) {
this.file = f;
this.handle = h;
this.notifyMask = mask;
this.recursive = recurse;
}
}
private Thread watcher;
private HANDLE port;
private final Map<File, FileInfo> fileMap = new HashMap<File, FileInfo>();
private final Map<HANDLE, FileInfo> handleMap = new HashMap<HANDLE, FileInfo>();
private boolean disposing = false;
private void handleChanges(FileInfo finfo) throws IOException {
Kernel32 klib = Kernel32.INSTANCE;
FILE_NOTIFY_INFORMATION fni = finfo.info;
// Need an explicit read, since data was filled in asynchronously
fni.read();
do {
FileEvent event = null;
File file = new File(finfo.file, fni.getFilename());
switch(fni.Action) {
case 0:
break;
case WinNT.FILE_ACTION_MODIFIED:
event = new FileEvent(file, FILE_MODIFIED);
break;
case WinNT.FILE_ACTION_ADDED:
event = new FileEvent(file, FILE_CREATED);
break;
case WinNT.FILE_ACTION_REMOVED:
event = new FileEvent(file, FILE_DELETED);
break;
case WinNT.FILE_ACTION_RENAMED_OLD_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_OLD);
break;
case WinNT.FILE_ACTION_RENAMED_NEW_NAME:
event = new FileEvent(file, FILE_NAME_CHANGED_NEW);
break;
default:
// TODO: other actions...
System.err.println("Unrecognized file action '" + fni.Action + "'");
}
if (event != null) {
notify(event);
}
fni = fni.next();
} while (fni != null);
// trigger the next read
if (!finfo.file.exists()) {
unwatch(finfo.file);
return;
}
if (!klib.ReadDirectoryChangesW(finfo.handle, finfo.info,
finfo.info.size(), finfo.recursive, finfo.notifyMask,
finfo.infoLength, finfo.overlapped, null)) {
if (! disposing) {
int err = klib.GetLastError();
throw new IOException("ReadDirectoryChangesW failed on "
+ finfo.file + ": '"
+ Kernel32Util.formatMessageFromLastErrorCode(err)
+ "' (" + err + ")");
}
}
}
private FileInfo waitForChange() {
IntByReference rcount = new IntByReference();
ULONG_PTRByReference rkey = new ULONG_PTRByReference();
PointerByReference roverlap = new PointerByReference();
if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) {
return null;
}
synchronized (this) {
return handleMap.get(new HANDLE(rkey.getValue().toPointer()));
}
}
private int convertMask(int mask) {
int result = 0;
if ((mask & FILE_CREATED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_CREATION;
}
if ((mask & FILE_DELETED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_NAME;
}
if ((mask & FILE_MODIFIED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_LAST_WRITE;
}
if ((mask & FILE_RENAMED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_NAME;
}
if ((mask & FILE_SIZE_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_SIZE;
}
if ((mask & FILE_ACCESSED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_LAST_ACCESS;
}
if ((mask & FILE_ATTRIBUTES_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_ATTRIBUTES;
}
if ((mask & FILE_SECURITY_CHANGED) != 0) {
result |= WinNT.FILE_NOTIFY_CHANGE_SECURITY;
}
return result;
}
private static int watcherThreadID;
protected synchronized void watch(File file, int eventMask, boolean recursive) throws IOException {
File dir = file;
if (!dir.isDirectory()) {
recursive = false;
dir = file.getParentFile();
}
while (dir != null && !dir.exists()) {
recursive = true;
dir = dir.getParentFile();
}
if (dir == null) {
throw new FileNotFoundException("No ancestor found for " + file);
}
Kernel32 klib = Kernel32.INSTANCE;
int mask = WinNT.FILE_SHARE_READ
| WinNT.FILE_SHARE_WRITE | WinNT.FILE_SHARE_DELETE;
int flags = WinNT.FILE_FLAG_BACKUP_SEMANTICS
| WinNT.FILE_FLAG_OVERLAPPED;
HANDLE handle = klib.CreateFile(file.getAbsolutePath(),
WinNT.FILE_LIST_DIRECTORY,
mask, null, WinNT.OPEN_EXISTING,
flags, null);
if (WinBase.INVALID_HANDLE_VALUE.equals(handle)) {
throw new IOException("Unable to open " + file + " ("
+ klib.GetLastError() + ")");
}
int notifyMask = convertMask(eventMask);
FileInfo finfo = new FileInfo(file, handle, notifyMask, recursive);
fileMap.put(file, finfo);
handleMap.put(handle, finfo);
// Existing port is returned
port = klib.CreateIoCompletionPort(handle, port, handle.getPointer(), 0);
if (WinBase.INVALID_HANDLE_VALUE.equals(port)) {
throw new IOException("Unable to create/use I/O Completion port "
+ "for " + file + " ("
+ klib.GetLastError() + ")");
}
// TODO: use FileIOCompletionRoutine callback method instead of a
// dedicated thread
if (!klib.ReadDirectoryChangesW(handle, finfo.info, finfo.info.size(),
recursive, notifyMask, finfo.infoLength,
finfo.overlapped, null)) {
int err = klib.GetLastError();
throw new IOException("ReadDirectoryChangesW failed on "
+ finfo.file + ", handle " + handle
+ ": '" + Kernel32Util.formatMessageFromLastErrorCode(err)
+ "' (" + err + ")");
}
if (watcher == null) {
watcher = new Thread("W32 File Monitor-" + (watcherThreadID++)) {
public void run() {
FileInfo finfo;
while (true) {
finfo = waitForChange();
if (finfo == null) {
synchronized(W32FileMonitor.this) {
if (fileMap.isEmpty()) {
watcher = null;
break;
}
}
continue;
}
try {
handleChanges(finfo);
}
catch(IOException e) {
// TODO: how is this best handled?
e.printStackTrace();
}
}
}
};
watcher.setDaemon(true);
watcher.start();
}
}
protected synchronized void unwatch(File file) {
FileInfo finfo = fileMap.remove(file);
if (finfo != null) {
handleMap.remove(finfo.handle);
Kernel32 klib = Kernel32.INSTANCE;
// bug: the watcher may still be processing this file
klib.CloseHandle(finfo.handle);
}
}
public synchronized void dispose() {
disposing = true;
// unwatch any remaining files in map, allows watcher thread to exit
int i = 0;
for (Object[] keys = fileMap.keySet().toArray(); !fileMap.isEmpty();) {
unwatch((File)keys[i++]);
}
Kernel32 klib = Kernel32.INSTANCE;
klib.PostQueuedCompletionStatus(port, 0, null, null);
klib.CloseHandle(port);
port = null;
watcher = null;
}
}
@@ -1,46 +1,46 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.IOException;
import com.sun.jna.WString;
import com.sun.jna.platform.FileUtils;
public class W32FileUtils extends FileUtils {
public boolean hasTrash() {
return true;
}
public void moveToTrash(File[] files) throws IOException {
Shell32 shell = Shell32.INSTANCE;
ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT();
fileop.wFunc = ShellAPI.FO_DELETE;
String[] paths = new String[files.length];
for (int i=0;i < paths.length;i++) {
paths[i] = files[i].getAbsolutePath();
}
fileop.pFrom = new WString(fileop.encodePaths(paths));
fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NO_UI;
int ret = shell.SHFileOperation(fileop);
if (ret != 0) {
throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
Kernel32Util.formatMessageFromLastErrorCode(ret));
}
if (fileop.fAnyOperationsAborted) {
throw new IOException("Move to trash aborted");
}
}
}
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.IOException;
import com.sun.jna.WString;
import com.sun.jna.platform.FileUtils;
public class W32FileUtils extends FileUtils {
public boolean hasTrash() {
return true;
}
public void moveToTrash(File[] files) throws IOException {
Shell32 shell = Shell32.INSTANCE;
ShellAPI.SHFILEOPSTRUCT fileop = new ShellAPI.SHFILEOPSTRUCT();
fileop.wFunc = ShellAPI.FO_DELETE;
String[] paths = new String[files.length];
for (int i=0;i < paths.length;i++) {
paths[i] = files[i].getAbsolutePath();
}
fileop.pFrom = new WString(fileop.encodePaths(paths));
fileop.fFlags = ShellAPI.FOF_ALLOWUNDO|ShellAPI.FOF_NO_UI;
int ret = shell.SHFileOperation(fileop);
if (ret != 0) {
throw new IOException("Move to trash failed: " + fileop.pFrom + ": " +
Kernel32Util.formatMessageFromLastErrorCode(ret));
}
if (fileop.fAnyOperationsAborted) {
throw new IOException("Move to trash aborted");
}
}
}
@@ -1,207 +1,207 @@
/* Copyright (c) 2010 EugineLev, 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.Winsvc.SC_HANDLE;
import com.sun.jna.platform.win32.Winsvc.SC_STATUS_TYPE;
import com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS;
import com.sun.jna.ptr.IntByReference;
/**
* Win32 Service wrapper
* @author EugineLev
*/
public class W32Service {
SC_HANDLE _handle = null;
/**
* Win32 Service
* @param handle
* A handle to the service. This handle is returned by the CreateService or OpenService
* function, and it must have the SERVICE_QUERY_STATUS access right.
*/
public W32Service(SC_HANDLE handle) {
_handle = handle;
}
/**
* Close service.
*/
public void close() {
if (_handle != null) {
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
_handle = null;
}
}
/**
* Retrieves the current status of the specified service based on the specified information level.
* @return
* Service status information
*/
public SERVICE_STATUS_PROCESS queryStatus() {
IntByReference size = new IntByReference();
Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
null, 0, size);
SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(size.getValue());
if(! Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
status, status.size(), size)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return status;
}
public void startService() {
waitForNonPendingState();
// If the service is already running - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
return;
}
if (! Advapi32.INSTANCE.StartService(_handle, 0, null)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
throw new RuntimeException("Unable to start the service");
}
}
/**
* Stop service.
*/
public void stopService() {
waitForNonPendingState();
// If the service is already stopped - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_STOPPED) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_STOP,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_STOPPED) {
throw new RuntimeException("Unable to stop the service");
}
}
/**
* Continue service.
*/
public void continueService() {
waitForNonPendingState();
// If the service is already stopped - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_CONTINUE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
throw new RuntimeException("Unable to continue the service");
}
}
/**
* Pause service.
*/
public void pauseService() {
waitForNonPendingState();
// If the service is already paused - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_PAUSED) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_PAUSE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_PAUSED) {
throw new RuntimeException("Unable to pause the service");
}
}
/**
* Wait for the state to change to something other than a pending state.
*/
public void waitForNonPendingState() {
SERVICE_STATUS_PROCESS status = queryStatus();
int previousCheckPoint = status.dwCheckPoint;
int checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();;
while (isPendingState(status.dwCurrentState)) {
// if the checkpoint advanced, start new tick count
if (status.dwCheckPoint != previousCheckPoint) {
previousCheckPoint = status.dwCheckPoint;
checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();
}
// if the time that passed is greater than the wait hint - throw timeout exception
if (Kernel32.INSTANCE.GetTickCount() - checkpointStartTickCount > status.dwWaitHint) {
throw new RuntimeException("Timeout waiting for service to change to a non-pending state.");
}
// do not wait longer than the wait hint. A good interval is
// one-tenth the wait hint, but no less than 1 second and no
// more than 10 seconds.
int dwWaitTime = status.dwWaitHint / 10;
if (dwWaitTime < 1000)
dwWaitTime = 1000;
else if (dwWaitTime > 10000)
dwWaitTime = 10000;
try {
Thread.sleep( dwWaitTime );
} catch (InterruptedException e){
throw new RuntimeException(e);
}
status = queryStatus();
}
}
private boolean isPendingState(int state) {
switch (state) {
case Winsvc.SERVICE_CONTINUE_PENDING:
case Winsvc.SERVICE_STOP_PENDING:
case Winsvc.SERVICE_PAUSE_PENDING:
case Winsvc.SERVICE_START_PENDING:
return true;
default:
return false;
}
}
/**
* Gets the service handle.
* @return
* Returns the service handle.
*/
public SC_HANDLE getHandle() {
return _handle;
}
}
/* Copyright (c) 2010 EugineLev, 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.Winsvc.SC_HANDLE;
import com.sun.jna.platform.win32.Winsvc.SC_STATUS_TYPE;
import com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS;
import com.sun.jna.ptr.IntByReference;
/**
* Win32 Service wrapper
* @author EugineLev
*/
public class W32Service {
SC_HANDLE _handle = null;
/**
* Win32 Service
* @param handle
* A handle to the service. This handle is returned by the CreateService or OpenService
* function, and it must have the SERVICE_QUERY_STATUS access right.
*/
public W32Service(SC_HANDLE handle) {
_handle = handle;
}
/**
* Close service.
*/
public void close() {
if (_handle != null) {
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
_handle = null;
}
}
/**
* Retrieves the current status of the specified service based on the specified information level.
* @return
* Service status information
*/
public SERVICE_STATUS_PROCESS queryStatus() {
IntByReference size = new IntByReference();
Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
null, 0, size);
SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(size.getValue());
if(! Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
status, status.size(), size)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return status;
}
public void startService() {
waitForNonPendingState();
// If the service is already running - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
return;
}
if (! Advapi32.INSTANCE.StartService(_handle, 0, null)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
throw new RuntimeException("Unable to start the service");
}
}
/**
* Stop service.
*/
public void stopService() {
waitForNonPendingState();
// If the service is already stopped - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_STOPPED) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_STOP,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_STOPPED) {
throw new RuntimeException("Unable to stop the service");
}
}
/**
* Continue service.
*/
public void continueService() {
waitForNonPendingState();
// If the service is already stopped - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_CONTINUE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
throw new RuntimeException("Unable to continue the service");
}
}
/**
* Pause service.
*/
public void pauseService() {
waitForNonPendingState();
// If the service is already paused - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_PAUSED) {
return;
}
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_PAUSE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_PAUSED) {
throw new RuntimeException("Unable to pause the service");
}
}
/**
* Wait for the state to change to something other than a pending state.
*/
public void waitForNonPendingState() {
SERVICE_STATUS_PROCESS status = queryStatus();
int previousCheckPoint = status.dwCheckPoint;
int checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();;
while (isPendingState(status.dwCurrentState)) {
// if the checkpoint advanced, start new tick count
if (status.dwCheckPoint != previousCheckPoint) {
previousCheckPoint = status.dwCheckPoint;
checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();
}
// if the time that passed is greater than the wait hint - throw timeout exception
if (Kernel32.INSTANCE.GetTickCount() - checkpointStartTickCount > status.dwWaitHint) {
throw new RuntimeException("Timeout waiting for service to change to a non-pending state.");
}
// do not wait longer than the wait hint. A good interval is
// one-tenth the wait hint, but no less than 1 second and no
// more than 10 seconds.
int dwWaitTime = status.dwWaitHint / 10;
if (dwWaitTime < 1000)
dwWaitTime = 1000;
else if (dwWaitTime > 10000)
dwWaitTime = 10000;
try {
Thread.sleep( dwWaitTime );
} catch (InterruptedException e){
throw new RuntimeException(e);
}
status = queryStatus();
}
}
private boolean isPendingState(int state) {
switch (state) {
case Winsvc.SERVICE_CONTINUE_PENDING:
case Winsvc.SERVICE_STOP_PENDING:
case Winsvc.SERVICE_PAUSE_PENDING:
case Winsvc.SERVICE_START_PENDING:
return true;
default:
return false;
}
}
/**
* Gets the service handle.
* @return
* Returns the service handle.
*/
public SC_HANDLE getHandle() {
return _handle;
}
}
@@ -1,91 +1,91 @@
/* Copyright (c) 2010 EugineLev, 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.Winsvc.SC_HANDLE;
/**
* Win32 Service Manager wrapper
* @author EugineLev
*/
public class W32ServiceManager {
SC_HANDLE _handle = null;
String _machineName = null;
String _databaseName = null;
public W32ServiceManager() {
}
public W32ServiceManager(String machineName, String databaseName) {
_machineName = machineName;
_databaseName = databaseName;
}
/**
* Opens the Service Manager with the supplied permissions.
* @param permissions
* Permissions.
*/
public void open(int permissions) {
close();
_handle = Advapi32.INSTANCE.OpenSCManager(
_machineName, _databaseName, permissions);
if (_handle == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Closes the previously opened Service Manager.
*/
public void close() {
if (_handle != null) {
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
_handle = null;
}
}
/**
* Opens a Service.
* @param serviceName
* Service name.
* @param permissions
* Permissions.
* @return
* Returns an opened service.
*/
public W32Service openService(String serviceName, int permissions) {
SC_HANDLE serviceHandle = Advapi32.INSTANCE.OpenService(
_handle, serviceName, permissions);
if (serviceHandle == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return new W32Service(serviceHandle);
}
/**
* Gets the service manager handle.
* @return
* Returns the service manager handle.
*/
public SC_HANDLE getHandle() {
return _handle;
}
/* Copyright (c) 2010 EugineLev, 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.Winsvc.SC_HANDLE;
/**
* Win32 Service Manager wrapper
* @author EugineLev
*/
public class W32ServiceManager {
SC_HANDLE _handle = null;
String _machineName = null;
String _databaseName = null;
public W32ServiceManager() {
}
public W32ServiceManager(String machineName, String databaseName) {
_machineName = machineName;
_databaseName = databaseName;
}
/**
* Opens the Service Manager with the supplied permissions.
* @param permissions
* Permissions.
*/
public void open(int permissions) {
close();
_handle = Advapi32.INSTANCE.OpenSCManager(
_machineName, _databaseName, permissions);
if (_handle == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Closes the previously opened Service Manager.
*/
public void close() {
if (_handle != null) {
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
_handle = null;
}
}
/**
* Opens a Service.
* @param serviceName
* Service name.
* @param permissions
* Permissions.
* @return
* Returns an opened service.
*/
public W32Service openService(String serviceName, int permissions) {
SC_HANDLE serviceHandle = Advapi32.INSTANCE.OpenService(
_handle, serviceName, permissions);
if (serviceHandle == null) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return new W32Service(serviceHandle);
}
/**
* Gets the service manager handle.
* @return
* Returns the service manager handle.
*/
public SC_HANDLE getHandle() {
return _handle;
}
}
@@ -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);
}
}
}
@@ -1,98 +1,98 @@
/* 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.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Wdm.h.
* Microsoft Windows DDK.
* @author dblock[at]dblock.org
*/
public interface Wdm extends StdCallLibrary {
/**
* The KEY_BASIC_INFORMATION structure defines a subset of
* the full information that is available for a registry key.
*/
public static class KEY_BASIC_INFORMATION extends Structure {
public KEY_BASIC_INFORMATION() {
super();
}
public KEY_BASIC_INFORMATION(int size) {
NameLength = size - 16; // write time, title index and name length
Name = new char[NameLength];
allocateMemory();
}
public KEY_BASIC_INFORMATION(Pointer memory) {
super(memory);
read();
}
/**
* The last time the key or any of its values changed.
*/
public long LastWriteTime;
/**
* Device and intermediate drivers should ignore this member.
*/
public int TitleIndex;
/**
* Specifies the size in bytes of the following name.
*/
public int NameLength;
/**
* A string of Unicode characters naming the key.
* 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.
*/
public String getName() {
return Native.toString(Name);
}
public void read() {
super.read();
Name = new char[NameLength / 2];
readField("Name");
}
}
/**
* The KEY_INFORMATION_CLASS enumeration type represents
* the type of information to supply about a registry key.
*/
public abstract class KEY_INFORMATION_CLASS {
public static final int KeyBasicInformation = 0;
public static final int KeyNodeInformation = 1;
public static final int KeyFullInformation = 2;
public static final int KeyNameInformation = 3;
public static final int KeyCachedInformation = 4;
public static final int KeyVirtualizationInformation = 5;
}
}
/* 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.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Wdm.h.
* Microsoft Windows DDK.
* @author dblock[at]dblock.org
*/
public interface Wdm extends StdCallLibrary {
/**
* The KEY_BASIC_INFORMATION structure defines a subset of
* the full information that is available for a registry key.
*/
public static class KEY_BASIC_INFORMATION extends Structure {
public KEY_BASIC_INFORMATION() {
super();
}
public KEY_BASIC_INFORMATION(int size) {
NameLength = size - 16; // write time, title index and name length
Name = new char[NameLength];
allocateMemory();
}
public KEY_BASIC_INFORMATION(Pointer memory) {
super(memory);
read();
}
/**
* The last time the key or any of its values changed.
*/
public long LastWriteTime;
/**
* Device and intermediate drivers should ignore this member.
*/
public int TitleIndex;
/**
* Specifies the size in bytes of the following name.
*/
public int NameLength;
/**
* A string of Unicode characters naming the key.
* 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.
*/
public String getName() {
return Native.toString(Name);
}
public void read() {
super.read();
Name = new char[NameLength / 2];
readField("Name");
}
}
/**
* The KEY_INFORMATION_CLASS enumeration type represents
* the type of information to supply about a registry key.
*/
public abstract class KEY_INFORMATION_CLASS {
public static final int KeyBasicInformation = 0;
public static final int KeyNodeInformation = 1;
public static final int KeyFullInformation = 2;
public static final int KeyNameInformation = 3;
public static final int KeyCachedInformation = 4;
public static final int KeyVirtualizationInformation = 5;
}
}
@@ -1,54 +1,54 @@
/* 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.platform.win32.WinNT.HRESULT;
/**
* Win32 exception.
* @author dblock[at]dblock[dot]org
*/
public class Win32Exception extends RuntimeException {
private static final long serialVersionUID = 1L;
private HRESULT _hr;
/**
* Returns the error code of the error.
* @return
* Error code.
*/
public HRESULT getHR() {
return _hr;
}
/**
* New Win32 exception from HRESULT.
* @param hr
* HRESULT
*/
public Win32Exception(HRESULT hr) {
super(Kernel32Util.formatMessageFromHR(hr));
_hr = hr;
}
/**
* New Win32 exception from an error code, usually obtained from GetLastError.
* @param code
* Error code.
*/
public Win32Exception(int code) {
this(W32Errors.HRESULT_FROM_WIN32(code));
}
}
/* 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.platform.win32.WinNT.HRESULT;
/**
* Win32 exception.
* @author dblock[at]dblock[dot]org
*/
public class Win32Exception extends RuntimeException {
private static final long serialVersionUID = 1L;
private HRESULT _hr;
/**
* Returns the error code of the error.
* @return
* Error code.
*/
public HRESULT getHR() {
return _hr;
}
/**
* New Win32 exception from HRESULT.
* @param hr
* HRESULT
*/
public Win32Exception(HRESULT hr) {
super(Kernel32Util.formatMessageFromHR(hr));
_hr = hr;
}
/**
* New Win32 exception from an error code, usually obtained from GetLastError.
* @param code
* Error code.
*/
public Win32Exception(int code) {
this(W32Errors.HRESULT_FROM_WIN32(code));
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,175 +1,175 @@
/* 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.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from WinCrypt.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinCrypt extends StdCallLibrary {
/**
* The CryptoAPI CRYPTOAPI_BLOB structure is used for an arbitrary array of bytes.
*/
public static class DATA_BLOB extends Structure {
public DATA_BLOB() {
super();
}
public DATA_BLOB(Pointer memory) {
super(memory);
read();
}
public DATA_BLOB(byte [] data) {
pbData = new Memory(data.length);
pbData.write(0, data, 0, data.length);
cbData = data.length;
allocateMemory();
}
public DATA_BLOB(String s) {
this(Native.toByteArray(s));
}
/**
* The count of bytes in the buffer pointed to by pbData.
*/
public int cbData;
/**
* A pointer to a block of data bytes.
*/
public Pointer pbData;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbData", "pbData" });
}
/**
* Get byte data.
* @return
* Byte data or null.
*/
public byte[] getData() {
return pbData == null ? null : pbData.getByteArray(0, cbData);
}
}
/**
* The CRYPTPROTECT_PROMPTSTRUCT structure provides the text of a prompt and
* information about when and where that prompt is to be displayed when using
* the CryptProtectData and CryptUnprotectData functions.
*/
public static class CRYPTPROTECT_PROMPTSTRUCT extends Structure {
public CRYPTPROTECT_PROMPTSTRUCT() {
super();
}
public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) {
super(memory);
read();
}
/**
* Size of this structure in bytes.
*/
public int cbSize;
/**
* DWORD flags that indicate when prompts to the user are to be displayed.
*/
public int dwPromptFlags;
/**
* Window handle to the parent window.
*/
public HWND hwndApp;
/**
* 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" });
}
}
//
// CryptProtect PromptStruct dwPromtFlags
//
/**
* Prompt on unprotect.
*/
int CRYPTPROTECT_PROMPT_ON_UNPROTECT = 0x1; // 1<<0
/**
* Prompt on protect.
*/
int CRYPTPROTECT_PROMPT_ON_PROTECT = 0x2; // 1<<1
/**
* Reserved, don't use.
*/
int CRYPTPROTECT_PROMPT_RESERVED = 0x04;
/**
* Default to strong variant UI protection (user supplied password currently).
*/
int CRYPTPROTECT_PROMPT_STRONG = 0x08; // 1<<3
/**
* Require strong variant UI protection (user supplied password currently).
*/
int CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 0x10; // 1<<4
//
// CryptProtectData and CryptUnprotectData dwFlags
//
/**
* For remote-access situations where ui is not an option, if UI was specified
* on protect or unprotect operation, the call will fail and GetLastError() will
* indicate ERROR_PASSWORD_RESTRICTION.
*/
int CRYPTPROTECT_UI_FORBIDDEN = 0x1;
/**
* Per machine protected data -- any user on machine where CryptProtectData
* took place may CryptUnprotectData.
*/
int CRYPTPROTECT_LOCAL_MACHINE = 0x4;
/**
* Force credential synchronize during CryptProtectData()
* Synchronize is only operation that occurs during this operation.
*/
int CRYPTPROTECT_CRED_SYNC = 0x8;
/**
* Generate an Audit on protect and unprotect operations.
*/
int CRYPTPROTECT_AUDIT = 0x10;
/**
* Protect data with a non-recoverable key.
*/
int CRYPTPROTECT_NO_RECOVERY = 0x20;
/**
* Verify the protection of a protected blob.
*/
int CRYPTPROTECT_VERIFY_PROTECTION = 0x40;
/**
* Regenerate the local machine protection.
*/
int CRYPTPROTECT_CRED_REGENERATE = 0x80;
}
/* 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.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from WinCrypt.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinCrypt extends StdCallLibrary {
/**
* The CryptoAPI CRYPTOAPI_BLOB structure is used for an arbitrary array of bytes.
*/
public static class DATA_BLOB extends Structure {
public DATA_BLOB() {
super();
}
public DATA_BLOB(Pointer memory) {
super(memory);
read();
}
public DATA_BLOB(byte [] data) {
pbData = new Memory(data.length);
pbData.write(0, data, 0, data.length);
cbData = data.length;
allocateMemory();
}
public DATA_BLOB(String s) {
this(Native.toByteArray(s));
}
/**
* The count of bytes in the buffer pointed to by pbData.
*/
public int cbData;
/**
* A pointer to a block of data bytes.
*/
public Pointer pbData;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbData", "pbData" });
}
/**
* Get byte data.
* @return
* Byte data or null.
*/
public byte[] getData() {
return pbData == null ? null : pbData.getByteArray(0, cbData);
}
}
/**
* The CRYPTPROTECT_PROMPTSTRUCT structure provides the text of a prompt and
* information about when and where that prompt is to be displayed when using
* the CryptProtectData and CryptUnprotectData functions.
*/
public static class CRYPTPROTECT_PROMPTSTRUCT extends Structure {
public CRYPTPROTECT_PROMPTSTRUCT() {
super();
}
public CRYPTPROTECT_PROMPTSTRUCT(Pointer memory) {
super(memory);
read();
}
/**
* Size of this structure in bytes.
*/
public int cbSize;
/**
* DWORD flags that indicate when prompts to the user are to be displayed.
*/
public int dwPromptFlags;
/**
* Window handle to the parent window.
*/
public HWND hwndApp;
/**
* 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" });
}
}
//
// CryptProtect PromptStruct dwPromtFlags
//
/**
* Prompt on unprotect.
*/
int CRYPTPROTECT_PROMPT_ON_UNPROTECT = 0x1; // 1<<0
/**
* Prompt on protect.
*/
int CRYPTPROTECT_PROMPT_ON_PROTECT = 0x2; // 1<<1
/**
* Reserved, don't use.
*/
int CRYPTPROTECT_PROMPT_RESERVED = 0x04;
/**
* Default to strong variant UI protection (user supplied password currently).
*/
int CRYPTPROTECT_PROMPT_STRONG = 0x08; // 1<<3
/**
* Require strong variant UI protection (user supplied password currently).
*/
int CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 0x10; // 1<<4
//
// CryptProtectData and CryptUnprotectData dwFlags
//
/**
* For remote-access situations where ui is not an option, if UI was specified
* on protect or unprotect operation, the call will fail and GetLastError() will
* indicate ERROR_PASSWORD_RESTRICTION.
*/
int CRYPTPROTECT_UI_FORBIDDEN = 0x1;
/**
* Per machine protected data -- any user on machine where CryptProtectData
* took place may CryptUnprotectData.
*/
int CRYPTPROTECT_LOCAL_MACHINE = 0x4;
/**
* Force credential synchronize during CryptProtectData()
* Synchronize is only operation that occurs during this operation.
*/
int CRYPTPROTECT_CRED_SYNC = 0x8;
/**
* Generate an Audit on protect and unprotect operations.
*/
int CRYPTPROTECT_AUDIT = 0x10;
/**
* Protect data with a non-recoverable key.
*/
int CRYPTPROTECT_NO_RECOVERY = 0x20;
/**
* Verify the protection of a protected blob.
*/
int CRYPTPROTECT_VERIFY_PROTECTION = 0x40;
/**
* Regenerate the local machine protection.
*/
int CRYPTPROTECT_CRED_REGENERATE = 0x80;
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,118 +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 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(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;
}
/* 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
@@ -1,70 +1,70 @@
/* 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.Pointer;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* This module contains the function prototypes and constant, type and structure
* definitions for the Windows 32-Bit Registry API.
* Ported from WinReg.h
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinReg extends StdCallLibrary {
public static class HKEY extends HANDLE {
public HKEY() { }
public HKEY(Pointer p) { super(p); }
public HKEY(int value) { super(new Pointer(value)); }
}
public static class HKEYByReference extends ByReference {
public HKEYByReference() {
this(null);
}
public HKEYByReference(HKEY h) {
super(Pointer.SIZE);
setValue(h);
}
public void setValue(HKEY h) {
getPointer().setPointer(0, h != null ? h.getPointer() : null);
}
public HKEY getValue() {
Pointer p = getPointer().getPointer(0);
if (p == null)
return null;
if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p))
return (HKEY) WinBase.INVALID_HANDLE_VALUE;
HKEY h = new HKEY();
h.setPointer(p);
return h;
}
}
HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
HKEY HKEY_CURRENT_USER = new HKEY(0x80000001);
HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002);
HKEY HKEY_USERS = new HKEY(0x80000003);
HKEY HKEY_PERFORMANCE_DATA= new HKEY(0x80000004);
HKEY HKEY_PERFORMANCE_TEXT= new HKEY(0x80000050);
HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060);
HKEY HKEY_CURRENT_CONFIG = new HKEY(0x80000005);
HKEY HKEY_DYN_DATA = new HKEY(0x80000006);
}
/* 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.Pointer;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* This module contains the function prototypes and constant, type and structure
* definitions for the Windows 32-Bit Registry API.
* Ported from WinReg.h
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface WinReg extends StdCallLibrary {
public static class HKEY extends HANDLE {
public HKEY() { }
public HKEY(Pointer p) { super(p); }
public HKEY(int value) { super(new Pointer(value)); }
}
public static class HKEYByReference extends ByReference {
public HKEYByReference() {
this(null);
}
public HKEYByReference(HKEY h) {
super(Pointer.SIZE);
setValue(h);
}
public void setValue(HKEY h) {
getPointer().setPointer(0, h != null ? h.getPointer() : null);
}
public HKEY getValue() {
Pointer p = getPointer().getPointer(0);
if (p == null)
return null;
if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p))
return (HKEY) WinBase.INVALID_HANDLE_VALUE;
HKEY h = new HKEY();
h.setPointer(p);
return h;
}
}
HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
HKEY HKEY_CURRENT_USER = new HKEY(0x80000001);
HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002);
HKEY HKEY_USERS = new HKEY(0x80000003);
HKEY HKEY_PERFORMANCE_DATA= new HKEY(0x80000004);
HKEY HKEY_PERFORMANCE_TEXT= new HKEY(0x80000050);
HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060);
HKEY HKEY_CURRENT_CONFIG = new HKEY(0x80000005);
HKEY HKEY_DYN_DATA = new HKEY(0x80000006);
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,144 +1,144 @@
/* 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.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Ported from Winspool.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface Winspool extends StdCallLibrary {
Winspool INSTANCE = (Winspool) Native.loadLibrary("Winspool.drv", Winspool.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* The EnumPrinters function enumerates available printers, print servers, domains, or print providers.
* @param Flags
* The types of print objects that the function should enumerate.
* @param Name
* If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is non-NULL, then Name is a pointer
* to a null-terminated string that specifies the name of the object to enumerate. This string can
* be the name of a server, a domain, or a print provider.
* If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is NULL, then the function enumerates
* the available print providers.
* If Level is 1, Flags contains PRINTER_ENUM_REMOTE, and Name is NULL, then the function enumerates
* the printers in the user's domain.
* If Level is 2 or 5,Name is a pointer to a null-terminated string that specifies the name of a
* server whose printers are to be enumerated. If this string is NULL, then the function enumerates
* the printers installed on the local computer.
* If Level is 4, Name should be NULL. The function always queries on the local computer.
* When Name is NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS enumerates
* printers that are installed on the local machine. These printers include those that are physically
* attached to the local machine as well as remote printers to which it has a network connection.
* When Name is not NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_NAME enumerates the
* local printers that are installed on the server Name.
* @param Level
* The type of data structures pointed to by pPrinterEnum. Valid values are 1, 2, 4, and 5, which
* correspond to the PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, and PRINTER_INFO_5 data
* structures.
* @param pPrinterEnum
* A pointer to a buffer that receives an array of PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4,
* or PRINTER_INFO_5 structures. Each structure contains data that describes an available print
* object.
* If Level is 1, the array contains PRINTER_INFO_1 structures. If Level is 2, the array contains
* PRINTER_INFO_2 structures. If Level is 4, the array contains PRINTER_INFO_4 structures. If Level
* is 5, the array contains PRINTER_INFO_5 structures.
* The buffer must be large enough to receive the array of data structures and any strings or other
* data to which the structure members point. If the buffer is too small, the pcbNeeded parameter
* returns the required buffer size.
* @param cbBuf
* The size, in bytes, of the buffer pointed to by pPrinterEnum.
* @param pcbNeeded
* A pointer to a value that receives the number of bytes copied if the function succeeds or the
* number of bytes required if cbBuf is too small.
* @param pcReturned
* A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4,
* or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points.
* @return
* If the function succeeds, the return value is a nonzero value.
* If the function fails, the return value is zero.
*/
boolean EnumPrinters(int Flags, String Name, int Level, Pointer pPrinterEnum,
int cbBuf, IntByReference pcbNeeded, IntByReference pcReturned);
public static class PRINTER_INFO_1 extends Structure {
public int Flags;
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) {
super(new Memory(size));
}
}
public static class PRINTER_INFO_4 extends Structure {
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) {
super(new Memory(size));
}
}
int PRINTER_ENUM_DEFAULT = 0x00000001;
int PRINTER_ENUM_LOCAL = 0x00000002;
int PRINTER_ENUM_CONNECTIONS = 0x00000004;
int PRINTER_ENUM_FAVORITE = 0x00000004;
int PRINTER_ENUM_NAME = 0x00000008;
int PRINTER_ENUM_REMOTE = 0x00000010;
int PRINTER_ENUM_SHARED = 0x00000020;
int PRINTER_ENUM_NETWORK = 0x00000040;
int PRINTER_ENUM_EXPAND = 0x00004000;
int PRINTER_ENUM_CONTAINER = 0x00008000;
int PRINTER_ENUM_ICONMASK = 0x00ff0000;
int PRINTER_ENUM_ICON1 = 0x00010000;
int PRINTER_ENUM_ICON2 = 0x00020000;
int PRINTER_ENUM_ICON3 = 0x00040000;
int PRINTER_ENUM_ICON4 = 0x00080000;
int PRINTER_ENUM_ICON5 = 0x00100000;
int PRINTER_ENUM_ICON6 = 0x00200000;
int PRINTER_ENUM_ICON7 = 0x00400000;
int PRINTER_ENUM_ICON8 = 0x00800000;
int PRINTER_ENUM_HIDE = 0x01000000;
}
/* 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.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Ported from Winspool.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface Winspool extends StdCallLibrary {
Winspool INSTANCE = (Winspool) Native.loadLibrary("Winspool.drv", Winspool.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* The EnumPrinters function enumerates available printers, print servers, domains, or print providers.
* @param Flags
* The types of print objects that the function should enumerate.
* @param Name
* If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is non-NULL, then Name is a pointer
* to a null-terminated string that specifies the name of the object to enumerate. This string can
* be the name of a server, a domain, or a print provider.
* If Level is 1, Flags contains PRINTER_ENUM_NAME, and Name is NULL, then the function enumerates
* the available print providers.
* If Level is 1, Flags contains PRINTER_ENUM_REMOTE, and Name is NULL, then the function enumerates
* the printers in the user's domain.
* If Level is 2 or 5,Name is a pointer to a null-terminated string that specifies the name of a
* server whose printers are to be enumerated. If this string is NULL, then the function enumerates
* the printers installed on the local computer.
* If Level is 4, Name should be NULL. The function always queries on the local computer.
* When Name is NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS enumerates
* printers that are installed on the local machine. These printers include those that are physically
* attached to the local machine as well as remote printers to which it has a network connection.
* When Name is not NULL, setting Flags to PRINTER_ENUM_LOCAL | PRINTER_ENUM_NAME enumerates the
* local printers that are installed on the server Name.
* @param Level
* The type of data structures pointed to by pPrinterEnum. Valid values are 1, 2, 4, and 5, which
* correspond to the PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4, and PRINTER_INFO_5 data
* structures.
* @param pPrinterEnum
* A pointer to a buffer that receives an array of PRINTER_INFO_1, PRINTER_INFO_2, PRINTER_INFO_4,
* or PRINTER_INFO_5 structures. Each structure contains data that describes an available print
* object.
* If Level is 1, the array contains PRINTER_INFO_1 structures. If Level is 2, the array contains
* PRINTER_INFO_2 structures. If Level is 4, the array contains PRINTER_INFO_4 structures. If Level
* is 5, the array contains PRINTER_INFO_5 structures.
* The buffer must be large enough to receive the array of data structures and any strings or other
* data to which the structure members point. If the buffer is too small, the pcbNeeded parameter
* returns the required buffer size.
* @param cbBuf
* The size, in bytes, of the buffer pointed to by pPrinterEnum.
* @param pcbNeeded
* A pointer to a value that receives the number of bytes copied if the function succeeds or the
* number of bytes required if cbBuf is too small.
* @param pcReturned
* A pointer to a value that receives the number of PRINTER_INFO_1, PRINTER_INFO_2 , PRINTER_INFO_4,
* or PRINTER_INFO_5 structures that the function returns in the array to which pPrinterEnum points.
* @return
* If the function succeeds, the return value is a nonzero value.
* If the function fails, the return value is zero.
*/
boolean EnumPrinters(int Flags, String Name, int Level, Pointer pPrinterEnum,
int cbBuf, IntByReference pcbNeeded, IntByReference pcReturned);
public static class PRINTER_INFO_1 extends Structure {
public int Flags;
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) {
super(new Memory(size));
}
}
public static class PRINTER_INFO_4 extends Structure {
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) {
super(new Memory(size));
}
}
int PRINTER_ENUM_DEFAULT = 0x00000001;
int PRINTER_ENUM_LOCAL = 0x00000002;
int PRINTER_ENUM_CONNECTIONS = 0x00000004;
int PRINTER_ENUM_FAVORITE = 0x00000004;
int PRINTER_ENUM_NAME = 0x00000008;
int PRINTER_ENUM_REMOTE = 0x00000010;
int PRINTER_ENUM_SHARED = 0x00000020;
int PRINTER_ENUM_NETWORK = 0x00000040;
int PRINTER_ENUM_EXPAND = 0x00004000;
int PRINTER_ENUM_CONTAINER = 0x00008000;
int PRINTER_ENUM_ICONMASK = 0x00ff0000;
int PRINTER_ENUM_ICON1 = 0x00010000;
int PRINTER_ENUM_ICON2 = 0x00020000;
int PRINTER_ENUM_ICON3 = 0x00040000;
int PRINTER_ENUM_ICON4 = 0x00080000;
int PRINTER_ENUM_ICON5 = 0x00100000;
int PRINTER_ENUM_ICON6 = 0x00200000;
int PRINTER_ENUM_ICON7 = 0x00400000;
int PRINTER_ENUM_ICON8 = 0x00800000;
int PRINTER_ENUM_HIDE = 0x01000000;
}
@@ -1,65 +1,65 @@
/* 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.platform.win32.Winspool.PRINTER_INFO_1;
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_4;
import com.sun.jna.ptr.IntByReference;
/**
* Winspool Utility API.
*
* @author dblock[at]dblock.org
*/
public abstract class WinspoolUtil {
public static PRINTER_INFO_1[] getPrinterInfo1() {
IntByReference pcbNeeded = new IntByReference();
IntByReference pcReturned = new IntByReference();
Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 1, null, 0, pcbNeeded, pcReturned);
if (pcbNeeded.getValue() <= 0) {
return new PRINTER_INFO_1[0];
}
PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue());
if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
pPrinterEnum.read();
return (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue());
}
public static PRINTER_INFO_4[] getPrinterInfo4() {
IntByReference pcbNeeded = new IntByReference();
IntByReference pcReturned = new IntByReference();
Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 4, null, 0, pcbNeeded, pcReturned);
if (pcbNeeded.getValue() <= 0) {
return new PRINTER_INFO_4[0];
}
PRINTER_INFO_4 pPrinterEnum = new PRINTER_INFO_4(pcbNeeded.getValue());
if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 4, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
pPrinterEnum.read();
return (PRINTER_INFO_4[]) pPrinterEnum.toArray(pcReturned.getValue());
}
/* 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.platform.win32.Winspool.PRINTER_INFO_1;
import com.sun.jna.platform.win32.Winspool.PRINTER_INFO_4;
import com.sun.jna.ptr.IntByReference;
/**
* Winspool Utility API.
*
* @author dblock[at]dblock.org
*/
public abstract class WinspoolUtil {
public static PRINTER_INFO_1[] getPrinterInfo1() {
IntByReference pcbNeeded = new IntByReference();
IntByReference pcReturned = new IntByReference();
Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 1, null, 0, pcbNeeded, pcReturned);
if (pcbNeeded.getValue() <= 0) {
return new PRINTER_INFO_1[0];
}
PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue());
if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
pPrinterEnum.read();
return (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue());
}
public static PRINTER_INFO_4[] getPrinterInfo4() {
IntByReference pcbNeeded = new IntByReference();
IntByReference pcReturned = new IntByReference();
Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 4, null, 0, pcbNeeded, pcReturned);
if (pcbNeeded.getValue() <= 0) {
return new PRINTER_INFO_4[0];
}
PRINTER_INFO_4 pPrinterEnum = new PRINTER_INFO_4(pcbNeeded.getValue());
if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
null, 4, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
pPrinterEnum.read();
return (PRINTER_INFO_4[]) pPrinterEnum.toArray(pcReturned.getValue());
}
}

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