Comparar commits
571 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| b7fb1b7e5a | |||
| eb60877793 | |||
| 5907ce0a02 | |||
| 5a1d431e51 | |||
| 0552c4a001 | |||
| 96d017869a | |||
| ddc2688af8 | |||
| baa60b6198 | |||
| 8abdddf11a | |||
| 9141018b27 | |||
| 3370fecdf2 | |||
| 5e91f76f0f | |||
| 557b3e1c93 | |||
| 3f65e56ccd | |||
| 5bd2cba2c2 | |||
| 3de7eb58a7 | |||
| 41eb294ce6 | |||
| ba94f2ebe0 | |||
| 7912248950 | |||
| 5d27c255b3 | |||
| 80e86e3b83 | |||
| 3a759f1eea | |||
| a09e503f19 | |||
| da4524b05c | |||
| 1a98283709 | |||
| acca8c5ac9 | |||
| 55eabb84e4 | |||
| 90ba9fce2a | |||
| 76b3982ddd | |||
| c946f80d5b | |||
| 8d350c7d99 | |||
| 7cd7fb8d6c | |||
| b12e563340 | |||
| 9c0aadce1e | |||
| b8d538b1b4 | |||
| 0219cd71b9 | |||
| 899fcbdfcc | |||
| 79fed6e32f | |||
| 55263ca11d | |||
| fe1f4a3bac | |||
| dd4fda55b5 | |||
| 2aae506110 | |||
| aae54a6f41 | |||
| 89da58adec | |||
| 57ef003eb9 | |||
| d378a64096 | |||
| 58ac91bc10 | |||
| 97602c0bf8 | |||
| 8523c487c1 | |||
| 3580b58bf6 | |||
| 9b26a4d5ce | |||
| c43fc68bc8 | |||
| df07539331 | |||
| 563931750b | |||
| 6b090de7b1 | |||
| d8863ef95f | |||
| 36f9595ce7 | |||
| 48565e6305 | |||
| 3727f9583b | |||
| 4a6bbf0b3c | |||
| 7513a7157f | |||
| e7dbdb6ead | |||
| db5f101bfc | |||
| 3c06e8b6fd | |||
| 28f94cbd0b | |||
| 6f37cbd946 | |||
| 396281263b | |||
| a00e8ac201 | |||
| b1772a89c1 | |||
| 58f07ff045 | |||
| 12f99d4fc7 | |||
| 05da0a6877 | |||
| 46ce871f34 | |||
| 4b22c2f044 | |||
| 4014828eff | |||
| bc87a62d59 | |||
| f6862442d3 | |||
| bff7f57eb8 | |||
| e19024ca0d | |||
| 73997e4799 | |||
| ffa97aa438 | |||
| d08244dfd8 | |||
| 2e0d367045 | |||
| 0f1fb2e6a1 | |||
| 672e362ed8 | |||
| bcae16c441 | |||
| 19b8f5cb59 | |||
| 68b37156d8 | |||
| d9237b64c0 | |||
| da037b38e3 | |||
| 62f864f4ab | |||
| bf89f1d37d | |||
| 3dc986e609 | |||
| 2f5e874201 | |||
| 05291932f8 | |||
| 72aa450ecb | |||
| 926ea21fe0 | |||
| 657a077cdb | |||
| 9a90f56845 | |||
| 7d36e0d63b | |||
| 865d5ed7a1 | |||
| 9dd91ee17e | |||
| 425ea821d7 | |||
| bea5049a2f | |||
| eae1e34696 | |||
| e63b6b00bc | |||
| e5b3ed226b | |||
| d5ce354c87 | |||
| e280838989 | |||
| 2309054b1f | |||
| 9dcc44a76b | |||
| 7a417c6d3b | |||
| 425ab15ae1 | |||
| c75ff4f118 | |||
| 75d3dd19ec | |||
| 4cd556555e | |||
| feebe921af | |||
| 92929308bd | |||
| ca4f14b555 | |||
| a7bcfacbd9 | |||
| e097b4820d | |||
| 566ec7974c | |||
| c735d6c420 | |||
| cf54ca9551 | |||
| 9f1da1b562 | |||
| f5a3dbf82b | |||
| 89f83e796a | |||
| 977a9e49c5 | |||
| 7ee0a4b39f | |||
| 4268e3a1d2 | |||
| 860b9a266a | |||
| c39d752ccb | |||
| 15db1cf385 | |||
| 38d684d1e6 | |||
| ccb1bc514b | |||
| 27c46a2c8e | |||
| ff2f1d237a | |||
| 402f4c162c | |||
| 81013a98b4 | |||
| 971dd622c7 | |||
| 0045d31e2d | |||
| caef8f4ebc | |||
| 6116c1ae71 | |||
| 03ecf2b0bb | |||
| d4a5005273 | |||
| 7522f29f0a | |||
| 09f0a2e4a6 | |||
| aa846929f3 | |||
| b378af7cb1 | |||
| 8b549a487f | |||
| 005f659eaa | |||
| a5aad94f24 | |||
| 52a6926da3 | |||
| b3c0f003bb | |||
| 3d2360bc56 | |||
| 1267f51d8c | |||
| e7328001a4 | |||
| fc7b53e809 | |||
| 50637cb3c2 | |||
| 11b4203874 | |||
| 60beb432eb | |||
| 64331c9cf0 | |||
| 00088d4093 | |||
| 472f3660e0 | |||
| 3c13cc8c4d | |||
| 0792ac8eee | |||
| 4952af4ffe | |||
| 3fcca7ef56 | |||
| e93244fef2 | |||
| acf75ce7fe | |||
| 7560b6e53d | |||
| f5346bbec2 | |||
| 41958889fb | |||
| d439a7811d | |||
| 4951c00d23 | |||
| 202cd0d45e | |||
| 1502db6095 | |||
| e8eea9e68e | |||
| 396eb9f283 | |||
| 378f400226 | |||
| 37e02dfbd5 | |||
| dce66ec8ec | |||
| 2fef67a08d | |||
| 50a17583c7 | |||
| bfe2c7df83 | |||
| b3186dde12 | |||
| 628a33eb76 | |||
| 4373e66b1e | |||
| 2e67b0ad9f | |||
| a4cbe0635f | |||
| 8563419280 | |||
| 0974bd4a90 | |||
| e1d47adc99 | |||
| e5e171d913 | |||
| 1e313227b8 | |||
| 8d45a9e0cd | |||
| 95568d76d3 | |||
| d4a3442468 | |||
| e262de22ea | |||
| 49243f1891 | |||
| 1a099ba549 | |||
| 2367133b4f | |||
| c648a1933d | |||
| 598acf08da | |||
| 208a8dee90 | |||
| e9fb299565 | |||
| 17a514ecd0 | |||
| 38ac62cedd | |||
| ce280731af | |||
| 751fb57f71 | |||
| be7d90abbf | |||
| d59585dd4f | |||
| 7a695707a2 | |||
| 4e590c9450 | |||
| b069d1c9e9 | |||
| 9fa1f7b981 | |||
| 4a68e4cd9d | |||
| 8320b6fd7c | |||
| e40cf0a1c4 | |||
| 19106985d7 | |||
| 3d817c54da | |||
| ca31877107 | |||
| f5f9afefb0 | |||
| d42863603e | |||
| 2c19cf3e31 | |||
| e7dc918c6a | |||
| 64c9e8212a | |||
| 499c39f13d | |||
| bccdae735b | |||
| 58120730a5 | |||
| 5b8db8a680 | |||
| 0acfd583c8 | |||
| 402b7ef67e | |||
| 6944871c42 | |||
| b60da35689 | |||
| 5204feddb1 | |||
| 68156df66b | |||
| a9e8b27285 | |||
| b8f470ddbd | |||
| 9d075dd1d1 | |||
| 4b802c6f60 | |||
| 8ce9344dd0 | |||
| cb2b386791 | |||
| 7ee4681c10 | |||
| 82c0ea9df2 | |||
| 9070d80880 | |||
| 45c53caf94 | |||
| c4947618c1 | |||
| 941ed59c37 | |||
| d76bbec1ab | |||
| f5a1d98cf9 | |||
| b0e6d837f0 | |||
| b1cfb1b733 | |||
| 26a1212546 | |||
| 03b05aaae9 | |||
| f41c87d7c9 | |||
| b74deb5e35 | |||
| 240e2db637 | |||
| 441947b6a4 | |||
| 194bdaffcd | |||
| db6e9ff4c6 | |||
| 57261a1164 | |||
| 0b116bb409 | |||
| a5ad2e5de2 | |||
| b6928ff6c0 | |||
| 4b03dd321c | |||
| f7eefbd3d7 | |||
| b23f7f9b27 | |||
| b95bc7e4c4 | |||
| 1593c0c347 | |||
| c154663455 | |||
| 13bc1901dc | |||
| 4f28322ac2 | |||
| 756e2ced8b | |||
| 1dc78b5209 | |||
| 3464093273 | |||
| 4487214494 | |||
| 6d7e222946 | |||
| d12a6a3178 | |||
| ed9d609c35 | |||
| b86f359d93 | |||
| 02080dfcf8 | |||
| 2768d25884 | |||
| 7bdf9896d2 | |||
| 3b4f84ded8 | |||
| 69abc52731 | |||
| 1671b1fb8b | |||
| 8735f4ef5c | |||
| 86967b5786 | |||
| ca8ceeb130 | |||
| 41d6f8eeea | |||
| 27b7805608 | |||
| fef39f7013 | |||
| b414b54c6b | |||
| ccdbb20ad0 | |||
| eb7e47bf29 | |||
| 53988c7184 | |||
| 9092b2bdc5 | |||
| 068353aa5b | |||
| 95a17ddbf0 | |||
| 6c8c455f5b | |||
| 282032e178 | |||
| af63e6a80d | |||
| a46ba0da29 | |||
| f7738bf65b | |||
| bb11d1fe37 | |||
| d02a2deb52 | |||
| 46105d849d | |||
| f16b6c3482 | |||
| a9cb497045 | |||
| d529a34ecb | |||
| 5394029dc5 | |||
| 28247737ca | |||
| 6448c2d8fb | |||
| 4460ccc8ec | |||
| 2b02a3c533 | |||
| 6705513b86 | |||
| 4bd8d12481 | |||
| ccaf3c283b | |||
| ce4276a0cb | |||
| 709e316e56 | |||
| e46635d6ab | |||
| 0af8677ba4 | |||
| 9ab13daf09 | |||
| 17977fbabc | |||
| 83854047b7 | |||
| 28e56fd587 | |||
| 29fc6308b8 | |||
| 14a7df128d | |||
| dd4ef89d0a | |||
| 830ec91cbf | |||
| aee2d55fab | |||
| 89ed7982e7 | |||
| 9f702c89ab | |||
| 2f76efd0f6 | |||
| fae18c72c3 | |||
| 1586f6ee2b | |||
| 4ce6214526 | |||
| e370e4b65e | |||
| 944de2d3f5 | |||
| f32146368d | |||
| 8d45e9b016 | |||
| 70227861ff | |||
| 20e542516b | |||
| 73ad21df73 | |||
| a67fe7e43d | |||
| a15ddd9f88 | |||
| b27f9bf930 | |||
| d5c28f98f1 | |||
| 16b283ed00 | |||
| 97b43889a1 | |||
| 05efa12411 | |||
| 3e60495232 | |||
| 45522b0710 | |||
| d67d25eb7b | |||
| 2538690fb4 | |||
| 4c23b2518e | |||
| 9daade9816 | |||
| 5f925f0070 | |||
| 38b0cd7780 | |||
| e46391042b | |||
| 553a03b05f | |||
| 24c1cc4efe | |||
| f6eabe7b58 | |||
| de2de1fdc7 | |||
| 8184ac8843 | |||
| a57d82d4cd | |||
| a266ef7337 | |||
| b30ca23180 | |||
| db5c8f00fc | |||
| d1bbacb06e | |||
| bff4e3b0fd | |||
| 14248ddbd9 | |||
| 391f39d291 | |||
| b4354efa8b | |||
| 686588a6e5 | |||
| 294267a605 | |||
| 7b53b9108b | |||
| 15be9ab501 | |||
| 7cfcd2daef | |||
| 6070429eec | |||
| b5f41ef6c7 | |||
| 716588a8fb | |||
| 95bc92f005 | |||
| 23425abe9d | |||
| 3bab5e1e78 | |||
| 79ed7e81b1 | |||
| a59e58cc94 | |||
| 72bd12e394 | |||
| 2c667ca016 | |||
| 209c4d724f | |||
| 95cf641f50 | |||
| 85750fd065 | |||
| 402b5c7f81 | |||
| be6f52b796 | |||
| f4e6c6ad94 | |||
| 99fe59cee9 | |||
| 0e80ba8b91 | |||
| 8965efdce1 | |||
| 1393a94804 | |||
| 52e558d877 | |||
| d9948105f1 | |||
| 87c91c1c04 | |||
| f15e471371 | |||
| fc0a83933d | |||
| f1cf2fe218 | |||
| 7a5679cb65 | |||
| 571b4604db | |||
| 29e15a40db | |||
| 6fb2286fa4 | |||
| ab2f78c7b4 | |||
| f9b918a05b | |||
| a46cde174a | |||
| 6eee0f8741 | |||
| 28d31bb9f6 | |||
| 23128be17f | |||
| 130885fda7 | |||
| c4fc42f8f4 | |||
| 21e73c5fb9 | |||
| b635bf5591 | |||
| be594bb1f6 | |||
| 543e3fca98 | |||
| b385d76dc6 | |||
| 2adc88fec3 | |||
| 2a9e2ceb61 | |||
| 47fa804469 | |||
| f70c01eee7 | |||
| eb4ea07a2d | |||
| 55cd72baaa | |||
| 940076d101 | |||
| 93ebb9f7a9 | |||
| 1a17ea52d8 | |||
| 68bc0c0c7c | |||
| 0e7dd6b350 | |||
| b3b0bf3845 | |||
| ddc32f1e43 | |||
| c9de508a2c | |||
| fac68bca4e | |||
| eaf250c3c6 | |||
| 8b99772d29 | |||
| 862a32e97e | |||
| 6cfb84d6ee | |||
| 2fda7ca6f6 | |||
| f2aecb53bc | |||
| 05fdc2f17a | |||
| b9868b993c | |||
| 573d8eefd1 | |||
| 51d64f29e6 | |||
| a39ab60ae5 | |||
| ba9671fae5 | |||
| a9340f354d | |||
| f9d6b069f7 | |||
| c363d5790d | |||
| 15a50d2a26 | |||
| bffc188151 | |||
| e78205430c | |||
| 4ef76d4f85 | |||
| 967da46793 | |||
| 46899503bd | |||
| 2dcf0f774c | |||
| d669db0cab | |||
| f8aabcc50a | |||
| 4bb3ece8dc | |||
| 495a7765d2 | |||
| 225296f253 | |||
| 52e6900e7a | |||
| 557bff1465 | |||
| add32ac107 | |||
| f7699b98fb | |||
| 05a8ec1fec | |||
| 004e63c433 | |||
| 898f41b95a | |||
| 859a6a75aa | |||
| b90dae6448 | |||
| dc1ddf4cff | |||
| 46ef5d86c3 | |||
| ac63a6b125 | |||
| 72778c97df | |||
| b4b86081f9 | |||
| e4a47a4ca5 | |||
| 79c60f6d4e | |||
| 4c4d55e0dc | |||
| 9504416beb | |||
| 99586d9b3f | |||
| 65b19cbbd3 | |||
| 7b64f4443d | |||
| abb2e857be | |||
| df10745963 | |||
| 3d729595d1 | |||
| 96a38d1895 | |||
| b4c1390af8 | |||
| e9604ac212 | |||
| ea3a4b34ea | |||
| 79a0d92161 | |||
| b10c40260c | |||
| 9e056d2097 | |||
| 8a250c5994 | |||
| e311ac3269 | |||
| 28078a2d0c | |||
| 7def8c1bbf | |||
| 24ca11387e | |||
| bccc9583c1 | |||
| 9643747b17 | |||
| c695848092 | |||
| 5011613e4c | |||
| 6cc7f69a59 | |||
| db6678637b | |||
| 93892e12a2 | |||
| c196aab89d | |||
| 54a7718b88 | |||
| cec6e6175a | |||
| bc5036bd34 | |||
| 021826eb1b | |||
| facd071967 | |||
| 486e81ad77 | |||
| 872cd3d7c0 | |||
| ca9851b311 | |||
| 2fa0940d45 | |||
| 3485338386 | |||
| 786a821f3f | |||
| da1c9c5ea5 | |||
| 93d8cce7ac | |||
| 5086ba2a3b | |||
| 4cf8611dcd | |||
| 101e9d705a | |||
| 7d8bfa1b62 | |||
| 5dcf9e2f41 | |||
| cdf18b6c4d | |||
| 609ce3b6e0 | |||
| 3ba8be2e21 | |||
| 6b13a97ce4 | |||
| 130e40957e | |||
| a7b28317d7 | |||
| 29fcd0fdcf | |||
| 9d5f63e543 | |||
| 208c28ead2 | |||
| 447d5ee94b | |||
| bb443add17 | |||
| cb954773ed | |||
| 89749c7eb1 | |||
| 30146f8744 | |||
| a623f374b1 | |||
| b41584feb3 | |||
| 77d5bbb767 | |||
| 171d428d3a | |||
| 61254c6cc4 | |||
| 44b3a8952e | |||
| 0fc8c5e7e9 | |||
| 6d969eb92f | |||
| 26ea0f81ca | |||
| dc45e38f11 | |||
| 9d5db40d3f | |||
| 9e25d52679 | |||
| 1f98d4f6ff | |||
| b73883ce1d | |||
| 7af42da5d2 | |||
| cf75057b67 | |||
| e5b1841030 | |||
| 57325a22a5 | |||
| c640166cf8 | |||
| 4b4c362c03 | |||
| c71bfb1602 | |||
| 022e6349c1 | |||
| 917671ac9a | |||
| a108975d78 | |||
| 62d31c5902 | |||
| 5d28314ee3 | |||
| 1b22109f95 | |||
| e5c05bfd66 | |||
| 62e97858d7 | |||
| b9da9b977e |
+8
-8
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 1.5"/>
|
||||
<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="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>
|
||||
|
||||
+74
-50
@@ -18,36 +18,40 @@
|
||||
* get system process information, basic process control
|
||||
* additional file utilities (meta info, free space, etc)
|
||||
* enforce window minimum/maximum size (workaround java bug)
|
||||
* OSX ObjC access
|
||||
|
||||
# TODO
|
||||
|
||||
* parser (gluegen? swig? others?) to auto-generate JNA interfaces from headers;
|
||||
ideally get the native library build system to output preprocessed headers,
|
||||
otherwise CPP crap is a nightmare to get right.
|
||||
o write SWIG transformer to auto-generate interfaces from header files
|
||||
* fix setFieldOrder to *always* apply if used
|
||||
* cache structure information
|
||||
|
||||
* stdcall/w32 underscore prefix issue
|
||||
* make direct calls call back *once* to Java where conversion is required,
|
||||
and process all arguments from there (instead of potentially swapping back
|
||||
and forth multipel times). This also makes it easer to perform conversions
|
||||
(no native changes required).
|
||||
|
||||
* should structure offsets be "long"?
|
||||
* direct/raw non-primitive array arguments (String[], Pointer[], NativeMapped[])
|
||||
|
||||
* allow return of W/String[] or Pointer[], if array is NULL-terminated?
|
||||
* ppc64 direct/raw failures (multiple)
|
||||
|
||||
* Direct buffers should be used where
|
||||
hotspot inlining can improve performance.
|
||||
* direct calls on ppc to varargs (callbacks) with FP args fail; avoid them for
|
||||
now
|
||||
|
||||
* combine direct and interface mapping calling code where possible
|
||||
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* make native dll extraction from jar public, to use with user dlls packaged
|
||||
in a jar
|
||||
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
* Callback.PostCallWrite.write() cf PostCallRead
|
||||
|
||||
* GetPrimitiveArrayCritical: use this if flagged (by annotation? method name?)
|
||||
|
||||
* MethodArgument/ReturnMapper: per method mapping of arguments/return type.
|
||||
Can use annotations as shorthand to initialize a map, but basically set up a
|
||||
per-NativeLibrary (or per-Function?) map of methods to mappers.
|
||||
|
||||
Requires separate compilation of annotation handling.
|
||||
|
||||
* ditch type conversion context (?)
|
||||
|
||||
* packaging: 'types', 'convert/marshal' subpackages?
|
||||
note: marshal/unmarshal vs to/fromnative: to/fromnative is more
|
||||
@@ -57,12 +61,6 @@
|
||||
Pointer into a types subpackage (which would leave just a few top-level
|
||||
classes). Javadoc is cluttered by example classes anyway.
|
||||
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc.
|
||||
|
||||
* support annotations of parameters and return values w/o breaking
|
||||
1.4 compatibility (retroweaver?), e.g.
|
||||
-- retroweaver (requires retroweaver runtime classes to provide annotation
|
||||
@@ -77,14 +75,6 @@
|
||||
this only really applies to NativeLong/IntegerType types that want to use a
|
||||
primitive value instead of creating an object instance.
|
||||
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* flag string(/wstring)-returning methods which need to free their result
|
||||
to avoid leaking memory whan auto-creating strings from the result
|
||||
(since normally we don't take explicit ownership of any returned pointers)
|
||||
@@ -101,9 +91,26 @@
|
||||
"pointer-requiring-free" (which is just Memory). For now, leave it up to
|
||||
the user to manage the pointer, since they have to define the free method
|
||||
anyway. use could always put a finalizer on a PointerType-derived type.
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* universal GCC build w/cross-compile (needs cross compilers...)
|
||||
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
|
||||
Long.SIZE, Integer.SIZE, et al.
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* bitfields for structs (how?)
|
||||
|
||||
|
||||
# DONE
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* check Structure "final" fields; should never write back to native memory
|
||||
* OSX ObjC access (see rococoa)
|
||||
* do Structure.write for any callback args
|
||||
* pointer.setValue(), to handle NativeMapped types and move read/writeValue
|
||||
methods out of Structure, to be used by Function w/NativeMapped[] parameter
|
||||
|
||||
* if method has "GetLastErrorException/ErrnoException" in its signature, use
|
||||
result codes + GetLastError/errno/errstr to auto-generate
|
||||
runtime exceptions? (cf P/Invoke; also useful for X11 return types)
|
||||
@@ -115,21 +122,13 @@
|
||||
if nonzero ?
|
||||
o otherwise, need an ExceptionOnZero, ExceptionOnNonZero runtime, from which
|
||||
derive GetLastError/ErrnoExceptionOnZero/NZ
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
* universal GCC build w/cross-compile (needs cross compilers...)
|
||||
* return Pointer.SIZE/LONG_SIZE/WCHAR_SIZE in bits (for consistency with 1.5)
|
||||
Long.SIZE, Integer.SIZE, et al.
|
||||
* interface "lvalue", which can provide a pointer to itself (reference() or
|
||||
addressOf())?
|
||||
* verify get/set methods vs read/write for performance (Pointer)?
|
||||
* bitfields for structs (how?)
|
||||
(see RawTest for performance comparisons)
|
||||
* Allow Buffer in Structures (and callbacks) (auto-wrap in direct byte buffer)?
|
||||
o this gets tricky when reading structs from native memory; we don't know if
|
||||
the value is already mapped to a buffer (cf CallbackReference)
|
||||
* standard types for various platforms: posix/types.h, w32 (DWORD, HANDLE)
|
||||
|
||||
|
||||
|
||||
|
||||
# DONE
|
||||
* embed version in DLL ('depends'-done)/so (symlink?)
|
||||
* use libffi closure allocation/deallocation
|
||||
|
||||
@@ -249,5 +248,30 @@ transient callbacks, and require callback+dispose for most callbacks?
|
||||
void setWindowMask(Window w, Shape clip);
|
||||
// needs:
|
||||
int findNativeWindow(Window w);
|
||||
|
||||
#MAYBE NOT
|
||||
* should structure offsets be 64-bit? technically yes, but in practice I don't
|
||||
think a structure that big actually works.
|
||||
* (maybe) move all native functions into Native (limit header files, easier
|
||||
management)
|
||||
* Does it make sense to define Int16/UInt16, Int32/UInt32, etc? Probably not
|
||||
the signed versions, but maybe the unsigned ones, to facilitate generating
|
||||
unsigned values (maybe just provide utilities to pack an unsigned int into a
|
||||
signed int). What about size_t, off_t, et al.? Would either need a
|
||||
bunch of native lookup functions (more accurate) or java-side conditionals
|
||||
(less robust but easier to change).
|
||||
o bounds checking is handled by IntegerType (pass in a long, get an
|
||||
exception if the value is out of bounds).
|
||||
o when used as struct fields, could allow detection of field order by order
|
||||
of initialization (requires all-or-nothing usage, though)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
* provide library load/unload hooks (Runnables in options?). Examples:
|
||||
o GetLastError (no longer needed)
|
||||
o WSAInit?
|
||||
* determine X11 display name from current java program (if any); null is ok
|
||||
since it uses getenv(DISPLAY), which is what java would do
|
||||
note: DISPLAY may be available in GraphicsDevice->getIDstring
|
||||
|
||||
|
||||
|
||||
+245
-96
@@ -15,10 +15,15 @@
|
||||
<!-- (all build-related props should go in -dynamic-properties) -->
|
||||
<property name="name" value="jna"/>
|
||||
<property name="jar" value="${name}.jar"/>
|
||||
<property name="testjar" value="${name}-test.jar"/>
|
||||
<property name="debug" value="true"/>
|
||||
<property name="debug.native" value="false"/>
|
||||
<property name="cflags_extra.native" value=""/>
|
||||
<property name="dynlink.native" value="false"/>
|
||||
<property name="native" location="native"/>
|
||||
<property name="src" location="src"/>
|
||||
<property name="platform.src" location="contrib/platform/src"/>
|
||||
<property name="contrib" location="contrib"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="test.src" location="test"/>
|
||||
<property name="doc" location="doc"/>
|
||||
@@ -26,27 +31,27 @@
|
||||
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
|
||||
<property name="vendor" value="JNA Development Team"/>
|
||||
<property name="copyright"
|
||||
value="Copyright &copy; 2007 Timothy Wall. All Rights Reserved."/>
|
||||
value="Copyright &copy; 2007-2010 Timothy Wall. All Rights Reserved."/>
|
||||
<buildnumber/>
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="0"/>
|
||||
<property name="jna.revision" value="2"/>
|
||||
<property name="jna.minor" value="3"/>
|
||||
<property name="jna.revision" value="0"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
<property name="jni.major" value="3"/>
|
||||
<property name="jni.minor" value="0"/>
|
||||
<property name="jni.revision" value="3"/>
|
||||
<property name="jni.minor" value="3"/>
|
||||
<property name="jni.revision" value="0"/>
|
||||
<property name="jni.build" value="${build.number}"/>
|
||||
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
|
||||
<property name="jni.md5" value="892beacd437514d23ed9b1cefeb2ead6"/>
|
||||
<property name="jni.md5" value="4c69bcf40b30785215211b5a5dad211e"/>
|
||||
<property name="spec.title" value="Java Native Access (JNA)"/>
|
||||
<property name="spec.vendor" value="${vendor}"/>
|
||||
<property name="spec.version" value="${jna.major}"/>
|
||||
<property name="impl.title" value="${spec.title}"/>
|
||||
<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}"/>
|
||||
<property name="impl.version" value="${jna.version} (b${jna.build})"/>
|
||||
|
||||
<property name="compatibility" value="1.4"/>
|
||||
<property name="test.compatibility" value="1.5"/>
|
||||
@@ -56,27 +61,65 @@
|
||||
|
||||
<target name="default" depends="test" description="Build and Test."/>
|
||||
|
||||
<import file="nbproject/profiler-build-impl.xml"/>
|
||||
<!-- uncomment for netbeans profiling -->
|
||||
<!--<import file="nbproject/profiler-build-impl.xml"/>-->
|
||||
<target name="init" depends="-setup"/>
|
||||
<target name="compile-test-single" depends="compile-tests"/>
|
||||
<target name="compile-single" depends="compile"/>
|
||||
|
||||
<target name="-dynamic-properties">
|
||||
<echo>Java version: ${java.version}, compatibility: ${compatibility}</echo>
|
||||
<echo>JNA version ${jna.version}, native API version ${jni.version}</echo>
|
||||
<property name="build" value="build"/>
|
||||
<echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
|
||||
<echo>JNA version ${jna.version}, native ${jni.version}</echo>
|
||||
<echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
|
||||
<echo>java.home=${java.home}</echo>
|
||||
<echo>java.library.path=${java.library.path}</echo>
|
||||
|
||||
<replaceregexp match="(<version>).*(</version>)"
|
||||
replace="\1${jna.version}\2"
|
||||
file="pom.xml"/>
|
||||
<replaceregexp match='VERSION = ".*";'
|
||||
replace='VERSION = "${jna.version}";'
|
||||
file="src/com/sun/jna/Native.java"/>
|
||||
|
||||
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
|
||||
<isset property="omit-jnilib"/>
|
||||
</condition>
|
||||
<condition property="vm.arch" value="-d64" else="">
|
||||
<or>
|
||||
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
|
||||
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
|
||||
<os arch="x86_64"/>
|
||||
<os arch="ppc64"/>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="amd64"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
|
||||
<and>
|
||||
<os name="SunOS"/>
|
||||
<equals arg1="${vm.arch}" arg2="-d64"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="build" value="build${vm.arch}"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="eclipse.classes" location="build.eclipse/classes"/>
|
||||
<property name="test.classes" location="${build}/test-classes"/>
|
||||
<property name="reports" value="${build}/reports"/>
|
||||
|
||||
<!-- Add other supported platforms here -->
|
||||
<condition property="jre.arch" value="i386">
|
||||
<equals arg1="x86" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<condition property="jre.arch" value="amd64">
|
||||
<equals arg1="x86_64" arg2="${os.arch}"/>
|
||||
</condition>
|
||||
<property name="jre.arch" value="${os.arch}"/>
|
||||
<condition property="os.prefix" value="linux-${jre.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="win32-${os.arch}">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="linux-${os.arch}">
|
||||
<os name="Linux"/>
|
||||
</condition>
|
||||
<!-- Darwin builds are universal, no arch required -->
|
||||
<condition property="os.prefix" value="darwin">
|
||||
<os family="mac"/>
|
||||
@@ -87,6 +130,9 @@
|
||||
<condition property="os.prefix" value="freebsd-${os.arch}">
|
||||
<os name="FreeBSD"/>
|
||||
</condition>
|
||||
<condition property="os.prefix" value="openbsd-${os.arch}">
|
||||
<os name="OpenBSD"/>
|
||||
</condition>
|
||||
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
|
||||
<condition property="jdk.home" value="${java.home}">
|
||||
<available file="${java.home}/include"/>
|
||||
@@ -94,8 +140,14 @@
|
||||
<condition property="jdk.home" value="${java.home}/..">
|
||||
<available file="${java.home}/../include"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
|
||||
|
||||
<condition property="jdk.home" value="/System/Library/Frameworks/JavaVM.framework/Home">
|
||||
<available file="/System/Library/Frameworks/JavaVM.framework/Headers"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="Can't find JNI headers (java.home=${java.home})"/>
|
||||
<condition property="libjsig"
|
||||
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
|
||||
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
|
||||
</condition>
|
||||
<property name="native.jar" value="${os.prefix}.jar"/>
|
||||
<property name="build.native" location="${build}/native"/>
|
||||
<property name="md5.file" location="${build.native}/sig"/>
|
||||
@@ -110,7 +162,7 @@
|
||||
</target>
|
||||
|
||||
<target name="-setup" depends="-dynamic-properties">
|
||||
<path id="compile-test.path">
|
||||
<path id="compile-test.path">
|
||||
<pathelement path="${test.src}"/>
|
||||
<path id="test.libs">
|
||||
<fileset dir="lib">
|
||||
@@ -122,14 +174,13 @@
|
||||
<path id="src.path">
|
||||
<pathelement location="${src}"/>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
|
||||
<path id="test.runpath">
|
||||
<pathelement path="${build}/${jar}"/>
|
||||
<pathelement path="${build}/examples.jar"/>
|
||||
<pathelement path="${test.classes}"/>
|
||||
<pathelement path="${ant.home}/lib/clover.jar"/>
|
||||
<pathelement path="lib/clover.jar"/>
|
||||
<path refid="test.libs"/>
|
||||
</path>
|
||||
</target>
|
||||
@@ -140,6 +191,7 @@
|
||||
source="${compatibility}"
|
||||
target="${compatibility}"
|
||||
destdir="${classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${src}"/>
|
||||
</javac>
|
||||
@@ -151,8 +203,6 @@
|
||||
<patternset id="jar-compiled">
|
||||
<include name="com/sun/jna/*"/>
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
<exclude name="com/sun/jna/examples/*"/>
|
||||
<exclude name="com/sun/jna/examples/**/*"/>
|
||||
</patternset>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
@@ -161,27 +211,42 @@
|
||||
description="Build primary jar">
|
||||
<jar jarfile="${build}/${jar}">
|
||||
<manifest>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!-- OSGi Bundle attributes -->
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="com.sun.jna*"/>
|
||||
</section>
|
||||
</manifest>
|
||||
<fileset dir="${classes}"><patternset refid="jar-compiled"/></fileset>
|
||||
<fileset dir="${classes}" excludes="${jar.omitted}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
<target name="examples" depends="jar,native">
|
||||
<jar jarfile="${build}/examples.jar">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="jna.jar"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
|
||||
</manifest>
|
||||
<fileset dir="${src}" includes="**/examples/**/*.png"/>
|
||||
<fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
|
||||
<fileset dir="${classes}" includes="jnidispatch.dll"/>
|
||||
</jar>
|
||||
|
||||
<target name="contrib-jars" depends="jar" description="Build contrib jars">
|
||||
<subant target="jar">
|
||||
<property name="file.reference.jna.build" location="${build}"/>
|
||||
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
|
||||
<property name="libs.junit.classpath" location="lib/junit.jar"/>
|
||||
<!-- platform.jar needs to be built first -->
|
||||
<fileset dir="${contrib}" includes="platform/build.xml" />
|
||||
<fileset dir="${contrib}" includes="*/build.xml" excludes="platform/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="javah" depends="compile">
|
||||
@@ -196,6 +261,9 @@
|
||||
<condition property="grep" value="/usr/sfw/bin/ggrep">
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<condition property="grep" value="ggrep">
|
||||
<os name="OpenBSD"/>
|
||||
</condition>
|
||||
<property name="grep" value="grep"/>
|
||||
<apply dir="${build.native}" executable="${grep}" parallel="true"
|
||||
failonerror="true" relative="true" output="${md5.file}">
|
||||
@@ -207,7 +275,10 @@
|
||||
<fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
|
||||
<checksum property="md5" file="${md5.file}" />
|
||||
<condition property="jni.valid" value="true">
|
||||
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
|
||||
<or>
|
||||
<equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
|
||||
<equals arg1="${jni.md5}" arg2=""/>
|
||||
</or>
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
@@ -216,10 +287,13 @@
|
||||
<echo>Invalidating native code, new checksum is ${md5}</echo>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
|
||||
@@ -259,20 +333,15 @@
|
||||
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
|
||||
description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
|
||||
<property name="comment" value="# auto-generated by ant"/>
|
||||
<replaceregexp match="^VERSION=.*"
|
||||
replace="VERSION=${jni.version} ${comment}"
|
||||
<replaceregexp match="^JNA_JNI_VERSION=.*"
|
||||
replace="JNA_JNI_VERSION=${jni.version} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<replaceregexp match="^CHECKSUM=.*"
|
||||
replace="CHECKSUM=${jni.md5} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
|
||||
<!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
|
||||
<condition property="ARCH" value="${os.arch}">
|
||||
<or>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="amd64"/>
|
||||
</or>
|
||||
</condition>
|
||||
<property name="ARCH" value="${os.arch}"/>
|
||||
<condition property="make.CC" value="CC=${CC}" else="IGNORE=">
|
||||
<isset property="CC"/>
|
||||
</condition>
|
||||
@@ -282,6 +351,10 @@
|
||||
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
|
||||
<isset property="SDKROOT"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
|
||||
@@ -302,8 +375,12 @@
|
||||
<os name="SunOS"/>
|
||||
</condition>
|
||||
<condition property="make" value="gmake">
|
||||
<os name="FreeBSD"/>
|
||||
<or>
|
||||
<os name="FreeBSD"/>
|
||||
<os name="OpenBSD"/>
|
||||
</or>
|
||||
</condition>
|
||||
|
||||
<!-- Default make program -->
|
||||
<property name="make" value="make"/>
|
||||
|
||||
@@ -311,23 +388,25 @@
|
||||
<arg value="JAVA_HOME=${jdk.home}"/>
|
||||
<arg value="JAVAH=${build.native}"/>
|
||||
<arg value="DEBUG=${debug.native}"/>
|
||||
<arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
|
||||
<arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
|
||||
<arg value="${make.CC}"/>
|
||||
<arg value="${make.BUILD}"/>
|
||||
<arg value="${make.SDKROOT}"/>
|
||||
<arg value="${make.ARCH}"/>
|
||||
<arg value="${make.PATH}"/>
|
||||
<arg value="VERSION=${jni.version}"/>
|
||||
<arg value="JNA_JNI_VERSION=${jni.version}"/>
|
||||
<arg value="CHECKSUM=${jni.md5}"/>
|
||||
</exec>
|
||||
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${classes}/com/sun/jna/${os.prefix}">
|
||||
<fileset dir="${build.native}"
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</copy>
|
||||
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
|
||||
failonerror="false">
|
||||
<fileset dir="${build.native}"
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</copy>
|
||||
<!-- For web start, native libraries may be provided in the root of -->
|
||||
@@ -341,54 +420,78 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile,native"
|
||||
description="Compile all test code">
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<javac classpathref="compile-test.path"
|
||||
source="${test.compatibility}"
|
||||
target="${test.compatibility}"
|
||||
destdir="${test.classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${test.src}"/>
|
||||
</javac>
|
||||
<jar jarfile="${build}/${testjar}">
|
||||
<fileset dir="${test.classes}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<mkdir dir="${build}/jws"/>
|
||||
<copy todir="${build}/jws" file="${build}/${jar}"/>
|
||||
<copy todir="${build}/jws" file="${build}/${testjar}"/>
|
||||
<copy todir="${build}/jws" file="lib/junit.jar"/>
|
||||
<copy todir="${build}/jws" file="lib/clover.jar"/>
|
||||
<jar jarfile="${build}/jws/jnidispatch.jar">
|
||||
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
|
||||
</jar>
|
||||
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
|
||||
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
</signjar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found -->
|
||||
<target name="test" depends="jar,examples,compile-tests"
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,contrib-jars,compile-tests"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="reports.junit" location="${reports}/junit"/>
|
||||
<property name="results.junit" location="${build}/junit-results"/>
|
||||
<mkdir dir="${results.junit}"/>
|
||||
<echo>Saving test results in ${results.junit}</echo>
|
||||
<condition property="tests.platform" value="**/win32/*Test.java">
|
||||
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
|
||||
<condition property="tests.platform" value="**/win32/**/*Test.java">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
|
||||
<and><os family="windows"/><not><os arch="x86"/></not></and>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="**/unix/*Test.java">
|
||||
<and>
|
||||
<os family="unix"/>
|
||||
<not><os family="mac"/></not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="vm.arch" value="-d64">
|
||||
<or>
|
||||
<and><os family="mac"/>
|
||||
<or><os arch="x86_64"/><os arch="ppc64"/></or>
|
||||
</and>
|
||||
<os arch="sparcv9"/>
|
||||
</or>
|
||||
<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="vm.arch" value="-Dignore"/>
|
||||
<property name="tests.platform" value=""/>
|
||||
<property name="tests.exclude" value=""/>
|
||||
<junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
|
||||
<!-- avoid VM conflicts with JNA protected mode -->
|
||||
<env key="${ld.preload}" file="${libjsig}"/>
|
||||
<jvmarg value="-Djna.library.path=${build.native}"/>
|
||||
<jvmarg value="${vm.arch}"/>
|
||||
<!-- Avoid VM crashes, if possible -->
|
||||
<jvmarg value="-Djna.protected=true"/>
|
||||
<jvmarg value="-Djna.builddir=${build}"/>
|
||||
<jvmarg value="${vmopt.arch}"/>
|
||||
<classpath><path refid="test.runpath"/></classpath>
|
||||
<formatter type="xml"/>
|
||||
<batchtest todir="${results.junit}">
|
||||
<fileset dir="${test.src}">
|
||||
<include name="com/sun/jna/*Test.java"/>
|
||||
<include name="com/sun/jna/examples/*Test.java"/>
|
||||
<include name="${tests.platform}"/>
|
||||
<exclude name="${tests.exclude}"/>
|
||||
</fileset>
|
||||
@@ -401,22 +504,17 @@
|
||||
<report todir="${reports.junit}"/>
|
||||
</junitreport>
|
||||
<echo>View test report in file://${reports.junit}/index.html</echo>
|
||||
<subant target="test">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
<fail if="testfailure" unless="clover">One or more tests failed</fail>
|
||||
</target>
|
||||
|
||||
<target name="with.clover" description="Enable code coverage for tests">
|
||||
<taskdef resource="clovertasks"/>
|
||||
<taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
|
||||
<property name="clover" value="true"/>
|
||||
<property name="build" value="build.clover"/>
|
||||
<property name="clover.include" value="**/*.java"/>
|
||||
<property name="clover.exclude" value="**/examples/**/*.java"/>
|
||||
<property name="tests.exclude" value="${clover.exclude}"/>
|
||||
<clover-setup initString="${build}/coverage.db">
|
||||
<fileset dir="${src}">
|
||||
<include name="${clover.include}"/>
|
||||
<exclude name="${clover.exclude}"/>
|
||||
</fileset>
|
||||
</clover-setup>
|
||||
<clover-setup/>
|
||||
</target>
|
||||
|
||||
<target name="clover" depends="with.clover,test"
|
||||
@@ -425,6 +523,8 @@
|
||||
<mkdir dir="${reports.clover}"/>
|
||||
<clover-report>
|
||||
<current outfile="${reports.clover}" title="clover">
|
||||
<fileset dir="." includes="**/*.java" />
|
||||
<testresults dir="${results.junit}" includes="TEST-*.xml"/>
|
||||
<format type="html"/>
|
||||
</current>
|
||||
</clover-report>
|
||||
@@ -432,6 +532,14 @@
|
||||
</target>
|
||||
|
||||
<target name="javadoc" depends="-setup">
|
||||
<path id="javadoc.src.path">
|
||||
<path refid="src.path"/>
|
||||
<pathelement location="${platform.src}"/>
|
||||
</path>
|
||||
<path id="javadoc.compile.path">
|
||||
<path refid="compile.path"/>
|
||||
<pathelement location="${classes}"/>
|
||||
</path>
|
||||
<property name="header"
|
||||
value="<b>JNA API</><font size="-1"> ${jna.version}</font>"/>
|
||||
<property name="footer"
|
||||
@@ -440,10 +548,10 @@
|
||||
<mkdir dir="${javadoc}"/>
|
||||
<javadoc package="true"
|
||||
windowtitle="JNA API"
|
||||
sourcepathref="src.path"
|
||||
classpathref="compile.path"
|
||||
sourcepathref="javadoc.src.path"
|
||||
classpathref="javadoc.compile.path"
|
||||
maxmemory="256m"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32"
|
||||
overview="${src}/com/sun/jna/overview.html"
|
||||
destdir="${javadoc}">
|
||||
<!-- stylesheetfile="${stylesheet}" -->
|
||||
@@ -457,27 +565,33 @@
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
<packageset dir="${platform.src}" defaultexcludes="yes">
|
||||
<patternset>
|
||||
<include name="com/sun/jna/platform/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
|
||||
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
|
||||
<group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
|
||||
<group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
|
||||
<group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
|
||||
|
||||
<group title="Platform Utilities" packages="com.sun.jna.platform,com.sun.jna.platform.dnd"/>
|
||||
<group title="Platform Specific" packages="com.sun.jna.platform.*"/>
|
||||
|
||||
<arg value="-notimestamp"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="jar,compile-tests,native,examples,javadoc"
|
||||
<target name="dist" depends="jar,contrib-jars,compile-tests,native,javadoc"
|
||||
description="Build distribution files">
|
||||
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
|
||||
<manifest>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
</section>
|
||||
</manifest>
|
||||
<zipfileset src="${build}/${jar}"/>
|
||||
<zipfileset src="${dist}/win32-x86.jar"
|
||||
@@ -492,6 +606,9 @@
|
||||
<zipfileset src="${dist}/linux-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-amd64"/>
|
||||
<zipfileset src="${dist}/linux-ia64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ia64"/>
|
||||
<zipfileset src="${dist}/sunos-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-x86"/>
|
||||
@@ -510,21 +627,49 @@
|
||||
<zipfileset src="${dist}/freebsd-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-amd64"/>
|
||||
<zipfileset src="${dist}/openbsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/openbsd-i386"/>
|
||||
<zipfileset src="${dist}/win32-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-amd64"/>
|
||||
</jar>
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${build}">
|
||||
<include name="${native.jar}"/>
|
||||
<include name="examples.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${contrib}/platform/dist">
|
||||
<include name="platform.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${dist}/jnacontrib" flatten="true">
|
||||
<fileset dir="${contrib}">
|
||||
<include name="**/build/demo-*.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<zip zipfile="${dist}/doc.zip">
|
||||
<zipfileset dir="${javadoc}" prefix="javadoc"/>
|
||||
</zip>
|
||||
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
|
||||
<zip zipfile="${dist}/src.zip">
|
||||
<zipfileset dir="." includes="build.xml"/>
|
||||
<zipfileset dir="." includes="build.xml,pom.xml,LICENSE.txt"/>
|
||||
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
|
||||
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
|
||||
<zipfileset dir="${native}" prefix="native"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*,build,build/**/*" prefix="native"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
|
||||
</zip>
|
||||
<!-- Full sources required to build and test everything -->
|
||||
<zip zipfile="${dist}/src-full.zip">
|
||||
<zipfileset src="${dist}/src.zip"/>
|
||||
<zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
|
||||
<zipfileset dir="." includes=".classpath,.project"/>
|
||||
<zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
|
||||
<zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
|
||||
</zip>
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${dist}/src-mvn.zip">
|
||||
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
@@ -533,9 +678,13 @@
|
||||
<fileset dir="${build}"/>
|
||||
</delete>
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir=".clover"/>
|
||||
<fileset dir="${javadoc}"/>
|
||||
<fileset dir="." includes="*~,**/*~"/>
|
||||
</delete>
|
||||
<subant target="clean">
|
||||
<fileset dir="${contrib}" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alphamaskdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+35
-29
@@ -10,9 +10,9 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
|
||||
import java.awt.event.*;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
@@ -26,6 +26,7 @@ import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
@@ -38,6 +39,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@@ -52,23 +54,26 @@ import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.Display;
|
||||
import com.sun.jna.examples.unix.X11.GC;
|
||||
import com.sun.jna.examples.unix.X11.XSetWindowAttributes;
|
||||
import com.sun.jna.examples.win32.GDI32;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.examples.win32.User32.POINT;
|
||||
import com.sun.jna.examples.win32.User32.SIZE;
|
||||
import com.sun.jna.examples.win32.W32API.HANDLE;
|
||||
import com.sun.jna.examples.win32.W32API.HBITMAP;
|
||||
import com.sun.jna.examples.win32.W32API.HDC;
|
||||
import com.sun.jna.examples.win32.W32API.HWND;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.unix.X11.GC;
|
||||
import com.sun.jna.platform.win32.GDI32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinGDI;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
@@ -124,7 +129,7 @@ public class AlphaMaskDemo implements Runnable {
|
||||
|
||||
private com.sun.jna.Memory buffer;
|
||||
private int[] pixels;
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
X11 x11 = X11.INSTANCE;
|
||||
X11.Window win = X11.Window.None;
|
||||
Display dpy = x11.XOpenDisplay(null);
|
||||
@@ -227,9 +232,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
|
||||
flags |= User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
@@ -257,11 +262,11 @@ public class AlphaMaskDemo implements Runnable {
|
||||
bmi.bmiHeader.biHeight = h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
|
||||
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
PointerByReference ppbits = new PointerByReference();
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, GDI32.DIB_RGB_COLORS,
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
oldBitmap = gdi.SelectObject(memDC, hBitmap);
|
||||
Pointer pbits = ppbits.getValue();
|
||||
@@ -290,9 +295,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
POINT srcLoc = new POINT();
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, screenDC, loc, size, memDC, srcLoc,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
finally {
|
||||
user.ReleaseDC(null, screenDC);
|
||||
@@ -306,9 +311,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
else if (a) {
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null, null,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
|
||||
if (!alphaWindow.isVisible()) {
|
||||
@@ -383,8 +388,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR)
|
||||
|| list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
@@ -421,8 +427,8 @@ public class AlphaMaskDemo implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
|
||||
List files = (List)t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://" + f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
+15
-15
@@ -8,9 +8,10 @@
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
@@ -51,16 +52,13 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
// just hard-coded blitting of an image into a window
|
||||
// Thanks to Rui Lopes for the C# example on which this is based:
|
||||
// rui@ruilopes.com
|
||||
// http://www.codeproject.com/cs/media/perpxalpha_sharp.asp?df=100&forumid=3270&exp=0&select=773155
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
public class AlphaMaskDemo2 implements Runnable {
|
||||
private static final DataFlavor URL_FLAVOR = new DataFlavor("application/x-java-url; class=java.net.URL",
|
||||
"URL");
|
||||
private static final DataFlavor URI_LIST_FLAVOR = new DataFlavor("text/uri-list; class=java.lang.String",
|
||||
"URI list");
|
||||
private static final DataFlavor URL_FLAVOR =
|
||||
new DataFlavor("application/x-java-url; class=java.net.URL", "URL");
|
||||
private static final DataFlavor URI_LIST_FLAVOR =
|
||||
new DataFlavor("text/uri-list; class=java.lang.String", "URI list");
|
||||
private JFrame frame;
|
||||
private JWindow alphaWindow;
|
||||
private JLabel icon;
|
||||
@@ -107,6 +105,7 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
frame = new JFrame("Alpha Mask Demo");
|
||||
alphaWindow = new JWindow(frame, gconfig);
|
||||
icon = new JLabel();
|
||||
icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
alphaWindow.getContentPane().add(icon);
|
||||
JButton quit = new JButton("Quit");
|
||||
JLabel label = new JLabel("Drag this window by its image");
|
||||
@@ -146,9 +145,10 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
public boolean canImport(JComponent comp,
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp,
|
||||
DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
|| list.contains(DataFlavor.javaFileListFlavor)) {
|
||||
@@ -186,9 +186,8 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
List files = (List)t
|
||||
.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://"
|
||||
+ f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
@@ -252,6 +251,7 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
"<html><center>Drop an image with an alpha channel onto this window<br>"
|
||||
+ "You may also adjust the overall transparency with the slider</center></html>"),
|
||||
BorderLayout.NORTH);
|
||||
p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
final JSlider slider = new JSlider(0, 255, 255);
|
||||
slider.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
|
Antes Largura: | Altura: | Tamanho: 18 KiB Depois Largura: | Altura: | Tamanho: 18 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloonmanagerdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+6
-1
@@ -10,7 +10,7 @@
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -31,11 +31,14 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* Provides a popup balloon containing an arbitrary component. This provides
|
||||
* a form of content-specific decoration less transient than a tooltip, and less
|
||||
@@ -54,6 +57,7 @@ public class BalloonManager {
|
||||
}
|
||||
|
||||
private static class DropShadow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final float SHADOW_ALPHA = .25f;
|
||||
private static final float YSCALE = .80f;
|
||||
private static final double ANGLE = 2*Math.PI/24;
|
||||
@@ -146,6 +150,7 @@ public class BalloonManager {
|
||||
}
|
||||
|
||||
private static final class BubbleWindow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int Y_OFFSET = 50;
|
||||
private static final int ARC = 25;
|
||||
|
||||
+4
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -24,6 +24,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
@@ -35,6 +36,8 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Demonstration of BalloonManager. */
|
||||
public class BalloonManagerDemo {
|
||||
private static final int ICON_SIZE = 48;
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloontips</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+3
-6
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -30,7 +30,7 @@ import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* The BalloonTipManager class handles creation and disposal of balloon style
|
||||
@@ -61,8 +61,8 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* The BalloonTip class defines the look of the BalloonTip object.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static final class BalloonTip extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Integer HMARGIN = 10;
|
||||
private static final Integer VMARGIN = 6;
|
||||
private static final Integer VSPACER = 4;
|
||||
@@ -476,7 +476,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned from moving the component.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class ComponentEar extends ComponentAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -491,7 +490,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when a mouse button is pressed.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class MouseEar extends MouseAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -506,7 +504,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when the component loses focus.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class FocusEar extends FocusAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>dnddemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+7
-2
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
@@ -32,6 +32,10 @@ import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.platform.dnd.DragHandler;
|
||||
import com.sun.jna.platform.dnd.DropHandler;
|
||||
|
||||
|
||||
/** Demonstrate ghosted drag images. Unfortunately, Swing drag support hides
|
||||
* the hooks we need to move the drag image around, so we don't use it and
|
||||
* roll our own.
|
||||
@@ -59,7 +63,8 @@ public class GhostedDragImageDemo {
|
||||
}
|
||||
|
||||
public static class DragLabel extends JLabel {
|
||||
private boolean dragging;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean dragging;
|
||||
public DragLabel(Icon icon) {
|
||||
super(icon);
|
||||
new DragHandler(this, DnDConstants.ACTION_COPY_OR_MOVE) {
|
||||
Arquivo executável → Arquivo normal
|
Antes Largura: | Altura: | Tamanho: 28 KiB Depois Largura: | Altura: | Tamanho: 28 KiB |
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ntservice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
Arquivo binário não exibido.
@@ -19,7 +19,7 @@ is divided into following sections:
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="JnaContrib-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
application.args=
|
||||
file.reference.jna.jar=D:\\temp\\JnaContrib\\lib\\jna.jar
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
jaxws.endorsed.dir=D:\\Program Files\\netbeans551\\ide7\\modules\\ext\\jaxws21\\api
|
||||
user.properties.file=C:\\Users\\tb\\.netbeans\\5.5.1\\build.properties
|
||||
@@ -14,12 +14,13 @@ debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/JnaContrib.jar
|
||||
dist.jar=${dist.dir}/contrib-ntservice.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=lib/jna.jar
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar}
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>JnaContrib</name>
|
||||
<name>ntservice</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
|
||||
@@ -18,49 +18,8 @@ import com.sun.jna.win32.*;
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
BOOL WINAPI LookupAccountName(
|
||||
LPCTSTR lpSystemName,
|
||||
LPCTSTR lpAccountName,
|
||||
PSID Sid,
|
||||
LPDWORD cbSid,
|
||||
LPTSTR ReferencedDomainName,
|
||||
LPDWORD cchReferencedDomainName,
|
||||
PSID_NAME_USE peUse
|
||||
);*/
|
||||
public boolean LookupAccountName(String lpSystemName, String lpAccountName,
|
||||
byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/*
|
||||
BOOL WINAPI LookupAccountSid(
|
||||
LPCTSTR lpSystemName,
|
||||
PSID lpSid,
|
||||
LPTSTR lpName,
|
||||
LPDWORD cchName,
|
||||
LPTSTR lpReferencedDomainName,
|
||||
LPDWORD cchReferencedDomainName,
|
||||
PSID_NAME_USE peUse
|
||||
);*/
|
||||
public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
|
||||
char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/*
|
||||
BOOL ConvertSidToStringSid(
|
||||
PSID Sid,
|
||||
LPTSTR* StringSid
|
||||
);*/
|
||||
public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ConvertStringSidToSid(
|
||||
LPCTSTR StringSid,
|
||||
PSID* Sid
|
||||
);*/
|
||||
public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenSCManager(
|
||||
@@ -163,88 +122,6 @@ BOOL WINAPI ChangeServiceConfig2(
|
||||
);*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegOpenKeyEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey,
|
||||
DWORD ulOptions,
|
||||
REGSAM samDesired,
|
||||
PHKEY phkResult
|
||||
);*/
|
||||
public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegQueryValueEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);*/
|
||||
public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegCloseKey(
|
||||
HKEY hKey
|
||||
);*/
|
||||
public int RegCloseKey(int hKey);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegDeleteValue(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName
|
||||
);*/
|
||||
public int RegDeleteValue(int hKey, String lpValueName);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegSetValueEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName,
|
||||
DWORD Reserved,
|
||||
DWORD dwType,
|
||||
const BYTE* lpData,
|
||||
DWORD cbData
|
||||
);*/
|
||||
public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegCreateKeyEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey,
|
||||
DWORD Reserved,
|
||||
LPTSTR lpClass,
|
||||
DWORD dwOptions,
|
||||
REGSAM samDesired,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
PHKEY phkResult,
|
||||
LPDWORD lpdwDisposition
|
||||
);*/
|
||||
public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
|
||||
int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
|
||||
IntByReference lpdwDisposition);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegDeleteKey(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey
|
||||
);*/
|
||||
public int RegDeleteKey(int hKey, String name);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumKeyEx(
|
||||
HKEY hKey,
|
||||
DWORD dwIndex,
|
||||
LPTSTR lpName,
|
||||
LPDWORD lpcName,
|
||||
LPDWORD lpReserved,
|
||||
LPTSTR lpClass,
|
||||
LPDWORD lpcClass,
|
||||
PFILETIME lpftLastWriteTime
|
||||
);*/
|
||||
public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
|
||||
char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumValue(
|
||||
HKEY hKey,
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Kernel32b.java
|
||||
*
|
||||
* Created on 6. August 2007, 14:43
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Kernel32b extends StdCallLibrary {
|
||||
Kernel32b INSTANCE = (Kernel32b) Native.loadLibrary("Kernel32", Kernel32b.class, Options.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
HLOCAL WINAPI LocalFree(
|
||||
HLOCAL hMem
|
||||
);*/
|
||||
public Pointer LocalFree(Pointer hMem);
|
||||
/*
|
||||
|
||||
DWORD WINAPI GetLastError(void);*/
|
||||
public int GetLastError();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* LMACCESS.java
|
||||
*
|
||||
* Created on 7. August 2007, 12:42
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface LMACCESS {
|
||||
public final static int FILTER_NORMAL_ACCOUNT = 2;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* LMCONS.java
|
||||
*
|
||||
* Created on 7. August 2007, 08:46
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface LMCONS {
|
||||
public final static int MAX_PREFERRED_LENGTH = -1;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* LMERR.java
|
||||
*
|
||||
* Created on 7. August 2007, 08:22
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface LMERR {
|
||||
public final static int NERR_Success = 0;
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* Netapi32.java
|
||||
*
|
||||
* Created on 2. August 2007, 13:12
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.*;
|
||||
import com.sun.jna.win32.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Netapi32 extends StdCallLibrary {
|
||||
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32", Netapi32.class, Options.UNICODE_OPTIONS);
|
||||
/*
|
||||
NET_API_STATUS NetGetDCName(
|
||||
LPCWSTR servername,
|
||||
LPCWSTR domainname,
|
||||
LPBYTE* bufptr
|
||||
);*/
|
||||
public int NetGetDCName(String serverName, String domainName, PointerByReference bufptr);
|
||||
|
||||
/*
|
||||
DWORD DsGetDcName(
|
||||
LPCTSTR ComputerName,
|
||||
LPCTSTR DomainName,
|
||||
GUID* DomainGuid,
|
||||
LPCTSTR SiteName,
|
||||
ULONG Flags,
|
||||
PDOMAIN_CONTROLLER_INFO* DomainControllerInfo
|
||||
);*/
|
||||
public int DsGetDcName(String ComputerName, String DomainName, ByReference DomainGuid,
|
||||
String SiteName, int Flags, PointerByReference DomainControllerInfo);
|
||||
|
||||
/*
|
||||
NET_API_STATUS NetUserGetGroups(
|
||||
LPCWSTR servername,
|
||||
LPCWSTR username,
|
||||
DWORD level,
|
||||
LPBYTE* bufptr,
|
||||
DWORD prefmaxlen,
|
||||
LPDWORD entriesread,
|
||||
LPDWORD totalentries
|
||||
);*/
|
||||
public int NetUserGetGroups(String servername, String username, int level,
|
||||
PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/*
|
||||
NET_API_STATUS NetUserGetLocalGroups(
|
||||
LPCWSTR servername,
|
||||
LPCWSTR username,
|
||||
DWORD level,
|
||||
DWORD flags,
|
||||
LPBYTE* bufptr,
|
||||
DWORD prefmaxlen,
|
||||
LPDWORD entriesread,
|
||||
LPDWORD totalentries
|
||||
);*/
|
||||
public int NetUserGetLocalGroups(String servername, String username, int level,
|
||||
int flags, PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/*
|
||||
NET_API_STATUS NetGroupEnum(
|
||||
LPCWSTR servername,
|
||||
DWORD level,
|
||||
LPBYTE* bufptr,
|
||||
DWORD prefmaxlen,
|
||||
LPDWORD entriesread,
|
||||
LPDWORD totalentries,
|
||||
PDWORD_PTR resume_handle
|
||||
);*/
|
||||
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/*
|
||||
NET_API_STATUS NetUserEnum(
|
||||
LPCWSTR servername,
|
||||
DWORD level,
|
||||
DWORD filter,
|
||||
LPBYTE* bufptr,
|
||||
DWORD prefmaxlen,
|
||||
LPDWORD entriesread,
|
||||
LPDWORD totalentries,
|
||||
LPDWORD resume_handle
|
||||
);*/
|
||||
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/*
|
||||
NET_API_STATUS NetApiBufferFree(
|
||||
LPVOID Buffer
|
||||
);*/
|
||||
public int NetApiBufferFree(Pointer Buffer);
|
||||
|
||||
/*
|
||||
typedef struct _GUID {
|
||||
DWORD Data1;
|
||||
WORD Data2;
|
||||
WORD Data3;
|
||||
BYTE Data4[8];
|
||||
} GUID;
|
||||
*/
|
||||
public static class GUID extends Structure {
|
||||
public GUID() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _DOMAIN_CONTROLLER_INFO {
|
||||
LPTSTR DomainControllerName;
|
||||
LPTSTR DomainControllerAddress;
|
||||
ULONG DomainControllerAddressType;
|
||||
GUID DomainGuid;
|
||||
LPTSTR DomainName;
|
||||
LPTSTR DnsForestName;
|
||||
ULONG Flags;
|
||||
LPTSTR DcSiteName;
|
||||
LPTSTR ClientSiteName;
|
||||
} DOMAIN_CONTROLLER_INFO,
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public String DomainControllerName;
|
||||
public String DomainControllerAddress;
|
||||
public int DomainControllerAddressType;
|
||||
public GUID DomainGuid;
|
||||
public String DomainName;
|
||||
public String DnsForestName;
|
||||
public int Flags;
|
||||
public String DcSiteName;
|
||||
public String ClientSiteName;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _GROUP_USERS_INFO_0 {
|
||||
LPWSTR grui0_name;
|
||||
} GROUP_USERS_INFO_0,
|
||||
*PGROUP_USERS_INFO_0,
|
||||
*LPGROUP_USERS_INFO_0;
|
||||
*/
|
||||
public static class GROUP_USERS_INFO_0 extends Structure {
|
||||
public GROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public String grui0_name;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _LOCALGROUP_USERS_INFO_0 {
|
||||
LPWSTR lgrui0_name;
|
||||
} LOCALGROUP_USERS_INFO_0,
|
||||
*PLOCALGROUP_USERS_INFO_0,
|
||||
*LPLOCALGROUP_USERS_INFO_0;
|
||||
*/
|
||||
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
|
||||
public LOCALGROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public String lgrui0_name;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _GROUP_INFO_0 {
|
||||
LPWSTR grpi0_name;
|
||||
} GROUP_INFO_0,
|
||||
*PGROUP_INFO_0,
|
||||
*LPGROUP_INFO_0;
|
||||
*/
|
||||
public static class GROUP_INFO_0 extends Structure {
|
||||
public GROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public String grpi0_name;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _USER_INFO_0 {
|
||||
LPWSTR usri0_name;
|
||||
} USER_INFO_0,
|
||||
*PUSER_INFO_0,
|
||||
*LPUSER_INFO_0;*/
|
||||
public static class USER_INFO_0 extends Structure {
|
||||
public USER_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public String usri0_name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Options.java
|
||||
*
|
||||
* Created on 8. August 2007, 17:07
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import static com.sun.jna.Library.*;
|
||||
import com.sun.jna.TypeMapper;
|
||||
import com.sun.jna.win32.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Options {
|
||||
Map<String, Object> UNICODE_OPTIONS = new HashMap<String, Object>() {
|
||||
{
|
||||
put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
|
||||
put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* WINBASE.java
|
||||
*
|
||||
* Created on 5. September 2007, 11:24
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINBASE {
|
||||
/*
|
||||
typedef struct _SECURITY_ATTRIBUTES {
|
||||
DWORD nLength;
|
||||
LPVOID lpSecurityDescriptor;
|
||||
BOOL bInheritHandle;
|
||||
} SECURITY_ATTRIBUTES,
|
||||
*PSECURITY_ATTRIBUTES,
|
||||
*LPSECURITY_ATTRIBUTES;*/
|
||||
public static class SECURITY_ATTRIBUTES extends Structure {
|
||||
public int nLength;
|
||||
public Pointer lpSecurityDescriptor;
|
||||
public boolean bInheritHandle;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _FILETIME {
|
||||
DWORD dwLowDateTime;
|
||||
DWORD dwHighDateTime;
|
||||
} FILETIME, *PFILETIME, *LPFILETIME;*/
|
||||
public static class FILETIME extends Structure {
|
||||
public int dwLowDateTime;
|
||||
public int dwHighDateTime;
|
||||
}
|
||||
}
|
||||
@@ -33,41 +33,4 @@ public interface WINNT {
|
||||
public final static int GENERIC_EXECUTE = 0x20000000;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
|
||||
public final static int KEY_QUERY_VALUE = 0x0001;
|
||||
public final static int KEY_SET_VALUE = 0x0002;
|
||||
public final static int KEY_CREATE_SUB_KEY = 0x0004;
|
||||
public final static int KEY_ENUMERATE_SUB_KEYS = 0x0008;
|
||||
public final static int KEY_NOTIFY = 0x0010;
|
||||
public final static int KEY_CREATE_LINK = 0x0020;
|
||||
|
||||
public final static int KEY_READ = ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & (~SYNCHRONIZE));
|
||||
public final static int KEY_WRITE = ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE));
|
||||
|
||||
public final static int REG_NONE = 0; // No value type
|
||||
public final static int REG_SZ = 1; // Unicode nul terminated string
|
||||
public final static int REG_EXPAND_SZ = 2; // Unicode nul terminated string
|
||||
// (with environment variable references)
|
||||
public final static int REG_BINARY = 3; // Free form binary
|
||||
public final static int REG_DWORD = 4; // 32-bit number
|
||||
public final static int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD)
|
||||
public final static int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number
|
||||
public final static int REG_LINK = 6; // Symbolic Link (unicode)
|
||||
public final static int REG_MULTI_SZ = 7; // Multiple Unicode strings
|
||||
public final static int REG_RESOURCE_LIST = 8; // Resource list in the resource map
|
||||
public final static int REG_FULL_RESOURCE_DESCRIPTOR = 9; // Resource list in the hardware description
|
||||
public final static int REG_RESOURCE_REQUIREMENTS_LIST = 10;
|
||||
|
||||
public final static int REG_OPTION_RESERVED = 0x00000000; // Parameter is reserved
|
||||
public final static int REG_OPTION_NON_VOLATILE = 0x00000000; // Key is preserved
|
||||
// when system is rebooted
|
||||
public final static int REG_OPTION_VOLATILE = 0x00000001; // Key is not preserved
|
||||
// when system is rebooted
|
||||
public final static int REG_OPTION_CREATE_LINK = 0x00000002; // Created key is a
|
||||
// symbolic link
|
||||
public final static int REG_OPTION_BACKUP_RESTORE = 0x00000004; // open for backup or restore
|
||||
// special access rules
|
||||
// privilege required
|
||||
public final static int REG_OPTION_OPEN_LINK = 0x00000008; // Open symbolic link
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* WINREG.java
|
||||
*
|
||||
* Created on 17. August 2007, 14:32
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINREG {
|
||||
public final static int HKEY_CLASSES_ROOT = 0x80000000;
|
||||
public final static int HKEY_CURRENT_USER = 0x80000001;
|
||||
public final static int HKEY_LOCAL_MACHINE = 0x80000002;
|
||||
public final static int HKEY_USERS = 0x80000003;
|
||||
}
|
||||
@@ -9,11 +9,6 @@
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,431 +0,0 @@
|
||||
/*
|
||||
* Accounts.java
|
||||
*
|
||||
* Created on 7. August 2007, 07:58
|
||||
*
|
||||
* 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.*;
|
||||
import com.sun.jna.ptr.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public class Accounts {
|
||||
private static Object userInfoLock = new Object();
|
||||
private static Object groupInfoLock = new Object();
|
||||
|
||||
/** Creates a new instance of Accounts */
|
||||
private Accounts() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing.
|
||||
* @param args arguments
|
||||
* @throws java.lang.Exception on error
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("FullDomainName: " + getFullDomainName());
|
||||
System.out.println("DomainControllerName: " + getDomainControllerName());
|
||||
System.out.println("UserDomainGroups: " + getUserDomainGroups("administrator"));
|
||||
System.out.println("UserLocalGroups: " + getUserLocalGroups(null, "administrator"));
|
||||
System.out.println("AllDomainGroups: " + getAllDomainGroups());
|
||||
System.out.println("AllDomainUsers: " + getAllDomainUsers());
|
||||
System.out.println("AccountSidString: " + getAccountSidString("administrator"));
|
||||
System.out.println("AccountNameBySid: " + getAccountName(getAccountSid("administrator")));
|
||||
System.out.println("AccountNameBySidString: " + getAccountName(getAccountSidString("administrator")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of the domain.
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public static String getFullDomainName() {
|
||||
Netapi32.DOMAIN_CONTROLLER_INFO dci;
|
||||
String domain = null;
|
||||
|
||||
dci = getDomainControllerInfo();
|
||||
|
||||
if(dci != null) {
|
||||
domain = dci.DomainName;
|
||||
}
|
||||
return(domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the domain controller.
|
||||
*
|
||||
* @return name
|
||||
*/
|
||||
public static String getDomainControllerName() {
|
||||
Netapi32.DOMAIN_CONTROLLER_INFO dci;
|
||||
String domainController = null;
|
||||
|
||||
dci = getDomainControllerInfo();
|
||||
|
||||
if(dci != null) {
|
||||
domainController = dci.DomainControllerName;
|
||||
}
|
||||
return(domainController);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about the domain controller.
|
||||
*
|
||||
* @return info
|
||||
*/
|
||||
private static Netapi32.DOMAIN_CONTROLLER_INFO getDomainControllerInfo() {
|
||||
Netapi32 netapi32;
|
||||
PointerByReference pDci;
|
||||
Netapi32.DOMAIN_CONTROLLER_INFO dci = null;
|
||||
|
||||
netapi32 = Netapi32.INSTANCE;
|
||||
pDci = new PointerByReference();
|
||||
|
||||
if(netapi32.DsGetDcName(null, null, null, null, 0, pDci) == WINERROR.ERROR_SUCCESS) {
|
||||
dci = new Netapi32.DOMAIN_CONTROLLER_INFO(pDci.getValue());
|
||||
netapi32.NetApiBufferFree(pDci.getValue());
|
||||
}
|
||||
return(dci);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the domain groups where a user belongs to.
|
||||
*
|
||||
* @param userName user
|
||||
* @return TreeSet of group names
|
||||
*/
|
||||
public static TreeSet<String> getUserDomainGroups(String userName) {
|
||||
Netapi32 netapi32;
|
||||
PointerByReference buf;
|
||||
IntByReference entriesread;
|
||||
IntByReference totalentries;
|
||||
Netapi32.GROUP_USERS_INFO_0 group;
|
||||
Structure[] groups;
|
||||
TreeSet<String> domainGroups;
|
||||
int i;
|
||||
|
||||
domainGroups = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
netapi32 = Netapi32.INSTANCE;
|
||||
|
||||
buf = new PointerByReference();
|
||||
entriesread = new IntByReference();
|
||||
totalentries = new IntByReference();
|
||||
|
||||
if(netapi32.NetUserGetGroups(getDomainControllerName(), // servername
|
||||
userName, // username
|
||||
0, // level of user info in buffer
|
||||
buf, // user info buffer
|
||||
LMCONS.MAX_PREFERRED_LENGTH,
|
||||
entriesread, // read ( out )
|
||||
totalentries // total ( out )
|
||||
) == LMERR.NERR_Success) {
|
||||
group = new Netapi32.GROUP_USERS_INFO_0(buf.getValue());
|
||||
groups = group.toArray(entriesread.getValue());
|
||||
|
||||
for(i = 0; i < entriesread.getValue(); i++) {
|
||||
group = (Netapi32.GROUP_USERS_INFO_0)groups[i];
|
||||
domainGroups.add(group.grui0_name);
|
||||
}
|
||||
|
||||
if(entriesread.getValue() > 0) {
|
||||
netapi32.NetApiBufferFree(buf.getValue());
|
||||
}
|
||||
}
|
||||
return(domainGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the local groups a user belongs to.
|
||||
*
|
||||
* @param serverName server name
|
||||
* @param userName user
|
||||
* @return TreeSetof group names
|
||||
*/
|
||||
public static TreeSet<String> getUserLocalGroups(String serverName, String userName) {
|
||||
Netapi32 netapi32;
|
||||
PointerByReference lbuf;
|
||||
IntByReference lentriesread;
|
||||
IntByReference ltotalentries;
|
||||
Netapi32.LOCALGROUP_USERS_INFO_0 lgroup;
|
||||
Structure[] lgroups;
|
||||
TreeSet<String> localGroups;
|
||||
int i;
|
||||
|
||||
localGroups = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
netapi32 = Netapi32.INSTANCE;
|
||||
|
||||
lbuf = new PointerByReference();
|
||||
lentriesread = new IntByReference();
|
||||
ltotalentries = new IntByReference();
|
||||
if(netapi32.NetUserGetLocalGroups(null, // servername
|
||||
userName, // username
|
||||
0, // level of user info in buffer
|
||||
0, // flags
|
||||
lbuf, // user info buffer
|
||||
LMCONS.MAX_PREFERRED_LENGTH,
|
||||
lentriesread, // read ( out )
|
||||
ltotalentries // total ( out )
|
||||
) == LMERR.NERR_Success) {
|
||||
lgroup = new Netapi32.LOCALGROUP_USERS_INFO_0(lbuf.getValue());
|
||||
lgroups = lgroup.toArray(lentriesread.getValue());
|
||||
|
||||
for(i = 0; i < lentriesread.getValue(); i++) {
|
||||
lgroup = (Netapi32.LOCALGROUP_USERS_INFO_0)lgroups[i];
|
||||
localGroups.add(lgroup.lgrui0_name);
|
||||
}
|
||||
|
||||
if(lentriesread.getValue() > 0) {
|
||||
netapi32.NetApiBufferFree(lbuf.getValue());
|
||||
}
|
||||
}
|
||||
return(localGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all domain groups.
|
||||
*
|
||||
* @return TreeSet of group names
|
||||
*/
|
||||
public static TreeSet<String> getAllDomainGroups() {
|
||||
Netapi32 netapi32;
|
||||
PointerByReference gbuf;
|
||||
IntByReference gentriesread;
|
||||
IntByReference gtotalentries;
|
||||
Netapi32.GROUP_INFO_0 ggroup;
|
||||
Structure[] ggroups;
|
||||
TreeSet<String> domainGroups;
|
||||
int i;
|
||||
|
||||
netapi32 = Netapi32.INSTANCE;
|
||||
domainGroups = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
gbuf = new PointerByReference();
|
||||
gentriesread = new IntByReference();
|
||||
gtotalentries = new IntByReference();
|
||||
|
||||
if(netapi32.NetGroupEnum(getDomainControllerName(), // servername
|
||||
0, // level of user info in buffer
|
||||
gbuf, // user info buffer
|
||||
LMCONS.MAX_PREFERRED_LENGTH,
|
||||
gentriesread, // read ( out )
|
||||
gtotalentries, // total ( out )
|
||||
null // resume_handle
|
||||
) == LMERR.NERR_Success) {
|
||||
ggroup = new Netapi32.GROUP_INFO_0(gbuf.getValue());
|
||||
ggroups = ggroup.toArray(gentriesread.getValue());
|
||||
|
||||
for(i = 0; i < gentriesread.getValue(); i++) {
|
||||
ggroup = (Netapi32.GROUP_INFO_0)ggroups[i];
|
||||
domainGroups.add(ggroup.grpi0_name);
|
||||
}
|
||||
|
||||
if(gentriesread.getValue() > 0) {
|
||||
netapi32.NetApiBufferFree(gbuf.getValue());
|
||||
}
|
||||
}
|
||||
return(domainGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all domain users.
|
||||
*
|
||||
* @return TreeSet of user names
|
||||
*/
|
||||
public static TreeSet<String> getAllDomainUsers() {
|
||||
Netapi32 netapi32;
|
||||
PointerByReference ubuf;
|
||||
IntByReference uentriesread;
|
||||
IntByReference utotalentries;
|
||||
Netapi32.USER_INFO_0 user;
|
||||
Structure[] users;
|
||||
TreeSet<String> domainUsers;
|
||||
int i;
|
||||
|
||||
netapi32 = Netapi32.INSTANCE;
|
||||
domainUsers = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
|
||||
ubuf = new PointerByReference();
|
||||
uentriesread = new IntByReference();
|
||||
utotalentries = new IntByReference();
|
||||
|
||||
if(netapi32.NetUserEnum(getDomainControllerName(), // servername
|
||||
0, // level of user info in buffer
|
||||
LMACCESS.FILTER_NORMAL_ACCOUNT, // filter
|
||||
ubuf, // user info buffer
|
||||
LMCONS.MAX_PREFERRED_LENGTH,
|
||||
uentriesread, // read ( out )
|
||||
utotalentries, // total ( out )
|
||||
null // resume_handle
|
||||
) == LMERR.NERR_Success) {
|
||||
user = new Netapi32.USER_INFO_0(ubuf.getValue());
|
||||
users = user.toArray(uentriesread.getValue());
|
||||
|
||||
for(i = 0; i < uentriesread.getValue(); i++) {
|
||||
user = (Netapi32.USER_INFO_0)users[i];
|
||||
domainUsers.add(user.usri0_name);
|
||||
}
|
||||
|
||||
if(uentriesread.getValue() > 0) {
|
||||
netapi32.NetApiBufferFree(ubuf.getValue());
|
||||
}
|
||||
}
|
||||
return(domainUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SID of account.
|
||||
*
|
||||
* @param account account name
|
||||
* @return SID
|
||||
*/
|
||||
public static byte[] getAccountSid(String account) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference cbSid;
|
||||
IntByReference cchReferencedDomainName;
|
||||
PointerByReference peUse;
|
||||
String sidString = null;
|
||||
byte[] sid;
|
||||
char[] referencedDomainName;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
cbSid = new IntByReference(0);
|
||||
cchReferencedDomainName = new IntByReference(0);
|
||||
peUse = new PointerByReference();
|
||||
advapi32.LookupAccountName(null, account, null, cbSid,
|
||||
null, cchReferencedDomainName, peUse);
|
||||
sid = new byte[cbSid.getValue()];
|
||||
referencedDomainName = new char[cchReferencedDomainName.getValue()];
|
||||
|
||||
if(! advapi32.LookupAccountName(null, account, sid, cbSid,
|
||||
referencedDomainName, cchReferencedDomainName, peUse)) {
|
||||
sid = null;
|
||||
}
|
||||
return(sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account name of SID.
|
||||
*
|
||||
* @param sid SID
|
||||
* @return account name
|
||||
*/
|
||||
public static String getAccountName(byte[] sid) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference cchName;
|
||||
IntByReference cchReferencedDomainName;
|
||||
PointerByReference peUse;
|
||||
String sidString = null;
|
||||
char[] lpName;
|
||||
char[] referencedDomainName;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
cchName = new IntByReference(0);
|
||||
cchReferencedDomainName = new IntByReference(0);
|
||||
peUse = new PointerByReference();
|
||||
advapi32.LookupAccountSid(null, sid, null, cchName,
|
||||
null, cchReferencedDomainName, peUse);
|
||||
lpName = new char[cchName.getValue()];
|
||||
referencedDomainName = new char[cchReferencedDomainName.getValue()];
|
||||
|
||||
if(! advapi32.LookupAccountSid(null, sid, lpName, cchName,
|
||||
referencedDomainName, cchReferencedDomainName, peUse)) {
|
||||
lpName = null;
|
||||
}
|
||||
|
||||
if(lpName != null) {
|
||||
return(Native.toString(lpName));
|
||||
|
||||
} else {
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SID of account as String.
|
||||
*
|
||||
* @param account account name
|
||||
* @return SID
|
||||
*/
|
||||
public static String getAccountSidString(String account) {
|
||||
String sidString = null;
|
||||
byte[] sid;
|
||||
|
||||
sid = getAccountSid(account);
|
||||
|
||||
if(sid != null) {
|
||||
sidString = convertSidToString(sid);
|
||||
}
|
||||
return(sidString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account of SID String.
|
||||
*
|
||||
* @param sidString SID
|
||||
* @return account name
|
||||
*/
|
||||
public static String getAccountName(String sidString) {
|
||||
String name = null;
|
||||
byte[] sid;
|
||||
|
||||
sid = convertStringToSid(sidString);
|
||||
|
||||
if(sid != null) {
|
||||
name = getAccountName(sid);
|
||||
}
|
||||
return(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a SID to String.
|
||||
*
|
||||
* @param sid SID
|
||||
* @return SID String
|
||||
*/
|
||||
public static String convertSidToString(byte[] sid) {
|
||||
Advapi32 advapi32;
|
||||
PointerByReference stringSid;
|
||||
String sidString = null;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
stringSid = new PointerByReference();
|
||||
|
||||
if(advapi32.ConvertSidToStringSid(sid, stringSid)) {
|
||||
sidString = stringSid.getValue().getString(0, true);
|
||||
Kernel32b.INSTANCE.LocalFree(stringSid.getValue());
|
||||
}
|
||||
return(sidString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a SID String to SID.
|
||||
*
|
||||
* @param sidString SID String
|
||||
* @return SID
|
||||
*/
|
||||
public static byte[] convertStringToSid(String sidString) {
|
||||
Advapi32 advapi32;
|
||||
PointerByReference pSid;
|
||||
byte[] sid = null;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
pSid = new PointerByReference();
|
||||
|
||||
if(advapi32.ConvertStringSidToSid(sidString, pSid)) {
|
||||
sid = pSid.getValue().getByteArray(0, 100);
|
||||
Kernel32b.INSTANCE.LocalFree(pSid.getValue());
|
||||
}
|
||||
return(sid);
|
||||
}
|
||||
}
|
||||
@@ -1,464 +0,0 @@
|
||||
/*
|
||||
* Registry.java
|
||||
*
|
||||
* Created on 17. August 2007, 15:07
|
||||
*
|
||||
* 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.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Methods for accessing the Windows Registry. Only String and DWORD values supported at the moment.
|
||||
*/
|
||||
public class Registry {
|
||||
public static enum REGISTRY_ROOT_KEY{CLASSES_ROOT, CURRENT_USER, LOCAL_MACHINE, USERS};
|
||||
private final static HashMap<REGISTRY_ROOT_KEY, Integer> rootKeyMap = new HashMap<REGISTRY_ROOT_KEY, Integer>();
|
||||
|
||||
static {
|
||||
rootKeyMap.put(REGISTRY_ROOT_KEY.CLASSES_ROOT, WINREG.HKEY_CLASSES_ROOT);
|
||||
rootKeyMap.put(REGISTRY_ROOT_KEY.CURRENT_USER, WINREG.HKEY_CURRENT_USER);
|
||||
rootKeyMap.put(REGISTRY_ROOT_KEY.LOCAL_MACHINE, WINREG.HKEY_LOCAL_MACHINE);
|
||||
rootKeyMap.put(REGISTRY_ROOT_KEY.USERS, WINREG.HKEY_USERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing.
|
||||
*
|
||||
* @param args arguments
|
||||
* @throws java.lang.Exception on error
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one of the root keys.
|
||||
*
|
||||
* @param key key type
|
||||
* @return root key
|
||||
*/
|
||||
private static int getRegistryRootKey(REGISTRY_ROOT_KEY key) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference pHandle;
|
||||
int handle = 0;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
pHandle = new IntByReference();
|
||||
|
||||
if(advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS) {
|
||||
handle = pHandle.getValue();
|
||||
}
|
||||
return(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a key.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param subKeyName name of the key
|
||||
* @param access access mode
|
||||
* @return handle to the key or 0
|
||||
*/
|
||||
private static int openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference pHandle;
|
||||
int rootKeyHandle;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
rootKeyHandle = getRegistryRootKey(rootKey);
|
||||
pHandle = new IntByReference();
|
||||
|
||||
if(advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WINERROR.ERROR_SUCCESS) {
|
||||
return(pHandle.getValue());
|
||||
|
||||
} else {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Windows buffer to a Java String.
|
||||
*
|
||||
* @param buf buffer
|
||||
* @throws java.io.UnsupportedEncodingException on error
|
||||
* @return String
|
||||
*/
|
||||
private static String convertBufferToString(byte[] buf) throws UnsupportedEncodingException {
|
||||
return(new String(buf, 0, buf.length - 2, "UTF-16LE"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Windows buffer to an int.
|
||||
*
|
||||
* @param buf buffer
|
||||
* @return int
|
||||
*/
|
||||
private static int convertBufferToInt(byte[] buf) {
|
||||
return(((int)(buf[0] & 0xff)) + (((int)(buf[1] & 0xff)) << 8) + (((int)(buf[2] & 0xff)) << 16) + (((int)(buf[3] & 0xff)) << 24));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a String value.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
* @throws java.io.UnsupportedEncodingException on error
|
||||
* @return String or null
|
||||
*/
|
||||
public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException {
|
||||
Advapi32 advapi32;
|
||||
IntByReference pType, lpcbData;
|
||||
byte[] lpData = new byte[1];
|
||||
int handle = 0;
|
||||
String ret = null;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
pType = new IntByReference();
|
||||
lpcbData = new IntByReference();
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
|
||||
lpData = new byte[lpcbData.getValue()];
|
||||
|
||||
if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = convertBufferToString(lpData);
|
||||
}
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an int value.
|
||||
*
|
||||
*
|
||||
* @return int or 0
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
*/
|
||||
public static int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference pType, lpcbData;
|
||||
byte[] lpData = new byte[1];
|
||||
int handle = 0;
|
||||
int ret = 0;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
pType = new IntByReference();
|
||||
lpcbData = new IntByReference();
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA) {
|
||||
lpData = new byte[lpcbData.getValue()];
|
||||
|
||||
if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = convertBufferToInt(lpData);
|
||||
}
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a value.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
|
||||
Advapi32 advapi32;
|
||||
int handle;
|
||||
boolean ret = true;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
|
||||
|
||||
if(handle != 0) {
|
||||
if(advapi32.RegDeleteValue(handle, name) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = true;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a String value.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
* @param value value
|
||||
* @throws java.io.UnsupportedEncodingException on error
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException {
|
||||
Advapi32 advapi32;
|
||||
int handle;
|
||||
byte[] data;
|
||||
boolean ret = false;
|
||||
|
||||
data = Arrays.copyOf(value.getBytes("UTF-16LE"), value.length() * 2 + 2);
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
|
||||
|
||||
if(handle != 0) {
|
||||
if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_SZ, data, data.length) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = true;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an int value.
|
||||
*
|
||||
*
|
||||
* @return true on success
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
* @param value value
|
||||
*/
|
||||
public static boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value) {
|
||||
Advapi32 advapi32;
|
||||
int handle;
|
||||
byte[] data;
|
||||
boolean ret = false;
|
||||
|
||||
data = new byte[4];
|
||||
data[0] = (byte)(value & 0xff);
|
||||
data[1] = (byte)((value >> 8) & 0xff);
|
||||
data[2] = (byte)((value >> 16) & 0xff);
|
||||
data[3] = (byte)((value >> 24) & 0xff);
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = true;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for existence of a value.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param subKeyName key name
|
||||
* @param name value name
|
||||
* @return true if exists
|
||||
*/
|
||||
public static boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference pType, lpcbData;
|
||||
byte[] lpData = new byte[1];
|
||||
int handle = 0;
|
||||
boolean ret = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
pType = new IntByReference();
|
||||
lpcbData = new IntByReference();
|
||||
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WINERROR.ERROR_FILE_NOT_FOUND) {
|
||||
ret = true;
|
||||
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new key.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param parent name of parent key
|
||||
* @param name key name
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
|
||||
Advapi32 advapi32;
|
||||
IntByReference hkResult, dwDisposition;
|
||||
int handle = 0;
|
||||
boolean ret = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
hkResult = new IntByReference();
|
||||
dwDisposition = new IntByReference();
|
||||
handle = openKey(rootKey, parent, WINNT.KEY_READ);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegCreateKeyEx(handle, name, 0, null, WINNT.REG_OPTION_NON_VOLATILE, WINNT.KEY_READ, null,
|
||||
hkResult, dwDisposition) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = true;
|
||||
advapi32.RegCloseKey(hkResult.getValue());
|
||||
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a key.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param parent name of parent key
|
||||
* @param name key name
|
||||
* @return true on success
|
||||
*/
|
||||
public static boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name) {
|
||||
Advapi32 advapi32;
|
||||
int handle = 0;
|
||||
boolean ret = false;
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = openKey(rootKey, parent, WINNT.KEY_READ);
|
||||
|
||||
if(handle != 0) {
|
||||
|
||||
if(advapi32.RegDeleteKey(handle, name) == WINERROR.ERROR_SUCCESS) {
|
||||
ret = true;
|
||||
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all sub keys of a key.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param parent key name
|
||||
* @return array with all sub key names
|
||||
*/
|
||||
public static String[] getSubKeys(REGISTRY_ROOT_KEY rootKey, String parent) {
|
||||
Advapi32 advapi32;
|
||||
int handle = 0, dwIndex;
|
||||
char[] lpName;
|
||||
IntByReference lpcName;
|
||||
WINBASE.FILETIME lpftLastWriteTime;
|
||||
TreeSet<String> subKeys = new TreeSet<String>();
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = openKey(rootKey, parent, WINNT.KEY_READ);
|
||||
lpName = new char[256];
|
||||
lpcName = new IntByReference(256);
|
||||
lpftLastWriteTime = new WINBASE.FILETIME();
|
||||
|
||||
if(handle != 0) {
|
||||
dwIndex = 0;
|
||||
|
||||
while(advapi32.RegEnumKeyEx(handle, dwIndex, lpName, lpcName, null,
|
||||
null, null, lpftLastWriteTime) == WINERROR.ERROR_SUCCESS) {
|
||||
subKeys.add(new String(lpName, 0, lpcName.getValue()));
|
||||
lpcName.setValue(256);
|
||||
dwIndex++;
|
||||
}
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
|
||||
return(subKeys.toArray(new String[]{}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all values under a key.
|
||||
*
|
||||
* @param rootKey root key
|
||||
* @param key jey name
|
||||
* @throws java.io.UnsupportedEncodingException on error
|
||||
* @return TreeMap with name and value pairs
|
||||
*/
|
||||
public static TreeMap<String, Object> getValues(REGISTRY_ROOT_KEY rootKey, String key) throws UnsupportedEncodingException {
|
||||
Advapi32 advapi32;
|
||||
int handle = 0, dwIndex, result = 0;
|
||||
char[] lpValueName;
|
||||
byte[] lpData;
|
||||
IntByReference lpcchValueName, lpType, lpcbData;
|
||||
String name;
|
||||
TreeMap<String, Object> values = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
advapi32 = Advapi32.INSTANCE;
|
||||
handle = openKey(rootKey, key, WINNT.KEY_READ);
|
||||
lpValueName = new char[16384];
|
||||
lpcchValueName = new IntByReference(16384);
|
||||
lpType = new IntByReference();
|
||||
lpData = new byte[1];
|
||||
lpcbData = new IntByReference();
|
||||
|
||||
if(handle != 0) {
|
||||
dwIndex = 0;
|
||||
|
||||
do {
|
||||
lpcbData.setValue(0);
|
||||
result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
|
||||
lpType, lpData, lpcbData);
|
||||
|
||||
if(result == WINERROR.ERROR_MORE_DATA) {
|
||||
lpData = new byte[lpcbData.getValue()];
|
||||
lpcchValueName = new IntByReference(16384);
|
||||
result = advapi32.RegEnumValue(handle, dwIndex, lpValueName, lpcchValueName, null,
|
||||
lpType, lpData, lpcbData);
|
||||
|
||||
if(result == WINERROR.ERROR_SUCCESS) {
|
||||
name = new String(lpValueName, 0, lpcchValueName.getValue());
|
||||
|
||||
switch(lpType.getValue()) {
|
||||
case WINNT.REG_SZ:
|
||||
values.put(name, convertBufferToString(lpData));
|
||||
break;
|
||||
case WINNT.REG_DWORD:
|
||||
values.put(name, convertBufferToInt(lpData));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dwIndex++;
|
||||
} while(result == WINERROR.ERROR_SUCCESS);
|
||||
|
||||
advapi32.RegCloseKey(handle);
|
||||
}
|
||||
return(values);
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,6 @@ public abstract class Win32Service {
|
||||
*/
|
||||
public void init() {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_TABLE_ENTRY[] entries = new Advapi32.SERVICE_TABLE_ENTRY[2];
|
||||
Advapi32.SERVICE_TABLE_ENTRY entry;
|
||||
|
||||
serviceMain = new ServiceMain();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?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>
|
||||
<target name="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>
|
||||
<echo message="View test report in file://${build.test.results.dir}/index.html" />
|
||||
</target>
|
||||
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
</project>
|
||||
@@ -0,0 +1,541 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -0,0 +1,59 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>platform</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,135 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.W32FileMonitor;
|
||||
|
||||
/** Provides notification of file system changes. Actual capabilities may
|
||||
* vary slightly by platform.
|
||||
* <p>
|
||||
* Watched files which are removed from the filesystem are no longer watched.
|
||||
* @author twall
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class FileMonitor {
|
||||
|
||||
public static final int FILE_CREATED = 0x1;
|
||||
public static final int FILE_DELETED = 0x2;
|
||||
public static final int FILE_MODIFIED = 0x4;
|
||||
public static final int FILE_ACCESSED = 0x8;
|
||||
public static final int FILE_NAME_CHANGED_OLD = 0x10;
|
||||
public static final int FILE_NAME_CHANGED_NEW = 0x20;
|
||||
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
|
||||
public static final int FILE_SIZE_CHANGED = 0x40;
|
||||
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
|
||||
public static final int FILE_SECURITY_CHANGED = 0x100;
|
||||
public static final int FILE_ANY = 0x1FF;
|
||||
|
||||
public interface FileListener {
|
||||
public void fileChanged(FileEvent e);
|
||||
}
|
||||
|
||||
public class FileEvent extends EventObject {
|
||||
private final File file;
|
||||
private final int type;
|
||||
public FileEvent(File file, int type) {
|
||||
super(FileMonitor.this);
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
public File getFile() { return file; }
|
||||
public int getType() { return type; }
|
||||
public String toString() {
|
||||
return "FileEvent: " + file + ":" + type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<File, Integer> watched = new HashMap<File, Integer>();
|
||||
private List<FileListener> listeners = new ArrayList<FileListener>();
|
||||
|
||||
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
|
||||
protected abstract void unwatch(File file);
|
||||
public abstract void dispose();
|
||||
|
||||
public void addWatch(File dir) throws IOException {
|
||||
addWatch(dir, FILE_ANY);
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask) throws IOException {
|
||||
addWatch(dir, mask, dir.isDirectory());
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
|
||||
watched.put(dir, new Integer(mask));
|
||||
watch(dir, mask, recursive);
|
||||
}
|
||||
|
||||
public void removeWatch(File file) {
|
||||
if (watched.remove(file) != null) {
|
||||
unwatch(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notify(FileEvent e) {
|
||||
for (FileListener listener : listeners) {
|
||||
listener.fileChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addFileListener(FileListener listener) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.add(listener);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
public synchronized void removeFileListener(FileListener x) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.remove(x);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
for (File watchedFile : watched.keySet()) {
|
||||
removeWatch(watchedFile);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileMonitor INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileMonitor();
|
||||
}
|
||||
else {
|
||||
throw new Error("FileMonitor not implemented for " + os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileMonitor getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
}
|
||||
+27
-58
@@ -10,11 +10,15 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import com.sun.jna.examples.win32.Shell32;
|
||||
import com.sun.jna.examples.win32.Shell32.SHFILEOPSTRUCT;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.mac.MacFileUtils;
|
||||
import com.sun.jna.platform.win32.W32FileUtils;
|
||||
|
||||
/** Miscellaneous file utils not provided for by Java. */
|
||||
public abstract class FileUtils {
|
||||
@@ -24,9 +28,9 @@ public abstract class FileUtils {
|
||||
}
|
||||
|
||||
/** Move the given file to the system trash, if one is available.
|
||||
Returns whether the operation was successful.
|
||||
Throws an exception on failure.
|
||||
*/
|
||||
public abstract boolean moveToTrash(File[] files);
|
||||
public abstract void moveToTrash(File[] files) throws IOException;
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
@@ -47,48 +51,7 @@ public abstract class FileUtils {
|
||||
|
||||
public static FileUtils getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class W32FileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public boolean moveToTrash(File[] files) {
|
||||
Shell32 shell = Shell32.INSTANCE;
|
||||
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
|
||||
fileop.wFunc = Shell32.FO_DELETE;
|
||||
String[] paths = new String[files.length];
|
||||
for (int i=0;i < paths.length;i++) {
|
||||
paths[i] = files[i].getAbsolutePath();
|
||||
}
|
||||
fileop.pFrom = fileop.encodePaths(paths);
|
||||
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
|
||||
return shell.SHFileOperation(fileop) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public boolean moveToTrash(File[] files) {
|
||||
// TODO: use native API for moving to trash (if any)
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (trash.exists()) {
|
||||
boolean success = true;
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DefaultFileUtils extends FileUtils {
|
||||
|
||||
@@ -105,6 +68,9 @@ public abstract class FileUtils {
|
||||
trash = new File(desktop, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(desktop, "Trash");
|
||||
if (!trash.exists()) {
|
||||
trash = new File(System.getProperty("fileutils.trash", "Trash"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,19 +85,22 @@ public abstract class FileUtils {
|
||||
/** The default implementation attempts to move the file to
|
||||
* the desktop "Trash" folder.
|
||||
*/
|
||||
public boolean moveToTrash(File[] files) {
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
File trash = getTrashDirectory();
|
||||
if (trash.exists()) {
|
||||
boolean success = true;
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target))
|
||||
success = false;
|
||||
}
|
||||
return success;
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-14
@@ -10,16 +10,17 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.Display;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
|
||||
/** Provide access to the local keyboard state. Note that this is meaningless
|
||||
* on a headless system and some VNC setups.
|
||||
@@ -71,30 +72,30 @@ public class KeyboardUtils {
|
||||
}
|
||||
if (code == KeyEvent.VK_SHIFT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RSHIFT;
|
||||
return WinUser.VK_RSHIFT;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LSHIFT;
|
||||
return WinUser.VK_LSHIFT;
|
||||
}
|
||||
return User32.VK_SHIFT;
|
||||
return WinUser.VK_SHIFT;
|
||||
}
|
||||
if (code == KeyEvent.VK_CONTROL) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RCONTROL;
|
||||
return WinUser.VK_RCONTROL;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LCONTROL;
|
||||
return WinUser.VK_LCONTROL;
|
||||
}
|
||||
return User32.VK_CONTROL;
|
||||
return WinUser.VK_CONTROL;
|
||||
}
|
||||
if (code == KeyEvent.VK_ALT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RMENU;
|
||||
return WinUser.VK_RMENU;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LMENU;
|
||||
return WinUser.VK_LMENU;
|
||||
}
|
||||
return User32.VK_MENU;
|
||||
return WinUser.VK_MENU;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -153,7 +154,7 @@ public class KeyboardUtils {
|
||||
int idx = code / 8;
|
||||
int shift = code % 8;
|
||||
if ((keys[idx] & (1 << shift)) != 0) {
|
||||
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0);
|
||||
int sym = lib.XKeycodeToKeysym(dpy, (byte)code, 0).intValue();
|
||||
if (sym == keysym)
|
||||
return true;
|
||||
}
|
||||
+93
-37
@@ -1,16 +1,17 @@
|
||||
/* Copyright (c) 2007 Olivier Chafik, All Rights Reserved
|
||||
*
|
||||
* Copyright (c) 2008 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.DataBuffer;
|
||||
@@ -20,10 +21,16 @@ import java.awt.image.MultiPixelPackedSampleModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
import java.awt.image.SinglePixelPackedSampleModel;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Methods that are useful to decompose a raster in ranges of contiguous unoccupied pixels.
|
||||
* An occupied pixel has two possible meanings, depending on the raster :
|
||||
* Methods that are useful to decompose a raster into a set of rectangles.
|
||||
* An occupied pixel has two possible meanings, depending on the raster :
|
||||
* <ul>
|
||||
* <li>if the raster has an alpha layer, occupied means with alpha not null</li>
|
||||
* <li>if the raster doesn't have any alpha layer, occupied means not completely black</li>
|
||||
@@ -31,12 +38,18 @@ import java.awt.image.SinglePixelPackedSampleModel;
|
||||
* @author Olivier Chafik
|
||||
*/
|
||||
public class RasterRangesUtils {
|
||||
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
|
||||
/// Masks used to isolate the current column in a set of 8 binary columns packed in a byte
|
||||
private static final int[] subColMasks = new int[] {
|
||||
0x0080, 0x0040, 0x0020, 0x0010,
|
||||
0x0008, 0x0004, 0x0002, 0x0001
|
||||
};
|
||||
|
||||
|
||||
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((Rectangle)o1).x - ((Rectangle)o2).x;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstraction of a sink for ranges.
|
||||
*/
|
||||
@@ -45,13 +58,13 @@ public class RasterRangesUtils {
|
||||
* Output a rectangular range.
|
||||
* @param x x coordinate of the top-left corner of the range
|
||||
* @param y y coordinate of the top-left corner of the range
|
||||
* @param w witdh of the range
|
||||
* @param w width of the range
|
||||
* @param h height of the range
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public boolean outputRange(int x, int y, int w, int h);
|
||||
boolean outputRange(int x, int y, int w, int h);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Outputs ranges of occupied pixels.
|
||||
* In a raster that has an alpha layer, a pixel is occupied if its alpha value is not null.
|
||||
@@ -64,15 +77,15 @@ public class RasterRangesUtils {
|
||||
Rectangle bounds = raster.getBounds();
|
||||
SampleModel sampleModel = raster.getSampleModel();
|
||||
boolean hasAlpha = sampleModel.getNumBands() == 4;
|
||||
|
||||
|
||||
// Try to use the underlying data array directly for a few common raster formats
|
||||
if (raster.getParent() == null && bounds.x == 0 && bounds.y == 0) {
|
||||
// No support for subraster (as obtained with Image.getSubimage(...))
|
||||
|
||||
|
||||
DataBuffer data = raster.getDataBuffer();
|
||||
if (data.getNumBanks() == 1) {
|
||||
// There is always a single bank for all BufferedImage types, except maybe TYPE_CUSTOM
|
||||
|
||||
|
||||
if (sampleModel instanceof MultiPixelPackedSampleModel) {
|
||||
MultiPixelPackedSampleModel packedSampleModel = (MultiPixelPackedSampleModel)sampleModel;
|
||||
if (packedSampleModel.getPixelBitStride() == 1) {
|
||||
@@ -93,18 +106,21 @@ public class RasterRangesUtils {
|
||||
int[] pixels = raster.getPixels(0, 0, bounds.width, bounds.height, (int[])null);
|
||||
return outputOccupiedRanges(pixels, bounds.width, bounds.height, hasAlpha ? 0xff000000 : 0xffffff, out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output the non-null values of a binary image as ranges of contiguous values.
|
||||
* @param binaryBits byte-packed binary bits of an image
|
||||
* @param w width of the image (in pixels)
|
||||
* @param h height of the image
|
||||
* @param output
|
||||
* @param out
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput output) {
|
||||
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
int scanlineBytes = binaryBits.length / h;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int rowOffsetBytes = row * scanlineBytes;
|
||||
int startCol = -1;
|
||||
// Look at each batch of 8 columns in this row
|
||||
@@ -115,9 +131,7 @@ public class RasterRangesUtils {
|
||||
// all 8 bits are zeroes
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
if (!output.outputRange(startCol, row, firstByteCol - startCol, 1)) {
|
||||
return false;
|
||||
}
|
||||
curLine.add(new Rectangle(startCol, row, firstByteCol - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
} else if (byteColBits == 0xff) {
|
||||
@@ -138,9 +152,7 @@ public class RasterRangesUtils {
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
if (!output.outputRange(startCol, row, col - startCol, 1)) {
|
||||
return false;
|
||||
}
|
||||
curLine.add(new Rectangle(startCol, row, col - startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
@@ -149,15 +161,23 @@ public class RasterRangesUtils {
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region
|
||||
if (!output.outputRange(startCol, row, w - startCol, 1)) {
|
||||
return false;
|
||||
}
|
||||
startCol = -1;
|
||||
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output the occupied values of an integer-pixels image as ranges of contiguous values.
|
||||
* A pixel is considered occupied if the bitwise AND of its integer value with the provided occupationMask is not null.
|
||||
@@ -169,11 +189,13 @@ public class RasterRangesUtils {
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
|
||||
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int idxOffset = row * w;
|
||||
int startCol = -1;
|
||||
|
||||
|
||||
for (int col = 0; col < w; col++) {
|
||||
if ((pixels[idxOffset + col] & occupationMask) != 0) {
|
||||
if (startCol < 0) {
|
||||
@@ -182,21 +204,55 @@ public class RasterRangesUtils {
|
||||
} else {
|
||||
if (startCol >= 0) {
|
||||
// end of current region
|
||||
if (!out.outputRange(startCol, row, col - startCol, 1)) {
|
||||
return false;
|
||||
}
|
||||
curLine.add(new Rectangle(startCol, row, col-startCol, 1));
|
||||
startCol = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startCol >= 0) {
|
||||
// end of last region of current row
|
||||
if (!out.outputRange(startCol, row, w - startCol, 1)) {
|
||||
return false;
|
||||
}
|
||||
startCol = -1;
|
||||
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
|
||||
}
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current) {
|
||||
Set<Rectangle> unmerged = new HashSet<Rectangle>(prev);
|
||||
if (!prev.isEmpty() && !current.isEmpty()) {
|
||||
Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]);
|
||||
Rectangle[] cr = current.toArray(new Rectangle[current.size()]);
|
||||
int ipr = 0;
|
||||
int icr = 0;
|
||||
while (ipr < pr.length && icr < cr.length) {
|
||||
while (cr[icr].x < pr[ipr].x) {
|
||||
if (++icr == cr.length) {
|
||||
return unmerged;
|
||||
}
|
||||
}
|
||||
if (cr[icr].x == pr[ipr].x && cr[icr].width == pr[ipr].width) {
|
||||
unmerged.remove(pr[ipr]);
|
||||
cr[icr].y = pr[ipr].y;
|
||||
cr[icr].height = pr[ipr].height + 1;
|
||||
++icr;
|
||||
}
|
||||
else {
|
||||
++ipr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return unmerged;
|
||||
}
|
||||
|
||||
}
|
||||
+383
-182
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+5
-4
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Component;
|
||||
@@ -38,6 +38,7 @@ import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFileChooser;
|
||||
@@ -162,7 +163,7 @@ public abstract class DragHandler
|
||||
try {
|
||||
// getTransferable is available during drag only on 1.5+
|
||||
return (Transferable)
|
||||
e.getClass().getMethod("getTransferable", null).invoke(e, null);
|
||||
e.getClass().getMethod("getTransferable", (Class[])null).invoke(e, (Object[])null);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
// Method not available
|
||||
@@ -179,7 +180,7 @@ public abstract class DragHandler
|
||||
private Component dragSource;
|
||||
private GhostedDragImage ghost;
|
||||
private Point imageOffset;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private float ghostAlpha = DEFAULT_GHOST_ALPHA;
|
||||
|
||||
/** Enable drags from the given component, supporting the actions in
|
||||
@@ -529,4 +530,4 @@ public abstract class DragHandler
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
@@ -88,7 +88,7 @@ import java.util.Set;
|
||||
public abstract class DropHandler implements DropTargetListener {
|
||||
|
||||
private int acceptedActions;
|
||||
private List acceptedFlavors;
|
||||
private List<DataFlavor> acceptedFlavors;
|
||||
private DropTarget dropTarget;
|
||||
private boolean active = true;
|
||||
private DropTargetPainter painter;
|
||||
@@ -347,7 +347,7 @@ public abstract class DropHandler implements DropTargetListener {
|
||||
* constructor.
|
||||
*/
|
||||
protected boolean isSupported(DataFlavor[] flavors) {
|
||||
Set set = new HashSet(Arrays.asList(flavors));
|
||||
Set<DataFlavor> set = new HashSet<DataFlavor>(Arrays.asList(flavors));
|
||||
set.retainAll(acceptedFlavors);
|
||||
return !set.isEmpty();
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
+3
-2
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@@ -29,7 +29,7 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Provide a ghosted drag image for use during drags where
|
||||
* {@link DragSource#isDragImageSupported} returns false.<p>
|
||||
@@ -56,6 +56,7 @@ public class GhostedDragImage {
|
||||
// FIXME ensure gc is compatible (X11)
|
||||
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
|
||||
dragImage = new Window(JOptionPane.getRootFrame(), gc) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public void paint(Graphics g) {
|
||||
icon.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides integrated, extended drag and drop functionality,
|
||||
allowing ghosted drag images to be used on all platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
// TODO: use native API for moving to trash (if any)
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2007 Timothy Wall
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides examples of w32 library mappings.
|
||||
Provides common library mappings for the OS X platform.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides cross-platform utilities based on platform-specific libraries.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for Unix and X11-based platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface BaseTSD extends StdCallLibrary {
|
||||
/**
|
||||
* Signed long type for pointer precision.
|
||||
* Use when casting a pointer to a long to perform pointer arithmetic.
|
||||
*/
|
||||
public static class LONG_PTR extends IntegerType {
|
||||
public LONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SSIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public DWORD_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
public static class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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);
|
||||
}
|
||||
@@ -0,0 +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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
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) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
|
||||
* is returned, if available. If the DNS-style name is not available, the
|
||||
* flat-style name (for example, "\\phoenix") is returned. This example would apply
|
||||
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
|
||||
* IP family of protocols.
|
||||
*/
|
||||
public WString DomainControllerName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the address of the discovered
|
||||
* domain controller. The address is prefixed with "\\". This WString is one of the
|
||||
* types defined by the DomainControllerAddressType member.
|
||||
*/
|
||||
public WString DomainControllerAddress;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the DomainControllerAddress member.
|
||||
*/
|
||||
public int DomainControllerAddressType;
|
||||
/**
|
||||
* The GUID of the domain. This member is zero if the domain controller does not have
|
||||
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
|
||||
* controller.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain. The
|
||||
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
|
||||
* the flat-style name, for example, "fabrikam", is returned. This name may be different
|
||||
* than the requested domain name if the domain has been renamed.
|
||||
*/
|
||||
public WString DomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
|
||||
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
|
||||
*/
|
||||
public WString DnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site where the
|
||||
* domain controller is located. This member may be NULL if the domain controller is
|
||||
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
|
||||
* controller.
|
||||
*/
|
||||
public WString DcSiteName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site that the
|
||||
* computer belongs to. The computer is specified in the ComputerName parameter passed
|
||||
* to DsGetDcName. This member may be NULL if the site that contains the computer
|
||||
* cannot be found; for example, if the DS administrator has not associated the
|
||||
* subnet that the computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to DOMAIN_CONTROLLER_INFO.
|
||||
*/
|
||||
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
}
|
||||
|
||||
/**
|
||||
* Domain is a member of the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_IN_FOREST = 0x0001;
|
||||
/**
|
||||
* Domain is directly trusted.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
|
||||
/**
|
||||
* Domain is root of a tree in the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
/**
|
||||
* Domain is the primary domain of queried server.
|
||||
*/
|
||||
public static final int DS_DOMAIN_PRIMARY = 0x0008;
|
||||
/**
|
||||
* Primary domain is running in native mode.
|
||||
*/
|
||||
public static final int DS_DOMAIN_NATIVE_MODE = 0x0010;
|
||||
/**
|
||||
* Domain is directly trusting.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
|
||||
/**
|
||||
* Valid domain flags.
|
||||
*/
|
||||
public static final int DS_DOMAIN_VALID_FLAGS =
|
||||
DS_DOMAIN_IN_FOREST |
|
||||
DS_DOMAIN_DIRECT_OUTBOUND |
|
||||
DS_DOMAIN_TREE_ROOT |
|
||||
DS_DOMAIN_PRIMARY |
|
||||
DS_DOMAIN_NATIVE_MODE |
|
||||
DS_DOMAIN_DIRECT_INBOUND;
|
||||
|
||||
/**
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
|
||||
* contain trust data for a domain.
|
||||
*/
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
|
||||
*/
|
||||
public WString NetbiosDomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
|
||||
*/
|
||||
public WString DnsDomainName;
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
*/
|
||||
public NativeLong ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustAttributes;
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID.ByReference DomainSid;
|
||||
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
};
|
||||
|
||||
/**
|
||||
* A pointer to an array of DS_DOMAIN_TRUSTS.
|
||||
*/
|
||||
public static class PDS_DOMAIN_TRUSTS extends Structure {
|
||||
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS.ByReference t;
|
||||
|
||||
/**
|
||||
* Returns domain trusts.
|
||||
* @param count
|
||||
* Number of domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
|
||||
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
|
||||
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>gdi32.dll</code>. */
|
||||
public interface GDI32 extends StdCallLibrary {
|
||||
|
||||
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ExtCreateRegion function creates a region from the specified region and transformation data.
|
||||
* @param lpXform
|
||||
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
|
||||
* the identity transformation is used.
|
||||
* @param nCount
|
||||
* Specifies the number of bytes pointed to by lpRgnData.
|
||||
* @param lpRgnData
|
||||
* Pointer to a RGNDATA structure that contains the region data in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the value of the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
|
||||
|
||||
/**
|
||||
* The CombineRgn function combines two regions and stores the result in a third region.
|
||||
* The two regions are combined according to the specified mode.
|
||||
* @param hrgnDest
|
||||
* Handle to a new region with dimensions defined by combining two other regions.
|
||||
* @param hrgnSrc1
|
||||
* Handle to the first of two regions to be combined.
|
||||
* @param hrgnSrc2
|
||||
* Handle to the second of two regions to be combined.
|
||||
* @param fnCombineMode
|
||||
* Specifies a mode indicating how the two regions will be combined.
|
||||
* @return
|
||||
* The return value specifies the type of the resulting region.
|
||||
*/
|
||||
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
|
||||
int fnCombineMode);
|
||||
|
||||
/**
|
||||
* The CreateRectRgn function creates a rectangular region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nWidthEllipse
|
||||
* Specifies the width of the ellipse used to create the rounded corners in logical units.
|
||||
* @param nHeightEllipse
|
||||
* Specifies the height of the ellipse used to create the rounded corners in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
/**
|
||||
* The CreatePolyPolygonRgn function creates a region consisting of a series
|
||||
* of polygons. The polygons can overlap.
|
||||
* @param lppt
|
||||
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
|
||||
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
|
||||
* specified only once.
|
||||
* @param lpPolyCounts
|
||||
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
|
||||
* in the array pointed to by lppt.
|
||||
* @param nCount
|
||||
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
|
||||
* @param fnPolyFillMode
|
||||
* Specifies the fill mode used to determine which pixels are in the region.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
|
||||
int nCount, int fnPolyFillMode);
|
||||
|
||||
/**
|
||||
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
|
||||
* @param hrgn
|
||||
* Handle to the region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @param x
|
||||
* Specifies the x-coordinate, in logical units, of the point to be set.
|
||||
* @param y
|
||||
* Specifies the y-coordinate, in logical units, of the point to be set.
|
||||
* @param crColor
|
||||
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
|
||||
* This value may differ from the color specified by crColor; that occurs when an exact match for the
|
||||
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
|
||||
* information, call GetLastError. This can be the following value.
|
||||
*/
|
||||
int SetPixel(HDC hDC, int x, int y, int crColor);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
|
||||
* @param hDC
|
||||
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
|
||||
* application's current screen.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to a memory DC.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HDC CreateCompatibleDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The DeleteDC function deletes the specified device context (DC).
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
|
||||
* sets the bitmap bits.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param lpbmih
|
||||
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
|
||||
* @param fdwInit
|
||||
* Specifies how the system initializes the bitmap bits.
|
||||
* @param lpbInit
|
||||
* Pointer to an array of bytes containing the initial bitmap data.
|
||||
* @param lpbmi
|
||||
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
|
||||
* the array pointed to by the lpbInit parameter.
|
||||
* @param fuUsage
|
||||
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
|
||||
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
|
||||
* fuUsage parameter must be one of the following values.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
|
||||
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
|
||||
|
||||
/**
|
||||
* The CreateDIBSection function creates a DIB that applications can write to directly.
|
||||
* The function gives you a pointer to the location of the bitmap bit values. You can supply
|
||||
* a handle to a file-mapping object that the function will use to create the bitmap, or you
|
||||
* can let the system allocate the memory for the bitmap.
|
||||
* @param hDC
|
||||
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
|
||||
* device context's logical palette to initialize the DIB colors.
|
||||
* @param pbmi
|
||||
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
|
||||
* the bitmap dimensions and colors.
|
||||
* @param iUsage
|
||||
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
|
||||
* pointed to by pbmi (either logical palette indexes or literal RGB values).
|
||||
* @param ppvBits
|
||||
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
|
||||
* @param hSection
|
||||
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
|
||||
* @param dwOffset
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
* @return
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
*/
|
||||
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
|
||||
PointerByReference ppvBits, Pointer hSection, int dwOffset);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
|
||||
* associated with the specified device context.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param width
|
||||
* Specifies the bitmap width, in pixels.
|
||||
* @param height
|
||||
* Specifies the bitmap height, in pixels.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
|
||||
|
||||
/**
|
||||
* The SelectObject function selects an object into the specified device context (DC).
|
||||
* The new object replaces the previous object of the same type.
|
||||
* @param hDC
|
||||
* Handle to the DC.
|
||||
* @param hGDIObj
|
||||
* Handle to the object to be selected.
|
||||
* @return
|
||||
* If the selected object is not a region and the function succeeds, the return value
|
||||
* is a handle to the object being replaced. If the selected object is a region and the
|
||||
* function succeeds, the return value is one of the REGION values.
|
||||
*/
|
||||
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
|
||||
|
||||
/**
|
||||
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
|
||||
* freeing all system resources associated with the object. After the object is deleted, the
|
||||
* specified handle is no longer valid.
|
||||
* @param hObject
|
||||
* Handle to a logical pen, brush, font, bitmap, region, or palette.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteObject(HANDLE hObject);
|
||||
|
||||
/** The GetDeviceCaps function retrieves device-specific information for
|
||||
* the specified device.
|
||||
* @param hdc A handle to the DC.
|
||||
* @param nIndex The item to be returned.
|
||||
* @return
|
||||
* The return value specifies the value of the desired item. When
|
||||
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
|
||||
* 16bpp, the return value is 16.
|
||||
*/
|
||||
int GetDeviceCaps(HDC hdc, int nIndex);
|
||||
|
||||
/** The GetDIBits function retrieves the bits fo the specified compatible
|
||||
* bitmap and copies them into a buffer as a DIB using the specified
|
||||
* format.
|
||||
* @param hdc A handle to the device context.
|
||||
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
|
||||
* (DDB).
|
||||
* @param uStartScan The first scan line to retrieve
|
||||
* @param cScanLines The number of scan lines to retrieve.
|
||||
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
|
||||
* this parameter is <code>null</code>, the function passes the dimensions
|
||||
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
|
||||
* by the <i>lpbi</i> parameter.
|
||||
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
|
||||
* the desired format for the DIB data.
|
||||
* @param uUsage The format of the bmiColors member of the {@link
|
||||
* BITMAPINFO} structure.
|
||||
*/
|
||||
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* 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.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Guid extends StdCallLibrary {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public static class ByReference extends GUID implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public GUID() {
|
||||
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,957 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX;
|
||||
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HMODULE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>kernel32.dll</code>. */
|
||||
public interface Kernel32 extends StdCallLibrary {
|
||||
|
||||
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Frees the specified local memory object and invalidates its handle.
|
||||
* @param hLocal
|
||||
* A handle to the local memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL.
|
||||
* If the function fails, the return value is equal to a handle to the local memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalFree(Pointer hLocal);
|
||||
|
||||
/**
|
||||
* Frees the specified global memory object and invalidates its handle.
|
||||
* @param hGlobal
|
||||
* A handle to the global memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL
|
||||
* If the function fails, the return value is equal to a handle to the global memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer GlobalFree(Pointer hGlobal);
|
||||
|
||||
/**
|
||||
* The GetModuleHandle function retrieves a module handle for the specified module
|
||||
* if the file has been mapped into the address space of the calling process.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the module
|
||||
* (either a .dll or .exe file).
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the specified module.
|
||||
* If the function fails, the return value is NULL. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
HMODULE GetModuleHandle(String name);
|
||||
|
||||
/**
|
||||
* The GetSystemTime function retrieves the current system date and time.
|
||||
* The system time is expressed in Coordinated Universal Time (UTC).
|
||||
* @param lpSystemTime
|
||||
* Pointer to a SYSTEMTIME structure to receive the current system date and time.
|
||||
*/
|
||||
void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime);
|
||||
|
||||
/**
|
||||
* The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
|
||||
* @return
|
||||
* Number of milliseconds that have elapsed since the system was started.
|
||||
*/
|
||||
int GetTickCount();
|
||||
|
||||
/**
|
||||
* The GetCurrentThreadId function retrieves the thread identifier of the calling thread.
|
||||
* @return
|
||||
* The return value is the thread identifier of the calling thread.
|
||||
*/
|
||||
int GetCurrentThreadId();
|
||||
|
||||
/**
|
||||
* The GetCurrentThread function retrieves a pseudo handle for the current thread.
|
||||
* @return
|
||||
* The return value is a pseudo handle for the current thread.
|
||||
*/
|
||||
HANDLE GetCurrentThread();
|
||||
|
||||
/**
|
||||
* This function returns the process identifier of the calling process.
|
||||
* @return
|
||||
* The return value is the process identifier of the calling process.
|
||||
*/
|
||||
int GetCurrentProcessId();
|
||||
|
||||
/**
|
||||
* This function returns a pseudohandle for the current process.
|
||||
* @return
|
||||
* The return value is a pseudohandle to the current process.
|
||||
*/
|
||||
HANDLE GetCurrentProcess();
|
||||
|
||||
/**
|
||||
* The GetProcessId function retrieves the process identifier of the
|
||||
* specified process.
|
||||
* @param process
|
||||
* Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the process identifier of the
|
||||
* specified process. If the function fails, the return value is zero. To get
|
||||
* extended error information, call GetLastError.
|
||||
*/
|
||||
int GetProcessId(HANDLE process);
|
||||
|
||||
/**
|
||||
* The GetProcessVersion function retrieves the major and minor version numbers of the system
|
||||
* on which the specified process expects to run.
|
||||
* @param processId
|
||||
* Process identifier of the process of interest. A value of zero specifies the
|
||||
* calling process.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the version of the system on
|
||||
* which the process expects to run. The high word of the return value contains
|
||||
* the major version number. The low word of the return value contains the minor
|
||||
* version number. If the function fails, the return value is zero. To get extended
|
||||
* error information, call GetLastError. The function fails if ProcessId is an
|
||||
* invalid value.
|
||||
*/
|
||||
int GetProcessVersion(int processId);
|
||||
|
||||
/**
|
||||
* Retrieves the termination status of the specified process.
|
||||
* @param hProcess A handle to the process.
|
||||
* @param lpExitCode A pointer to a variable to receive the process termination status.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetExitCodeProcess(HANDLE hProcess, IntByReference lpExitCode);
|
||||
|
||||
/**
|
||||
* Terminates the specified process and all of its threads.
|
||||
* @param hProcess A handle to the process to be terminated.
|
||||
* @param uExitCode The exit code to be used by the process and threads
|
||||
* terminated as a result of this call.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean TerminateProcess(HANDLE hProcess, int uExitCode);
|
||||
|
||||
/**
|
||||
* The GetLastError function retrieves the calling thread's last-error code value.
|
||||
* The last-error code is maintained on a per-thread basis. Multiple threads do not
|
||||
* overwrite each other's last-error code.
|
||||
* @return
|
||||
* The return value is the calling thread's last-error code value.
|
||||
*/
|
||||
int GetLastError();
|
||||
|
||||
/**
|
||||
* The SetLastError function sets the last-error code for the calling thread.
|
||||
* @param dwErrCode
|
||||
* Last-error code for the thread.
|
||||
*/
|
||||
void SetLastError(int dwErrCode);
|
||||
|
||||
/**
|
||||
* The GetDriveType function determines whether a disk drive is a removable,
|
||||
* fixed, CD-ROM, RAM disk, or network drive.
|
||||
* @param lpRootPathName
|
||||
* Pointer to a null-terminated string that specifies the root directory of
|
||||
* the disk to return information about. A trailing backslash is required.
|
||||
* If this parameter is NULL, the function uses the root of the current directory.
|
||||
* @return
|
||||
* The return value specifies the type of drive.
|
||||
*/
|
||||
int GetDriveType(String lpRootPathName);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, PointerByReference lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, Buffer lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The CreateFile function creates or opens a file, file stream, directory, physical
|
||||
* disk, volume, console buffer, tape drive, communications resource, mailslot, or
|
||||
* named pipe. The function returns a handle that can be used to access an object.
|
||||
* @param lpFileName
|
||||
* A pointer to a null-terminated string that specifies the name of an object to create or open.
|
||||
* @param dwDesiredAccess
|
||||
* The access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode
|
||||
* The sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param lpSecurityAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not
|
||||
* the returned handle can be inherited by child processes. If lpSecurityAttributes
|
||||
* is NULL, the handle cannot be inherited.
|
||||
* @param dwCreationDisposition
|
||||
* An action to take on files that exist and do not exist.
|
||||
* @param dwFlagsAndAttributes
|
||||
* The file attributes and flags.
|
||||
* @param hTemplateFile
|
||||
* Handle to a template file with the GENERIC_READ access right. The template file
|
||||
* supplies file attributes and extended attributes for the file that is being
|
||||
* created. This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to a specified file.
|
||||
* If a specified file exists before the function call and dwCreationDisposition is
|
||||
* CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS,
|
||||
* even when the function succeeds. If a file does not exist before the call,
|
||||
* GetLastError returns 0 (zero). If the function fails, the return value is
|
||||
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition,
|
||||
int dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
|
||||
|
||||
/**
|
||||
* The CreateDirectory function creates a new directory. If the underlying file
|
||||
* system supports security on files and directories, the function applies a
|
||||
* specified security descriptor to the new directory.
|
||||
* @param lpPathName
|
||||
* Pointer to a null-terminated string that specifies the path of the directory
|
||||
* to be created.
|
||||
* @param lpSecurityAttributes
|
||||
* Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member
|
||||
* of the structure specifies a security descriptor for the new directory. If
|
||||
* lpSecurityAttributes is NULL, the directory gets a default security descriptor.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. If the function fails,
|
||||
* the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean CreateDirectory(String lpPathName,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
/**
|
||||
* Reads data from the specified file or input/output (I/O) device. Reads
|
||||
* occur at the position specified by the file pointer if supported by the
|
||||
* device.
|
||||
*
|
||||
* This function is designed for both synchronous and asynchronous
|
||||
* operations. For a similar function designed solely for asynchronous
|
||||
* operation, see ReadFileEx
|
||||
*
|
||||
* @param hFile A handle to the device (for example, a file, file stream,
|
||||
* physical disk, volume, console buffer, tape drive, socket, communications
|
||||
* resource, mailslot, or pipe).
|
||||
* @param lpBuffer A pointer to the buffer that receives the data read from a file or device.
|
||||
* @param nNumberOfBytesToRead The maximum number of bytes to be read.
|
||||
* @param lpNumberOfBytesRead A pointer to the variable that receives the number of bytes
|
||||
* read when using a synchronous hFile parameter
|
||||
* @param lpOverlapped A pointer to an OVERLAPPED structure is required if the hFile
|
||||
* parameter was opened with FILE_FLAG_OVERLAPPED, otherwise it can be NULL.
|
||||
* @return If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*
|
||||
* Note The GetLastError code ERROR_IO_PENDING is not a failure; it designates the read
|
||||
* operation is pending completion asynchronously. For more information, see Remarks.
|
||||
*/
|
||||
boolean ReadFile(
|
||||
HANDLE hFile,
|
||||
Buffer lpBuffer,
|
||||
int nNumberOfBytesToRead,
|
||||
IntByReference lpNumberOfBytesRead,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
/**
|
||||
* Creates an input/output (I/O) completion port and associates it with a specified
|
||||
* file handle, or creates an I/O completion port that is not yet associated with a
|
||||
* file handle, allowing association at a later time.
|
||||
* @param FileHandle
|
||||
* An open file handle or INVALID_HANDLE_VALUE.
|
||||
* @param ExistingCompletionPort
|
||||
* A handle to an existing I/O completion port or NULL.
|
||||
* @param CompletionKey
|
||||
* The per-handle user-defined completion key that is included in every I/O completion
|
||||
* packet for the specified file handle.
|
||||
* @param NumberOfConcurrentThreads
|
||||
* The maximum number of threads that the operating system can allow to concurrently
|
||||
* process I/O completion packets for the I/O completion port.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to an I/O completion port:
|
||||
* If the ExistingCompletionPort parameter was NULL, the return value is a new handle.
|
||||
* If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle.
|
||||
* If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
|
||||
Pointer CompletionKey, int NumberOfConcurrentThreads);
|
||||
|
||||
/**
|
||||
* Attempts to dequeue an I/O completion packet from the specified I/O completion
|
||||
* port. If there is no completion packet queued, the function waits for a pending
|
||||
* I/O operation associated with the completion port to complete.
|
||||
* @param CompletionPort
|
||||
* A handle to the completion port.
|
||||
* @param lpNumberOfBytes
|
||||
* A pointer to a variable that receives the number of bytes transferred during
|
||||
* an I/O operation that has completed.
|
||||
* @param lpCompletionKey
|
||||
* A pointer to a variable that receives the completion key value associated with
|
||||
* the file handle whose I/O operation has completed.
|
||||
* @param lpOverlapped
|
||||
* A pointer to a variable that receives the address of the OVERLAPPED structure
|
||||
* that was specified when the completed I/O operation was started.
|
||||
* @param dwMilliseconds
|
||||
* The number of milliseconds that the caller is willing to wait for a completion
|
||||
* packet to appear at the completion port.
|
||||
* @return
|
||||
* Returns nonzero (TRUE) if successful or zero (FALSE) otherwise.
|
||||
*/
|
||||
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
|
||||
PointerByReference lpOverlapped, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Posts an I/O completion packet to an I/O completion port.
|
||||
* @param CompletionPort
|
||||
* A handle to an I/O completion port to which the I/O completion packet is to be posted.
|
||||
* @param dwNumberOfBytesTransferred
|
||||
* The value to be returned through the lpNumberOfBytesTransferred parameter of the GetQueuedCompletionStatus function.
|
||||
* @param dwCompletionKey
|
||||
* The value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function.
|
||||
* @param lpOverlapped
|
||||
* The value to be returned through the lpOverlapped parameter of the GetQueuedCompletionStatus function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError .
|
||||
*/
|
||||
boolean PostQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
int dwNumberOfBytesTransferred, Pointer dwCompletionKey,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Waits until the specified object is in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForSingleObjectEx function.
|
||||
* To wait for multiple objects, use the WaitForMultipleObjects.
|
||||
* @param hHandle
|
||||
* A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
|
||||
* If this handle is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForMultipleObjectsEx function.
|
||||
* @param nCount
|
||||
* The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS.
|
||||
* @param hHandle
|
||||
* An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types.
|
||||
* It may not contain multiple copies of the same handle.
|
||||
* If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param bWaitAll
|
||||
* If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled.
|
||||
* If FALSE, the function returns when the state of any one of the objects is set to signaled.
|
||||
* In the latter case, the return value indicates the object whose state caused the function to return.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* The DuplicateHandle function duplicates an object handle.
|
||||
*
|
||||
* @param hSourceProcessHandle
|
||||
* Handle to the process with the handle to duplicate.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param hSourceHandle
|
||||
* Handle to duplicate. This is an open object handle that is valid in the
|
||||
* context of the source process.
|
||||
* @param hTargetProcessHandle
|
||||
* Handle to the process that is to receive the duplicated handle.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param lpTargetHandle
|
||||
* Pointer to a variable that receives the duplicate handle. This handle value is valid in
|
||||
* the context of the target process. If hSourceHandle is a pseudo handle returned by
|
||||
* GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to
|
||||
* a process or thread, respectively.
|
||||
* @param dwDesiredAccess
|
||||
* Access requested for the new handle.
|
||||
* @param bInheritHandle
|
||||
* Indicates whether the handle is inheritable.
|
||||
* @param dwOptions
|
||||
* Optional actions.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
|
||||
HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle,
|
||||
int dwDesiredAccess, boolean bInheritHandle, int dwOptions);
|
||||
|
||||
/**
|
||||
* The CloseHandle function closes an open object handle.
|
||||
*
|
||||
* @param hObject
|
||||
* Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean CloseHandle(HANDLE hObject);
|
||||
|
||||
// TODO: figure out how OVERLAPPED is used and apply an appropriate mapping
|
||||
interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback {
|
||||
void callback(int errorCode, int nBytesTransferred,
|
||||
WinBase.OVERLAPPED overlapped);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves information that describes the changes within the specified directory.
|
||||
* The function does not report changes to the specified directory itself.
|
||||
* Note: there's no ReadDirectoryChangesA.
|
||||
* @param directory
|
||||
* A handle to the directory to be monitored. This directory must be opened with the
|
||||
* FILE_LIST_DIRECTORY access right.
|
||||
* @param info
|
||||
* A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned.
|
||||
* @param length
|
||||
* The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
|
||||
* @param watchSubtree
|
||||
* If this parameter is TRUE, the function monitors the directory tree rooted at the specified
|
||||
* directory. If this parameter is FALSE, the function monitors only the directory specified by
|
||||
* the hDirectory parameter.
|
||||
* @param notifyFilter
|
||||
* The filter criteria that the function checks to determine if the wait operation has completed.
|
||||
* @param bytesReturned
|
||||
* For synchronous calls, this parameter receives the number of bytes transferred into the
|
||||
* lpBuffer parameter. For asynchronous calls, this parameter is undefined. You must use an asynchronous
|
||||
* notification technique to retrieve the number of bytes transferred.
|
||||
* @param overlapped
|
||||
* A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
|
||||
* Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used.
|
||||
* @param completionRoutine
|
||||
* A pointer to a completion routine to be called when the operation has been completed or canceled and
|
||||
* the calling thread is in an alertable wait state.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. For synchronous calls, this means that the
|
||||
* operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the network redirector or the target file system does not support this operation, the function
|
||||
* fails with ERROR_INVALID_FUNCTION.
|
||||
*/
|
||||
public boolean ReadDirectoryChangesW(HANDLE directory,
|
||||
WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree,
|
||||
int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped,
|
||||
OVERLAPPED_COMPLETION_ROUTINE completionRoutine);
|
||||
|
||||
/**
|
||||
* Retrieves the short path form of the specified path.
|
||||
* @param lpszLongPath
|
||||
* The path string.
|
||||
* @param lpdzShortPath
|
||||
* A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies.
|
||||
* @param cchBuffer
|
||||
* The size of the buffer that lpszShortPath points to, in TCHARs.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to
|
||||
* lpszShortPath, not including the terminating null character.
|
||||
* If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer,
|
||||
* in TCHARs, that is required to hold the path and the terminating null character.
|
||||
* If the function fails for any other reason, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer);
|
||||
|
||||
/**
|
||||
* The LocalAlloc function allocates the specified number of bytes from the heap.
|
||||
* Windows memory management does not provide a separate local heap and global heap.
|
||||
* @param type
|
||||
* Memory allocation attributes. The default is the LMEM_FIXED value.
|
||||
* @param cbInput
|
||||
* Number of bytes to allocate. If this parameter is zero and the uFlags parameter
|
||||
* specifies LMEM_MOVEABLE, the function returns a handle to a memory object that
|
||||
* is marked as discarded.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly allocated memory object.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalAlloc(int type, int cbInput);
|
||||
|
||||
/**
|
||||
* Writes data to the specified file or input/output (I/O) device.
|
||||
* @param hFile
|
||||
* A handle to the file or I/O device (for example, a file, file stream, physical disk, volume,
|
||||
* console buffer, tape drive, socket, communications resource, mailslot, or pipe).
|
||||
* @param lpBuffer
|
||||
* A pointer to the buffer containing the data to be written to the file or device.
|
||||
* @param nNumberOfBytesToWrite
|
||||
* The number of bytes to be written to the file or device.
|
||||
* @param lpNumberOfBytesWritten
|
||||
* A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.
|
||||
* @param lpOverlapped
|
||||
* A pointer to an OVERLAPPED structure is required if the hFile parameter was opened with FILE_FLAG_OVERLAPPED,
|
||||
* otherwise this parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
|
||||
IntByReference lpNumberOfBytesWritten,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed event object.
|
||||
* @param lpEventAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL,
|
||||
* the handle cannot be inherited by child processes.
|
||||
* @param bManualReset
|
||||
* If this parameter is TRUE, the function creates a manual-reset event object,
|
||||
* which requires the use of the ResetEvent function to set the event state to nonsignaled.
|
||||
* If this parameter is FALSE, the function creates an auto-reset event object, and system
|
||||
* automatically resets the event state to nonsignaled after a single waiting thread has
|
||||
* been released.
|
||||
* @param bInitialState
|
||||
* If this parameter is TRUE, the initial state of the event object is signaled; otherwise,
|
||||
* it is nonsignaled.
|
||||
* @param lpName
|
||||
* The name of the event object. The name is limited to MAX_PATH characters. Name comparison
|
||||
* is case sensitive.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the event object. If the named event
|
||||
* object existed before the function call, the function returns a handle to the existing object
|
||||
* and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateEvent(WinBase.SECURITY_ATTRIBUTES lpEventAttributes,
|
||||
boolean bManualReset, boolean bInitialState,
|
||||
String lpName);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state and then resets it to the nonsignaled
|
||||
* state after releasing the appropriate number of waiting threads.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean PulseEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed file mapping object for a specified file.
|
||||
* @param hFile
|
||||
* A handle to the file from which to create a file mapping object.
|
||||
* @param lpAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object.
|
||||
* @param flProtect
|
||||
* Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection.
|
||||
* @param dwMaximumSizeHigh
|
||||
* The high-order DWORD of the maximum size of the file mapping object.
|
||||
* @param dwMaximumSizeLow
|
||||
* The low-order DWORD of the maximum size of the file mapping object.
|
||||
* @param lpName
|
||||
* The name of the file mapping object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly created file mapping object.
|
||||
* If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFileMapping(HANDLE hFile, WinBase.SECURITY_ATTRIBUTES lpAttributes,
|
||||
int flProtect, int dwMaximumSizeHigh,
|
||||
int dwMaximumSizeLow, String lpName);
|
||||
|
||||
/**
|
||||
* Maps a view of a file mapping into the address space of a calling process.
|
||||
* @param hFileMappingObject
|
||||
* A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle.
|
||||
* @param dwDesiredAccess
|
||||
* The type of access to a file mapping object, which determines the protection of the pages.
|
||||
* @param dwFileOffsetHigh
|
||||
* A high-order DWORD of the file offset where the view begins.
|
||||
* @param dwFileOffsetLow
|
||||
* A low-order DWORD of the file offset where the view is to begin.
|
||||
* @param dwNumberOfBytesToMap
|
||||
* The number of bytes of a file mapping to map to the view.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
|
||||
int dwFileOffsetHigh, int dwFileOffsetLow,
|
||||
int dwNumberOfBytesToMap);
|
||||
|
||||
/**
|
||||
* Unmaps a mapped view of a file from the calling process's address space.
|
||||
* @param lpBaseAddress
|
||||
* A pointer to the base address of the mapped view of a file that is to be unmapped.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UnmapViewOfFile(Pointer lpBaseAddress);
|
||||
|
||||
/**
|
||||
* Retrieves only the NetBIOS name of the local computer.
|
||||
*
|
||||
* @param buffer
|
||||
* A pointer to a buffer that receives the computer name or the cluster virtual server
|
||||
* name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1
|
||||
* characters.
|
||||
* @param lpnSize
|
||||
* On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs
|
||||
* copied to the destination buffer, not including the terminating null character. If
|
||||
* the buffer is too small, the function fails and GetLastError returns
|
||||
* ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required,
|
||||
* including the terminating null character.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean GetComputerName(char[] buffer, IntByReference lpnSize);
|
||||
|
||||
/**
|
||||
* The OpenThread function opens an existing thread object.
|
||||
* @param dwDesiredAccess
|
||||
* Access to the thread object. This access right is checked against any security
|
||||
* descriptor for the thread.
|
||||
* @param bInheritHandle
|
||||
* If this parameter is TRUE, the new process inherits the handle. If the parameter
|
||||
* is FALSE, the handle is not inherited.
|
||||
* @param dwThreadId
|
||||
* Identifier of the thread to be opened.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to the specified process.
|
||||
* If the function fails, the return value is NULL. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId);
|
||||
|
||||
/**
|
||||
* This function returns a handle to an existing process object.
|
||||
* @param fdwAccess
|
||||
* Not supported; set to zero.
|
||||
* @param fInherit
|
||||
* Not supported; set to FALSE.
|
||||
* @param IDProcess
|
||||
* Specifies the process identifier of the process to open.
|
||||
* @return
|
||||
* An open handle to the specified process indicates success.
|
||||
* NULL indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE OpenProcess(int fdwAccess, boolean fInherit, int IDProcess);
|
||||
|
||||
/**
|
||||
* The GetTempPath function retrieves the path of the directory designated
|
||||
* for temporary files.
|
||||
* @param nBufferLength
|
||||
* Size of the string buffer identified by lpBuffer, in TCHARs.
|
||||
* @param buffer
|
||||
* Pointer to a string buffer that receives the null-terminated string specifying the
|
||||
* temporary file path. The returned string ends with a backslash, for example,
|
||||
* C:\TEMP\.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string
|
||||
* copied to lpBuffer, not including the terminating null character. If the return value
|
||||
* is greater than nBufferLength, the return value is the length, in TCHARs, of the
|
||||
* buffer required to hold the path.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
DWORD GetTempPath(DWORD nBufferLength, char[] buffer);
|
||||
|
||||
/**
|
||||
* The GetVersion function returns the current version number of the operating system.
|
||||
* @return
|
||||
* If the function succeeds, the return value includes the major and minor version numbers
|
||||
* of the operating system in the low order word, and information about the operating system
|
||||
* platform in the high order word.
|
||||
*/
|
||||
DWORD GetVersion();
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFO data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFO lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFOEX data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFOEX lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetSystemInfo function returns information about the current system.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The GetNativeSystemInfo function retrieves information about the current system to an
|
||||
* application running under WOW64. If the function is called from a 64-bit application,
|
||||
* it is equivalent to the GetSystemInfo function.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The IsWow64Process function determines whether the specified process is running under WOW64.
|
||||
* @param hProcess
|
||||
* Handle to a process.
|
||||
* @param Wow64Process
|
||||
* Pointer to a value that is set to TRUE if the process is running under WOW64.
|
||||
* Otherwise, the value is set to FALSE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
|
||||
|
||||
/**
|
||||
* Retrieves information about the system's current usage of both physical and virtual memory.
|
||||
* @param lpBuffer
|
||||
* A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetLogicalDriveStrings function fills a buffer with strings that specify
|
||||
* valid drives in the system.
|
||||
* @param nBufferLength
|
||||
* Maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include
|
||||
* the terminating null character. If this parameter is zero, lpBuffer is not used.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives a series of null-terminated strings, one for each valid
|
||||
* drive in the system, plus with an additional null character. Each string is a device name.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in characters, of the strings
|
||||
* copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII
|
||||
* null character uses one byte, but a Unicode null character uses two bytes.
|
||||
* If the buffer is not large enough, the return value is greater than nBufferLength. It is
|
||||
* the size of the buffer required to hold the drive strings.
|
||||
* If the function fails, the return value is zero. To get extended error information, use
|
||||
* the GetLastError function.
|
||||
*/
|
||||
DWORD GetLogicalDriveStrings(DWORD nBufferLength, char[] lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetDiskFreeSpaceEx function retrieves information about the amount of space that is
|
||||
* available on a disk volume, which is the total amount of space, the total amount of free
|
||||
* space, and the total amount of free space available to the user that is associated with
|
||||
* the calling thread.
|
||||
* @param lpDirectoryName
|
||||
* A pointer to a null-terminated string that specifies a directory on a disk.
|
||||
* If this parameter is NULL, the function uses the root of the current disk.
|
||||
* If this parameter is a UNC name, it must include a trailing backslash, for example,
|
||||
* \\MyServer\MyShare\.
|
||||
* This parameter does not have to specify the root directory on a disk. The function
|
||||
* accepts any directory on a disk.
|
||||
* @param lpFreeBytesAvailable
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk that
|
||||
* are available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfBytes
|
||||
* A pointer to a variable that receives the total number of bytes on a disk that are
|
||||
* available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfFreeBytes
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk.
|
||||
* This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is 0 (zero). To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable,
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
|
||||
|
||||
/**
|
||||
* Deletes an existing file.
|
||||
* @param filename
|
||||
* The name of the file to be deleted.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean DeleteFile(String filename);
|
||||
|
||||
/**
|
||||
* Creates an anonymous pipe, and returns handles to the read and write ends of the pipe.
|
||||
* @param hReadPipe A pointer to a variable that receives the read handle for the pipe.
|
||||
* @param hWritePipe A pointer to a variable that receives the write handle for the pipe.
|
||||
* @param lpPipeAttributes A pointer to a SECURITY_ATTRIBUTES structure that determines whether
|
||||
* the returned handle can be inherited by child processes.
|
||||
* @param nSize The size of the buffer for the pipe, in bytes.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CreatePipe(
|
||||
HANDLEByReference hReadPipe,
|
||||
HANDLEByReference hWritePipe,
|
||||
WinBase.SECURITY_ATTRIBUTES lpPipeAttributes,
|
||||
int nSize);
|
||||
|
||||
/**
|
||||
* Sets certain properties of an object handle.
|
||||
* @param hObject A handle to an object whose information is to be set.
|
||||
* @param dwMask A mask that specifies the bit flags to be changed. Use the same constants shown in the description of dwFlags.
|
||||
* @param dwFlags Set of bit flags that specifies properties of the object handle.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetHandleInformation(
|
||||
HANDLE hObject,
|
||||
int dwMask,
|
||||
int dwFlags);
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
* @param lpFileName The name of the file or directory. Prepend \\?\ to the path for names up to 32,767 wide characters
|
||||
* @return INVALID_FILE_ATTRIBUTES if the function fails, otherwise the file attributes WinNT.FILE_ATTRIBUTE_*
|
||||
*/
|
||||
public int GetFileAttributes(String lpFileName);
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/* 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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.LastErrorException;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Kernel32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Kernel32Util {
|
||||
|
||||
/**
|
||||
* Get current computer NetBIOS name.
|
||||
* @return
|
||||
* Netbios name.
|
||||
*/
|
||||
public static String getComputerName() {
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1];
|
||||
IntByReference lpnSize = new IntByReference(buffer.length);
|
||||
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a message from an HRESULT.
|
||||
* @param code
|
||||
* HRESULT
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromHR(HRESULT code) {
|
||||
PointerByReference buffer = new PointerByReference();
|
||||
if (0 == Kernel32.INSTANCE.FormatMessage(
|
||||
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
null,
|
||||
code.intValue(),
|
||||
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
|
||||
buffer,
|
||||
0,
|
||||
null)) {
|
||||
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
|
||||
s = s.replace(".\r",".").replace(".\n",".");
|
||||
Kernel32.INSTANCE.LocalFree(buffer.getValue());
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a system message from an error code.
|
||||
* @param code
|
||||
* Error code, typically a result of GetLastError.
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromLastErrorCode(int code) {
|
||||
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path designated for temporary files.
|
||||
* @return
|
||||
* Path.
|
||||
*/
|
||||
public static String getTempPath() {
|
||||
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
|
||||
char[] buffer = new char[nBufferLength.intValue()];
|
||||
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
/* 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.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMAccess.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMAccess extends StdCallLibrary {
|
||||
|
||||
public static class LOCALGROUP_INFO_0 extends Structure {
|
||||
public LOCALGROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
public static class LOCALGROUP_INFO_1 extends Structure {
|
||||
public LOCALGROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui1_name;
|
||||
public WString lgrui1_comment;
|
||||
}
|
||||
|
||||
//
|
||||
// bit masks for the NetUserEnum filter parameter.
|
||||
//
|
||||
|
||||
public static final int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
|
||||
public static final int FILTER_NORMAL_ACCOUNT = 0x0002;
|
||||
// public static final int FILTER_PROXY_ACCOUNT = 0x0004;
|
||||
public static final int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
|
||||
public static final int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
|
||||
public static final int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
|
||||
|
||||
/**
|
||||
* The USER_INFO_0 structure contains a user account name.
|
||||
*/
|
||||
public static class USER_INFO_0 extends Structure {
|
||||
public USER_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user account.
|
||||
*/
|
||||
public WString usri0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The USER_INFO_1 structure contains information about a user account, including
|
||||
* account name, password data, privilege level, and the path to the user's home
|
||||
* directory.
|
||||
*/
|
||||
public static class USER_INFO_1 extends Structure {
|
||||
public USER_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user
|
||||
* account.
|
||||
*/
|
||||
public WString usri1_name;
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the password of the user
|
||||
* indicated by the usri1_name member.
|
||||
*/
|
||||
public WString usri1_password;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the number of seconds that have
|
||||
* elapsed since the usri1_password member was last changed.
|
||||
*/
|
||||
public int usri1_password_age;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the level of privilege assigned
|
||||
* to the usri1_name member.
|
||||
*/
|
||||
public int usri1_priv;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path of the home directory
|
||||
* for the user specified in the usri1_name member.
|
||||
*/
|
||||
public WString usri1_home_dir;
|
||||
/**
|
||||
* Pointer to a Unicode string that contains a comment to associate with
|
||||
* the user account.
|
||||
*/
|
||||
public WString usri1_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that determines several features.
|
||||
*/
|
||||
public int usri1_flags;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path for the user's
|
||||
* logon script file.
|
||||
*/
|
||||
public WString usri1_script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_USERS_INFO_0 structure contains global group member information.
|
||||
*/
|
||||
public static class GROUP_USERS_INFO_0 extends Structure {
|
||||
public GROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies a name.
|
||||
*/
|
||||
public WString grui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The LOCALGROUP_USERS_INFO_0 structure contains local group member information.
|
||||
*/
|
||||
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
|
||||
public LOCALGROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
|
||||
*/
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_0 structure contains the name of a global group in the security
|
||||
* database, which is the security accounts manager (SAM) database or, in the case
|
||||
* of domain controllers, the Active Directory.
|
||||
*/
|
||||
public static class GROUP_INFO_0 extends Structure {
|
||||
public GROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_1 structure contains a global group name and a comment to
|
||||
* associate with the group.
|
||||
*/
|
||||
public static class GROUP_INFO_1 extends Structure {
|
||||
public GROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi1_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* a remark associated with the global group. This member can be a null
|
||||
* string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi1_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_2 structure contains information about a global group, including
|
||||
* name, identifier, and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_2 extends Structure {
|
||||
public GROUP_INFO_2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_2(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi2_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that contains a
|
||||
* remark associated with the global group. This member can be a null string.
|
||||
* The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi2_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that contains the relative identifier (RID) of
|
||||
* the global group.
|
||||
*/
|
||||
public int grpi2_group_id;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED,
|
||||
* and SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi2_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_3 structure contains information about a global group, including
|
||||
* name, security identifier (SID), and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_3 extends Structure {
|
||||
public GROUP_INFO_3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_3(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi3_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* contains a remark associated with the global group. This member can be
|
||||
* a null string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi3_comment;
|
||||
/**
|
||||
* Pointer to a SID structure that contains the security identifier (SID) that
|
||||
* uniquely identifies the global group.
|
||||
*/
|
||||
public PSID grpi3_group_sid;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and
|
||||
* SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi3_attributes;
|
||||
}
|
||||
|
||||
//
|
||||
// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
|
||||
//
|
||||
|
||||
public static final int USER_PRIV_MASK = 3;
|
||||
public static final int USER_PRIV_GUEST = 0;
|
||||
public static final int USER_PRIV_USER = 1;
|
||||
public static final int USER_PRIV_ADMIN = 2;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/* 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.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMCons.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMCons extends StdCallLibrary {
|
||||
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
|
||||
|
||||
/**
|
||||
* Value to be used with APIs which have a "preferred maximum length" parameter.
|
||||
* This value indicates that the API should just allocate "as much as it takes."
|
||||
*/
|
||||
public static final int MAX_PREFERRED_LENGTH = -1;
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMErr.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMErr extends StdCallLibrary {
|
||||
public static final int NERR_Success = 0;
|
||||
public static final int NERR_BASE = 2100;
|
||||
|
||||
public static final int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */
|
||||
public static final int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */
|
||||
public static final int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */
|
||||
|
||||
public static final int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */
|
||||
public static final int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */
|
||||
public static final int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */
|
||||
/* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
|
||||
/* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
|
||||
/* UNUSED BASE + 10 */
|
||||
/* UNUSED BASE + 11 */
|
||||
/* UNUSED BASE + 12 */
|
||||
/* UNUSED BASE + 13 */
|
||||
public static final int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */
|
||||
public static final int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */
|
||||
public static final int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */
|
||||
public static final int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */
|
||||
public static final int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */
|
||||
public static final int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */
|
||||
/* UNUSED BASE + 20 */
|
||||
public static final int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */
|
||||
public static final int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */
|
||||
public static final int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */
|
||||
/* UNUSED BASE + 24 */
|
||||
/* UNUSED BASE + 25 */
|
||||
/* UNUSED BASE + 26 */
|
||||
public static final int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */
|
||||
/* UNUSED BASE + 28 */
|
||||
/* UNUSED BASE + 29 */
|
||||
/* UNUSED BASE + 30 */
|
||||
public static final int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */
|
||||
/* UNUSED BASE + 32 */
|
||||
/* UNUSED BASE + 33 */
|
||||
/* UNUSED BASE + 34 */
|
||||
/* UNUSED BASE + 35 */
|
||||
public static final int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */
|
||||
public static final int NERR_WkstaInconsistentState = NERR_BASE + 37;
|
||||
/* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */
|
||||
public static final int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */
|
||||
public static final int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */
|
||||
public static final int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/
|
||||
public static final int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */
|
||||
public static final int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */
|
||||
public static final int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */
|
||||
public static final int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */
|
||||
/*
|
||||
* Config API related
|
||||
* Error codes from BASE + 45 to BASE + 49
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 45 */
|
||||
public static final int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */
|
||||
public static final int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */
|
||||
public static final int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */
|
||||
|
||||
/*
|
||||
* Spooler API related
|
||||
* Error codes from BASE + 50 to BASE + 79
|
||||
*/
|
||||
|
||||
public static final int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */
|
||||
public static final int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */
|
||||
public static final int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */
|
||||
public static final int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */
|
||||
public static final int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */
|
||||
public static final int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */
|
||||
public static final int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */
|
||||
public static final int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */
|
||||
public static final int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */
|
||||
public static final int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */
|
||||
public static final int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */
|
||||
public static final int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */
|
||||
public static final int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */
|
||||
public static final int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */
|
||||
public static final int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */
|
||||
public static final int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */
|
||||
public static final int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */
|
||||
public static final int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */
|
||||
public static final int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */
|
||||
|
||||
/*
|
||||
* Service API related
|
||||
* Error codes from BASE + 80 to BASE + 99
|
||||
*/
|
||||
|
||||
public static final int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */
|
||||
public static final int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */
|
||||
public static final int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */
|
||||
public static final int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */
|
||||
public static final int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */
|
||||
public static final int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */
|
||||
public static final int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */
|
||||
public static final int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */
|
||||
public static final int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */
|
||||
public static final int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */
|
||||
public static final int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */
|
||||
public static final int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */
|
||||
public static final int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */
|
||||
public static final int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */
|
||||
public static final int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */
|
||||
|
||||
/*
|
||||
* Wksta and Logon API related
|
||||
* Error codes from BASE + 100 to BASE + 118
|
||||
*/
|
||||
|
||||
public static final int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */
|
||||
public static final int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */
|
||||
public static final int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */
|
||||
public static final int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */
|
||||
public static final int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */
|
||||
public static final int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */
|
||||
/* UNUSED BASE + 108 */
|
||||
public static final int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */
|
||||
public static final int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */
|
||||
public static final int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */
|
||||
public static final int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */
|
||||
/* UNUSED BASE + 113 */
|
||||
public static final int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */
|
||||
public static final int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */
|
||||
public static final int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */
|
||||
public static final int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */
|
||||
|
||||
/*
|
||||
* ACF API related = access, user, group;
|
||||
* Error codes from BASE + 119 to BASE + 149
|
||||
*/
|
||||
|
||||
public static final int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */
|
||||
public static final int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */
|
||||
public static final int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */
|
||||
public static final int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */
|
||||
public static final int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */
|
||||
public static final int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */
|
||||
public static final int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */
|
||||
public static final int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */
|
||||
public static final int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */
|
||||
public static final int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */
|
||||
public static final int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/
|
||||
public static final int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */
|
||||
public static final int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */
|
||||
public static final int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */
|
||||
public static final int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */
|
||||
public static final int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */
|
||||
public static final int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */
|
||||
public static final int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */
|
||||
public static final int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */
|
||||
public static final int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */
|
||||
public static final int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */
|
||||
public static final int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */
|
||||
public static final int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */
|
||||
public static final int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */
|
||||
public static final int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */
|
||||
public static final int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */
|
||||
public static final int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */
|
||||
public static final int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */
|
||||
public static final int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */
|
||||
public static final int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */
|
||||
public static final int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */
|
||||
|
||||
/*
|
||||
* Use API related
|
||||
* Error codes from BASE + 150 to BASE + 169
|
||||
*/
|
||||
|
||||
public static final int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */
|
||||
public static final int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */
|
||||
public static final int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */
|
||||
public static final int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */
|
||||
|
||||
|
||||
/*
|
||||
* Message Server related
|
||||
* Error codes BASE + 170 to BASE + 209
|
||||
*/
|
||||
|
||||
public static final int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */
|
||||
public static final int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */
|
||||
public static final int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */
|
||||
public static final int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */
|
||||
public static final int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */
|
||||
public static final int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */
|
||||
public static final int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */
|
||||
public static final int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */
|
||||
public static final int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/
|
||||
public static final int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */
|
||||
public static final int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */
|
||||
public static final int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */
|
||||
public static final int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */
|
||||
public static final int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */
|
||||
public static final int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */
|
||||
public static final int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */
|
||||
public static final int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */
|
||||
public static final int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */
|
||||
public static final int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */
|
||||
public static final int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */
|
||||
public static final int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */
|
||||
public static final int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */
|
||||
/* UNUSED BASE + 196 */
|
||||
public static final int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */
|
||||
public static final int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */
|
||||
public static final int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */
|
||||
public static final int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */
|
||||
|
||||
/*
|
||||
* Server API related
|
||||
* Error codes BASE + 210 to BASE + 229
|
||||
*/
|
||||
|
||||
public static final int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/
|
||||
public static final int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */
|
||||
public static final int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */
|
||||
public static final int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */
|
||||
public static final int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */
|
||||
public static final int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */
|
||||
public static final int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */
|
||||
public static final int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */
|
||||
public static final int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */
|
||||
public static final int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */
|
||||
public static final int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */
|
||||
|
||||
/*
|
||||
* CharDev API related
|
||||
* Error codes BASE + 230 to BASE + 249
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 230 */
|
||||
public static final int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */
|
||||
public static final int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */
|
||||
public static final int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */
|
||||
public static final int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */
|
||||
public static final int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */
|
||||
public static final int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */
|
||||
public static final int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */
|
||||
public static final int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */
|
||||
public static final int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */
|
||||
public static final int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */
|
||||
public static final int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */
|
||||
|
||||
/*
|
||||
* NetICanonicalize and NetIType and NetIMakeLMFileName
|
||||
* NetIListCanon and NetINameCheck
|
||||
* Error codes BASE + 250 to BASE + 269
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */
|
||||
/* UNUSED BASE + 252 */
|
||||
/* UNUSED BASE + 253 */
|
||||
public static final int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */
|
||||
/* UNUSED BASE + 255 */
|
||||
public static final int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */
|
||||
public static final int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */
|
||||
/* UNUSED BASE + 258 */
|
||||
/* UNUSED BASE + 259 */
|
||||
public static final int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */
|
||||
|
||||
/*
|
||||
* NetProfile
|
||||
* Error codes BASE + 270 to BASE + 276
|
||||
*/
|
||||
|
||||
public static final int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */
|
||||
public static final int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */
|
||||
public static final int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */
|
||||
public static final int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/
|
||||
public static final int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */
|
||||
public static final int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */
|
||||
|
||||
|
||||
/*
|
||||
* NetAudit and NetErrorLog
|
||||
* Error codes BASE + 277 to BASE + 279
|
||||
*/
|
||||
|
||||
public static final int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */
|
||||
public static final int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */
|
||||
public static final int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */
|
||||
|
||||
|
||||
/*
|
||||
* NetRemote
|
||||
* Error codes BASE + 280 to BASE + 299
|
||||
*/
|
||||
public static final int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */
|
||||
public static final int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */
|
||||
public static final int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */
|
||||
public static final int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */
|
||||
/* UNUSED BASE + 284 */
|
||||
public static final int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */
|
||||
/* UNUSED BASE + 286 */
|
||||
/* UNUSED BASE + 287 */
|
||||
/* UNUSED BASE + 288 */
|
||||
public static final int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */
|
||||
/* UNUSED BASE + 290 */
|
||||
public static final int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */
|
||||
public static final int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/
|
||||
/* UNUSED BASE + 293 */
|
||||
/* UNUSED BASE + 294 */
|
||||
|
||||
|
||||
/*
|
||||
* NetWksta.sys = redir; returned error codes.
|
||||
*
|
||||
* NERR_BASE + = 300-329;
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */
|
||||
public static final int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */
|
||||
public static final int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */
|
||||
public static final int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */
|
||||
public static final int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */
|
||||
public static final int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */
|
||||
|
||||
/*
|
||||
* Alert error codes.
|
||||
*
|
||||
* NERR_BASE + = 330-339;
|
||||
*/
|
||||
public static final int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */
|
||||
public static final int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */
|
||||
public static final int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */
|
||||
public static final int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/
|
||||
public static final int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted
|
||||
* because the user's logon hours are no longer valid. */
|
||||
|
||||
/*
|
||||
* Additional Error and Audit log codes.
|
||||
*
|
||||
* NERR_BASE + (340-343;
|
||||
*/
|
||||
public static final int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */
|
||||
/* UNUSED BASE + 341 */
|
||||
/* UNUSED BASE + 342 */
|
||||
/* UNUSED BASE + 343 */
|
||||
|
||||
/*
|
||||
* Additional UAS and NETLOGON codes
|
||||
*
|
||||
* NERR_BASE + (350-359;
|
||||
*/
|
||||
public static final int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */
|
||||
public static final int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */
|
||||
public static final int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */
|
||||
public static final int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */
|
||||
public static final int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */
|
||||
public static final int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */
|
||||
public static final int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */
|
||||
public static final int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */
|
||||
public static final int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */
|
||||
|
||||
|
||||
/*
|
||||
* Server Integration error codes.
|
||||
*
|
||||
* NERR_BASE + (360-369;
|
||||
*/
|
||||
public static final int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */
|
||||
public static final int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */
|
||||
public static final int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */
|
||||
public static final int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */
|
||||
public static final int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */
|
||||
public static final int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */
|
||||
public static final int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */
|
||||
public static final int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */
|
||||
/* UNUSED BASE + 368 */
|
||||
/* UNUSED BASE + 369 */
|
||||
|
||||
public static final int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */
|
||||
|
||||
/*
|
||||
* UPS error codes.
|
||||
*
|
||||
* NERR_BASE + = 380-384;
|
||||
*/
|
||||
public static final int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */
|
||||
public static final int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */
|
||||
public static final int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */
|
||||
public static final int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */
|
||||
public static final int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */
|
||||
|
||||
/*
|
||||
* Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 400-419;
|
||||
* Error codes 400 - 405 are used by RPLBOOT.SYS.
|
||||
* Error codes 403, 407 - 416 are used by RPLLOADR.COM,
|
||||
* Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;.
|
||||
* Error code 418 is for when REMOTEBOOT can't start
|
||||
* Error code 419 is for a disallowed 2nd rpl connection
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/
|
||||
public static final int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/
|
||||
public static final int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/
|
||||
public static final int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/
|
||||
public static final int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/
|
||||
public static final int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/
|
||||
public static final int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/
|
||||
public static final int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/
|
||||
public static final int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/
|
||||
public static final int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/
|
||||
public static final int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/
|
||||
public static final int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/
|
||||
public static final int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/
|
||||
public static final int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/
|
||||
public static final int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/
|
||||
public static final int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/
|
||||
|
||||
/*
|
||||
* FTADMIN API error codes
|
||||
*
|
||||
* NERR_BASE + = 425-434;
|
||||
*
|
||||
* = Currently not used in NT;
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Browser service API error codes
|
||||
*
|
||||
* NERR_BASE + = 450-475;
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */
|
||||
|
||||
/*
|
||||
* Additional Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 510-550;
|
||||
*/
|
||||
public static final int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/
|
||||
public static final int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/
|
||||
public static final int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/
|
||||
public static final int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/
|
||||
public static final int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/
|
||||
public static final int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/
|
||||
public static final int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/
|
||||
public static final int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/
|
||||
public static final int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/
|
||||
public static final int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/
|
||||
public static final int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/
|
||||
public static final int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/
|
||||
public static final int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/
|
||||
public static final int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/
|
||||
public static final int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/
|
||||
public static final int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/
|
||||
public static final int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/
|
||||
public static final int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/
|
||||
public static final int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/
|
||||
public static final int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/
|
||||
public static final int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/
|
||||
public static final int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/
|
||||
public static final int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/
|
||||
public static final int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/
|
||||
public static final int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/
|
||||
public static final int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/
|
||||
public static final int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/
|
||||
public static final int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/
|
||||
public static final int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/
|
||||
public static final int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/
|
||||
|
||||
/**INTERNAL_ONLY**/
|
||||
|
||||
/*
|
||||
* Dfs API error codes.
|
||||
*
|
||||
* NERR_BASE + = 560-590;
|
||||
*/
|
||||
|
||||
public static final int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/
|
||||
public static final int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/
|
||||
public static final int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/
|
||||
public static final int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/
|
||||
public static final int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/
|
||||
public static final int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/
|
||||
public static final int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/
|
||||
public static final int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/
|
||||
public static final int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/
|
||||
public static final int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/
|
||||
public static final int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/
|
||||
public static final int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/
|
||||
public static final int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/
|
||||
public static final int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/
|
||||
public static final int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/
|
||||
public static final int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/
|
||||
public static final int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/
|
||||
public static final int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/
|
||||
public static final int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/
|
||||
public static final int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/
|
||||
public static final int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/
|
||||
public static final int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/
|
||||
public static final int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/
|
||||
|
||||
/*
|
||||
* Net setup error codes.
|
||||
*
|
||||
* NERR_BASE + = 591-600;
|
||||
*/
|
||||
public static final int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/
|
||||
public static final int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/
|
||||
public static final int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/
|
||||
public static final int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/
|
||||
public static final int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/
|
||||
public static final int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/
|
||||
public static final int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/
|
||||
public static final int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/
|
||||
public static final int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/
|
||||
|
||||
/*
|
||||
* Some Password and account error results
|
||||
*
|
||||
* NERR_BASE + = 601 - 608;
|
||||
*/
|
||||
public static final int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */
|
||||
public static final int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */
|
||||
public static final int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */
|
||||
public static final int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */
|
||||
public static final int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2750-2799 has been *
|
||||
*allocated to the IBM LAN Server *
|
||||
***********************************/
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2900-2999 has been *
|
||||
*reserved for Microsoft OEMs *
|
||||
***********************************/
|
||||
|
||||
public static final int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/* 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.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMJoin.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMJoin extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* Status of a workstation.
|
||||
*/
|
||||
public abstract class NETSETUP_JOIN_STATUS {
|
||||
public static final int NetSetupUnknownStatus = 0;
|
||||
public static final int NetSetupUnjoined = 1;
|
||||
public static final int NetSetupWorkgroupName = 2;
|
||||
public static final int NetSetupDomainName = 3;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
/* 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.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
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;
|
||||
|
||||
/**
|
||||
* String representation of the buffer.
|
||||
* @return
|
||||
* Unicode string.
|
||||
*/
|
||||
public String getString() {
|
||||
byte[] data = Buffer.getByteArray(0, Length);
|
||||
if (data.length < 2 || data[data.length - 1] != 0) {
|
||||
Memory newdata = new Memory(data.length + 2);
|
||||
newdata.write(0, data, 0, data.length);
|
||||
return newdata.getString(0, true);
|
||||
}
|
||||
return Buffer.getString(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to an LSA_UNICODE_STRING.
|
||||
*/
|
||||
public static class PLSA_UNICODE_STRING {
|
||||
public static class ByReference extends PLSA_UNICODE_STRING
|
||||
implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING.ByReference s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record contains an included top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelName = 0;
|
||||
/**
|
||||
* Record contains an excluded top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelNameEx = 1;
|
||||
/**
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
*/
|
||||
public static final int ForestTrustDomainInfo = 2;
|
||||
|
||||
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
|
||||
public PSID.ByReference Sid;
|
||||
public LSA_UNICODE_STRING DnsName;
|
||||
public LSA_UNICODE_STRING NetbiosName;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
|
||||
public NativeLong Length;
|
||||
public Pointer Buffer;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_RECORD extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public static class UNION extends Union {
|
||||
public static class ByReference extends UNION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING TopLevelName;
|
||||
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
|
||||
public LSA_FOREST_TRUST_BINARY_DATA Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags that control the behavior of the operation.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
|
||||
/**
|
||||
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
|
||||
* The following table shows the possible values.
|
||||
* ForestTrustTopLevelName
|
||||
* Record contains an included top-level name.
|
||||
* ForestTrustTopLevelNameEx
|
||||
* Record contains an excluded top-level name.
|
||||
* ForestTrustDomainInfo
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
* ForestTrustRecordTypeLast
|
||||
* Marks the end of an enumeration.
|
||||
*/
|
||||
public int ForestTrustType;
|
||||
public LARGE_INTEGER Time;
|
||||
|
||||
/**
|
||||
* Data type depending on ForestTrustType.
|
||||
*/
|
||||
public UNION u;
|
||||
|
||||
public void read() {
|
||||
super.read();
|
||||
|
||||
switch(ForestTrustType) {
|
||||
case NTSecApi.ForestTrustTopLevelName:
|
||||
case NTSecApi.ForestTrustTopLevelNameEx:
|
||||
u.setType(LSA_UNICODE_STRING.class);
|
||||
break;
|
||||
case NTSecApi.ForestTrustDomainInfo:
|
||||
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
|
||||
break;
|
||||
default:
|
||||
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
|
||||
break;
|
||||
}
|
||||
|
||||
u.read();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_RECORD.ByReference tr;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
|
||||
* Entries member.
|
||||
*/
|
||||
public NativeLong RecordCount;
|
||||
/**
|
||||
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
|
||||
* each of which contains one piece of forest trust information.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
|
||||
|
||||
/**
|
||||
* Get an array of LSA_FOREST_TRUST_RECORD entries.
|
||||
* @return
|
||||
* An array of forest trust records.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
|
||||
* forest trust information.
|
||||
*/
|
||||
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
public interface NTStatus extends StdCallLibrary {
|
||||
|
||||
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
|
||||
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_0
|
||||
//
|
||||
public static final int STATUS_WAIT_0 = 0x00000000; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_1
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_1
|
||||
//
|
||||
public static final int STATUS_WAIT_1 = 0x00000001;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_2
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_2
|
||||
//
|
||||
public static final int STATUS_WAIT_2 = 0x00000002;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_3
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_3
|
||||
//
|
||||
public static final int STATUS_WAIT_3 = 0x00000003;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_63
|
||||
//
|
||||
public static final int STATUS_WAIT_63 = 0x0000003F;
|
||||
|
||||
//
|
||||
// The success status codes 128 - 191 are reserved for wait completion
|
||||
// status with an abandoned mutant object.
|
||||
//
|
||||
public static final int STATUS_ABANDONED = 0x00000080;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_63 = 0x000000BF;
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
/* 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.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
|
||||
* Each structure in this array contains trust data about a domain. The caller must free this
|
||||
* memory when it is no longer required by calling NetApiBufferFree.
|
||||
* @param DomainCount
|
||||
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
|
||||
* @return
|
||||
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
|
||||
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
/* Copyright (c) 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.ArrayList;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Netapi32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Netapi32Util {
|
||||
|
||||
/**
|
||||
* A group.
|
||||
*/
|
||||
public static class Group {
|
||||
/**
|
||||
* Group name.
|
||||
*/
|
||||
public String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user.
|
||||
*/
|
||||
public static class User {
|
||||
/**
|
||||
* The name of the user account.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Contains a comment associated with the user account.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
/**
|
||||
* A local group.
|
||||
*/
|
||||
public static class LocalGroup extends Group {
|
||||
/**
|
||||
* Group comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC) on the current computer.
|
||||
* @return The name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName() {
|
||||
return getDCName(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC).
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on which the function is
|
||||
* to execute.
|
||||
* @param domainName
|
||||
* Specifies the name of the domain.
|
||||
* @return
|
||||
* Name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName(String serverName, String domainName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufptr.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus() {
|
||||
return getJoinStatus(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @param computerName Computer name.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufferType.getValue();
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a computer.
|
||||
* @param computerName
|
||||
* @return Domain or workgroup name.
|
||||
*/
|
||||
public static String getDomainName(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// type of domain: bufferType.getValue()
|
||||
return lpNameBuffer.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on the current computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups() {
|
||||
return getLocalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LOCALGROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui1_name.toString();
|
||||
lgp.comment = lgpi.lgrui1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups() {
|
||||
return getGlobalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.grpi1_name.toString();
|
||||
lgp.comment = lgpi.grpi1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a local computer.
|
||||
* @return Users.
|
||||
*/
|
||||
public static User[] getUsers() {
|
||||
return getUsers(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of users.
|
||||
*/
|
||||
public static User[] getUsers(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
|
||||
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<User> result = new ArrayList<User>();
|
||||
for(LMAccess.USER_INFO_1 lu : users) {
|
||||
User auser = new User();
|
||||
auser.name = lu.usri1_name.toString();
|
||||
result.add(auser);
|
||||
}
|
||||
return result.toArray(new User[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of the current user.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserLocalGroups() {
|
||||
return getUserLocalGroups(Secur32Util.getUserNameEx(
|
||||
EXTENDED_NAME_FORMAT.NameSamCompatible));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName) {
|
||||
return getUserLocalGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
|
||||
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
|
||||
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName) {
|
||||
return getUserGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
|
||||
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
|
||||
GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
Group lgp = new Group();
|
||||
lgp.name = lgpi.grui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain controller.
|
||||
*/
|
||||
public static class DomainController {
|
||||
/**
|
||||
* Specifies the computer name of the discovered domain controller.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Specifies the address of the discovered domain controller.
|
||||
*/
|
||||
public String address;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the
|
||||
* DomainControllerAddress member.
|
||||
*/
|
||||
public int addressType;
|
||||
/**
|
||||
* The GUID of the domain.
|
||||
*/
|
||||
public GUID domainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain.
|
||||
*/
|
||||
public String domainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree.
|
||||
*/
|
||||
public String dnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int flags;
|
||||
/**
|
||||
* The name of the site that the computer belongs to.
|
||||
*/
|
||||
public String clientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain controller for a current computer.
|
||||
* @return
|
||||
* Domain controller information.
|
||||
*/
|
||||
public static DomainController getDC() {
|
||||
PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
|
||||
if (W32Errors.ERROR_SUCCESS != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
DomainController dc = new DomainController();
|
||||
dc.address = pdci.dci.DomainControllerAddress.toString();
|
||||
dc.addressType = pdci.dci.DomainControllerAddressType;
|
||||
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
|
||||
dc.dnsForestName = pdci.dci.DnsForestName.toString();
|
||||
dc.domainGuid = pdci.dci.DomainGuid;
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
dc.flags = pdci.dci.Flags;
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain trust relationship.
|
||||
*/
|
||||
public static class DomainTrust {
|
||||
/**
|
||||
* NetBIOS name of the domain.
|
||||
*/
|
||||
public String NetbiosDomainName;
|
||||
/**
|
||||
* DNS name of the domain.
|
||||
*/
|
||||
public String DnsDomainName;
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID DomainSid;
|
||||
/**
|
||||
* Contains the string representation of the security identifier of the domain
|
||||
* represented by this structure.
|
||||
*/
|
||||
public String DomainSidString;
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Contains the string representation of the GUID of the domain represented by
|
||||
* this structure.
|
||||
*/
|
||||
public String DomainGuidString;
|
||||
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
private int flags;
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is a member of the same forest
|
||||
* as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInForest() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is directly trusted by the domain
|
||||
* that the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isOutbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the root of a tree and a member
|
||||
* of the same forest as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isRoot() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the primary domain of the server
|
||||
* specified in the ServerName parameter of the DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isPrimary() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is running in the Windows 2000 native mode.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isNativeMode() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure directly trusts the domain that
|
||||
* the server specified in the ServerName parameter of the DsEnumerateDomainTrusts
|
||||
* function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts() {
|
||||
return getDomainTrusts(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts for a given server.
|
||||
* @param serverName
|
||||
* Server name.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts(String serverName) {
|
||||
NativeLongByReference domainCount = new NativeLongByReference();
|
||||
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
|
||||
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
int domainCountValue = domainCount.getValue().intValue();
|
||||
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
|
||||
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
|
||||
DomainTrust t = new DomainTrust();
|
||||
t.DnsDomainName = trust.DnsDomainName.toString();
|
||||
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
|
||||
t.DomainSid = trust.DomainSid;
|
||||
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
|
||||
t.DomainGuid = trust.DomainGuid;
|
||||
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
|
||||
t.flags = trust.Flags.intValue();
|
||||
trusts.add(t);
|
||||
}
|
||||
return trusts.toArray(new DomainTrust[0]);
|
||||
} finally {
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,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);
|
||||
}
|
||||
@@ -0,0 +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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
|
||||
/**
|
||||
* Definitions from ObjBase.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface ObjBase {
|
||||
|
||||
public static final int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
|
||||
|
||||
// With DCOM, CLSCTX_REMOTE_SERVER should be included
|
||||
public static final int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_INPROC_HANDLER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
|
||||
public static final int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Ole32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Ole32 extends StdCallLibrary {
|
||||
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
|
||||
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
|
||||
* @param pguid
|
||||
* A pointer to the requested GUID.
|
||||
* @return
|
||||
* S_OK if the GUID was successfully created.
|
||||
*/
|
||||
HRESULT CoCreateGuid(GUID.ByReference pguid);
|
||||
|
||||
/**
|
||||
* Converts a globally unique identifier (GUID) into a string of printable characters.
|
||||
* @param rguid
|
||||
* The GUID to be converted.
|
||||
* @param lpsz
|
||||
* A pointer to a caller-allocated string variable to receive the resulting string.
|
||||
* @param cchMax
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of characters in the
|
||||
* returned string, including the null terminator. If the buffer is too small to contain
|
||||
* the string, the return value is 0.
|
||||
*/
|
||||
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* original interface identifier (IID).
|
||||
* @param lpsz
|
||||
* A pointer to the string representation of the IID.
|
||||
* @param lpiid
|
||||
* A pointer to the requested IID on return.
|
||||
* @return
|
||||
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
|
||||
* and S_OK.
|
||||
*/
|
||||
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
|
||||
|
||||
/**
|
||||
* Initializes the COM library for use by the calling thread, sets the thread's
|
||||
* concurrency model, and creates a new apartment for the thread if one is required.
|
||||
* @param reserved This parameter is reserved and must be NULL.
|
||||
* @param dwCoInit The concurrency model and initialization options for the
|
||||
* thread. Values for this parameter are taken from the COINIT enumeration.
|
||||
* Any combination of values from COINIT can be used, except that the
|
||||
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
|
||||
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
|
||||
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
|
||||
*/
|
||||
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
|
||||
|
||||
/**
|
||||
* Closes the COM library on the current thread, unloads all DLLs loaded by
|
||||
* the thread, frees any other resources that the thread maintains, and
|
||||
* forces all RPC connections on the thread to close.
|
||||
*
|
||||
*/
|
||||
void CoUninitialize();
|
||||
|
||||
/**
|
||||
* Creates a single uninitialized object of the class associated with a specified CLSID.
|
||||
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
|
||||
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
|
||||
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
|
||||
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
|
||||
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
|
||||
* @return an HRESULT
|
||||
*/
|
||||
HRESULT CoCreateInstance(
|
||||
GUID rclsid,
|
||||
Pointer pUnkOuter,
|
||||
int dwClsContext,
|
||||
GUID riid,
|
||||
PointerByReference ppv);
|
||||
|
||||
}
|
||||
@@ -0,0 +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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Digital Rapids Corp., All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface Oleaut32 extends StdCallLibrary {
|
||||
|
||||
Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary(
|
||||
"Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function allocates a new string and copies the passed string into it.
|
||||
* @param sz
|
||||
* Null-terminated UNICODE string to copy.
|
||||
* @return
|
||||
* Null if there is insufficient memory or if a null pointer is passed in.
|
||||
*/
|
||||
Pointer SysAllocString(String sz);
|
||||
|
||||
/**
|
||||
* This function frees a string allocated previously by SysAllocString,
|
||||
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
|
||||
* SysReAllocStringLen.
|
||||
* @param bstr
|
||||
* Unicode string that was allocated previously, or NULL. Setting this parameter
|
||||
* to NULL causes the function to simply return.
|
||||
*/
|
||||
void SysFreeString(Pointer bstr);
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
/* 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.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Sspi.CredHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
|
||||
import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
|
||||
import com.sun.jna.platform.win32.Sspi.TimeStamp;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LUID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Secur32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Secur32 extends StdCallLibrary {
|
||||
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
|
||||
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Specifies a format for a directory service object name.
|
||||
* http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx
|
||||
*/
|
||||
public abstract class EXTENDED_NAME_FORMAT {
|
||||
public static final int NameUnknown = 0;
|
||||
public static final int NameFullyQualifiedDN = 1;
|
||||
public static final int NameSamCompatible = 2;
|
||||
public static final int NameDisplay = 3;
|
||||
public static final int NameUniqueId = 6;
|
||||
public static final int NameCanonical = 7;
|
||||
public static final int NameUserPrincipal = 8;
|
||||
public static final int NameCanonicalEx = 9;
|
||||
public static final int NameServicePrincipal = 10;
|
||||
public static final int NameDnsDomain = 12;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated with
|
||||
* the calling thread. You can specify the format of the returned name.
|
||||
* @param nameFormat The format of the name.
|
||||
* @param lpNameBuffer A pointer to a buffer that receives the name in the specified format.
|
||||
* @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character.
|
||||
* @return True if the function succeeds. False otherwise.
|
||||
*/
|
||||
public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len);
|
||||
|
||||
/**
|
||||
* The AcquireCredentialsHandle function acquires a handle to preexisting credentials
|
||||
* of a security principal. This handle is required by the AcceptSecurityContext
|
||||
* and InitializeSecurityContext functions. These can be either preexisting credentials,
|
||||
* which are established through a system logon that is not described here, or the
|
||||
* caller can provide alternative credentials.
|
||||
* @param pszPrincipal
|
||||
* A pointer to a null-terminated string that specifies the name of the principal whose
|
||||
* credentials the handle will reference.
|
||||
* @param pszPackage
|
||||
* A pointer to a null-terminated string that specifies the name of the security package
|
||||
* with which these credentials will be used.
|
||||
* @param fCredentialUse
|
||||
* A flag that indicates how these credentials will be used.
|
||||
* @param pvLogonID
|
||||
* A pointer to a locally unique identifier (LUID) that identifies the user.
|
||||
* @param pAuthData
|
||||
* A pointer to package-specific data. This parameter can be NULL, which indicates
|
||||
* that the default credentials for that package must be used. To use supplied
|
||||
* credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials
|
||||
* in this parameter.
|
||||
* @param pGetKeyFn
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param pvGetKeyArgument
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param phCredential
|
||||
* A pointer to a CredHandle structure to receive the credential handle.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the time at which the returned
|
||||
* credentials expire. The value returned in this TimeStamp structure depends on
|
||||
* the security package. The security package must return this value in local time.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
|
||||
NativeLong fCredentialUse, LUID pvLogonID,
|
||||
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
|
||||
Pointer pvGetKeyArgument, CredHandle phCredential,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The InitializeSecurityContext function initiates the client side, outbound security
|
||||
* context from a credential handle. The function is used to build a security context
|
||||
* between the client application and a remote peer. InitializeSecurityContext returns
|
||||
* a token that the client must pass to the remote peer, which the peer in turn submits
|
||||
* to the local security implementation through the AcceptSecurityContext call. The
|
||||
* token generated should be considered opaque by all callers.
|
||||
*
|
||||
* Typically, the InitializeSecurityContext function is called in a loop until a
|
||||
* sufficient security context is established.
|
||||
*
|
||||
* @param phCredential
|
||||
* A handle to the credentials returned by AcquireCredentialsHandle. This handle is
|
||||
* used to build the security context. The InitializeSecurityContext function requires
|
||||
* at least OUTBOUND credentials.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer is NULL. On the second call, this parameter is a pointer to the handle
|
||||
* to the partially formed context returned in the phNewContext parameter by the first
|
||||
* call.
|
||||
* @param pszTargetName
|
||||
* A pointer to a null-terminated string that indicates the target of the context.
|
||||
* The string contents are security-package specific.
|
||||
* @param fContextReq
|
||||
* Bit flags that indicate requests for the context. Not all packages can support all
|
||||
* requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example,
|
||||
* ISC_REQ_DELEGATE.
|
||||
* @param Reserved1
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can be
|
||||
* either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied
|
||||
* as input to the package. The pointer must be NULL on the first call to the function.
|
||||
* On subsequent calls to the function, it is a pointer to a buffer allocated with enough
|
||||
* memory to hold the token returned by the remote peer.
|
||||
* @param Reserved2
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer receives the new context handle. On the second call, phNewContext can be
|
||||
* the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure
|
||||
* that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it
|
||||
* will be there on output. The system will allocate a buffer for the security token if
|
||||
* requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer
|
||||
* descriptor for the security token.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable to receive a set of bit flags that indicate the attributes of
|
||||
* the established context. Flags used for this parameter are prefixed with ISC_RET,
|
||||
* such as ISC_RET_DELEGATE.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* It is recommended that the security package always return this value in local time.
|
||||
* This parameter is optional and NULL should be passed for short-lived clients.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
|
||||
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The DeleteSecurityContext function deletes the local data structures associated
|
||||
* with the specified security context.
|
||||
* @param phContext
|
||||
* Handle of the security context to delete.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int DeleteSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* The FreeCredentialsHandle function notifies the security system that the
|
||||
* credentials are no longer needed. An application calls this function to free
|
||||
* the credential handle acquired in the call to the AcquireCredentialsHandle
|
||||
* function. When all references to this credential set have been removed, the
|
||||
* credentials themselves can be removed.
|
||||
* @param phCredential
|
||||
* A pointer to the credential handle obtained by using the AcquireCredentialsHandle
|
||||
* function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int FreeCredentialsHandle(CredHandle phCredential);
|
||||
|
||||
/**
|
||||
* The AcceptSecurityContext function enables the server component of a transport
|
||||
* application to establish a security context between the server and a remote client.
|
||||
* The remote client uses the InitializeSecurityContext function to start the process
|
||||
* of establishing a security context. The server can require one or more reply tokens
|
||||
* from the remote client to complete establishing the security context.
|
||||
* @param phCredential
|
||||
* A handle to the credentials of the server. The server calls the AcquireCredentialsHandle
|
||||
* function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve
|
||||
* this handle.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer is NULL. On subsequent calls, phContext is the handle to the partially
|
||||
* formed context that was returned in the phNewContext parameter by the first call.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure generated by a client call to
|
||||
* InitializeSecurityContext that contains the input buffer descriptor.
|
||||
* @param fContextReq
|
||||
* Bit flags that specify the attributes required by the server to establish the
|
||||
* context. Bit flags can be combined by using bitwise-OR operations.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can
|
||||
* be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer receives the new context handle. On subsequent calls, phNewContext
|
||||
* can be the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains the output buffer descriptor.
|
||||
* This buffer is sent to the client for input into additional calls to
|
||||
* InitializeSecurityContext. An output buffer may be generated even if the function
|
||||
* returns SEC_E_OK. Any buffer generated must be sent back to the client application.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable that receives a set of bit flags that indicate the
|
||||
* attributes of the established context. For a description of the various attributes,
|
||||
* see Context Requirements. Flags used for this parameter are prefixed with ASC_RET,
|
||||
* for example, ASC_RET_DELEGATE.
|
||||
* @param ptsTimeStamp
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* @return
|
||||
* This function returns one of SEC_* values.
|
||||
*/
|
||||
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsTimeStamp);
|
||||
|
||||
/**
|
||||
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
|
||||
* describe the security packages available to the client.
|
||||
* @param pcPackages
|
||||
* A pointer to a ULONG variable that receives the number of packages returned.
|
||||
* @param ppPackageInfo
|
||||
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
|
||||
* Each structure contains information from the security support provider (SSP) that
|
||||
* describes a security package that is available within that SSP.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int EnumerateSecurityPackages(IntByReference pcPackages,
|
||||
PSecPkgInfo.ByReference ppPackageInfo);
|
||||
|
||||
/**
|
||||
* The FreeContextBuffer function enables callers of security package functions to free a memory
|
||||
* buffer that was allocated by the security package as a result of calls to InitializeSecurityContext
|
||||
* and AcceptSecurityContext.
|
||||
* @param buffer
|
||||
* A pointer to memory allocated by the security package.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int FreeContextBuffer(Pointer buffer);
|
||||
|
||||
/**
|
||||
* The QuerySecurityContextToken function obtains the access token for a client security context
|
||||
* and uses it directly.
|
||||
* @param phContext
|
||||
* Handle of the context to query.
|
||||
* @param phToken
|
||||
* Returned handle to the access token.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code. One possible error code return is
|
||||
* SEC_E_INVALID_HANDLE.
|
||||
*/
|
||||
public int QuerySecurityContextToken(CtxtHandle phContext,
|
||||
HANDLEByReference phToken);
|
||||
|
||||
/**
|
||||
* The ImpersonateSecurityContext function allows a server to impersonate a client by using
|
||||
* a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken.
|
||||
* This function allows the application server to act as the client, and thus all necessary
|
||||
* access controls are enforced.
|
||||
* @param phContext
|
||||
* The handle of the context to impersonate. This handle must have been obtained by a call
|
||||
* to the AcceptSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or
|
||||
* SEC_E_UNSUPPORTED_FUNCTION error code.
|
||||
*/
|
||||
public int ImpersonateSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* Allows a security package to discontinue the impersonation of the caller and restore its
|
||||
* own security context.
|
||||
* @param phContext
|
||||
* Handle of the security context being impersonated. This handle must have been obtained in
|
||||
* the call to the AcceptSecurityContext function and used in the call to the
|
||||
* ImpersonateSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION.
|
||||
*/
|
||||
public int RevertSecurityContext(CtxtHandle phContext);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* 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.ArrayList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
|
||||
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Secur32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Secur32Util {
|
||||
|
||||
/**
|
||||
* An SSPI package.
|
||||
*/
|
||||
public static class SecurityPackage {
|
||||
/**
|
||||
* Package name.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Package comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated
|
||||
* with the calling thread.
|
||||
*
|
||||
* @param format User name format.
|
||||
* @return User name in a given format.
|
||||
*/
|
||||
public static String getUserNameEx(int format) {
|
||||
char[] buffer = new char[128];
|
||||
IntByReference len = new IntByReference(buffer.length);
|
||||
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
|
||||
if (! result) {
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_MORE_DATA:
|
||||
buffer = new char[len.getValue() + 1];
|
||||
break;
|
||||
default:
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
}
|
||||
|
||||
if (! result) {
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the security packages installed on the current computer.
|
||||
* @return
|
||||
* An array of SSPI security packages.
|
||||
*/
|
||||
public static SecurityPackage[] getSecurityPackages() {
|
||||
IntByReference pcPackages = new IntByReference();
|
||||
PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference();
|
||||
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
|
||||
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
|
||||
for(SecPkgInfo packageInfo : packagesInfo) {
|
||||
SecurityPackage securityPackage = new SecurityPackage();
|
||||
securityPackage.name = packageInfo.Name.toString();
|
||||
securityPackage.comment = packageInfo.Comment.toString();
|
||||
packages.add(securityPackage);
|
||||
}
|
||||
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer());
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return packages.toArray(new SecurityPackage[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Shell32.dll Interface.
|
||||
*/
|
||||
public interface Shell32 extends StdCallLibrary {
|
||||
|
||||
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function can be used to copy, move, rename, or delete a file system object.
|
||||
* @param fileop
|
||||
* Address of an SHFILEOPSTRUCT structure that contains information this function
|
||||
* needs to carry out the specified operation.
|
||||
* @return
|
||||
* Returns zero if successful, or nonzero otherwise.
|
||||
*/
|
||||
int SHFileOperation(SHFILEOPSTRUCT fileop);
|
||||
|
||||
/**
|
||||
* Takes the CSIDL of a folder and returns the path.
|
||||
* @param hwndOwner
|
||||
* Handle to an owner window. This parameter is typically set to NULL. If it is not NULL,
|
||||
* and a dial-up connection needs to be made to access the folder, a user interface (UI)
|
||||
* prompt will appear in this window.
|
||||
* @param nFolder
|
||||
* A CSIDL value that identifies the folder whose path is to be retrieved. Only real
|
||||
* folders are valid. If a virtual folder is specified, this function will fail. You can
|
||||
* force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with
|
||||
* CSIDL_FLAG_CREATE.
|
||||
* @param hToken
|
||||
* An access token that can be used to represent a particular user.
|
||||
* @param dwFlags
|
||||
* Flags to specify which path is to be returned.
|
||||
* @param pszPath
|
||||
* Pointer to a null-terminated string of length MAX_PATH which will receive the path.
|
||||
* If an error occurs or S_FALSE is returned, this string will be empty.
|
||||
* @return
|
||||
* Returns standard HRESULT codes.
|
||||
*/
|
||||
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
|
||||
char[] pszPath);
|
||||
|
||||
/**
|
||||
* Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
|
||||
* The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call
|
||||
* given a suitable interface definition for IShellFolder
|
||||
* @param ppshf A place to put the IShellFolder interface pointer
|
||||
* @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
|
||||
*/
|
||||
HRESULT SHGetDesktopFolder( PointerByReference ppshf );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/* 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.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 = Structure.ALIGN_NONE;
|
||||
|
||||
public static final int FO_MOVE = 0x0001;
|
||||
public static final int FO_COPY = 0x0002;
|
||||
public static final int FO_DELETE = 0x0003;
|
||||
public static final int FO_RENAME = 0x0004;
|
||||
|
||||
public static final int FOF_MULTIDESTFILES = 0x0001;
|
||||
public static final int FOF_CONFIRMMOUSE = 0x0002;
|
||||
public static final int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
|
||||
public static final int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
|
||||
public static final int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
|
||||
public static final int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
|
||||
public static final int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
|
||||
public static final int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
|
||||
public static final int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
|
||||
public static final int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
|
||||
public static final int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
|
||||
public static final int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
|
||||
public static final int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
|
||||
public static final int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
|
||||
public static final int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
|
||||
public static final int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
|
||||
public static final int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
|
||||
|
||||
public static final int PO_DELETE = 0x0013; // printer is being deleted
|
||||
public static final int PO_RENAME = 0x0014; // printer is being renamed
|
||||
public static final int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
|
||||
public static final int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
|
||||
|
||||
/**
|
||||
* Contains information that the SHFileOperation function uses to perform file operations.
|
||||
*/
|
||||
public static class SHFILEOPSTRUCT extends Structure {
|
||||
/**
|
||||
* A window handle to the dialog box to display information about
|
||||
* the status of the file operation.
|
||||
*/
|
||||
public HANDLE hwnd;
|
||||
/**
|
||||
* An FO_* value that indicates which operation to perform.
|
||||
*/
|
||||
public int wFunc;
|
||||
/**
|
||||
* A pointer to one or more source file names, double null-terminated.
|
||||
*/
|
||||
public WString pFrom;
|
||||
/**
|
||||
* A pointer to the destination file or directory name.
|
||||
*/
|
||||
public WString pTo;
|
||||
/**
|
||||
* Flags that control the file operation.
|
||||
*/
|
||||
public short fFlags;
|
||||
/**
|
||||
* When the function returns, this member contains TRUE if any file operations
|
||||
* were aborted before they were completed; otherwise, FALSE. An operation can
|
||||
* be manually aborted by the user through UI or it can be silently aborted by
|
||||
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
|
||||
*/
|
||||
public boolean fAnyOperationsAborted;
|
||||
/**
|
||||
* When the function returns, this member contains a handle to a name mapping
|
||||
* object that contains the old and new names of the renamed files. This member
|
||||
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
|
||||
*/
|
||||
public Pointer pNameMappings;
|
||||
/**
|
||||
* A pointer to the title of a progress dialog box. This is a null-terminated string.
|
||||
*/
|
||||
public WString lpszProgressTitle;
|
||||
|
||||
/** Use this to encode <code>pFrom/pTo</code> paths. */
|
||||
public String encodePaths(String[] paths) {
|
||||
String encoded = "";
|
||||
for (int i=0; i < paths.length;i++) {
|
||||
encoded += paths[i];
|
||||
encoded += "\0";
|
||||
}
|
||||
return encoded + "\0";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/* 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;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from ShlObj.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface ShlObj extends StdCallLibrary {
|
||||
|
||||
public static final DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
|
||||
public static final DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
|
||||
|
||||
public static final int CSIDL_DESKTOP = 0x0000; // <desktop>
|
||||
public static final int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
|
||||
public static final int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
|
||||
public static final int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
|
||||
public static final int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
|
||||
public static final int CSIDL_PERSONAL = 0x0005; // My Documents
|
||||
public static final int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
|
||||
public static final int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
|
||||
public static final int CSIDL_RECENT = 0x0008; // <user name>\Recent
|
||||
public static final int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
|
||||
public static final int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
|
||||
public static final int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
|
||||
public static final int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
|
||||
public static final int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
|
||||
public static final int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
|
||||
public static final int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
|
||||
public static final int CSIDL_DRIVES = 0x0011; // My Computer
|
||||
public static final int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
|
||||
public static final int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
|
||||
public static final int CSIDL_FONTS = 0x0014; // windows\fonts
|
||||
public static final int CSIDL_TEMPLATES = 0x0015;
|
||||
public static final int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
|
||||
public static final int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
|
||||
public static final int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
|
||||
public static final int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
|
||||
public static final int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
|
||||
public static final int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
|
||||
public static final int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
|
||||
public static final int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
|
||||
public static final int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
|
||||
public static final int CSIDL_COMMON_FAVORITES = 0x001f;
|
||||
public static final int CSIDL_INTERNET_CACHE = 0x0020;
|
||||
public static final int CSIDL_COOKIES = 0x0021;
|
||||
public static final int CSIDL_HISTORY = 0x0022;
|
||||
public static final int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
|
||||
public static final int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
|
||||
public static final int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
|
||||
public static final int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
|
||||
public static final int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
|
||||
public static final int CSIDL_PROFILE = 0x0028; // USERPROFILE
|
||||
public static final int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
|
||||
public static final int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
|
||||
public static final int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
|
||||
public static final int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
|
||||
public static final int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
|
||||
public static final int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
|
||||
public static final int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
|
||||
public static final int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
|
||||
public static final int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
|
||||
public static final int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
|
||||
public static final int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
|
||||
public static final int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
|
||||
public static final int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
|
||||
public static final int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
|
||||
public static final int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
|
||||
public static final int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
|
||||
public static final int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
/* 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.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Sspi.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Sspi extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of a security token.
|
||||
*/
|
||||
public static final int MAX_TOKEN_SIZE = 12288;
|
||||
|
||||
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
|
||||
|
||||
/**
|
||||
* Validate an incoming server credential. Inbound credentials might be validated
|
||||
* by using an authenticating authority when InitializeSecurityContext or
|
||||
* AcceptSecurityContext is called. If such an authority is not available, the function will
|
||||
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
|
||||
*/
|
||||
public static final int SECPKG_CRED_INBOUND = 1;
|
||||
|
||||
/**
|
||||
* Allow a local client credential to prepare an outgoing token.
|
||||
*/
|
||||
public static final int SECPKG_CRED_OUTBOUND = 2;
|
||||
|
||||
|
||||
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
|
||||
|
||||
/**
|
||||
* Specifies Native data representation.
|
||||
*/
|
||||
public static final int SECURITY_NATIVE_DREP = 0x10;
|
||||
|
||||
|
||||
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
|
||||
|
||||
/**
|
||||
* The security package allocates output buffers for you.
|
||||
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
|
||||
*/
|
||||
public static final int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
|
||||
|
||||
/**
|
||||
* Encrypt messages by using the EncryptMessage function.
|
||||
*/
|
||||
public static final int ISC_REQ_CONFIDENTIALITY = 0x00000010;
|
||||
|
||||
/**
|
||||
* The security context will not handle formatting messages. This value is the default.
|
||||
*/
|
||||
public static final int ISC_REQ_CONNECTION = 0x00000800;
|
||||
|
||||
/**
|
||||
* The server can use the context to authenticate to other servers as the client.
|
||||
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
|
||||
* Ignore this flag for constrained delegation.
|
||||
*/
|
||||
public static final int ISC_REQ_DELEGATE = 0x00000001;
|
||||
|
||||
/**
|
||||
* When errors occur, the remote party will be notified.
|
||||
*/
|
||||
public static final int ISC_REQ_EXTENDED_ERROR = 0x00004000;
|
||||
|
||||
/**
|
||||
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
|
||||
*/
|
||||
public static final int ISC_REQ_INTEGRITY = 0x00010000;
|
||||
|
||||
/**
|
||||
* The mutual authentication policy of the service will be satisfied.
|
||||
*/
|
||||
public static final int ISC_REQ_MUTUAL_AUTH = 0x00000002;
|
||||
|
||||
/**
|
||||
* Detect replayed messages that have been encoded by using the
|
||||
* EncryptMessage or MakeSignature functions.
|
||||
*/
|
||||
public static final int ISC_REQ_REPLAY_DETECT = 0x00000004;
|
||||
|
||||
/**
|
||||
* Detect messages received out of sequence.
|
||||
*/
|
||||
public static final int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
|
||||
|
||||
/**
|
||||
* Support a stream-oriented connection.
|
||||
*/
|
||||
public static final int ISC_REQ_STREAM = 0x00008000;
|
||||
|
||||
/**
|
||||
* Version of the SecBuffer struct.
|
||||
*/
|
||||
public static final int SECBUFFER_VERSION = 0;
|
||||
|
||||
/**
|
||||
* This is a placeholder in the buffer array.
|
||||
*/
|
||||
public static final int SECBUFFER_EMPTY = 0;
|
||||
/**
|
||||
* This buffer type is used for common data. The security package can read
|
||||
* and write this data.
|
||||
*/
|
||||
public static final int SECBUFFER_DATA = 1;
|
||||
/**
|
||||
* This buffer type is used to indicate the security token portion of the message.
|
||||
* This is read-only for input parameters or read/write for output parameters.
|
||||
*/
|
||||
public static final int SECBUFFER_TOKEN = 2;
|
||||
|
||||
/**
|
||||
* Security handle.
|
||||
*/
|
||||
public static class SecHandle extends Structure {
|
||||
public Pointer dwLower;
|
||||
public Pointer dwUpper;
|
||||
|
||||
public static class ByReference extends SecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty SecHandle.
|
||||
*/
|
||||
public SecHandle() {
|
||||
dwLower = null;
|
||||
dwUpper = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the handle is NULL.
|
||||
* @return
|
||||
* True if NULL, False otherwise.
|
||||
*/
|
||||
public boolean isNull() {
|
||||
return dwLower == null && dwUpper == null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointer to a SecHandle
|
||||
*/
|
||||
public static class PSecHandle extends Structure {
|
||||
|
||||
public static class ByReference extends PSecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first entry in an array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecHandle.ByReference secHandle;
|
||||
|
||||
public PSecHandle() {
|
||||
|
||||
}
|
||||
|
||||
public PSecHandle(SecHandle h) {
|
||||
useMemory(h.getPointer());
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Credentials handle.
|
||||
*/
|
||||
public static class CredHandle extends SecHandle {
|
||||
}
|
||||
|
||||
/**
|
||||
* Security context handle.
|
||||
*/
|
||||
public static class CtxtHandle extends SecHandle {
|
||||
}
|
||||
|
||||
/**
|
||||
* The SecBuffer structure describes a buffer allocated by a transport application
|
||||
* to pass to a security package.
|
||||
*/
|
||||
public static class SecBuffer extends Structure {
|
||||
|
||||
/**
|
||||
* A ByReference SecBuffer.
|
||||
*/
|
||||
public static class ByReference extends SecBuffer implements Structure.ByReference {
|
||||
/**
|
||||
* Create a SECBUFFER_EMPTY SecBuffer.
|
||||
*/
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param size
|
||||
* Buffer size, eg. MAX_TOKEN_SIZE.
|
||||
*/
|
||||
public ByReference(int type, int size) {
|
||||
super(type, size);
|
||||
}
|
||||
|
||||
public ByReference(int type, byte[] token) {
|
||||
super(type, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buffer bytes.
|
||||
* @return
|
||||
* Raw buffer bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return super.getBytes();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
|
||||
*/
|
||||
public NativeLong cbBuffer;
|
||||
/**
|
||||
* Bit flags that indicate the type of buffer. Must be one of the values of
|
||||
* the SecBufferType enumeration.
|
||||
*/
|
||||
public NativeLong BufferType;
|
||||
/**
|
||||
* A pointer to a buffer.
|
||||
*/
|
||||
public Pointer pvBuffer;
|
||||
|
||||
/**
|
||||
* Create a new SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBuffer() {
|
||||
cbBuffer = new NativeLong(0);
|
||||
pvBuffer = null;
|
||||
BufferType = new NativeLong(SECBUFFER_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param size
|
||||
* Buffer size, eg. MAX_TOKEN_SIZE.
|
||||
*/
|
||||
public SecBuffer(int type, int size) {
|
||||
cbBuffer = new NativeLong(size);
|
||||
pvBuffer = new Memory(size);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type with initial data.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param token
|
||||
* Existing token.
|
||||
*/
|
||||
public SecBuffer(int type, byte[] token) {
|
||||
cbBuffer = new NativeLong(token.length);
|
||||
pvBuffer = new Memory(token.length);
|
||||
pvBuffer.write(0, token, 0, token.length);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buffer bytes.
|
||||
* @return
|
||||
* Raw buffer bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return pvBuffer.getByteArray(0, cbBuffer.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static class SecBufferDesc extends Structure {
|
||||
|
||||
/**
|
||||
* Version number.
|
||||
*/
|
||||
public NativeLong ulVersion;
|
||||
/**
|
||||
* Number of buffers.
|
||||
*/
|
||||
public NativeLong cBuffers;
|
||||
/**
|
||||
* Pointer to array of buffers.
|
||||
*/
|
||||
public SecBuffer.ByReference[] pBuffers;
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBufferDesc() {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with initial data.
|
||||
* @param type
|
||||
* Token type.
|
||||
* @param token
|
||||
* Initial token data.
|
||||
*/
|
||||
public SecBufferDesc(int type, byte[] token) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* @param tokenSize
|
||||
*/
|
||||
public SecBufferDesc(int type, int tokenSize) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
if (pBuffers == null || cBuffers == null) {
|
||||
throw new RuntimeException("pBuffers | cBuffers");
|
||||
}
|
||||
if (cBuffers.intValue() == 1) {
|
||||
return pBuffers[0].getBytes();
|
||||
}
|
||||
throw new RuntimeException("cBuffers > 1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A security integer.
|
||||
*/
|
||||
public static class SECURITY_INTEGER extends Structure {
|
||||
public NativeLong dwLower;
|
||||
public NativeLong dwUpper;
|
||||
|
||||
/**
|
||||
* An security integer of 0.
|
||||
*/
|
||||
public SECURITY_INTEGER() {
|
||||
dwLower = new NativeLong(0);
|
||||
dwUpper = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A timestamp.
|
||||
*/
|
||||
public static class TimeStamp extends SECURITY_INTEGER {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointer to an array of SecPkgInfo structures.
|
||||
*/
|
||||
public static class PSecPkgInfo extends Structure {
|
||||
|
||||
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first entry in an array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecPkgInfo.ByReference pPkgInfo;
|
||||
|
||||
public PSecPkgInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecPkgInfo.ByReference[] toArray(int size) {
|
||||
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The SecPkgInfo structure provides general information about a security package,
|
||||
* such as its name and capabilities.
|
||||
*/
|
||||
public static class SecPkgInfo extends Structure {
|
||||
|
||||
/**
|
||||
* A reference pointer to a SecPkgInfo structure.
|
||||
*/
|
||||
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of bit flags that describes the capabilities of the security package.
|
||||
*/
|
||||
public NativeLong fCapabilities;
|
||||
/**
|
||||
* Specifies the version of the package protocol. Must be 1.
|
||||
*/
|
||||
public short wVersion;
|
||||
/**
|
||||
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
|
||||
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
|
||||
*/
|
||||
public short wRPCID;
|
||||
/**
|
||||
* Specifies the maximum size, in bytes, of the token.
|
||||
*/
|
||||
public NativeLong cbMaxToken;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the name of the security package.
|
||||
*/
|
||||
public WString Name;
|
||||
/**
|
||||
* Pointer to a null-terminated string. This can be any additional string passed
|
||||
* back by the package.
|
||||
*/
|
||||
public WString Comment;
|
||||
|
||||
/**
|
||||
* Create a new package info.
|
||||
*/
|
||||
public SecPkgInfo() {
|
||||
fCapabilities = new NativeLong(0);
|
||||
wVersion = 1;
|
||||
wRPCID = 0;
|
||||
cbMaxToken = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,735 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.BaseTSD.LONG_PTR;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HICON;
|
||||
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
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.RECT;
|
||||
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.FLASHWINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.GUITHREADINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.HHOOK;
|
||||
import com.sun.jna.platform.win32.WinUser.HOOKPROC;
|
||||
import com.sun.jna.platform.win32.WinUser.MSG;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.platform.win32.WinUser.WINDOWINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Provides access to the w32 user32 library. Incomplete implementation to
|
||||
* support demos.
|
||||
*
|
||||
* @author Todd Fast, todd.fast@sun.com
|
||||
* @author twalljava@dev.java.net
|
||||
*/
|
||||
public interface User32 extends StdCallLibrary {
|
||||
|
||||
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function retrieves a handle to a display device context (DC) for the
|
||||
* client area of the specified window. The display device context can be
|
||||
* used in subsequent graphics display interface (GDI) functions to draw in
|
||||
* the client area of the window.
|
||||
* @param hWnd
|
||||
* Handle to the window whose device context is to be retrieved.
|
||||
* If this value is NULL, GetDC retrieves the device context for
|
||||
* the entire screen.
|
||||
* @return
|
||||
* The handle the device context for the specified window's client
|
||||
* area indicates success. NULL indicates failure. To get extended
|
||||
* error information, call GetLastError.
|
||||
*/
|
||||
HDC GetDC(HWND hWnd);
|
||||
|
||||
/**
|
||||
* This function releases a device context (DC), freeing it for use by other
|
||||
* applications. The effect of ReleaseDC depends on the type of device
|
||||
* context.
|
||||
*
|
||||
* @param hWnd
|
||||
* Handle to the window whose device context is to be released.
|
||||
* @param hDC
|
||||
* Handle to the device context to be released.
|
||||
* @return
|
||||
* The return value specifies whether the device context is
|
||||
* released. 1 indicates that the device context is released. Zero
|
||||
* indicates that the device context is not released.
|
||||
*/
|
||||
int ReleaseDC(HWND hWnd, HDC hDC);
|
||||
|
||||
/**
|
||||
* This function retrieves the handle to the top-level window whose class name and
|
||||
* window name match the specified strings. This function does not search child windows.
|
||||
* @param lpClassName
|
||||
* Long pointer to a null-terminated string that specifies the class name or is an atom
|
||||
* that identifies the class-name string. If this parameter is an atom, it must be a
|
||||
* global atom created by a previous call to the GlobalAddAtom function. The atom, a
|
||||
* 16-bit value, must be placed in the low-order word of lpClassName; the high-order
|
||||
* word must be zero.
|
||||
* @param lpWindowName
|
||||
* Long pointer to a null-terminated string that specifies the window name (the window's
|
||||
* title). If this parameter is NULL, all window names match.
|
||||
* @return
|
||||
* A handle to the window that has the specified class name and window name indicates
|
||||
* success. NULL indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HWND FindWindow(String lpClassName, String lpWindowName);
|
||||
|
||||
/**
|
||||
* This function retrieves the name of the class to which the specified window belongs.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param lpClassName
|
||||
* Long pointer to the buffer that is to receive the class name string.
|
||||
* @param nMaxCount
|
||||
* Specifies the length, in characters, of the buffer pointed to by the lpClassName
|
||||
* parameter. The class name string is truncated if it is longer than the buffer.
|
||||
* @return
|
||||
* The number of characters copied to the specified buffer indicates success. Zero
|
||||
* indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount);
|
||||
|
||||
/**
|
||||
* Retrieves information about the active window or a specified graphical user
|
||||
* interface (GUI) thread.
|
||||
* @param idThread
|
||||
* Identifies the thread for which information is to be retrieved. To retrieve
|
||||
* this value, use the GetWindowThreadProcessId function. If this parameter is NULL,
|
||||
* the function returns information for the foreground thread.
|
||||
* @param lpgui
|
||||
* Pointer to a GUITHREADINFO structure that receives information describing the thread.
|
||||
* Note that you must set GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling this function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
|
||||
|
||||
/**
|
||||
* The GetWindowInfo function retrieves information about the specified window.
|
||||
* @param hWnd
|
||||
* Handle to the window whose information is to be retrieved.
|
||||
* @param pwi
|
||||
* Pointer to a WINDOWINFO structure to receive the information. Note that you must set WINDOWINFO.cbSize
|
||||
* to sizeof(WINDOWINFO) before calling this function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
*/
|
||||
boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi);
|
||||
|
||||
/**
|
||||
* This function retrieves the dimensions of the bounding rectangle of the specified window. The
|
||||
* dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
|
||||
* @param hWnd
|
||||
* Handle to the window.
|
||||
* @param rect
|
||||
* Long pointer to a RECT structure that receives the screen coordinates of the upper-left and lower-right
|
||||
* corners of the window.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetWindowRect(HWND hWnd, RECT rect);
|
||||
|
||||
/**
|
||||
* This function copies the text of the specified window's title bar - if it has one - into a buffer. If
|
||||
* the specified window is a control, the text of the control is copied.
|
||||
* @param hWnd
|
||||
* Handle to the window or control containing the text.
|
||||
* @param lpString
|
||||
* Long pointer to the buffer that will receive the text.
|
||||
* @param nMaxCount
|
||||
* Specifies the maximum number of characters to copy to the buffer, including the NULL character.
|
||||
* If the text exceeds this limit, it is truncated.
|
||||
* @return
|
||||
* The length, in characters, of the copied string, not including the terminating null character,
|
||||
* indicates success. Zero indicates that the window has no title bar or text, if the title bar is
|
||||
* empty, or if the window or control handle is invalid. To get extended error information, call
|
||||
* GetLastError. This function cannot retrieve the text of an edit control in another application.
|
||||
*/
|
||||
int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount);
|
||||
|
||||
/**
|
||||
* This function retrieves the length, in characters, of the specified window's title bar text -
|
||||
* if the window has a title bar. If the specified window is a control, the function retrieves the
|
||||
* length of the text within the control.
|
||||
* @param hWnd
|
||||
* Handle to the window or control.
|
||||
* @return
|
||||
* The length, in characters, of the text indicates success. Under certain conditions, this value
|
||||
* may actually be greater than the length of the text. Zero indicates that the window has no text.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetWindowTextLength(HWND hWnd);
|
||||
|
||||
/**
|
||||
* The GetWindowModuleFileName function retrieves the full path and file name of the module associated
|
||||
* with the specified window handle.
|
||||
* @param hWnd
|
||||
* Handle to the window whose module file name will be retrieved.
|
||||
* @param lpszFileName
|
||||
* Pointer to a buffer that receives the path and file name.
|
||||
* @param cchFileNameMax
|
||||
* Specifies the maximum number of TCHARs that can be copied into the lpszFileName buffer.
|
||||
* @return
|
||||
* The return value is the total number of TCHARs copied into the buffer.
|
||||
*/
|
||||
int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName,
|
||||
int cchFileNameMax);
|
||||
|
||||
/**
|
||||
* This function retrieves the identifier of the thread that created the specified window and, optionally,
|
||||
* the identifier of the process that created the window.
|
||||
* @param hWnd
|
||||
* Handle to the window.
|
||||
* @param lpdwProcessId
|
||||
* Pointer to a 32-bit value that receives the process identifier. If this parameter is not NULL,
|
||||
* GetWindowThreadProcessId copies the identifier of the process to the 32-bit value; otherwise,
|
||||
* it does not.
|
||||
* @return
|
||||
* The return value is the identifier of the thread that created the window.
|
||||
*/
|
||||
int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId);
|
||||
|
||||
/**
|
||||
* This function enumerates all top-level windows on the screen by passing the handle to each window,
|
||||
* in turn, to an application-defined callback function. EnumWindows continues until the last top-level
|
||||
* window is enumerated or the callback function returns FALSE.
|
||||
* @param lpEnumFunc
|
||||
* Long pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
|
||||
|
||||
/**
|
||||
* The EnumChildWindows function enumerates the child windows that belong to the specified parent window
|
||||
* by passing the handle to each child window, in turn, to an application-defined callback function.
|
||||
* EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.
|
||||
* @param hWnd
|
||||
* Handle to the parent window whose child windows are to be enumerated. If this parameter is NULL, this
|
||||
* function is equivalent to EnumWindows.
|
||||
* @param lpEnumFunc
|
||||
* Pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If EnumChildProc returns zero, the return value is also zero. In this case, the callback function
|
||||
* should call SetLastError to obtain a meaningful error code to be returned to the caller of
|
||||
* EnumChildWindows.
|
||||
*/
|
||||
boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);
|
||||
|
||||
/**
|
||||
* The EnumThreadWindows function enumerates all nonchild windows associated with a thread by passing
|
||||
* the handle to each window, in turn, to an application-defined callback function. EnumThreadWindows
|
||||
* continues until the last window is enumerated or the callback function returns FALSE. To enumerate
|
||||
* child windows of a particular window, use the EnumChildWindows function.
|
||||
* @param dwThreadId
|
||||
* Identifies the thread whose windows are to be enumerated.
|
||||
* @param lpEnumFunc
|
||||
* Pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* If the callback function returns TRUE for all windows in the thread specified by dwThreadId, the
|
||||
* return value is TRUE. If the callback function returns FALSE on any enumerated window, or if there
|
||||
* are no windows found in the thread specified by dwThreadId, the return value is FALSE.
|
||||
*/
|
||||
boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc,
|
||||
Pointer data);
|
||||
|
||||
/**
|
||||
* The FlashWindowEx function flashes the specified window. It does not change the active state of the window.
|
||||
* @param pfwi
|
||||
* Pointer to the FLASHWINFO structure.
|
||||
* @return
|
||||
* The return value specifies the window's state before the call to the FlashWindowEx function. If the window
|
||||
* caption was drawn as active before the call, the return value is nonzero. Otherwise, the return value is zero.
|
||||
*/
|
||||
boolean FlashWindowEx(FLASHWINFO pfwi);
|
||||
|
||||
/**
|
||||
* This function loads the specified icon resource from the executable (.exe) file associated with an
|
||||
* application instance.
|
||||
* @param hInstance
|
||||
* Handle to an instance of the module whose executable file contains the icon to be loaded.
|
||||
* This parameter must be NULL when a standard icon is being loaded.
|
||||
* @param iconName
|
||||
* Long pointer to a null-terminated string that contains the name of the icon resource to be loaded.
|
||||
* Alternatively, this parameter can contain the resource identifier in the low-order word and zero
|
||||
* in the high-order word. Use the MAKEINTRESOURCE macro to create this value.
|
||||
* @return
|
||||
* A handle to the newly loaded icon indicates success. NULL indicates failure. To get extended
|
||||
* error information, call GetLastError.
|
||||
*/
|
||||
HICON LoadIcon(HINSTANCE hInstance, String iconName);
|
||||
|
||||
/**
|
||||
* This function loads an icon, cursor, or bitmap.
|
||||
* @param hinst
|
||||
* Handle to an instance of the module that contains the image to be loaded.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the image resource
|
||||
* in the hinst module that identifies the image to load.
|
||||
* @param type
|
||||
* Specifies the type of image to be loaded.
|
||||
* @param xDesired
|
||||
* Specifies the width, in pixels, of the icon or cursor. If this parameter is zero, the function uses
|
||||
* the SM_CXICON or SM_CXCURSOR system metric value to set the width. If uType is IMAGE_BITMAP, this
|
||||
* parameter must be zero.
|
||||
* @param yDesired
|
||||
* Specifies the height, in pixels, of the icon or cursor. If this parameter is zero, the function uses
|
||||
* the SM_CYICON or SM_CYCURSOR system metric value to set the height. If uType is IMAGE_BITMAP, this
|
||||
* parameter must be zero.
|
||||
* @param load
|
||||
* Set to zero.
|
||||
* @return
|
||||
* The handle of the newly loaded image indicates success. NULL indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired,
|
||||
int yDesired, int load);
|
||||
|
||||
/**
|
||||
* This function destroys an icon and frees any memory the icon occupied.
|
||||
* @param hicon
|
||||
* Handle to the icon to be destroyed. The icon must not be in use.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DestroyIcon(HICON hicon);
|
||||
|
||||
/**
|
||||
* This function retrieves information about the specified window. GetWindowLong also retrieves
|
||||
* the 32-bit (long) value at the specified offset into the extra window memory of a window.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be retrieved.
|
||||
* @return
|
||||
* The requested 32-bit value indicates success. Zero indicates failure. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
int GetWindowLong(HWND hWnd, int nIndex);
|
||||
|
||||
/**
|
||||
* This function changes an attribute of the specified window. SetWindowLong also sets a 32-bit (LONG)
|
||||
* value at the specified offset into the extra window memory of a window.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLong
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* The previous value of the specified 32-bit integer indicates success. Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
/**
|
||||
* This function changes an attribute of the specified window. SetWindowLong also sets a
|
||||
* 32-bit (LONG) value at the specified offset into the extra window memory of a window.
|
||||
* Do not use this version on Windows-64.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLong
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* The previous value of the specified 32-bit integer indicates success. Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer SetWindowLong(HWND hWnd, int nIndex, Pointer dwNewLong);
|
||||
|
||||
/**
|
||||
* The GetWindowLongPtr function retrieves information about the specified window.
|
||||
* The function also retrieves the value at a specified offset into the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be retrieved.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the requested value.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If SetWindowLong or SetWindowLongPtr has not been called previously, GetWindowLongPtr returns zero for
|
||||
* values in the extra window or class memory.
|
||||
*/
|
||||
LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex);
|
||||
|
||||
/**
|
||||
* The SetWindowLongPtr function changes an attribute of the specified window. The function also
|
||||
* sets a value at the specified offset in the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLongPtr
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the previous value of the specified offset.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the previous value is zero and the function succeeds, the return value is zero, but the function
|
||||
* does not clear the last error information. To determine success or failure, clear the last error
|
||||
* information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated
|
||||
* by a return value of zero and a GetLastError result that is nonzero.
|
||||
*/
|
||||
LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLongPtr);
|
||||
|
||||
/**
|
||||
* The SetWindowLongPtr function changes an attribute of the specified window. The function also
|
||||
* sets a value at the specified offset in the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLongPtr
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the previous value of the specified offset.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the previous value is zero and the function succeeds, the return value is zero, but the function
|
||||
* does not clear the last error information. To determine success or failure, clear the last error
|
||||
* information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated
|
||||
* by a return value of zero and a GetLastError result that is nonzero.
|
||||
*/
|
||||
Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr);
|
||||
|
||||
/**
|
||||
* The SetLayeredWindowAttributes function sets the opacity and transparency color key of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to the layered window.
|
||||
* @param crKey
|
||||
* COLORREF structure that specifies the transparency color key to be used when composing the layered window.
|
||||
* @param bAlpha
|
||||
* Alpha value used to describe the opacity of the layered window.
|
||||
* @param dwFlags
|
||||
* Specifies an action to take.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha,
|
||||
int dwFlags);
|
||||
|
||||
/**
|
||||
* The GetLayeredWindowAttributes function retrieves the opacity and transparency color
|
||||
* key of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to the layered window. A layered window is created by specifying WS_EX_LAYERED
|
||||
* when creating the window with the CreateWindowEx function or by setting WS_EX_LAYERED
|
||||
* via SetWindowLong after the window has been created.
|
||||
* @param pcrKey
|
||||
* Pointer to a COLORREF value that receives the transparency color key to be used when
|
||||
* composing the layered window. All pixels painted by the window in this color will be
|
||||
* transparent. This can be NULL if the argument is not needed.
|
||||
* @param pbAlpha
|
||||
* Pointer to a BYTE that receives the Alpha value used to describe the opacity of the
|
||||
* layered window. Similar to the SourceConstantAlpha member of the BLENDFUNCTION structure.
|
||||
* When the variable referred to by pbAlpha is 0, the window is completely transparent.
|
||||
* When the variable referred to by pbAlpha is 255, the window is opaque. This can be NULL
|
||||
* if the argument is not needed.
|
||||
* @param pdwFlags
|
||||
* Pointer to a DWORD that receives a layering flag. This can be NULL if the argument is not needed.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey,
|
||||
ByteByReference pbAlpha, IntByReference pdwFlags);
|
||||
|
||||
/**
|
||||
* The UpdateLayeredWindow function updates the position, size, shape, content, and
|
||||
* translucency of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to a layered window. A layered window is created by specifying WS_EX_LAYERED
|
||||
* when creating the window with the CreateWindowEx function.
|
||||
* @param hdcDst
|
||||
* Handle to a device context (DC) for the screen. This handle is obtained by specifying NULL
|
||||
* when calling the function. It is used for palette color matching when the window contents
|
||||
* are updated. If hdcDst isNULL, the default palette will be used. If hdcSrc is NULL, hdcDst must be NULL.
|
||||
* @param pptDst
|
||||
* Pointer to a POINT structure that specifies the new screen position of the layered window.
|
||||
* If the current position is not changing, pptDst can be NULL.
|
||||
* @param psize
|
||||
* Pointer to a SIZE structure that specifies the new size of the layered window. If the size of the window
|
||||
* is not changing, psize can be NULL. If hdcSrc is NULL, psize must be NULL.
|
||||
* @param hdcSrc
|
||||
* Handle to a DC for the surface that defines the layered window. This handle can be obtained by calling
|
||||
* the CreateCompatibleDC function. If the shape and visual context of the window are not changing, hdcSrc
|
||||
* can be NULL.
|
||||
* @param pptSrc
|
||||
* Pointer to a POINT structure that specifies the location of the layer in the device context.
|
||||
* If hdcSrc is NULL, pptSrc should be NULL.
|
||||
* @param crKey
|
||||
* Pointer to a COLORREF value that specifies the color key to be used when composing the layered window.
|
||||
* To generate a COLORREF, use the RGB macro.
|
||||
* @param pblend
|
||||
* Pointer to a BLENDFUNCTION structure that specifies the transparency value to be used when composing
|
||||
* the layered window.
|
||||
* @param dwFlags
|
||||
* ULW_* flags.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst,
|
||||
SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey,
|
||||
BLENDFUNCTION pblend, int dwFlags);
|
||||
|
||||
/**
|
||||
* This function sets the window region of a window. The window region determines the area within the
|
||||
* window where the system permits drawing. The system does not display any portion of a window that lies
|
||||
* outside of the window region.
|
||||
* @param hWnd
|
||||
* Handle to the window whose window region is to be set.
|
||||
* @param hRgn
|
||||
* Handle to a region. The function sets the window region of the window to this region.
|
||||
* If hRgn is NULL, the function sets the window region to NULL.
|
||||
* @param bRedraw
|
||||
* Specifies whether the system redraws the window after setting the window region.
|
||||
* If bRedraw is TRUE, the system does so; otherwise, it does not.
|
||||
* Typically, you set bRedraw to TRUE if the window is visible.
|
||||
* @return
|
||||
* Nonzero indicates success.
|
||||
* Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw);
|
||||
|
||||
/**
|
||||
* The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.
|
||||
* @param lpKeyState
|
||||
* Pointer to the 256-byte array that receives the status data for each virtual key.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetKeyboardState(byte[] lpKeyState);
|
||||
|
||||
/**
|
||||
* This function determines whether a key is up or down at the time the function is called,
|
||||
* and whether the key was pressed after a previous call to GetAsyncKeyState.
|
||||
* @param vKey
|
||||
* Specifies one of 256 possible virtual-key codes.
|
||||
* @return
|
||||
* If the function succeeds, the return value specifies whether the key was pressed since the last
|
||||
* call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant
|
||||
* bit is set, the key is down.
|
||||
*/
|
||||
short GetAsyncKeyState(int vKey);
|
||||
|
||||
/**
|
||||
* The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain.
|
||||
* You would install a hook procedure to monitor the system for certain types of events. These
|
||||
* events are associated either with a specific thread or with all threads in the same desktop
|
||||
* as the calling thread.
|
||||
* @param idHook
|
||||
* Specifies the type of hook procedure to be installed.
|
||||
* @param lpfn
|
||||
* Pointer to the hook procedure.
|
||||
* @param hMod
|
||||
* Handle to the DLL containing the hook procedure pointed to by the lpfn parameter.
|
||||
* @param dwThreadId
|
||||
* Specifies the identifier of the thread with which the hook procedure is to be associated.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the hook procedure.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod,
|
||||
int dwThreadId);
|
||||
|
||||
/**
|
||||
* The CallNextHookEx function passes the hook information to the next hook procedure
|
||||
* in the current hook chain. A hook procedure can call this function either before or
|
||||
* after processing the hook information.
|
||||
* @param hhk
|
||||
* Ignored.
|
||||
* @param nCode
|
||||
* Specifies the hook code passed to the current hook procedure. The next hook procedure
|
||||
* uses this code to determine how to process the hook information.
|
||||
* @param wParam
|
||||
* Specifies the wParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @param lParam
|
||||
* Specifies the lParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @return
|
||||
* This value is returned by the next hook procedure in the chain. The current hook procedure
|
||||
* must also return this value. The meaning of the return value depends on the hook type.
|
||||
*/
|
||||
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* The CallNextHookEx function passes the hook information to the next hook procedure
|
||||
* in the current hook chain. A hook procedure can call this function either before or
|
||||
* after processing the hook information.
|
||||
* @param hhk
|
||||
* Ignored.
|
||||
* @param nCode
|
||||
* Specifies the hook code passed to the current hook procedure. The next hook procedure
|
||||
* uses this code to determine how to process the hook information.
|
||||
* @param wParam
|
||||
* Specifies the wParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @param lParam
|
||||
* Specifies the lParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @return
|
||||
* This value is returned by the next hook procedure in the chain. The current hook procedure
|
||||
* must also return this value. The meaning of the return value depends on the hook type.
|
||||
*/
|
||||
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam);
|
||||
|
||||
/**
|
||||
* The UnhookWindowsHookEx function removes a hook procedure installed in
|
||||
* a hook chain by the SetWindowsHookEx function.
|
||||
* @param hhk
|
||||
* Handle to the hook to be removed. This parameter is a hook handle obtained
|
||||
* by a previous call to SetWindowsHookEx.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UnhookWindowsHookEx(HHOOK hhk);
|
||||
|
||||
/**
|
||||
* This function retrieves a message from the calling thread's message queue
|
||||
* and places it in the specified structure.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that receives message information from the thread's message queue.
|
||||
* @param hWnd
|
||||
* Handle to the window whose messages are to be retrieved. One value has a special meaning.
|
||||
* @param wMsgFilterMin
|
||||
* Specifies the integer value of the lowest message value to be retrieved.
|
||||
* @param wMsgFilterMax
|
||||
* Specifies the integer value of the highest message value to be retrieved.
|
||||
* @return
|
||||
* Nonzero indicates that the function retrieves a message other than WM_QUIT. Zero indicates
|
||||
* that the function retrieves the WM_QUIT message, or that lpMsg is an invalid pointer. To
|
||||
* get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax);
|
||||
|
||||
/**
|
||||
* This function checks a thread message queue for a message and places the
|
||||
* message (if any) in the specified structure.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that receives message information.
|
||||
* @param hWnd
|
||||
* Handle to the window whose messages are to be examined.
|
||||
* @param wMsgFilterMin
|
||||
* Specifies the value of the first message in the range of messages to be examined.
|
||||
* @param wMsgFilterMax
|
||||
* Specifies the value of the last message in the range of messages to be examined.
|
||||
* @param wRemoveMsg
|
||||
* Specifies how messages are handled. This parameter can be one of the following values.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure.
|
||||
*/
|
||||
boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin,
|
||||
int wMsgFilterMax, int wRemoveMsg);
|
||||
|
||||
/**
|
||||
* This function translates virtual-key messages into character messages. The character messages
|
||||
* are posted to the calling thread's message queue, to be read the next time the thread calls the
|
||||
* GetMessage or PeekMessage function.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that contains message information retrieved from the calling thread's
|
||||
* message queue by using the GetMessage or PeekMessage function.
|
||||
* @return
|
||||
* Nonzero indicates that the message is translated, that is, a character message is posted to the
|
||||
* thread's message queue. If the message is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is nonzero,
|
||||
* regardless of the translation. Zero indicates that the message is not translated, that is, a
|
||||
* character message is not posted to the thread's message queue.
|
||||
*/
|
||||
boolean TranslateMessage(MSG lpMsg);
|
||||
|
||||
/**
|
||||
* This function dispatches a message to a window procedure. It is typically used
|
||||
* to dispatch a message retrieved by the GetMessage function.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that contains the message.
|
||||
* @return
|
||||
* The return value specifies the value returned by the window procedure. Although its meaning
|
||||
* depends on the message being dispatched, the return value generally is ignored.
|
||||
*/
|
||||
LRESULT DispatchMessage(MSG lpMsg);
|
||||
|
||||
/**
|
||||
* This function places a message in the message queue associated with the thread that
|
||||
* created the specified window and then returns without waiting for the thread to process
|
||||
* the message. Messages in a message queue are retrieved by calls to the GetMessage
|
||||
* or PeekMessage function.
|
||||
* @param hWnd
|
||||
* Handle to the window whose window procedure is to receive the message.
|
||||
* @param msg
|
||||
* Specifies the message to be posted.
|
||||
* @param wParam
|
||||
* Specifies additional message-specific information.
|
||||
* @param lParam
|
||||
* Specifies additional message-specific information.
|
||||
*/
|
||||
void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* This function indicates to Windows that a thread has made a request to terminate (quit).
|
||||
* It is typically used in response to a WM_DESTROY message.
|
||||
* @param nExitCode
|
||||
* Specifies an application exit code. This value is used as the wParam parameter of
|
||||
* the WM_QUIT message.
|
||||
*/
|
||||
void PostQuitMessage(int nExitCode);
|
||||
|
||||
/**
|
||||
* The GetSystemMetrics function retrieves various system metrics (widths
|
||||
* and heights of display elements) and system configuration settings. All
|
||||
* dimensions retrieved by GetSystemMetrics are in pixels.
|
||||
* @param nIndex
|
||||
* System metric or configuration setting to retrieve. This
|
||||
* parameter can be one of the following values. Note that all
|
||||
* SM_CX* values are widths and all SM_CY* values are heights.
|
||||
* Also note that all settings designed to return Boolean data
|
||||
* represent TRUE as any nonzero value, and FALSE as a zero
|
||||
* value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the requested
|
||||
* system metric or configuration setting. If the function fails,
|
||||
* the return value is zero. GetLastError does not provide extended
|
||||
* error information.
|
||||
*/
|
||||
public int GetSystemMetrics(int nIndex);
|
||||
}
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário