Comparar commits
836 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| f0080de225 | |||
| e176d09eac | |||
| 9ff14b0a90 | |||
| 1b234b6c3b | |||
| 84cfea1ac0 | |||
| 85d8d08972 | |||
| 5cf120de75 | |||
| bdf38eaf8e | |||
| 3823533c17 | |||
| fecaf92ec1 | |||
| 830dc666ad | |||
| b7951759ec | |||
| ead2c70a1a | |||
| e0016e875f | |||
| 24f60158d4 | |||
| 910642248d | |||
| 6fdb21414d | |||
| 6178c5c6a0 | |||
| e7b0c5d05d | |||
| 1140b4eed2 | |||
| 99613775b1 | |||
| 13c1a17018 | |||
| e51a82e19d | |||
| 5180a7e092 | |||
| a2bfccb15b | |||
| 7904663f14 | |||
| 69fbc85665 | |||
| 65a246f39b | |||
| 0d9bd6d96b | |||
| ed58f42176 | |||
| 626bf14b2d | |||
| 683e7351f0 | |||
| 5242a7d826 | |||
| f3a384f011 | |||
| 5267a6ddde | |||
| a9f757f39c | |||
| af1ef9330f | |||
| cf58970bdf | |||
| 4595abcebe | |||
| 4b73c277fa | |||
| 9f80a92973 | |||
| b4091b4f45 | |||
| cb714b9f8b | |||
| 0769a8e597 | |||
| 846cbb3c96 | |||
| e6d7829ca2 | |||
| 404cf22380 | |||
| 6c75db5003 | |||
| 71a8ecfd27 | |||
| 2582708b2f | |||
| 5587a8fadc | |||
| 22cb28ec50 | |||
| c4d9966709 | |||
| c69d03a74b | |||
| 38643d974b | |||
| 00308279df | |||
| 896f4b8b85 | |||
| ae1bafb39b | |||
| 3e2e7ffec7 | |||
| 46bc91fc63 | |||
| fb9e4c6262 | |||
| aa043c73e7 | |||
| 68ed3e521e | |||
| b6b3a51d32 | |||
| 7573196742 | |||
| b2e16a0ca5 | |||
| 53809b3c38 | |||
| 2549728a97 | |||
| 06fde953b1 | |||
| 21b9287cfd | |||
| eeeed87239 | |||
| 97e50d7a35 | |||
| f0195711b5 | |||
| 68ba4117f6 | |||
| dbd584d305 | |||
| e69d7fa485 | |||
| cdb4797fa3 | |||
| bd4207dfa4 | |||
| c9493636a9 | |||
| e6d76b9bc8 | |||
| 49868b8203 | |||
| 528e1bcbe9 | |||
| f0fd47dbdb | |||
| e1c2632941 | |||
| ef19ab440b | |||
| 75bb17e11f | |||
| 2c2f4bee15 | |||
| 58696f0c2c | |||
| 4130e11693 | |||
| 19de232dd2 | |||
| afb3fb6ab1 | |||
| 4dda1bcdd1 | |||
| c665f2ccb9 | |||
| 1f01a50e09 | |||
| 9cc0ce3148 | |||
| bd0425966f | |||
| 7089c83878 | |||
| 9511c34c54 | |||
| c6e9d44c7d | |||
| 3d051ecbb5 | |||
| f0ae20f0b6 | |||
| 2c83e4c22b | |||
| 07eaffd28f | |||
| 8c1f995e4e | |||
| f721075ac3 | |||
| da711cc76b | |||
| d9fb94a13d | |||
| 9da1b4528d | |||
| 768ea368a6 | |||
| 6ff34c29db | |||
| acdfd6ea20 | |||
| b9bf45ecce | |||
| b5df2c589a | |||
| dff973e9ee | |||
| 4a0644f3cd | |||
| f8d521999c | |||
| be0e5b51cd | |||
| f10c45b1f8 | |||
| 6d608dd49b | |||
| 70658a0279 | |||
| f3ceebecfd | |||
| 251eae5cac | |||
| 07b88af439 | |||
| 959616e992 | |||
| f7b2f910b7 | |||
| 4220566fb4 | |||
| 415179f9b7 | |||
| 9a9f8cbd99 | |||
| 319f6e9047 | |||
| 9b7d02618e | |||
| ed2f4d3b05 | |||
| fef81ce17f | |||
| 1942640b2d | |||
| d8232c9122 | |||
| 1a8b3b55d8 | |||
| 156d2015a5 | |||
| 8cbbb1eec8 | |||
| 351d68faf6 | |||
| 6d0651acbc | |||
| 7bd83c65f9 | |||
| dfe8862e0f | |||
| e89e70c9a6 | |||
| 8f06411357 | |||
| 011a2eaed7 | |||
| f29b2f5c51 | |||
| 1a9d2daef3 | |||
| 662f961d91 | |||
| 7e06d1ab81 | |||
| 6a22e39d4c | |||
| ff27aaffe3 | |||
| 601f1026eb | |||
| bdf59518fb | |||
| 3f7e52a4d9 | |||
| 8da7dc2e56 | |||
| b1cda9cd72 | |||
| 811d025b88 | |||
| c7e96bd3c0 | |||
| bc67864e57 | |||
| 96a4450d70 | |||
| 8591ebd55f | |||
| 16b6d591d5 | |||
| 5e3e485d4d | |||
| f7bd979d1b | |||
| 176b44fd65 | |||
| 548714343a | |||
| 8ce6297b97 | |||
| 52897e2693 | |||
| d5582d6181 | |||
| d9868285a0 | |||
| 429bed5aba | |||
| 3442e07023 | |||
| fef7e3786e | |||
| e77f69908a | |||
| c2be88fd9c | |||
| 85f8c409de | |||
| ad442d822d | |||
| bbfc36e8c6 | |||
| 136dbaa257 | |||
| b6215a24b5 | |||
| c62b73bdf5 | |||
| 2832feaa8e | |||
| f90fd1288b | |||
| 2e27312ea0 | |||
| f2b6eb5e7a | |||
| 24439832da | |||
| 89c1f7fa4c | |||
| b78eef7789 | |||
| aaa7fd0123 | |||
| 8b17879219 | |||
| 6ab495c8eb | |||
| 03be32b103 | |||
| 4218a07549 | |||
| 17a26e7dbc | |||
| 580dd76041 | |||
| 74ae45c476 | |||
| d6d99a9b6b | |||
| 3854e50e64 | |||
| a8966e8dcf | |||
| 98c7993a41 | |||
| 662763fdcc | |||
| 47211510b0 | |||
| 997ff2e7ed | |||
| 32d19f0a61 | |||
| a5ce77f5c4 | |||
| 464e03172f | |||
| d9ad71341c | |||
| 4eedc67bf0 | |||
| c96712eadc | |||
| 3b2fd06dc0 | |||
| 296b97d58a | |||
| 363db04779 | |||
| 13f2419f33 | |||
| ec9868b85b | |||
| a31faf3026 | |||
| e1fda6694b | |||
| 2fb117023b | |||
| d2a70dac78 | |||
| 18218163fd | |||
| fccab0ac15 | |||
| 02a01db39a | |||
| bd950aa654 | |||
| 32758ee8e2 | |||
| 0c79114d30 | |||
| 43b426410d | |||
| 26de4b0dd0 | |||
| 58243488fc | |||
| 489b5ddde1 | |||
| 0d0d36d599 | |||
| 2d454fb7dc | |||
| 5097ed533f | |||
| 160dee7d84 | |||
| 7395736b9f | |||
| b64c489135 | |||
| fffc3f0f7c | |||
| 5dd4e0c846 | |||
| e32ae1cae6 | |||
| 8771dce348 | |||
| 3ac6f75611 | |||
| f88d243071 | |||
| feb7b88279 | |||
| 070b47e825 | |||
| c1289c07be | |||
| e68fd9dfaf | |||
| f23a4bf9d5 | |||
| b769daec0c | |||
| 4e36f71f3a | |||
| 25db8ccfa7 | |||
| 5c2923c0af | |||
| 018ad7f2c0 | |||
| c1a7fd7267 | |||
| 3c086de42c | |||
| b48390fc1e | |||
| 136fe02333 | |||
| 5f9d100b2d | |||
| 176f3f32d4 | |||
| 2667202a3f | |||
| 245eb88b40 | |||
| d51479c357 | |||
| 7a583b1aaa | |||
| eaff9bd176 | |||
| da4d941906 | |||
| ed94e60da3 | |||
| 2fe6c956b4 | |||
| 559c7d7f13 | |||
| 6b7f2eeadb | |||
| 7bda1b3d0e | |||
| d516b01c75 | |||
| 08c579f0cb | |||
| c231069066 | |||
| ec16947808 | |||
| 2d61573175 | |||
| 507c065c0e | |||
| cf6b6299e0 | |||
| 862a746170 | |||
| 14717ce21f | |||
| 72aade4f8f | |||
| fbf75539f9 | |||
| 879402d020 | |||
| 7296f2213d | |||
| fb243c6cf5 | |||
| 20d1a720ce | |||
| ea12e0755b | |||
| 83cc22a24c | |||
| c795c80439 | |||
| edab625da6 | |||
| 9f9240391b | |||
| 4fbbc6b42a | |||
| cdbc379608 | |||
| bfeac30452 | |||
| 2e7d188afa | |||
| d291bd52cd | |||
| d8e8fd09a6 | |||
| d66471e4c0 | |||
| bb7d364f45 | |||
| f9f8474e7f | |||
| e2cac3a280 | |||
| d6b5c2c797 | |||
| c0e51cb47f | |||
| 03f054b474 | |||
| 511676e0e9 | |||
| 94ac8af162 | |||
| a814936bd7 | |||
| e42b2ca09d | |||
| 7be159d0c2 | |||
| c53c384096 | |||
| 6a52c22a02 | |||
| 6f30debd34 | |||
| d400921e17 | |||
| e95b37e5de | |||
| b9cc27c1ad | |||
| c8852f7c44 | |||
| 18b0700337 | |||
| 8d535e72c7 | |||
| 2f51fc68cb | |||
| 1f1972bf0e | |||
| e91fbd35c2 | |||
| f46c5ffc2b | |||
| a9f90b508a | |||
| 7dd96c6978 | |||
| 0c888d992b | |||
| 14da21e9f9 | |||
| 019e861539 | |||
| 79d208096b | |||
| 28c4c5fef5 | |||
| 5e211134d5 | |||
| 310e829d70 | |||
| 3d0040a183 | |||
| bbb0501f76 | |||
| 641b7aa3ad | |||
| 1572b12f75 | |||
| 689ddc493f | |||
| cb05293c11 | |||
| d5e2ee902d | |||
| b9995b2ad0 | |||
| bd243519df | |||
| f11614bc27 | |||
| 58a5185c20 | |||
| e92ff82c19 | |||
| c4c07d7878 | |||
| e07ed3082d | |||
| 5728822dad | |||
| fd13022f7c | |||
| 296eaec0e6 | |||
| 8b8672214c | |||
| 2f662bcf6d | |||
| 35f12b7027 | |||
| 719fab1ad2 | |||
| 67ffdd5168 | |||
| afc3fe3687 | |||
| 14dbeda4ed | |||
| f5ee066cc0 | |||
| ad65bcccfb | |||
| fab66d7d49 | |||
| d78c38e4e2 | |||
| 21cecef8ef | |||
| 3e8511fbc6 | |||
| 21863e190d | |||
| fb84300563 | |||
| a8de00b8e5 | |||
| 5fd52be589 | |||
| 6335fef0b1 | |||
| 3455742d89 | |||
| 6ba364f64f | |||
| 164da6cf1c | |||
| 1b6bc6342e | |||
| bde74fdccf | |||
| 6dd612162d | |||
| 2ff4d20fad | |||
| fbcd02ae6e | |||
| 6de51cdf5a | |||
| e97b1df6ee | |||
| 65d68b8d70 | |||
| f915ec7e05 | |||
| 44b4bc0cac | |||
| 2a6ac9a20d | |||
| 076298e343 | |||
| 1c3ab0f80f | |||
| a0ae2836d9 | |||
| 2309762aca | |||
| e4d89f7087 | |||
| 44c41b6faf | |||
| 8003de03ec | |||
| c5ae6a3cbb | |||
| 4581cb2f61 | |||
| 804795c5f8 | |||
| efce3ec30e | |||
| e56835fccc | |||
| 4f495756aa | |||
| 9dce43affa | |||
| 7200f90633 | |||
| 861e4cc3bc | |||
| c2c1f81ea5 | |||
| 14481ee346 | |||
| a92256bc72 | |||
| be42dda63d | |||
| 7313da6156 | |||
| b7d94d6a14 | |||
| 782b11f201 | |||
| aea387ce02 | |||
| 4ddad49369 | |||
| 224f18fef4 | |||
| 2390543445 | |||
| 473d48b39b | |||
| a947dfdac5 | |||
| b83e977839 | |||
| ab2d5a72e7 | |||
| bc5855e900 | |||
| 2c5993d680 | |||
| 2cc7fe3272 | |||
| 958ecde56b | |||
| 0a9a4c926a | |||
| a0b50515e2 | |||
| edf2dacfac | |||
| d65bd51895 | |||
| e0bd677ffc | |||
| c7123cf59b | |||
| 187fcdc2fb | |||
| a064b2a0e1 | |||
| 777406eb7b | |||
| 37f108fa51 | |||
| f0817a3e75 | |||
| 0eb9636bdf | |||
| 3f3872974e | |||
| 99533d2052 | |||
| dce035056a | |||
| 53cb504e90 | |||
| 2162f14786 | |||
| bd7fdf2438 | |||
| cc399eca28 | |||
| adb048c01a | |||
| 738900d840 | |||
| 3755747fda | |||
| 36020c6d33 | |||
| b64e24691b | |||
| a97377bb4a | |||
| b661a7ecbd | |||
| 2f3807d9a4 | |||
| 9932ce345e | |||
| b254399c02 | |||
| 5c08bfcd5c | |||
| fcd4cafe8a | |||
| cd6a1f48c8 | |||
| 2996d99914 | |||
| 785173f106 | |||
| bf66cb55d6 | |||
| 9ce2f894c3 | |||
| 436e842faa | |||
| adf4a382a3 | |||
| d4ba6b3575 | |||
| 6439e36464 | |||
| 57ded8d803 | |||
| aa5fc9b3d8 | |||
| afb3a7cc84 | |||
| e14201201d | |||
| 92b5085dd8 | |||
| 4c814e7700 | |||
| fb6d9e6908 | |||
| 1398a5764b | |||
| e66bea10d4 | |||
| 8ba666dfe0 | |||
| 882bd3dd11 | |||
| 317d41e1df | |||
| 02bd142758 | |||
| 5f2620944f | |||
| 0405f305f9 | |||
| 501dc9054a | |||
| b2c3c585db | |||
| 481010d0b3 | |||
| 4f79bd12e1 | |||
| 0bfd959bcb | |||
| d7845899b4 | |||
| 76f7b189fa | |||
| d330f19292 | |||
| b14ccb8eab | |||
| d873f6f6be | |||
| 7f0d465e98 | |||
| 7855615a9d | |||
| 9889489355 | |||
| 09b23cfc1d | |||
| 213ed15c70 | |||
| 6f7ece8603 | |||
| 5d44e011b9 | |||
| ff3d76fd42 | |||
| 7e0a412c4f | |||
| 39e6a58604 | |||
| 853cc722a1 | |||
| 3f5023068c | |||
| ebb8e89456 | |||
| a098b44f4c | |||
| 10d1e51393 | |||
| 9bcc884276 | |||
| a044a56b1c | |||
| 59bb61a366 | |||
| f2981454cb | |||
| 39dccddb60 | |||
| 3afaa9a34a | |||
| 65f40c35a2 | |||
| 0a1ab12a8d | |||
| e1539266e6 | |||
| 7c5e60b5f4 | |||
| e72ed5eeaa | |||
| bd78c9c331 | |||
| 84d3253f86 | |||
| 964c5b93f8 | |||
| 6c194233a5 | |||
| 8360bf1cd0 | |||
| d578b89619 | |||
| dee20f8e45 | |||
| 4130e1972d | |||
| 1ff9c604bb | |||
| 211060eb8f | |||
| 78d9c638ba | |||
| afaf338160 | |||
| 9e9c4aeb77 | |||
| 8efc0b1f40 | |||
| 1df51398ae | |||
| cd2277cc79 | |||
| 164e6fe04b | |||
| c365ee7577 | |||
| f22c38bbd9 | |||
| 03e9ee321a | |||
| 95f31151ec | |||
| 198ed1ef85 | |||
| 4f17e1f142 | |||
| ff9454da44 | |||
| ea14ae85e8 | |||
| 52891f8a93 | |||
| c8f1bde8e2 | |||
| 6a6e7f862f | |||
| d52fbed05c | |||
| 322052ce65 | |||
| af18df2bc2 | |||
| 236c939132 | |||
| c411f140f3 | |||
| 3d56106b07 | |||
| 8c01954c50 | |||
| fed646a207 | |||
| d76441cf71 | |||
| ee6696fdf4 | |||
| c6265c36a9 | |||
| cc5e41bf32 | |||
| 049d8386ff | |||
| 3b7efa4e74 | |||
| d992ac54a2 | |||
| 2d3fb36420 | |||
| 30ff28e1d8 | |||
| 09f8f310f4 | |||
| 53d7b16564 | |||
| 18dd85d6cb | |||
| 74ee6ea8b4 | |||
| 2541679dbd | |||
| cbb062cc35 | |||
| 8cf8878425 | |||
| 24b72070c0 | |||
| d72c49e556 | |||
| 3000dc237f | |||
| 1fbf9dc44f | |||
| 90af15ef5c | |||
| 55e4a5aa15 | |||
| a0c80f279b | |||
| 8195e0e11d | |||
| 56b3f8cef0 | |||
| 28a00f61ff | |||
| 7f2ea33a80 | |||
| 92ff23e77f | |||
| 58fb8ca2df | |||
| cc3fbd975c | |||
| e449a43bbe | |||
| 71c792f51b | |||
| 7c7c9f3272 | |||
| ed62e48b95 | |||
| 17d9e9e68d | |||
| 6972a4ffda | |||
| 1833aa0fb9 | |||
| f1fb139b4e | |||
| 5cb470331d | |||
| 269deef6db | |||
| 42695e7250 | |||
| a6e56b97f6 | |||
| 747d6c32d4 | |||
| eab6e41cde | |||
| 69dbe845f4 | |||
| f498318c07 | |||
| 630b9c0ac4 | |||
| 0cad4386fa | |||
| 09cb76f264 | |||
| 2e3a48ccdd | |||
| 5e4814d992 | |||
| 5c0cc6f153 | |||
| 857fe3de46 | |||
| e2214f8adb | |||
| 1106229a57 | |||
| bc9d0be295 | |||
| 3b836249fe | |||
| a26e394061 | |||
| b8099539f0 | |||
| dc411e8f99 | |||
| 404585d134 | |||
| 19ce713188 | |||
| 89284fe55f | |||
| ba022c338a | |||
| 097e5f3924 | |||
| ed2c518d96 | |||
| 0e5843995f | |||
| 5b9cd52784 | |||
| 2db72615b5 | |||
| f6ab3edc23 | |||
| cef6194628 | |||
| 53f387b203 | |||
| 4fbcb5b5fb | |||
| 8e7652ef6a | |||
| 83038cf24a | |||
| b00ff3e98f | |||
| da2773e02a | |||
| 01d71b7bed | |||
| 19afda0069 | |||
| 9e1196444e | |||
| f38364b399 | |||
| 36849e7716 | |||
| b764162526 | |||
| a3d9aa8501 | |||
| c71480eaf8 | |||
| 9af9291b73 | |||
| 68ce0c383e | |||
| 75af086be8 | |||
| 1ac92cca9b | |||
| be72fbab29 | |||
| 70150bdf45 | |||
| 6b452bafae | |||
| 8ddac835b6 | |||
| 69043d0293 | |||
| a82e6c354e | |||
| 84e8de6e9f | |||
| 3aeecc9eb1 | |||
| 00d0b59cd1 | |||
| bda487e870 | |||
| c1d28ba8d5 | |||
| 5feacad4a5 | |||
| 10ea848900 | |||
| d14178be4c | |||
| 3f5b1375ab | |||
| eaf444eabc | |||
| 6309741522 | |||
| 9dc9a293f3 | |||
| f2c2a4fce9 | |||
| c0b69e57d5 | |||
| 59a259f4d3 | |||
| 3de1eb36d3 | |||
| c3813b6d7f | |||
| 8d27f68baa | |||
| ff3cd68b8c | |||
| cadeba6cb5 | |||
| 0739e7dc00 | |||
| edfdfd2e85 | |||
| 7b7a42f221 | |||
| 4b18d1f73d | |||
| c3042afaf3 | |||
| b0304e9679 | |||
| 2e7e03d014 | |||
| aea706c528 | |||
| 0cfe60e9d1 | |||
| 14e2e92e86 | |||
| 884402787b | |||
| 01c78756af | |||
| 7086846465 | |||
| 838d4ad920 | |||
| 7e37eaaf77 | |||
| 07cc7a3719 | |||
| 2b9be16ffa | |||
| 9458d88f67 | |||
| 6a34124175 | |||
| 39c8792ece | |||
| 1d04af52e3 | |||
| 26e9509c9b | |||
| 9c157d3215 | |||
| d22de05b0b | |||
| 1fe3dc7c20 | |||
| f7c0bc613a | |||
| c7fa2da826 | |||
| da11bece0f | |||
| e3399b11ed | |||
| 115ab36fce | |||
| f8c7a245bf | |||
| ce806772f0 | |||
| dcc1f6b4f1 | |||
| 2829f5941a | |||
| cd98813de5 | |||
| e4a91de766 | |||
| 3425a763bc | |||
| 2340e7a777 | |||
| 5cbe2058c1 | |||
| c6dddbd02b | |||
| 5ffc0c3748 | |||
| bd29f83ee9 | |||
| 9474f853f8 | |||
| 0c25275ec2 | |||
| 39228c27ed | |||
| 5e93cc704d | |||
| b509af8959 | |||
| d57e96dc56 | |||
| b01d6d1982 | |||
| 35b6ded138 | |||
| acc46605f2 | |||
| 16d1996ed0 | |||
| 92a515c33e | |||
| e4363160ba | |||
| 1dc2781d2b | |||
| bb27735fe6 | |||
| b2a54c100c | |||
| 25723e7141 | |||
| 70758199c7 | |||
| e8bb12563f | |||
| d66a8e32c3 | |||
| 7c3b7fd6b5 | |||
| 1a2f93a8b3 | |||
| 944c95cf7a | |||
| 00fa972430 | |||
| f5179e6794 | |||
| 80e2b5a749 | |||
| 7063d9996f | |||
| bdfeb13f0d | |||
| 69205de17d | |||
| 260d513fea | |||
| 3704031875 | |||
| 8406f5f48f | |||
| 23a9e73212 | |||
| 429e37d3ad | |||
| 51e79c4283 | |||
| affcab04e2 | |||
| 59689d5522 | |||
| b13c84cf46 | |||
| 265289f679 | |||
| fb5036cd6d | |||
| 40bec108e7 | |||
| b922048fa8 | |||
| affca4b92d | |||
| 3e53d8752e | |||
| 4d92f6c8e7 | |||
| 0e185fa11a | |||
| f73986bd21 | |||
| 0208f68fe5 | |||
| 01adb0e638 | |||
| 1edd456322 | |||
| c9b5428008 | |||
| d5fa5633d5 | |||
| ac35bfc6fc | |||
| f7942975fe | |||
| 59aa6bb1bf | |||
| 45a45ab990 | |||
| 4db74cbea8 | |||
| c3e1101ffa | |||
| 7e0cc12e92 | |||
| 2d7dc885ec | |||
| a0525f03ee | |||
| 2b30dfb314 | |||
| bf41e64840 | |||
| 4d39ddee67 | |||
| d58b032b41 | |||
| 91e5478df6 | |||
| bd0768f877 | |||
| 49d345f767 | |||
| 12ac48fc79 | |||
| 6b91c41da8 | |||
| 2b59579e35 | |||
| 6cbdf3f3a3 | |||
| 1d1dc81104 | |||
| f045a2367f | |||
| 6257f07d1a | |||
| 4232af563c | |||
| 961543615c | |||
| aeb0abab87 | |||
| 77fe243556 | |||
| d4970cf452 | |||
| f0b1462f2d | |||
| 27e52f33ba | |||
| fadab28eb6 | |||
| b5e44c8dfa | |||
| f359848d1a | |||
| c30df49e15 | |||
| 675561bb9a | |||
| abc0bbf381 | |||
| e332366d15 | |||
| d420424039 | |||
| f4932dd020 | |||
| 085520ddc8 | |||
| 77175b3f72 | |||
| 2544e45a0b | |||
| 6002211b1c | |||
| ccabd2b16b | |||
| e680ecfbfc | |||
| e7ba089659 | |||
| 0cd4aa24e2 | |||
| 5826120fbd | |||
| 220aa4b27d | |||
| 1c3adc892c | |||
| 4af66bb62f | |||
| 5435965f90 | |||
| 6fdb7de0fe | |||
| bc7144b01b | |||
| e57279831e | |||
| 7247436b5f | |||
| a8b0d40ff9 | |||
| f893d22733 | |||
| 688ddfeced | |||
| f9e40776d4 | |||
| 8c1d2eb47f | |||
| 1359dfc658 | |||
| 6e2de5eee3 | |||
| 8807355af3 | |||
| f7e9f91ade | |||
| c4860de618 | |||
| c578b58314 | |||
| acdb200512 | |||
| e75be655ce | |||
| d6669a0dd5 | |||
| 4819d52b00 | |||
| 2dbf801eb4 | |||
| d170961701 | |||
| c7747d9769 | |||
| dd2aa9a8de | |||
| 4e9452abed | |||
| 6d3b2bddaf | |||
| ebc6a9c28a | |||
| 78ffc52a8b | |||
| b4d77e827d | |||
| bfb73f08fd | |||
| af8b7f037c | |||
| 334f0b0609 | |||
| 3ab5cb4a1d | |||
| d2a9eb5a8b | |||
| bc75c54bd3 | |||
| d3782ec816 | |||
| 8d8d3843c4 | |||
| 49634f3bf2 | |||
| c64a84c769 | |||
| 9813273b07 |
+11
-17
@@ -1,17 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="contrib/ntservice/src"/>
|
||||
<classpathentry kind="src" path="contrib/platform/src"/>
|
||||
<classpathentry kind="src" path="contrib/x11/src"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/balloontips"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/shapedwindowdemo"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/dnddemo"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/w32keyhook"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/alphamaskdemo"/>
|
||||
<classpathentry excluding="build*" kind="src" path="contrib/balloonmanagerdemo"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="jna/build.eclipse/test-classes" path="contrib/platform/test"/>
|
||||
<classpathentry kind="src" path="contrib/platform/src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/test-classes" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
|
||||
<classpathentry kind="output" path="build.eclipse/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -2,9 +2,18 @@ build
|
||||
build-d64
|
||||
build.eclipse
|
||||
build.number
|
||||
build.clover
|
||||
.metadata
|
||||
.DS_Store
|
||||
bin
|
||||
contrib/ntservice/dist
|
||||
contrib/platform/dist
|
||||
doc
|
||||
*~
|
||||
**/*~
|
||||
dist/*.asc
|
||||
dist/*-sources.jar
|
||||
dist/*-javadoc.jar
|
||||
dist/src-mvn.zip
|
||||
dist/out-of-date.jar
|
||||
perf*.txt
|
||||
@@ -1,3 +1,99 @@
|
||||
Release 3.5.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Basic [COM support](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md) for w32 - [@wolftobias](https://github.com/wolftobias).
|
||||
* Avoid superfluous Structure memory allocation by using Structure(Pointer) ctors if available - [@twall](https://github.com/twall).
|
||||
* [PR#120](https://github.com/twall/jna/pull/120): Provide methods for extracting native libraries from the class path for use by JNA - [@Zlika](https://github.com/Zlika).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): The Java `GUID` structure can be used directly as alternative to `Ole32Util.getGUIDFromString()` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Ported Win32 `dbt.h` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `WTSRegisterSessionNotification()` and `WTSUnRegisterSessionNotification()` from `Wtsapi32.dll` - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `native_window_msg` that creates windows, registers for USB device and logon/logoff notifications - [@wolftobias](https://github.com/wolftobias).
|
||||
* [PR#178](https://github.com/twall/jna/pull/178): Added Win32 `USER_INFO_10` structure from `LMAccess.h` - [@davidmc24](https://github.com/davidmc24).
|
||||
* [PR#174](https://github.com/twall/jna/pull/174): Recompile linux-amd64 natives to remove glibc-2.11 dependencies, now requires only 2.2.5 or better - [@twall](https://github.com/twall).
|
||||
* [PR#183](https://github.com/twall/jna/pull/183): Added `StructureFieldOrderInspector` unit test utility to scan for `Structure` field issues; see: `com.sun.jna.platform.StructureFieldOrderTest.testMethodGetFieldOrder` - [@bhamail](https://github.com/bhamail).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Allow `StructureFieldOrderTest` unit test in platform project to run on Linux - [@bhamail](https://github.com/bhamail).
|
||||
* [PR#192](https://github.com/twall/jna/pull/192): Added Win32 `SHGetSpecialFolderPath()` and initialization file (.ini) API functions from `kernel32.dll` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#194](https://github.com/twall/jna/pull/194): Added Unit Test for `CLSIDFromProgID()` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#196](https://github.com/twall/jna/pull/196): Added Win32 `RegisterWindowMessage()` and new wrapper `User32Util` for convenient use of `RegisterWindowMessage`, `CreateWindow` and `CreateWindowEx` - [@headcrashing](https://github.com/headcrashing).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Allow StructureFieldOrderTest unit test in platform project to run on Linux. - [@bhamail](https://github.com/bhamail).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* [PR#180](https://github.com/twall/jna/pull/180): Fix: added missing fields in `XEvents.getFieldOrder()` - [@xwizard](https://github.com/xwizard).
|
||||
* [PR#183](https://github.com/twall/jna/pull/183): Fix `LMAccess.GROUP_INFO_3.getFieldOrder()` to return correct fields names - [@bhamail](https://github.com/bhamail).
|
||||
* [PR#187](https://github.com/twall/jna/pull/187): Fix `getFieldOrder()` to return correct field names for some X11 structures - [@bhamail](https://github.com/bhamail).
|
||||
* Remove deprecated methods on Memory (getSize,isValid) and Structure (getSize) - [@twall](https://github.com/twall).
|
||||
* [PR#206](https://github.com/twall/jna/pull/206): Fix `moveToTrash()` on OSX to work with symlinks - [@twall](https://github.com/twall).
|
||||
* Remove problematic AWT check via `Class.forName("java.awt.Component")` (see [here](https://bugs.eclipse.org/bugs/show_bug.cgi?id=388170)) - [@twall](https://github.com/twall).
|
||||
* [PR#210](https://github.com/twall/jna/pull/210) Add OSGI processor specs for Mac OS X - [@bertfrees](https://github.com/bertfrees).
|
||||
|
||||
Release 3.5.1
|
||||
=============
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fix bug where string fields sometimes failed to be writtern - [@twall](https://github.com/twall) (roman kisluhin).
|
||||
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
|
||||
* [PR#151](https://github.com/twall/jna/pull/151): 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
|
||||
|
||||
Release 3.5.0
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* [#62](https://github.com/twall/jna/issues/62) If a callback is required to reside in a DLL, use [`DLLCallback`](http://twall.github.com/jna/3.5.1/javadoc/com/sun/jna/win32/DLLCallback.html) to tag your Callback object - [@twall](https://github.com/twall).
|
||||
* `Structure.getFieldOrder()` supersedes `Structure.setFieldOrder()` and is now required - [@twall](https://github.com/twall).
|
||||
* Search `~/Library/Frameworks` and `/Library/Frameworks` on OSX - [@shaneholloway](https://github.com/shaneholloway).
|
||||
* Automatic cleanup of native threads (based on suggestions from neil smith) - [@twall](https://github.com/twall).
|
||||
* Add `android-arm` target - [@ochafik](https://github.com/ochafik), [@twall](https://github.com/twall).
|
||||
* Add `jna.tmpdir` to override temporary JNA storage location - [@twall](https://github.com/twall).
|
||||
* Add `EXTRA_MAKE_OPTS` ant property to override make variables - [@twall](https://github.com/twall).
|
||||
* Add `Library.OPTION_OPEN_FLAGS` to customize dlopen behavior - [@twall](https://github.com/twall).
|
||||
* [#113](https://github.com/twall/jna/issues/113), [#114](https://github.com/twall/jna/issues/114): Add support for GNU/kFreeBSD and debian multi-arch distros - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Fix `Advapi32Util.registryGetValues()` tried to allocate memory for a zero-length `REG_BINARY` value - [@phailwhale22](https://github.com/phailwhale22).
|
||||
* Fix crash in direct mode callbacks with certain type conversions - [@twall](https://github.com/twall).
|
||||
* More thoroughly propagate unexpected exceptions generated in jnidispatch - [@twall](https://github.com/twall).
|
||||
* Cleanup maven poms and publishing to central repo - [@bhamail](https://github.com/bhamail).
|
||||
* [#129](https://github.com/twall/jna/issues/129): Allow `Memory` field in structure - [@twall](https://github.com/twall).
|
||||
* Preserve `PointerType` fields on `Structure.read()` if unchanged - [@twall](https://github.com/twall).
|
||||
* [#128](https://github.com/twall/jna/issues/128): Fix masking extracting DWORD upper and lower WORD values - [@twall](https://github.com/twall).
|
||||
* [#135](https://github.com/twall/jna/issues/135): Fix for `Advapi32Util.registryGetValues()` when reading zero length values - [@danwi](https://github.com/danwi).
|
||||
|
||||
Release 3.4.2
|
||||
=============
|
||||
|
||||
Features
|
||||
--------
|
||||
* Add `platform.win32.Kernel32.GetEnvironmentVariable` and `platform.win32.Kernel32Util.getEnvironmentVariable` - [@dblock](https://github.com/dblock).
|
||||
* Moved `Kernel32.dll` function definitions from `WinNT.java` into `Kernel32.java` - [@dblock](https://github.com/dblock).
|
||||
* Provide `toPointer()` methods on all `_PTR` types (platform win32) - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dskip-native` to skip platform native build - [@twall](https://github.com/twall).
|
||||
* Provide `ant -Dheadless=true` to run unit tests headless - [@twall](https://github.com/twall).
|
||||
* Added Windows dev environment instructions - [@twall](https://github.com/twall).
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
* Ensure platform win32 classes use unsigned where appropriate (`ULONG_PTR`, `UINT_PTR`, `ULONGLONG`, `WORD`, `DWORDLONG`) - [@twall](https://github.com/twall).
|
||||
* [#71](https://github.com/twall/jna/issues/71), [#73](https://github.com/twall/jna/issues/73): Fix OSGI entries in manifest - [@twall](https://github.com/twall).
|
||||
* [#78](https://github.com/twall/jna/issues/78): Fix NPE in `platform.win32.Netapi32Util.getDomainTrusts` - [@dblock](https://github.com/dblock).
|
||||
* Fix: auto-sync memory for `struct**` arguments (array of struct pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.Secur32.AcquireCredentialsHandle`, `InitializeSecurityContext` and `AcceptSecurityContext` on Win32 64-bit - [@dblock](https://github.com/dblock).
|
||||
* Fix: avoid overwriting native `char *` or `wchar_t *` fields within structures when unmodified (similar to current operation with pointers) - [@twall](https://github.com/twall).
|
||||
* Fix: `platform.win32.DsGetDC.DS_DOMAIN_TRUSTS` and `DsEnumerateDomainTrusts` on Win32 64-bit - [@trejkaz](https://github.com/trejkaz).
|
||||
* Fix: Crash freeing the wrong pointer in `Netapi32Util.getDomainTrusts` - [@trejkaz](https://github.com/trejkaz).
|
||||
* [#100](https://github.com/twall/jna/issues/100): Fix `platform.win32.W32FileMonitor` - [@dblock](https://github.com/dblock).
|
||||
* Return INT_PTR from `platform.win32.Shell32.ShellExecute`, since returning
|
||||
`HINSTANCE` is useless.
|
||||
* Fix runtime error in some instances where Structure.setFieldOrder is used (never return self when sharing AutoAllocated memory).
|
||||
* [#107](https://github.com/twall/jna/issues/107): `Structure.clear()` always calls `ensureAllocated()` to avoid NPE.
|
||||
* Ensure internal memory pointer is *always* allocated when calling `Structure.useMemory()`, even if layout is not yet determined.
|
||||
|
||||
Release 3.4.1
|
||||
=============
|
||||
|
||||
|
||||
+30
-26
@@ -3,7 +3,7 @@
|
||||
Java Native Access (JNA)
|
||||
========================
|
||||
|
||||
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.4.0/javadoc/). Please read the [overview](http://twall.github.com/jna/3.4.0/javadoc/overview-summary.html#overview_description).
|
||||
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/). Please read the [overview](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#overview_description).
|
||||
|
||||
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
|
||||
|
||||
@@ -18,15 +18,10 @@ JNA includes a platform library with many native functions already mapped as wel
|
||||
Download
|
||||
========
|
||||
|
||||
Version 3.4.1
|
||||
Version 3.5.1
|
||||
|
||||
* [jna.jar](jna/blob/3.4.1/dist/jna.jar)
|
||||
* [platform.jar](jna/blob/3.4.1/dist/platform.jar)
|
||||
|
||||
Version 3.4.0
|
||||
|
||||
* [jna.jar](jna/blob/3.4.0/dist/jna.jar)
|
||||
* [platform.jar](jna/blob/3.4.0/dist/platform.jar)
|
||||
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/3.5.1/jna-3.5.1.jar)
|
||||
* [platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/3.5.1/platform-3.5.1.jar)
|
||||
|
||||
Features
|
||||
========
|
||||
@@ -42,7 +37,7 @@ Features
|
||||
* Nested structures and arrays
|
||||
* Wide (wchar_t-based) strings
|
||||
* Native long support (32- or 64-bit as appropriate)
|
||||
* Demo applications
|
||||
* [Demo applications/examples](https://github.com/twall/jna/tree/master/contrib)
|
||||
* Supported on 1.4 or later JVMs, including JavaME (earlier VMs may work with stubbed NIO support)
|
||||
* Customizable marshalling/unmarshalling (argument and return value conversions)
|
||||
* Customizable mapping from Java method to native function name, and customizable invocation to simulate C preprocessor function macros
|
||||
@@ -55,7 +50,7 @@ Features
|
||||
Community and Support
|
||||
=====================
|
||||
|
||||
All questions should be posted ot the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
|
||||
All questions should be posted to the [jna-users Google group](http://groups.google.com/group/jna-users). Issues can be submitted [here on Github](https://github.com/twall/jna/issues).
|
||||
|
||||
When posting to the mailing list, please include the following:
|
||||
|
||||
@@ -73,29 +68,39 @@ For commercial support, please contact twalljava [at] java [dot] net.
|
||||
Using the Library
|
||||
=================
|
||||
|
||||
* [Getting Started](jna/tree/master/www/GettingStarted.md)
|
||||
* [Mapping between Java and Native](jna/tree/master/www/Mappings.md)
|
||||
* [Using Pointers and Arrays](jna/tree/master/www/PointersAndArrays.md)
|
||||
* [Using Structures and Unions](jna/tree/master/www/StructuresAndUnions.md)
|
||||
* [Using By-Reference Arguments](jna/tree/master/www/ByRefArguments.md)
|
||||
* [Customization](jna/tree/master/www/CustomMappings.md)
|
||||
* [Callbacks/Closures](jna/tree/master/www/CallbacksAndClosures.md)
|
||||
* [Dynamically Typed Languages (JRuby/Jython)](jna/tree/master/www/DynamicallyTypedLanguages.md)
|
||||
* [Platform Library](jna/tree/master/www/PlatformLibrary.md)
|
||||
* [Direct Method Mapping](jna/tree/master/www/DirectMapping.md)
|
||||
* [Frequently Asked Questions (FAQ)](jna/tree/master/www/FrequentlyAskedQuestions.md)
|
||||
* [Getting Started](https://github.com/twall/jna/blob/master/www/GettingStarted.md)
|
||||
* [Mapping between Java and Native](https://github.com/twall/jna/blob/master/www/Mappings.md)
|
||||
* [Using Pointers and Arrays](https://github.com/twall/jna/blob/master/www/PointersAndArrays.md)
|
||||
* [Using Structures and Unions](https://github.com/twall/jna/blob/master/www/StructuresAndUnions.md)
|
||||
* [Using By-Reference Arguments](https://github.com/twall/jna/blob/master/www/ByRefArguments.md)
|
||||
* [Customization of Type Mapping](https://github.com/twall/jna/blob/master/www/CustomMappings.md)
|
||||
* [Callbacks/Function Pointers/Closures](https://github.com/twall/jna/blob/master/www/CallbacksAndClosures.md)
|
||||
* [Dynamically Typed Languages (JRuby/Jython)](https://github.com/twall/jna/blob/master/www/DynamicallyTypedLanguages.md)
|
||||
* [Platform Library](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md)
|
||||
* [Direct Method Mapping](https://github.com/twall/jna/blob/master/www/DirectMapping.md) (Optimization)
|
||||
* [Frequently Asked Questions (FAQ)](https://github.com/twall/jna/blob/master/www/FrequentlyAskedQuestions.md)
|
||||
* [Avoiding Crashes](http://twall.github.com/jna/3.5.1/javadoc/overview-summary.html#crash-protection)
|
||||
|
||||
Primary Documentation (JavaDoc)
|
||||
===============================
|
||||
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.4.0/javadoc/).
|
||||
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/3.5.1/javadoc/).
|
||||
|
||||
Developers
|
||||
==========
|
||||
|
||||
* [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md)
|
||||
* [Setting up a Windows Development Environment](https://github.com/twall/jna/blob/master/www/WindowsDevelopmentEnvironment.md)
|
||||
* [Setting up an Android Development Environment](https://github.com/twall/jna/blob/master/www/AndroidDevelopmentEnvironment.md)
|
||||
* [Releasing JNA](https://github.com/twall/jna/blob/master/www/ReleasingJNA.md)
|
||||
* [Publishing to Maven Central](https://github.com/twall/jna/blob/master/www/PublishingToMavenCentral.md)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
You're encouraged to contribute to JNA. Fork the code from [github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
|
||||
You're encouraged to contribute to JNA. Fork the code from [https://github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
|
||||
|
||||
For more informationon setting up a development environment see [Contributing to JNA](jna/tree/master/www/Contributing.md).
|
||||
For more information on setting up a development environment see [Contributing to JNA](https://github.com/twall/jna/blob/master/www/Contributing.md).
|
||||
|
||||
If you are interested in paid support, feel free to say so on the [jna-users mailing list](http://groups.google.com/group/jna-users). Most simple questions will be answered on the list, but more complicated work, new features or target platforms can be negotiated with any of the JNA developers (this is how several of JNA's features came into being). You may even encounter other users with the same need and be able to cost share the new development.
|
||||
|
||||
@@ -105,4 +110,3 @@ License
|
||||
This library is provided under the LGPL, version 2.1 or later. Alternative license arrangements are negotiable.
|
||||
|
||||
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
|
||||
|
||||
|
||||
+3
@@ -21,6 +21,9 @@
|
||||
|
||||
# TODO
|
||||
|
||||
* use consistent cpu references (x86->i386, x86_64->amd64)
|
||||
* osgi for osx
|
||||
|
||||
* make native dll extraction from jar public, to use with user dlls packaged
|
||||
in a jar
|
||||
|
||||
|
||||
+367
-254
@@ -9,7 +9,12 @@
|
||||
support it).
|
||||
|
||||
Cross-compile by specifying -Dos.prefix={name-arch} to ant
|
||||
(cross-compile currently only configured/tested on w32ce-arm)
|
||||
(cross-compile currently only configured/tested on w32ce-arm and
|
||||
android-arm)
|
||||
|
||||
Use ANT_OPTS=-Dskip-native to skip building native parts.
|
||||
Use ANT_OPTS=-Dheadless to run tests headless
|
||||
Use ANT_OPTS=-Dmaven-release to stage a final, non-snapshot version
|
||||
-->
|
||||
|
||||
<!--
|
||||
@@ -25,6 +30,7 @@
|
||||
<!-- (all build-related props should go in -dynamic-properties) -->
|
||||
<property name="name" value="jna"/>
|
||||
<property name="jar" value="${name}.jar"/>
|
||||
<property name="minjar" value="${name}-min.jar"/>
|
||||
<property name="testjar" value="${name}-test.jar"/>
|
||||
<property name="debug" value="true"/>
|
||||
<property name="debug.native" value="false"/>
|
||||
@@ -35,33 +41,43 @@
|
||||
<property name="platform.src" location="contrib/platform/src"/>
|
||||
<property name="contrib" location="contrib"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="lib.native" location="lib/native"/>
|
||||
<property name="test.src" location="test"/>
|
||||
<property name="doc" location="doc"/>
|
||||
<property name="javadoc" location="${doc}/javadoc"/>
|
||||
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
|
||||
<property name="vendor" value="JNA Development Team"/>
|
||||
<tstamp>
|
||||
<format property="year" pattern="yyyy" locale="en,US"/>
|
||||
</tstamp>
|
||||
<property name="copyright"
|
||||
value="Copyright &copy; 2007-2012 Timothy Wall. All Rights Reserved."/>
|
||||
value="Copyright &copy; 2007-${year} Timothy Wall. All Rights Reserved."/>
|
||||
<buildnumber/>
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="4"/>
|
||||
<property name="jna.revision" value="1"/>
|
||||
<property name="jna.minor" value="5"/>
|
||||
<property name="jna.revision" value="2"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<condition property="version.suffix" value="" else="-SNAPSHOT">
|
||||
<isset property="maven-release"/>
|
||||
</condition>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}${version.suffix}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
<property name="jni.major" value="3"/>
|
||||
<property name="jni.minor" value="4"/>
|
||||
<property name="jni.minor" value="5"/>
|
||||
<property name="jni.revision" value="0"/>
|
||||
<property name="jni.build" value="${build.number}"/>
|
||||
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
|
||||
<property name="jni.md5" value="4c69bcf40b30785215211b5a5dad211e"/>
|
||||
<property name="jni.md5" value="60417f69d77e4d8d693b43391a4a5b91"/>
|
||||
<property name="spec.title" value="Java Native Access (JNA)"/>
|
||||
<property name="spec.vendor" value="${vendor}"/>
|
||||
<property name="spec.version" value="${jna.major}"/>
|
||||
<property name="impl.title" value="com.sun.jna"/>
|
||||
<property name="impl.vendor" value="${spec.vendor}"/>
|
||||
<property name="impl.version" value="${jna.version} (b${jna.build})"/>
|
||||
<condition property="jni.valid" value="true">
|
||||
<isset property="skip-native"/>
|
||||
</condition>
|
||||
|
||||
<!-- Set up restrictions for w32ce, based on JavaME/CDC -->
|
||||
<property name="compatibility" value="1.4"/>
|
||||
@@ -69,31 +85,32 @@
|
||||
<condition property="test.compatibility" value="1.4">
|
||||
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
|
||||
</condition>
|
||||
<condition property="tests.exclude-patterns" value="**/VarArgsTest.java,**/AnnotatedLibraryTest.java,**/WebStartTest.java,**/PointerBufferTest.java,**/HeadlessLoadLibraryTest.java,**/StructureBufferFieldTest.java,**/PerformanceTest.java,**/*BufferArgumentsMarshalTest.java">
|
||||
<condition property="tests.exclude-patterns" value="**/VarArgsTest.java,**/AnnotatedLibraryTest.java,**/WebStartTest.java,**/PointerBufferTest.java,**/HeadlessLoadLibraryTest.java,**/StructureBufferFieldTest.java,**/PerformanceTest.java,**/*BufferArgumentsMarshalTest.java" else="**/wince/*.java">
|
||||
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
|
||||
</condition>
|
||||
<property name="test.compatibility" value="1.5"/>
|
||||
<property name="dist-jar" value="${dist}/${jar}"/>
|
||||
|
||||
<!-- Maven -->
|
||||
<!-- define Maven coordinates -->
|
||||
<property name="groupId" value="net.java.dev.jna" />
|
||||
<property name="artifactId" value="jna" />
|
||||
<property name="version" value="${jna.major}.${jna.minor}.${jna.revision}" />
|
||||
|
||||
<property name="maven-jar" value="${dist}/jna.jar"/>
|
||||
<property name="maven-javadoc-jar" value="${dist}/${artifactId}-${version}-javadoc.jar" />
|
||||
<property name="maven-sources-jar" value="${dist}/src-mvn.zip" />
|
||||
<property name="maven-javadoc-jar" value="${dist}/${artifactId}-${jna.version}-javadoc.jar" />
|
||||
<property name="maven-sources-jar" value="${dist}/${artifactId}-${jna.version}-sources.jar" />
|
||||
|
||||
<property name="platform-jar" value="${dist}/platform.jar"/>
|
||||
<property name="platform-javadoc-jar" value="${dist}/platforms-javadoc.jar" />
|
||||
<property name="platform-sources-jar" value="${dist}/platforms-sources.jar" />
|
||||
<property name="platform-javadoc-jar" value="${dist}/platform-${jna.version}-javadoc.jar" />
|
||||
<property name="platform-sources-jar" value="${dist}/platform-${jna.version}-sources.jar" />
|
||||
|
||||
<property name="pom" value="pom-jna.xml" />
|
||||
<property name="pom-platform" value="pom-platform.xml" />
|
||||
|
||||
<!-- defined maven snapshots and staging repository id and url -->
|
||||
<property name="maven-snapshots-repository-id" value="snapshots.java.net" />
|
||||
<property name="maven-snapshots-repository-url" value="https://maven.java.net/content/repositories/snapshots" />
|
||||
<property name="maven-snapshots-repository-url" value="https://maven.java.net/content/repositories/snapshots/" />
|
||||
<property name="maven-staging-repository-id" value="staging.java.net" />
|
||||
<property name="maven-staging-repository-url" value="https://maven.java.net/service/local/staging/deploy/maven2" />
|
||||
<property name="maven-staging-repository-url" value="https://maven.java.net/service/local/staging/deploy/maven2/" />
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
<property name="build.compiler.emacs" value="true"/>
|
||||
@@ -109,6 +126,12 @@
|
||||
<replaceregexp match="(<version>).*(</version>)"
|
||||
replace="\1${jna.version}\2"
|
||||
file="${pom}"/>
|
||||
|
||||
<replaceregexp match="(<version>).*(</version>)"
|
||||
replace="\1${jna.version}\2"
|
||||
flags="g"
|
||||
file="${pom-platform}"/>
|
||||
|
||||
<replaceregexp match='VERSION = ".*";'
|
||||
replace='VERSION = "${jna.version}";'
|
||||
file="src/com/sun/jna/Native.java"/>
|
||||
@@ -119,16 +142,26 @@
|
||||
<condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
|
||||
<isset property="omit-jnilib"/>
|
||||
</condition>
|
||||
<condition property="cross-compile" value="true">
|
||||
<isset property="os.prefix"/>
|
||||
</condition>
|
||||
<!-- Keep cross-compiled natives separate from normal builds -->
|
||||
<condition property="native.subdir" value="native-${os.prefix}" else="native">
|
||||
<isset property="cross-compile"/>
|
||||
</condition>
|
||||
<condition property="vm.arch" value="-d64" else="">
|
||||
<or>
|
||||
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
|
||||
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
|
||||
<os arch="x86_64"/>
|
||||
<os arch="amd64"/>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="ppc64"/>
|
||||
<os arch="ia64"/>
|
||||
</or>
|
||||
<and>
|
||||
<not><equals arg1="${os.prefix}" arg2="android-arm" trim="true"/></not>
|
||||
<or>
|
||||
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
|
||||
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
|
||||
<os arch="x86_64"/>
|
||||
<os arch="amd64"/>
|
||||
<os arch="sparcv9"/>
|
||||
<os arch="ppc64"/>
|
||||
<os arch="ia64"/>
|
||||
</or>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
|
||||
<and>
|
||||
@@ -191,7 +224,7 @@
|
||||
<not><equals arg1="${libjsig}" arg2=""/></not>
|
||||
</condition>
|
||||
<property name="native.jar" value="${os.prefix}.jar"/>
|
||||
<property name="build.native" location="${build}/native"/>
|
||||
<property name="build.native" location="${build}/${native.subdir}"/>
|
||||
<property name="md5.file" location="${build.native}/jni.checksum"/>
|
||||
|
||||
<mkdir dir="${build}"/>
|
||||
@@ -207,6 +240,10 @@
|
||||
<echo>java.home=${java.home}</echo>
|
||||
<echo>java.library.path=${java.library.path}</echo>
|
||||
<echo>os.prefix=${os.prefix}</echo>
|
||||
<echo>os.name=${os.name}</echo>
|
||||
<echo>os.arch=${os.arch}</echo>
|
||||
<echo>build=${build}</echo>
|
||||
<echo>build.native=${build.native}</echo>
|
||||
|
||||
</target>
|
||||
|
||||
@@ -216,6 +253,7 @@
|
||||
<fileset dir="lib">
|
||||
<include name="junit.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="lib/test"/>
|
||||
<pathelement path="${classes}"/>
|
||||
</path>
|
||||
</path>
|
||||
@@ -226,6 +264,7 @@
|
||||
<path id="test.runpath">
|
||||
<pathelement path="${build}/${jar}"/>
|
||||
<pathelement path="${test.classes}"/>
|
||||
<pathelement path="${build}/${testjar}"/>
|
||||
<pathelement path="lib/clover.jar"/>
|
||||
<path refid="test.libs"/>
|
||||
</path>
|
||||
@@ -255,23 +294,147 @@
|
||||
</target>
|
||||
<target name="jar" depends="-setup,native,:jar" unless="-jar"
|
||||
description="Build primary jar">
|
||||
<jar jarfile="${build}/${jar}">
|
||||
<!-- Bundle native components with primary jar to facilitate
|
||||
easy distribution to common platforms.
|
||||
-->
|
||||
<jar jarfile="${build}/${jar}" duplicate="preserve">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
</section>
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!--
|
||||
OSGi Bundle attributes
|
||||
See http://www.osgi.org/Specifications/Reference
|
||||
-->
|
||||
<attribute name="Bundle-Category" value="jni"/>
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32"/>
|
||||
<!-- Note that no terminal "*" is included in this list,
|
||||
which will force failure on unsupported platforms.
|
||||
-->
|
||||
<attribute name="Bundle-NativeCode"
|
||||
value="
|
||||
com/sun/jna/win32-x86/jnidispatch.dll;
|
||||
processor=x86;osname=win32,
|
||||
com/sun/jna/win32-amd64/jnidispatch.dll;
|
||||
processor=x86-64;osname=win32,
|
||||
com/sun/jna/w32ce-arm/jnidispatch.dll;
|
||||
processor=arm;osname=wince,
|
||||
|
||||
com/sun/jna/sunos-x86/libjnidispatch.so;
|
||||
processor=x86;osname=sunos,
|
||||
com/sun/jna/sunos-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=sunos,
|
||||
com/sun/jna/sunos-sparc/libjnidispatch.so;
|
||||
processor=sparc;osname=sunos,
|
||||
com/sun/jna/sunos-sparcv9/libjnidispatch.so;
|
||||
processor=sparcv9;osname=sunos,
|
||||
|
||||
com/sun/jna/aix-ppc/libjnidispatch.a;
|
||||
processor=ppc;osname=aix,
|
||||
com/sun/jna/aix-ppc64/libjnidispatch.a;
|
||||
processor=ppc64;osname=aix,
|
||||
|
||||
com/sun/jna/linux-ppc/libjnidispatch.so;
|
||||
processor=ppc;osname=linux,
|
||||
com/sun/jna/linux-ppc64/libjnidispatch.so;
|
||||
processor=ppc64;osname=linux,
|
||||
com/sun/jna/linux-i386/libjnidispatch.so;
|
||||
processor=x86;osname=linux,
|
||||
com/sun/jna/linux-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=linux,
|
||||
com/sun/jna/linux-arm/libjnidispatch.so;
|
||||
processor=arm;osname=linux,
|
||||
com/sun/jna/linux-ia64/libjnidispatch.so;
|
||||
processor=ia64;osname=linux,
|
||||
|
||||
com/sun/jna/openbsd-i386/libjnidispatch.so;
|
||||
processor=x86;osname=openbsd,
|
||||
com/sun/jna/freebsd-i386/libjnidispatch.so;
|
||||
processor=x86;osname=freebsd,
|
||||
com/sun/jna/freebsd-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=freebsd,
|
||||
|
||||
com/sun/jna/darwin/libjnidispatch.jnilib;
|
||||
osname=macosx;processor=x86;processor=x86-64;processor=ppc
|
||||
"/>
|
||||
</manifest>
|
||||
<fileset dir="${classes}" excludes="${jar.omitted}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
<zipfileset src="${lib.native}/win32-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-x86"/>
|
||||
<zipfileset src="${lib.native}/aix-ppc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/aix-ppc"/>
|
||||
<zipfileset src="${lib.native}/aix-ppc64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/aix-ppc64"/>
|
||||
<zipfileset src="${lib.native}/darwin.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/darwin"/>
|
||||
<zipfileset src="${lib.native}/linux-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-i386"/>
|
||||
<zipfileset src="${lib.native}/linux-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-amd64"/>
|
||||
<zipfileset src="${lib.native}/linux-arm.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-arm"/>
|
||||
<zipfileset src="${lib.native}/linux-ia64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ia64"/>
|
||||
<zipfileset src="${lib.native}/linux-ppc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ppc"/>
|
||||
<zipfileset src="${lib.native}/linux-ppc64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ppc64"/>
|
||||
<zipfileset src="${lib.native}/sunos-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-x86"/>
|
||||
<zipfileset src="${lib.native}/sunos-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-amd64"/>
|
||||
<zipfileset src="${lib.native}/sunos-sparc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparc"/>
|
||||
<zipfileset src="${lib.native}/sunos-sparcv9.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparcv9"/>
|
||||
<zipfileset src="${lib.native}/freebsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-i386"/>
|
||||
<zipfileset src="${lib.native}/freebsd-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-amd64"/>
|
||||
<zipfileset src="${lib.native}/openbsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/openbsd-i386"/>
|
||||
<zipfileset src="${lib.native}/win32-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-amd64"/>
|
||||
<zipfileset src="${lib.native}/w32ce-arm.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/w32ce-arm"/>
|
||||
</jar>
|
||||
<zip zipfile="${build}/${minjar}">
|
||||
<zipfileset src="${build}/${jar}" excludes="**/*jnidispatch*"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="platform-jar" depends="jar">
|
||||
@@ -285,12 +448,8 @@
|
||||
</subant>
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${platform-sources-jar}">
|
||||
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
|
||||
<zipfileset dir="${contrib}/platform/src" />
|
||||
</zip>
|
||||
<jar jarfile="${platform-javadoc-jar}">
|
||||
<fileset dir="${javadoc}" />
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="contrib-jars" depends="platform-jar" description="Build contrib jars">
|
||||
@@ -302,10 +461,11 @@
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="javah" depends="compile">
|
||||
<target name="javah" depends="compile" unless="skip-native">
|
||||
<javah classpath="${classes}" destdir="${build.native}" force="yes">
|
||||
<class name="com.sun.jna.Function"/>
|
||||
<class name="com.sun.jna.Native"/>
|
||||
<class name="com.sun.jna.win32.DLLCallback"/>
|
||||
</javah>
|
||||
<condition property="grep" value="/usr/sfw/bin/ggrep">
|
||||
<os name="SunOS"/>
|
||||
@@ -348,23 +508,24 @@
|
||||
<!-- Invalidate native libraries when native API changes -->
|
||||
<target name="-native-api-check" depends="javah" unless="jni.valid">
|
||||
<echo>Invalidating native code, new checksum is ${md5}</echo>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/w32ce-arm.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-arm.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ppc.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ppc64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
|
||||
<copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-amd64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/w32ce-arm.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-i386.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-amd64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-arm.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ia64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ppc.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/linux-ppc64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/freebsd-amd64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/openbsd-i386.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-x86.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-amd64.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparc.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparcv9.jar" overwrite="true"/>
|
||||
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-arm.jar" overwrite="true"/>
|
||||
<delete failOnError="false" includeEmptyDirs="true">
|
||||
<fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
|
||||
</delete>
|
||||
@@ -400,7 +561,7 @@
|
||||
file="${rsrc}" byline="true"/>
|
||||
</target>
|
||||
|
||||
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
|
||||
<target name="native" depends="-setup,javah,-native-api-check,rsrc" unless="skip-native"
|
||||
description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
|
||||
<property name="comment" value="# auto-generated by ant"/>
|
||||
<replaceregexp match="^JNA_JNI_VERSION=.*"
|
||||
@@ -410,11 +571,19 @@
|
||||
replace="CHECKSUM=${jni.md5} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<!-- Handle cross-compilation -->
|
||||
<condition property="make.OS" value="OS=w32ce" else="IGNORE=">
|
||||
<condition property="make.OS" value="OS=w32ce">
|
||||
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
|
||||
</condition>
|
||||
<condition property="make.OS" value="OS=android">
|
||||
<equals arg1="${os.prefix}" arg2="android-arm"/>
|
||||
</condition>
|
||||
<property name="make.OS" value="IGNORE="/>
|
||||
<!-- Ensure Makefile ARCH property properly set -->
|
||||
<condition property="ARCH" value="arm">
|
||||
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
|
||||
</condition>
|
||||
<condition property="ARCH" value="arm">
|
||||
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
|
||||
<equals arg1="${os.prefix}" arg2="android-arm"/>
|
||||
</condition>
|
||||
<condition property="ARCH" value="ppc">
|
||||
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
|
||||
@@ -436,19 +605,28 @@
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
<and>
|
||||
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
|
||||
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
|
||||
<and>
|
||||
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
|
||||
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
|
||||
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
|
||||
<and>
|
||||
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
|
||||
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
|
||||
</and>
|
||||
</condition>
|
||||
<!-- Windows' drive letters and spaces in absolute paths wreak havoc on
|
||||
make -->
|
||||
<condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
|
||||
<condition property="make.BUILD" value="BUILD=../${build}/${native.subdir}" else="BUILD=${build.native}">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="make.PATH" value="PATH=/opt/csw/bin:/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
|
||||
@@ -468,6 +646,12 @@
|
||||
<os name="AIX"/>
|
||||
</or>
|
||||
</condition>
|
||||
<!-- Allow explicit override of make variables -->
|
||||
<condition property="make.OPTS" value="${EXTRA_MAKE_OPTS}" else="IGNORE=">
|
||||
<isset property="EXTRA_MAKE_OPTS"/>
|
||||
</condition>
|
||||
<!-- Native resource path within jna.jar -->
|
||||
<property name="native.path" value="com/sun/jna/${os.prefix}"/>
|
||||
|
||||
<!-- Default make program -->
|
||||
<property name="make" value="make"/>
|
||||
@@ -484,16 +668,17 @@
|
||||
<arg value="${make.ARCH}"/>
|
||||
<arg value="${make.PATH}"/>
|
||||
<arg value="${make.OS}"/>
|
||||
<arg line="${make.OPTS}"/>
|
||||
<arg value="JNA_JNI_VERSION=${jni.version}"/>
|
||||
<arg value="CHECKSUM=${jni.md5}"/>
|
||||
</exec>
|
||||
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${classes}/com/sun/jna/${os.prefix}">
|
||||
<mkdir dir="${classes}/${native.path}"/>
|
||||
<copy todir="${classes}/${native.path}">
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
</copy>
|
||||
<mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
|
||||
<copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
|
||||
<mkdir dir="${eclipse.classes}/${native.path}"/>
|
||||
<copy todir="${eclipse.classes}/${native.path}"
|
||||
failonerror="false">
|
||||
<fileset dir="${build.native}"
|
||||
includes="jnidispatch.dll,libjnidispatch.*"/>
|
||||
@@ -507,6 +692,9 @@
|
||||
<attribute name="Specification-Version" value="${jni.version}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
<copy todir="${lib.native}">
|
||||
<fileset dir="${build}" includes="${native.jar}"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
@@ -521,12 +709,28 @@
|
||||
<src path="${test.src}"/>
|
||||
<exclude name="${tests.exclude}"/>
|
||||
</javac>
|
||||
<!-- Create a jar for easy movement of tests -->
|
||||
<!-- Move (not copy) embedded testlib to test class folder so that it will be -->
|
||||
<!-- packaged into the test jar and NOT available in the FS-based class path -->
|
||||
<move todir="${test.classes}/${os.prefix}">
|
||||
<fileset dir="${build.native}">
|
||||
<patternset id="embedded-testlib">
|
||||
<include name="**/*embedded-testlib*"/>
|
||||
</patternset>
|
||||
</fileset>
|
||||
</move>
|
||||
<!-- Create a jar for easy movement of tests, and embedded load test -->
|
||||
<jar jarfile="${build}/${testjar}">
|
||||
<fileset dir="${test.classes}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
<include name="**/*embedded-testlib*"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<!-- Ensure embedded library unavailable on FS-based class path -->
|
||||
<delete>
|
||||
<fileset dir="${test.classes}">
|
||||
<include name="**/*embedded-testlib*"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<mkdir dir="${build}/jws"/>
|
||||
<copy todir="${build}/jws" file="${build}/${jar}"/>
|
||||
<copy todir="${build}/jws" file="${build}/${testjar}"/>
|
||||
@@ -536,31 +740,38 @@
|
||||
<fileset dir="${build.native}" includes="*jnidispatch.*"/>
|
||||
</jar>
|
||||
<signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
|
||||
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
<fileset dir="${build}/jws" includes="${jar},${testjar},junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
</signjar>
|
||||
</target>
|
||||
|
||||
<target name="android-test-setup" depends="compile-tests"
|
||||
description="Configure tests for running on an Android emulator">
|
||||
<!-- 'shared' should be the path to a folder mounted as the mobile
|
||||
device/simulator storage card. -->
|
||||
<property name="shared" value="shared"/>
|
||||
</target>
|
||||
|
||||
<target name="wince-test-setup" depends="compile-tests"
|
||||
description="Configure tests for running on a Windows Mobile device">
|
||||
description="Configure tests for running on the WM emulator">
|
||||
<!-- 'shared' should be the path to a folder mounted as the mobile
|
||||
device/simulator storage card. -->
|
||||
<property name="shared" value="shared"/>
|
||||
<!-- w32ce arm testing -->
|
||||
<jar jarfile="${shared}/test.jar">
|
||||
<zipfileset src="${build}/jna.jar"/>
|
||||
<zipfileset src="${build}/jna-test.jar"/>
|
||||
<zipfileset src="${build}/${jar}"/>
|
||||
<zipfileset src="${build}/${testjar}"/>
|
||||
</jar>
|
||||
<copy todir="${shared}" file="${build}/jna.jar"/>
|
||||
<copy todir="${shared}" file="${build}/native/jnidispatch.dll"/>
|
||||
<copy todir="${shared}" file="${build}/native/testlib.dll"/>
|
||||
<copy todir="${shared}" file="${build}/native/testlib2.dll"/>
|
||||
<copy todir="${shared}" file="${build}/${jar}"/>
|
||||
<copy todir="${shared}" file="${build.native}/jnidispatch.dll"/>
|
||||
<copy todir="${shared}" file="${build.native}/testlib.dll"/>
|
||||
<copy todir="${shared}" file="${build.native}/testlib2.dll"/>
|
||||
<copy todir="${shared}" file="w32ce-test.lnk"/>
|
||||
<chmod file="${shared}/*.dll" perm="+x"/>
|
||||
</target>
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,compile-tests"
|
||||
<target name="test" depends="jar,compile-tests" unless="cross-compile"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="reports.junit" location="${reports}/junit"/>
|
||||
@@ -590,7 +801,15 @@
|
||||
<property name="tests.platform" value=""/>
|
||||
<property name="tests.exclude" value=""/>
|
||||
<property name="tests.exclude-patterns" value=""/>
|
||||
<condition property="java.awt.headless" value="true">
|
||||
<isset property="headless"/>
|
||||
</condition>
|
||||
<propertyset id="headless">
|
||||
<propertyref prefix="java.awt.headless"/>
|
||||
</propertyset>
|
||||
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build}">
|
||||
<!-- optionally run headless -->
|
||||
<syspropertyset refid="headless"/>
|
||||
<!-- avoid VM conflicts with JNA protected mode -->
|
||||
<env key="${ld.preload.name}" file="${libjsig}"/>
|
||||
<sysproperty key="jna.library.path" file="${build.native}"/>
|
||||
@@ -699,152 +918,19 @@
|
||||
|
||||
<arg value="-notimestamp"/>
|
||||
</javadoc>
|
||||
<jar jarfile="${platform-javadoc-jar}">
|
||||
<fileset dir="${javadoc}" />
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="jar,javadoc,contrib-jars,compile-tests,native"
|
||||
description="Build distribution files">
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${build}">
|
||||
<include name="${native.jar}"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<jar jarfile="${maven-jar}" duplicate="preserve">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!--
|
||||
OSGi Bundle attributes
|
||||
see http://www.osgi.org/Specifications/Reference
|
||||
-->
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32"/>
|
||||
<!-- Note that no terminal "*" is included in this list,
|
||||
which will force failure on unsupported platforms.
|
||||
-->
|
||||
<attribute name="Bundle-NativeCode"
|
||||
value="
|
||||
com/sun/jna/win32-x86/jnidispatch.dll;
|
||||
processor=x86;osname=win32,
|
||||
com/sun/jna/win32-amd64/jnidispatch.dll;
|
||||
processor=x86-64;osname=win32,
|
||||
com/sun/jna/w32ce-arm/jnidispatch.dll;
|
||||
processor=arm;osname=wince,
|
||||
|
||||
com/sun/jna/sunos-x86/libjnidispatch.so;
|
||||
processor=x86;osname=sunos,
|
||||
com/sun/jna/sunos-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=sunos,
|
||||
com/sun/jna/sunos-sparc/libjnidispatch.so;
|
||||
processor=sparc;osname=sunos,
|
||||
com/sun/jna/sunos-sparcv9/libjnidispatch.so;
|
||||
processor=sparcv9;osname=sunos,
|
||||
|
||||
com/sun/jna/aix-ppc/libjnidispatch.a;
|
||||
processor=ppc;osname=aix,
|
||||
com/sun/jna/aix-ppc64/libjnidispatch.a;
|
||||
processor=ppc64;osname=aix,
|
||||
|
||||
com/sun/jna/linux-ppc/libjnidispatch.so;
|
||||
processor=ppc;osname=linux,
|
||||
com/sun/jna/linux-ppc64/libjnidispatch.so;
|
||||
processor=ppc64;osname=linux,
|
||||
com/sun/jna/linux-i386/libjnidispatch.so;
|
||||
processor=x86;osname=linux,
|
||||
com/sun/jna/linux-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=linux,
|
||||
com/sun/jna/linux-arm/libjnidispatch.so;
|
||||
processor=arm;osname=linux,
|
||||
com/sun/jna/linux-ia64/libjnidispatch.so;
|
||||
processor=ia64;osname=linux,
|
||||
|
||||
com/sun/jna/openbsd-i386/libjnidispatch.so;
|
||||
processor=x86;osname=openbsd,
|
||||
com/sun/jna/freebsd-i386/libjnidispatch.so;
|
||||
processor=x86;osname=freebsd,
|
||||
com/sun/jna/freebsd-amd64/libjnidispatch.so;
|
||||
processor=x86-64;osname=freebsd,
|
||||
|
||||
com/sun/jna/darwin/libjnidispatch.jnilib;
|
||||
osname=macos,
|
||||
"/>
|
||||
|
||||
</section>
|
||||
</manifest>
|
||||
<zipfileset src="${build}/${jar}"/>
|
||||
<zipfileset src="${dist}/win32-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-x86"/>
|
||||
<zipfileset src="${dist}/aix-ppc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/aix-ppc"/>
|
||||
<zipfileset src="${dist}/aix-ppc64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/aix-ppc64"/>
|
||||
<zipfileset src="${dist}/darwin.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/darwin"/>
|
||||
<zipfileset src="${dist}/linux-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-i386"/>
|
||||
<zipfileset src="${dist}/linux-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-amd64"/>
|
||||
<zipfileset src="${dist}/linux-arm.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-arm"/>
|
||||
<zipfileset src="${dist}/linux-ia64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ia64"/>
|
||||
<zipfileset src="${dist}/linux-ppc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ppc"/>
|
||||
<zipfileset src="${dist}/linux-ppc64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/linux-ppc64"/>
|
||||
<zipfileset src="${dist}/sunos-x86.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-x86"/>
|
||||
<zipfileset src="${dist}/sunos-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-amd64"/>
|
||||
<zipfileset src="${dist}/sunos-sparc.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparc"/>
|
||||
<zipfileset src="${dist}/sunos-sparcv9.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/sunos-sparcv9"/>
|
||||
<zipfileset src="${dist}/freebsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-i386"/>
|
||||
<zipfileset src="${dist}/freebsd-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/freebsd-amd64"/>
|
||||
<zipfileset src="${dist}/openbsd-i386.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/openbsd-i386"/>
|
||||
<zipfileset src="${dist}/win32-amd64.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/win32-amd64"/>
|
||||
<zipfileset src="${dist}/w32ce-arm.jar"
|
||||
includes="*jnidispatch*"
|
||||
prefix="com/sun/jna/w32ce-arm"/>
|
||||
</jar>
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${contrib}/platform/dist">
|
||||
<include name="platform.jar" />
|
||||
<fileset dir="${build}" includes="${jar},${minjar}"/>
|
||||
<fileset dir="${contrib}/platform/dist" includes="platform.jar"/>
|
||||
<fileset dir="${lib.native}">
|
||||
<include name="*.jar"/>
|
||||
<exclude name="out-of-date.jar"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${dist}/jnacontrib" flatten="true">
|
||||
@@ -856,6 +942,10 @@ osname=macos,
|
||||
<fileset dir="${javadoc}" />
|
||||
</jar>
|
||||
|
||||
<zip zipfile="${dist}/doc.zip">
|
||||
<zipfileset dir="${javadoc}" prefix="javadoc"/>
|
||||
</zip>
|
||||
<!-- Javadoc -->
|
||||
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
|
||||
<zip zipfile="${dist}/src.zip">
|
||||
<zipfileset dir="." includes="build.xml,${pom},LICENSE.txt"/>
|
||||
@@ -873,8 +963,7 @@ osname=macos,
|
||||
</zip>
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${maven-sources-jar}">
|
||||
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
|
||||
<zipfileset dir="${src}" />
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
@@ -892,79 +981,103 @@ osname=macos,
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="deploy" depends="dist,platform-jar" description="deploy snapshot version to Maven snapshot repository">
|
||||
<artifact:mvn>
|
||||
|
||||
<path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
|
||||
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
|
||||
uri="antlib:org.apache.maven.artifact.ant"
|
||||
classpathref="maven-ant-tasks.classpath" />
|
||||
|
||||
<!-- NOTE: The 'deploy' target works only if the version (jna.version in build.xml) ends in '-SNAPSHOT'. -->
|
||||
<target name="deploy" depends="dist" description="deploy snapshot version to Maven snapshot repository">
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/>
|
||||
<arg value="-Durl=${maven-snapshots-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-snapshots-repository-id}"/>
|
||||
<arg value="-DpomFile=${pom}"/>
|
||||
<arg value="-Dfile=${maven-jar}"/>
|
||||
<arg value="-Dfile=${dist-jar}"/>
|
||||
<arg value="-Dfiles=${maven-sources-jar},${maven-javadoc-jar}"/>
|
||||
<arg value="-Dtypes=jar,jar"/>
|
||||
<arg value="-Dclassifiers=sources,javadoc"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file"/>
|
||||
<arg value="-Durl=${maven-snapshots-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-snapshots-repository-id}"/>
|
||||
<arg value="-DpomFile=${pom-platform}"/>
|
||||
<arg value="-Dfile=${platform-jar}"/>
|
||||
<arg value="-Dfiles=${platform-sources-jar},${platform-javadoc-jar}"/>
|
||||
<arg value="-Dtypes=jar,jar"/>
|
||||
<arg value="-Dclassifiers=sources,javadoc"/>
|
||||
</artifact:mvn>
|
||||
</target>
|
||||
|
||||
<!-- before this, update project version (both build.xml and ${pom}) from SNAPSHOT to RELEASE -->
|
||||
|
||||
<property name="version-maven-gpg-plugin" value="1.4"/>
|
||||
|
||||
<target name="stage" depends="dist" description="deploy release version to Maven staging repository">
|
||||
<!-- sign and deploy the main artifact -->
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the jna artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=${pom}"/>
|
||||
<arg value="-Dfile=${maven-jar}"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dfile=${dist-jar}"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<!-- sign and deploy the sources artifact -->
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the jna sources artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=${pom}"/>
|
||||
<arg value="-Dfile=${maven-sources-jar}"/>
|
||||
<arg value="-Dclassifier=sources"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<!-- sign and deploy the javadoc artifact -->
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the jna javadoc artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=${pom}"/>
|
||||
<arg value="-Dfile=${maven-javadoc-jar}"/>
|
||||
<arg value="-Dclassifier=javadoc"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the platform artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=pom-platform.xml"/>
|
||||
<arg value="-DpomFile=${pom-platform}"/>
|
||||
<arg value="-Dfile=${platform-jar}"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<!-- sign and deploy the sources artifact -->
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the platform sources artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=pom-platform.xml"/>
|
||||
<arg value="-DpomFile=${pom-platform}"/>
|
||||
<arg value="-Dfile=${platform-sources-jar}"/>
|
||||
<arg value="-Dclassifier=sources"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
<!-- sign and deploy the javadoc artifact -->
|
||||
<artifact:mvn>
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.4:sign-and-deploy-file"/>
|
||||
<!-- sign and deploy the platform javadoc artifact -->
|
||||
<artifact:mvn failonerror="true">
|
||||
<arg value="org.apache.maven.plugins:maven-gpg-plugin:${version-maven-gpg-plugin}:sign-and-deploy-file"/>
|
||||
<arg value="-Durl=${maven-staging-repository-url}"/>
|
||||
<arg value="-DrepositoryId=${maven-staging-repository-id}"/>
|
||||
<arg value="-DpomFile=pom-platform.xml"/>
|
||||
<arg value="-DpomFile=${pom-platform}"/>
|
||||
<arg value="-Dfile=${platform-javadoc-jar}"/>
|
||||
<arg value="-Dclassifier=javadoc"/>
|
||||
<arg value="-Pgpg"/>
|
||||
<arg value="-Dgpg.useagent=true"/>
|
||||
</artifact:mvn>
|
||||
|
||||
</target>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
@@ -37,7 +36,6 @@
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
@@ -45,29 +43,24 @@
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -154,7 +154,7 @@ public class AlphaMaskDemo implements Runnable {
|
||||
int w = image.getWidth(null);
|
||||
int h = image.getHeight(null);
|
||||
alphaWindow.setSize(w, h);
|
||||
if (buffer == null || buffer.getSize() != w*h*4) {
|
||||
if (buffer == null || buffer.size() != w*h*4) {
|
||||
buffer = new com.sun.jna.Memory(w*h*4);
|
||||
pixels = new int[w*h];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
@@ -37,7 +36,6 @@
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
@@ -45,29 +43,26 @@
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
@@ -37,7 +36,6 @@
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
@@ -45,29 +43,26 @@
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
@@ -37,7 +36,6 @@
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
@@ -45,29 +43,26 @@
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com"/>
|
||||
<!-- jna -->
|
||||
<zipfileset src="${file.reference.jna.jar}"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>msoffice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/com/sun/jna/platform/win32/office/MSWord.java=UTF-8
|
||||
Arquivo binário não exibido.
Arquivo binário não exibido.
@@ -0,0 +1,36 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils.COMInfo;
|
||||
|
||||
public class COMInfoUtil {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String filename = "C:\\TEMP\\CLSIDs.txt";
|
||||
ArrayList<COMInfo> comInfos = COMUtils.getAllCOMInfoOnSystem();
|
||||
FileWriter writer = new FileWriter(filename);
|
||||
|
||||
for (COMInfo comInfo : comInfos) {
|
||||
String result = "CLSID: " + comInfo.clsid + "\n";
|
||||
result += "InprocHandler32: " + comInfo.inprocHandler32 + "\n";
|
||||
result += "InprocServer32: " + comInfo.inprocServer32 + "\n";
|
||||
result += "LocalServer32: " + comInfo.localServer32 + "\n";
|
||||
result += "ProgID: " + comInfo.progID + "\n";
|
||||
result += "ProgTypeLibID: " + comInfo.typeLib + "\n";
|
||||
|
||||
writer.write(result + "\n");
|
||||
}
|
||||
|
||||
System.out.println("file written to: " + filename);
|
||||
System.out.println("Found CLSID`s on the system: "
|
||||
+ comInfos.size());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMObject;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
|
||||
public class MSExcel extends COMObject {
|
||||
|
||||
public MSExcel() throws COMException {
|
||||
super("Excel.Application", false);
|
||||
}
|
||||
|
||||
public MSExcel(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(Variant.VARIANT_TRUE);
|
||||
}
|
||||
|
||||
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
|
||||
"Visible", new VARIANT(bVisible));
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Version");
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
public HRESULT newExcelBook() throws COMException {
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
|
||||
.getIDispatch(), "Add");
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT openExcelBook(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
|
||||
VARIANT varFilename = new VARIANT(bstrFilename);
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null, getWorkbooks()
|
||||
.getIDispatch(), "Open", varFilename);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT closeActiveWorkbook(VARIANT_BOOL bSave) throws COMException {
|
||||
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getActiveWorkbook().getIDispatch(), "Close", new VARIANT(bSave));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT quit() throws COMException {
|
||||
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
this.iDispatch, "Quit");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT insertValue(String range, String value) throws COMException {
|
||||
HRESULT hr;
|
||||
|
||||
BSTR bstrRange = OleAuto.INSTANCE.SysAllocString(range);
|
||||
VARIANT varRange = new VARIANT(bstrRange);
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this
|
||||
.getActiveSheet().getIDispatch(), "Range", varRange);
|
||||
Range pRange = new Range((IDispatch) result.getValue());
|
||||
|
||||
BSTR bstrValue = OleAuto.INSTANCE.SysAllocString(value);
|
||||
VARIANT varText = new VARIANT(bstrValue);
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYPUT, null,
|
||||
pRange.getIDispatch(), "Value", varText);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "Application");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Application((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public ActiveWorkbook getActiveWorkbook() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "ActiveWorkbook");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveWorkbook((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Workbooks getWorkbooks() {
|
||||
// GetDocuments
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "WorkBooks");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Workbooks((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public ActiveSheet getActiveSheet() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "ActiveSheet");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveSheet((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public class Application extends COMObject {
|
||||
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Workbooks extends COMObject {
|
||||
|
||||
public Workbooks(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveWorkbook extends COMObject {
|
||||
|
||||
public ActiveWorkbook(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveSheet extends COMObject {
|
||||
|
||||
public ActiveSheet(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Range extends COMObject {
|
||||
|
||||
public Range(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
|
||||
public class MSOfficeDemo {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new MSOfficeDemo();
|
||||
}
|
||||
|
||||
private String currentWorkingDir = new File("").getAbsolutePath()
|
||||
+ File.separator;
|
||||
|
||||
public MSOfficeDemo() {
|
||||
//this.testMSWord();
|
||||
this.testMSExcel();
|
||||
}
|
||||
|
||||
public void testMSWord() {
|
||||
MSWord msWord = null;
|
||||
|
||||
try {
|
||||
msWord = new MSWord();
|
||||
System.out.println("MSWord version: " + msWord.getVersion());
|
||||
msWord.setVisible(Variant.VARIANT_TRUE);
|
||||
msWord.newDocument();
|
||||
//msWord.openDocument(currentWorkingDir + "jnatest.doc", true);
|
||||
msWord.insertText("Hello from JNA!");
|
||||
// close and save the document
|
||||
msWord.closeActiveDocument(Variant.VARIANT_TRUE);
|
||||
// wait then close word
|
||||
msWord.quit();
|
||||
} catch (COMException e) {
|
||||
if (e.getExcepInfo() != null) {
|
||||
System.out
|
||||
.println("bstrSource: " + e.getExcepInfo().bstrSource);
|
||||
System.out.println("bstrDescription: "
|
||||
+ e.getExcepInfo().bstrDescription);
|
||||
} else
|
||||
e.printStackTrace();
|
||||
|
||||
if(msWord != null)
|
||||
msWord.quit();
|
||||
}
|
||||
}
|
||||
|
||||
public void testMSExcel() {
|
||||
MSExcel msExcel = null;
|
||||
|
||||
try {
|
||||
msExcel = new MSExcel();
|
||||
System.out.println("MSExcel version: " + msExcel.getVersion());
|
||||
msExcel.setVisible(Variant.VARIANT_TRUE);
|
||||
//msExcel.newExcelBook();
|
||||
msExcel.openExcelBook(currentWorkingDir + "jnatest.xls", true);
|
||||
msExcel.insertValue("A1", "Hello from JNA!");
|
||||
// close and save the active sheet
|
||||
msExcel.closeActiveWorkbook(Variant.VARIANT_TRUE);
|
||||
// wait then close excel
|
||||
msExcel.quit();
|
||||
} catch (COMException e) {
|
||||
if (e.getExcepInfo() != null) {
|
||||
System.out
|
||||
.println("bstrSource: " + e.getExcepInfo().bstrSource);
|
||||
System.out.println("bstrDescription: "
|
||||
+ e.getExcepInfo().bstrDescription);
|
||||
} else
|
||||
e.printStackTrace();
|
||||
|
||||
if(msExcel != null)
|
||||
msExcel.quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.sun.jna.platform.win32.office;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.Variant;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.COMObject;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
|
||||
public class MSWord extends COMObject {
|
||||
|
||||
public MSWord() throws COMException {
|
||||
super("Word.Application", false);
|
||||
}
|
||||
|
||||
public MSWord(boolean visible) throws COMException {
|
||||
this();
|
||||
this.setVisible(Variant.VARIANT_TRUE);
|
||||
}
|
||||
|
||||
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
|
||||
"Visible", new VARIANT(bVisible));
|
||||
}
|
||||
|
||||
public String getVersion() throws COMException {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Version");
|
||||
|
||||
return result.getValue().toString();
|
||||
}
|
||||
|
||||
public HRESULT newDocument() throws COMException {
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getDocuments().getIDispatch(), "Add");
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT openDocument(String filename, boolean bVisible)
|
||||
throws COMException {
|
||||
// OpenDocument
|
||||
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
|
||||
VARIANT varFilename = new VARIANT(bstrFilename);
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getDocuments().getIDispatch(), "Open", varFilename);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT closeActiveDocument(VARIANT_BOOL bSave)
|
||||
throws COMException {
|
||||
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
getActiveDocument().getIDispatch(), "Close", new VARIANT(bSave));
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT quit() throws COMException {
|
||||
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
this.iDispatch, "Quit");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
public HRESULT insertText(String text) throws COMException {
|
||||
HRESULT hr;
|
||||
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
|
||||
this.iDispatch, "Selection");
|
||||
Selection pSelection = new Selection((IDispatch) result.getValue());
|
||||
|
||||
BSTR bstrText = OleAuto.INSTANCE.SysAllocString(text);
|
||||
VARIANT varText = new VARIANT(bstrText);
|
||||
hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
|
||||
pSelection.getIDispatch(), "TypeText", varText);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
public ActiveDocument getActiveDocument() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"ActiveDocument");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new ActiveDocument((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Documents getDocuments() {
|
||||
// GetDocuments
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Documents");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Documents((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public Application getApplication() {
|
||||
VARIANT.ByReference result = new VARIANT.ByReference();
|
||||
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
|
||||
"Application");
|
||||
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return new Application((IDispatch) result.getValue());
|
||||
}
|
||||
|
||||
public class Application extends COMObject {
|
||||
|
||||
public Application(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Documents extends COMObject {
|
||||
|
||||
public Documents(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class ActiveDocument extends COMObject {
|
||||
|
||||
public ActiveDocument(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
|
||||
public class Selection extends COMObject {
|
||||
|
||||
public Selection(IDispatch iDispatch) throws COMException {
|
||||
super(iDispatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
|
||||
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>native_window_msg</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,313 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.DBT;
|
||||
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_DEVICEINTERFACE;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinDef.HMODULE;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||
import com.sun.jna.platform.win32.WinDef.LRESULT;
|
||||
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
|
||||
import com.sun.jna.platform.win32.WinUser.MSG;
|
||||
import com.sun.jna.platform.win32.WinUser.WNDCLASSEX;
|
||||
import com.sun.jna.platform.win32.WinUser.WindowProc;
|
||||
import com.sun.jna.platform.win32.Wtsapi32;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Win32WindowTest.
|
||||
*/
|
||||
public class Win32WindowDemo implements WindowProc {
|
||||
|
||||
/**
|
||||
* Instantiates a new win32 window test.
|
||||
*/
|
||||
public Win32WindowDemo() {
|
||||
// define new window class
|
||||
WString windowClass = new WString("MyWindowClass");
|
||||
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
|
||||
|
||||
WNDCLASSEX wClass = new WNDCLASSEX();
|
||||
wClass.hInstance = hInst;
|
||||
wClass.lpfnWndProc = Win32WindowDemo.this;
|
||||
wClass.lpszClassName = windowClass;
|
||||
|
||||
// register window class
|
||||
User32.INSTANCE.RegisterClassEx(wClass);
|
||||
getLastError();
|
||||
|
||||
// create new window
|
||||
HWND hWnd = User32.INSTANCE
|
||||
.CreateWindowEx(
|
||||
User32.WS_EX_TOPMOST,
|
||||
windowClass,
|
||||
"My hidden helper window, used only to catch the windows events",
|
||||
0, 0, 0, 0, 0, WinUser.HWND_MESSAGE, null, hInst, null);
|
||||
|
||||
getLastError();
|
||||
System.out.println("window sucessfully created! window hwnd: "
|
||||
+ hWnd.getPointer().toString());
|
||||
|
||||
Wtsapi32.INSTANCE.WTSRegisterSessionNotification(hWnd,
|
||||
Wtsapi32.NOTIFY_FOR_THIS_SESSION);
|
||||
|
||||
/* this filters for all device classes */
|
||||
// DEV_BROADCAST_HDR notificationFilter = new DEV_BROADCAST_HDR();
|
||||
// notificationFilter.dbch_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
|
||||
|
||||
/* this filters for all usb device classes */
|
||||
DEV_BROADCAST_DEVICEINTERFACE notificationFilter = new DEV_BROADCAST_DEVICEINTERFACE();
|
||||
notificationFilter.dbcc_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
|
||||
notificationFilter.dbcc_classguid = DBT.GUID_DEVINTERFACE_USB_DEVICE;
|
||||
|
||||
/*
|
||||
* use User32.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES instead of
|
||||
* DEVICE_NOTIFY_WINDOW_HANDLE to ignore the dbcc_classguid value
|
||||
*/
|
||||
HDEVNOTIFY hDevNotify = User32.INSTANCE.RegisterDeviceNotification(
|
||||
hWnd, notificationFilter, User32.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
getLastError();
|
||||
if (hDevNotify != null)
|
||||
System.out.println("RegisterDeviceNotification was sucessfully!");
|
||||
|
||||
MSG msg = new MSG();
|
||||
while (User32.INSTANCE.GetMessage(msg, hWnd, 0, 0) != 0) {
|
||||
User32.INSTANCE.TranslateMessage(msg);
|
||||
User32.INSTANCE.DispatchMessage(msg);
|
||||
}
|
||||
|
||||
User32.INSTANCE.UnregisterDeviceNotification(hDevNotify);
|
||||
Wtsapi32.INSTANCE.WTSUnRegisterSessionNotification(hWnd);
|
||||
User32.INSTANCE.UnregisterClass(windowClass, hInst);
|
||||
User32.INSTANCE.DestroyWindow(hWnd);
|
||||
|
||||
System.out.println("program exit!");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.sun.jna.platform.win32.User32.WindowProc#callback(com.sun.jna.platform
|
||||
* .win32.WinDef.HWND, int, com.sun.jna.platform.win32.WinDef.WPARAM,
|
||||
* com.sun.jna.platform.win32.WinDef.LPARAM)
|
||||
*/
|
||||
public LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WinUser.WM_CREATE: {
|
||||
onCreate(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_DESTROY: {
|
||||
User32.INSTANCE.PostQuitMessage(0);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_SESSION_CHANGE: {
|
||||
this.onSessionChange(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
case WinUser.WM_DEVICECHANGE: {
|
||||
this.onDeviceChange(wParam, lParam);
|
||||
return new LRESULT(0);
|
||||
}
|
||||
default:
|
||||
return User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last error.
|
||||
*
|
||||
* @return the last error
|
||||
*/
|
||||
public int getLastError() {
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
if (rc != 0)
|
||||
System.out.println("error: " + rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* On session change.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
*/
|
||||
protected void onSessionChange(WPARAM wParam, LPARAM lParam) {
|
||||
switch (wParam.intValue()) {
|
||||
case Wtsapi32.WTS_CONSOLE_CONNECT: {
|
||||
this.onConsoleConnect(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_CONSOLE_DISCONNECT: {
|
||||
this.onConsoleDisconnect(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOGON: {
|
||||
this.onMachineLogon(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOGOFF: {
|
||||
this.onMachineLogoff(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_LOCK: {
|
||||
this.onMachineLocked(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
case Wtsapi32.WTS_SESSION_UNLOCK: {
|
||||
this.onMachineUnlocked(lParam.intValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On console connect.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onConsoleConnect(int sessionId) {
|
||||
System.out.println("onConsoleConnect: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On console disconnect.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onConsoleDisconnect(int sessionId) {
|
||||
System.out.println("onConsoleDisconnect: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine locked.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLocked(int sessionId) {
|
||||
System.out.println("onMachineLocked: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine unlocked.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineUnlocked(int sessionId) {
|
||||
System.out.println("onMachineUnlocked: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine logon.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLogon(int sessionId) {
|
||||
System.out.println("onMachineLogon: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On machine logoff.
|
||||
*
|
||||
* @param sessionId
|
||||
* the session id
|
||||
*/
|
||||
protected void onMachineLogoff(int sessionId) {
|
||||
System.out.println("onMachineLogoff: " + sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* On device change.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
*/
|
||||
protected void onDeviceChange(WPARAM wParam, LPARAM lParam) {
|
||||
//
|
||||
// This is the actual message from the interface via Windows messaging.
|
||||
// This code includes some additional decoding for this particular
|
||||
// device type
|
||||
// and some common validation checks.
|
||||
//
|
||||
// Note that not all devices utilize these optional parameters in the
|
||||
// same
|
||||
// way. Refer to the extended information for your particular device
|
||||
// type
|
||||
// specified by your GUID.
|
||||
//
|
||||
DEV_BROADCAST_DEVICEINTERFACE bdif = new DEV_BROADCAST_DEVICEINTERFACE(
|
||||
lParam.longValue());
|
||||
System.out.println("dbcc_devicetype: " + bdif.dbcc_devicetype);
|
||||
System.out.println("dbcc_name: " + bdif.getDbcc_name());
|
||||
System.out.println("dbcc_classguid: "
|
||||
+ bdif.dbcc_classguid.toGuidString());
|
||||
|
||||
// Output some messages to the window.
|
||||
switch (wParam.intValue()) {
|
||||
case DBT.DBT_DEVICEARRIVAL:
|
||||
System.out.println("Message DBT_DEVICEARRIVAL");
|
||||
break;
|
||||
case DBT.DBT_DEVICEREMOVECOMPLETE:
|
||||
System.out.println("Message DBT_DEVICEREMOVECOMPLETE");
|
||||
break;
|
||||
case DBT.DBT_DEVNODES_CHANGED:
|
||||
System.out.println("Message DBT_DEVNODES_CHANGED");
|
||||
break;
|
||||
default:
|
||||
System.out
|
||||
.println("Message WM_DEVICECHANGE message received, value unhandled.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On create.
|
||||
*
|
||||
* @param wParam
|
||||
* the w param
|
||||
* @param lParam
|
||||
* the l param
|
||||
*/
|
||||
protected void onCreate(WPARAM wParam, LPARAM lParam) {
|
||||
System.out.println("onCreate: WM_CREATE");
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new Win32WindowDemo();
|
||||
}
|
||||
}
|
||||
@@ -9,204 +9,188 @@
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.*;
|
||||
import com.sun.jna.win32.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenSCManager(
|
||||
LPCTSTR lpMachineName,
|
||||
LPCTSTR lpDatabaseName,
|
||||
DWORD dwDesiredAccess
|
||||
);*/
|
||||
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName, int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
BOOL WINAPI CloseServiceHandle(
|
||||
SC_HANDLE hSCObject
|
||||
);*/
|
||||
public boolean CloseServiceHandle(Pointer hSCObject);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenService(
|
||||
SC_HANDLE hSCManager,
|
||||
LPCTSTR lpServiceName,
|
||||
DWORD dwDesiredAccess
|
||||
);*/
|
||||
public Pointer OpenService(Pointer hSCManager, String lpServiceName, int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
BOOL WINAPI StartService(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwNumServiceArgs,
|
||||
LPCTSTR* lpServiceArgVectors
|
||||
);*/
|
||||
public boolean StartService(Pointer hService, int dwNumServiceArgs, char[] lpServiceArgVectors);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ControlService(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwControl,
|
||||
LPSERVICE_STATUS lpServiceStatus
|
||||
);*/
|
||||
public boolean ControlService(Pointer hService, int dwControl, SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
BOOL WINAPI StartServiceCtrlDispatcher(
|
||||
const SERVICE_TABLE_ENTRY* lpServiceTable
|
||||
);*/
|
||||
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
|
||||
|
||||
/*
|
||||
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler(
|
||||
LPCTSTR lpServiceName,
|
||||
LPHANDLER_FUNCTION lpHandlerProc
|
||||
);*/
|
||||
public Pointer RegisterServiceCtrlHandler(String lpServiceName, Handler lpHandlerProc);
|
||||
|
||||
/*
|
||||
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx(
|
||||
LPCTSTR lpServiceName,
|
||||
LPHANDLER_FUNCTION_EX lpHandlerProc,
|
||||
LPVOID lpContext
|
||||
);*/
|
||||
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName, HandlerEx lpHandlerProc, Pointer lpContext);
|
||||
|
||||
/*
|
||||
BOOL WINAPI SetServiceStatus(
|
||||
SERVICE_STATUS_HANDLE hServiceStatus,
|
||||
LPSERVICE_STATUS lpServiceStatus
|
||||
);*/
|
||||
public boolean SetServiceStatus(Pointer hServiceStatus, SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI CreateService(
|
||||
SC_HANDLE hSCManager,
|
||||
LPCTSTR lpServiceName,
|
||||
LPCTSTR lpDisplayName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwServiceType,
|
||||
DWORD dwStartType,
|
||||
DWORD dwErrorControl,
|
||||
LPCTSTR lpBinaryPathName,
|
||||
LPCTSTR lpLoadOrderGroup,
|
||||
LPDWORD lpdwTagId,
|
||||
LPCTSTR lpDependencies,
|
||||
LPCTSTR lpServiceStartName,
|
||||
LPCTSTR lpPassword
|
||||
);*/
|
||||
public Pointer CreateService(Pointer hSCManager, String lpServiceName, String lpDisplayName,
|
||||
int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl,
|
||||
String lpBinaryPathName, String lpLoadOrderGroup, IntByReference lpdwTagId,
|
||||
String lpDependencies, String lpServiceStartName, String lpPassword);
|
||||
|
||||
/*
|
||||
BOOL WINAPI DeleteService(
|
||||
SC_HANDLE hService
|
||||
);*/
|
||||
public boolean DeleteService(Pointer hService);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ChangeServiceConfig2(
|
||||
SC_HANDLE hService,
|
||||
DWORD dwInfoLevel,
|
||||
LPVOID lpInfo
|
||||
);*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumValue(
|
||||
HKEY hKey,
|
||||
DWORD dwIndex,
|
||||
LPTSTR lpValueName,
|
||||
LPDWORD lpcchValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);*/
|
||||
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
|
||||
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
|
||||
/*
|
||||
VOID WINAPI ServiceMain(
|
||||
DWORD dwArgc,
|
||||
LPTSTR* lpszArgv
|
||||
);*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv);
|
||||
}
|
||||
* SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR
|
||||
* lpDatabaseName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
interface Handler extends StdCallCallback {
|
||||
/*
|
||||
VOID WINAPI Handler(
|
||||
DWORD fdwControl
|
||||
);*/
|
||||
public void callback(int fdwControl);
|
||||
}
|
||||
|
||||
interface HandlerEx extends StdCallCallback {
|
||||
* BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
|
||||
*/
|
||||
public boolean CloseServiceHandle(Pointer hSCObject);
|
||||
|
||||
/*
|
||||
DWORD WINAPI HandlerEx(
|
||||
DWORD dwControl,
|
||||
DWORD dwEventType,
|
||||
LPVOID lpEventData,
|
||||
LPVOID lpContext
|
||||
);*/
|
||||
public int callback(int dwControl, int dwEventType, Pointer lpEventData, Pointer lpContext);
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_STATUS {
|
||||
DWORD dwServiceType;
|
||||
DWORD dwCurrentState;
|
||||
DWORD dwControlsAccepted;
|
||||
DWORD dwWin32ExitCode;
|
||||
DWORD dwServiceSpecificExitCode;
|
||||
DWORD dwCheckPoint;
|
||||
DWORD dwWaitHint;
|
||||
} SERVICE_STATUS,
|
||||
*LPSERVICE_STATUS;*/
|
||||
public static class SERVICE_STATUS extends Structure {
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_TABLE_ENTRY {
|
||||
LPTSTR lpServiceName;
|
||||
LPSERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
} SERVICE_TABLE_ENTRY,
|
||||
*LPSERVICE_TABLE_ENTRY;*/
|
||||
public static class SERVICE_TABLE_ENTRY extends Structure {
|
||||
public String lpServiceName;
|
||||
public SERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
}
|
||||
|
||||
public static class ChangeServiceConfig2Info extends Structure {
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct _SERVICE_DESCRIPTION {
|
||||
LPTSTR lpDescription;
|
||||
} SERVICE_DESCRIPTION,
|
||||
*LPSERVICE_DESCRIPTION;*/
|
||||
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
|
||||
public String lpDescription;
|
||||
}
|
||||
* SC_HANDLE WINAPI OpenService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, DWORD dwDesiredAccess );
|
||||
*/
|
||||
public Pointer OpenService(Pointer hSCManager, String lpServiceName,
|
||||
int dwDesiredAccess);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartService( SC_HANDLE hService, DWORD dwNumServiceArgs,
|
||||
* LPCTSTR* lpServiceArgVectors );
|
||||
*/
|
||||
public boolean StartService(Pointer hService, int dwNumServiceArgs,
|
||||
char[] lpServiceArgVectors);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean ControlService(Pointer hService, int dwControl,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI StartServiceCtrlDispatcher( const SERVICE_TABLE_ENTRY*
|
||||
* lpServiceTable );
|
||||
*/
|
||||
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION lpHandlerProc );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandler(String lpServiceName,
|
||||
Handler lpHandlerProc);
|
||||
|
||||
/*
|
||||
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( LPCTSTR
|
||||
* lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext );
|
||||
*/
|
||||
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName,
|
||||
HandlerEx lpHandlerProc, Pointer lpContext);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus,
|
||||
* LPSERVICE_STATUS lpServiceStatus );
|
||||
*/
|
||||
public boolean SetServiceStatus(Pointer hServiceStatus,
|
||||
SERVICE_STATUS lpServiceStatus);
|
||||
|
||||
/*
|
||||
* SC_HANDLE WINAPI CreateService( SC_HANDLE hSCManager, LPCTSTR
|
||||
* lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD
|
||||
* dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR
|
||||
* lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR
|
||||
* lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword );
|
||||
*/
|
||||
public Pointer CreateService(Pointer hSCManager, String lpServiceName,
|
||||
String lpDisplayName, int dwDesiredAccess, int dwServiceType,
|
||||
int dwStartType, int dwErrorControl, String lpBinaryPathName,
|
||||
String lpLoadOrderGroup, IntByReference lpdwTagId,
|
||||
String lpDependencies, String lpServiceStartName, String lpPassword);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI DeleteService( SC_HANDLE hService );
|
||||
*/
|
||||
public boolean DeleteService(Pointer hService);
|
||||
|
||||
/*
|
||||
* BOOL WINAPI ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel,
|
||||
* LPVOID lpInfo );
|
||||
*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel,
|
||||
ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
* LONG WINAPI RegEnumValue( HKEY hKey, DWORD dwIndex, LPTSTR lpValueName,
|
||||
* LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE
|
||||
* lpData, LPDWORD lpcbData );
|
||||
*/
|
||||
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName,
|
||||
IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv );
|
||||
*/
|
||||
public void callback(int dwArgc, Pointer lpszArgv);
|
||||
}
|
||||
|
||||
interface Handler extends StdCallCallback {
|
||||
/*
|
||||
* VOID WINAPI Handler( DWORD fdwControl );
|
||||
*/
|
||||
public void callback(int fdwControl);
|
||||
}
|
||||
|
||||
interface HandlerEx extends StdCallCallback {
|
||||
/*
|
||||
* DWORD WINAPI HandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID
|
||||
* lpEventData, LPVOID lpContext );
|
||||
*/
|
||||
public int callback(int dwControl, int dwEventType,
|
||||
Pointer lpEventData, Pointer lpContext);
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD
|
||||
* dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD
|
||||
* dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; }
|
||||
* SERVICE_STATUS,LPSERVICE_STATUS;
|
||||
*/
|
||||
public static class SERVICE_STATUS extends Structure {
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_TABLE_ENTRY { LPTSTR lpServiceName;
|
||||
* LPSERVICE_MAIN_FUNCTION lpServiceProc; } SERVICE_TABLE_ENTRY,
|
||||
* LPSERVICE_TABLE_ENTRY;
|
||||
*/
|
||||
public static class SERVICE_TABLE_ENTRY extends Structure {
|
||||
public String lpServiceName;
|
||||
public SERVICE_MAIN_FUNCTION lpServiceProc;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class ChangeServiceConfig2Info extends Structure {
|
||||
}
|
||||
|
||||
/*
|
||||
* typedef struct _SERVICE_DESCRIPTION { LPTSTR lpDescription; }
|
||||
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
|
||||
*/
|
||||
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
|
||||
public String lpDescription;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lpDescription" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,9 @@
|
||||
<condition property="tests.platform" value="test-osx">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<condition property="tests.platform" value="test-linux">
|
||||
<os family="unix"/>
|
||||
</condition>
|
||||
<target name="test" depends="init,compile-test" description="Run unit tests." if="tests.platform">
|
||||
<antcall target="${tests.platform}" />
|
||||
</target>
|
||||
@@ -86,4 +89,20 @@
|
||||
<echo>No platform tests yet for OSX</echo>
|
||||
</target>
|
||||
<target name="test-win32" depends="-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
|
||||
<target name="test-linux" depends="-pre-test-run-single" >
|
||||
<!-- @todo How to ensure sys prop: jna.nosys=true is seen in tests? -->
|
||||
<!--<property name="test.includes" value="com/sun/jna/platform/**/*.java"/>-->
|
||||
<property name="test.includes" value="com/sun/jna/platform/StructureFieldOrderTest.java"/>
|
||||
|
||||
<property name="javac.includes" value="**/*"/>
|
||||
|
||||
<antcall target="test-single"/>
|
||||
|
||||
<!--
|
||||
<antcall target="test-report"/>
|
||||
<antcall target="-post-test-run"/>
|
||||
<antcall target="-test-browse"/>
|
||||
-->
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -1,59 +1,70 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
file.reference.jna-d64.jar=../../build-d64/jna.jar
|
||||
file.reference.jna-test.jar=../../build/jna-test.jar
|
||||
file.reference.jna-test-d64.jar=../../build-d64/jna-test.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar}:\
|
||||
${file.reference.jna-d64.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${file.reference.jna-test.jar}:\
|
||||
${file.reference.jna-test-d64.jar}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
../../lib/test/reflections-0.9.8.jar:\
|
||||
../../lib/test/guava-11.0.2.jar:\
|
||||
../../lib/test/javassist-3.12.1.GA.jar:\
|
||||
../../lib/test/slf4j-api-1.6.1.jar:\
|
||||
../../lib/test/dom4j-1.6.1.jar:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -17,19 +17,22 @@
|
||||
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/**
|
||||
* Author: Denis Tulskiy
|
||||
* Date: 7/25/11
|
||||
*/
|
||||
public interface Carbon {
|
||||
public interface Carbon extends Library {
|
||||
public static Carbon INSTANCE = (Carbon) Native.loadLibrary("Carbon", Carbon.class);
|
||||
|
||||
public static final int cmdKey = 0x0100;
|
||||
@@ -70,15 +73,17 @@ public interface Carbon {
|
||||
public class EventTypeSpec extends Structure {
|
||||
public int eventClass;
|
||||
public int eventKind;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "eventClass", "eventKind" }); }
|
||||
}
|
||||
|
||||
public static class EventHotKeyID extends Structure {
|
||||
public int signature;
|
||||
public int id;
|
||||
|
||||
public static class ByValue extends EventHotKeyID implements Structure.ByValue {
|
||||
|
||||
}
|
||||
public static class ByValue extends EventHotKeyID implements Structure.ByValue { }
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "signature", "id" }); }
|
||||
}
|
||||
|
||||
public static interface EventHandlerProcPtr extends Callback {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -15,11 +15,15 @@ package com.sun.jna.platform.mac;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
@@ -27,14 +31,30 @@ public class MacFileUtils extends FileUtils {
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public interface FileManager extends Library {
|
||||
|
||||
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
|
||||
|
||||
int kFSFileOperationDefaultOptions = 0;
|
||||
int kFSFileOperationsOverwrite = 0x01;
|
||||
int kFSFileOperationsSkipSourcePermissionErrors = 0x02;
|
||||
int kFSFileOperationsDoNotMoveAcrossVolumes = 0x04;
|
||||
int kFSFileOperationsSkipPreflight = 0x08;
|
||||
|
||||
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
|
||||
int FSPathMoveObjectToTrashSync(String src, PointerByReference target, int options);
|
||||
int kFSPathDefaultOptions = 0x0;
|
||||
int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01;
|
||||
|
||||
class FSRef extends Structure {
|
||||
public byte[] hidden = new byte[80];
|
||||
protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); }
|
||||
}
|
||||
|
||||
// Deprecated; use trashItemAtURL instead:
|
||||
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
|
||||
int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize);
|
||||
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
|
||||
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
|
||||
int FSPathMoveObjectToTrashSync(String source, PointerByReference target, int options);
|
||||
int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options);
|
||||
}
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
@@ -43,11 +63,20 @@ public class MacFileUtils extends FileUtils {
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List<File> failed = new ArrayList<File>();
|
||||
List<String> failed = new ArrayList<String>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
if (FileManager.INSTANCE.FSPathMoveObjectToTrashSync(src.getAbsolutePath(), null, 0) != 0) {
|
||||
failed.add(src);
|
||||
FileManager.FSRef fsref = new FileManager.FSRef();
|
||||
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
|
||||
FileManager.kFSPathMakeRefDoNotFollowLeafSymlink,
|
||||
fsref, null);
|
||||
if (status != 0) {
|
||||
failed.add(src + " (FSRef: " + status + ")");
|
||||
continue;
|
||||
}
|
||||
status = FileManager.INSTANCE.FSMoveObjectToTrashSync(fsref, null, 0);
|
||||
if (status != 0) {
|
||||
failed.add(src + " (" + status + ")");
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.unix;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Callback;
|
||||
import com.sun.jna.FromNativeContext;
|
||||
import com.sun.jna.Library;
|
||||
@@ -277,9 +280,12 @@ public interface X11 extends Library {
|
||||
public short green, greenMask;
|
||||
public short blue, blueMask;
|
||||
public short alpha, alphaMask;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "red", "redMask", "green", "greenMask", "blue", "blueMask", "alpha", "alphaMask" });
|
||||
}
|
||||
}
|
||||
class PictFormat extends NativeLong {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public PictFormat(long value) { super(value); }
|
||||
public PictFormat() { }
|
||||
}
|
||||
@@ -289,6 +295,9 @@ public interface X11 extends Library {
|
||||
public int depth;
|
||||
public XRenderDirectFormat direct;
|
||||
public Colormap colormap;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "id", "type", "depth", "direct", "colormap" });
|
||||
}
|
||||
}
|
||||
int PictTypeIndexed = 0x0;
|
||||
int PictTypeDirect = 0x1;
|
||||
@@ -337,12 +346,18 @@ public interface X11 extends Library {
|
||||
class XInputClassInfoByReference extends Structure implements Structure.ByReference {
|
||||
public byte input_class;
|
||||
public byte event_type_base;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "input_class", "event_type_base" });
|
||||
}
|
||||
}
|
||||
|
||||
class XDeviceByReference extends Structure implements Structure.ByReference {
|
||||
public XID device_id;
|
||||
public int num_classes;
|
||||
public XInputClassInfoByReference classes;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "device_id", "num_classes", "classes" });
|
||||
}
|
||||
}
|
||||
|
||||
X11 INSTANCE = (X11)Native.loadLibrary("X11", X11.class);
|
||||
@@ -370,6 +385,9 @@ public interface X11 extends Library {
|
||||
public int icon_x, icon_y;
|
||||
public Pixmap icon_mask;
|
||||
public XID window_group;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "flags", "input", "initial_state", "icon_pixmap", "icon_window", "icon_x", "icon_y", "icon_mask", "window_group" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -385,6 +403,9 @@ public interface X11 extends Library {
|
||||
public Atom encoding;
|
||||
public int format;
|
||||
public NativeLong nitems;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "value", "encoding", "format", "nitems" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -413,10 +434,14 @@ public interface X11 extends Library {
|
||||
public static class Aspect extends Structure {
|
||||
public int x; // numerator
|
||||
public int y; // denominator
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "x", "y" }); }
|
||||
}
|
||||
public Aspect min_aspect, max_aspect;
|
||||
public int base_width, base_height;
|
||||
public int win_gravity;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "flags", "x", "y", "width", "height", "min_width", "min_height", "max_width", "max_height", "width_inc", "height_inc", "min_aspect", "max_aspect", "base_width", "base_height", "win_gravity" }); }
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -470,6 +495,9 @@ public interface X11 extends Library {
|
||||
public NativeLong do_not_propagate_mask;
|
||||
public boolean override_redirect;
|
||||
public Screen screen;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "x", "y", "width", "height", "border_width", "depth", "visual", "root", "c_class", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "colormap", "map_installed", "map_state", "all_event_masks", "your_event_mask", "do_not_propagate_mask", "override_redirect", "screen" });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -507,6 +535,9 @@ public interface X11 extends Library {
|
||||
public boolean override_redirect;
|
||||
public Colormap colormap;
|
||||
public Cursor cursor;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "background_pixmap", "background_pixel", "border_pixmap", "border_pixel", "bit_gravity", "win_gravity", "backing_store", "backing_planes", "backing_pixel", "save_under", "event_mask", "do_not_propagate_mask", "override_redirect", "colormap", "cursor" });
|
||||
}
|
||||
}
|
||||
|
||||
int XK_0 = 0x30;
|
||||
@@ -549,10 +580,16 @@ public interface X11 extends Library {
|
||||
public NativeLong blue_mask;
|
||||
public int colormap_size;
|
||||
public int bits_per_rgb;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "visual", "visualid", "screen", "depth", "c_class", "red_mask", "green_mask", "blue_mask", "colormap_size", "bits_per_rgb" });
|
||||
}
|
||||
}
|
||||
class XPoint extends Structure {
|
||||
public short x, y;
|
||||
public XPoint() { }
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "x", "y" });
|
||||
}
|
||||
public XPoint() { this((short)0, (short)0); }
|
||||
public XPoint(short x, short y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -561,7 +598,10 @@ public interface X11 extends Library {
|
||||
class XRectangle extends Structure {
|
||||
public short x, y;
|
||||
public short width, height;
|
||||
public XRectangle() { }
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "x", "y", "width", "height" });
|
||||
}
|
||||
public XRectangle() { this((short)0, (short)0, (short)0, (short)0); }
|
||||
public XRectangle(short x, short y, short width, short height) {
|
||||
this.x = x; this.y = y;
|
||||
this.width = width; this.height = height;
|
||||
@@ -705,6 +745,9 @@ public interface X11 extends Library {
|
||||
public Pixmap clip_mask; /* bitmap clipping; other calls for rects */
|
||||
public int dash_offset; /* patterned/dashed line information */
|
||||
public byte dashes;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "function", "plane_mask", "foreground", "background", "line_width", "line_style", "cap_style", "join_style", "fill_style", "fill_rule", "arc_mode", "tile", "stipple", "ts_x_origin", "ts_y_origin", "font", "subwindow_mode", "graphics_exposures", "clip_x_origin", "clip_y_origin", "clip_mask", "dash_offset", "dashes" });
|
||||
}
|
||||
}
|
||||
GC XCreateGC(Display display, Drawable drawable, NativeLong mask, XGCValues values);
|
||||
int XSetFillRule(Display display, GC gc, int fill_rule);
|
||||
@@ -1330,6 +1373,9 @@ public interface X11 extends Library {
|
||||
public int send_event; // true if this came from a SendEvent request
|
||||
public Display display; // Display the event was read from
|
||||
public Window window; // window on which event was requested in event mask
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window" });
|
||||
}
|
||||
}
|
||||
|
||||
class XKeyEvent extends Structure {
|
||||
@@ -1346,6 +1392,9 @@ public interface X11 extends Library {
|
||||
public int state; // key or button mask
|
||||
public int keycode; // detail
|
||||
public int same_screen; // same screen flag
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "keycode", "same_screen" });
|
||||
}
|
||||
}
|
||||
|
||||
class XButtonEvent extends Structure {
|
||||
@@ -1362,6 +1411,9 @@ public interface X11 extends Library {
|
||||
public int state; // key or button mask
|
||||
public int button; // detail
|
||||
public int same_screen; // same screen flag
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "button", "same_screen" });
|
||||
}
|
||||
}
|
||||
|
||||
class XButtonPressedEvent extends XButtonEvent {
|
||||
@@ -1379,6 +1431,9 @@ public interface X11 extends Library {
|
||||
public Atom message_type;
|
||||
public int format;
|
||||
public Data data;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "message_type", "format", "data" });
|
||||
}
|
||||
|
||||
public static class Data extends Union {
|
||||
public byte b[] = new byte[20];
|
||||
@@ -1401,6 +1456,9 @@ public interface X11 extends Library {
|
||||
public int state; // key or button mask
|
||||
public byte is_hint; // detail
|
||||
public int same_screen; // same screen flag
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "state", "is_hint", "same_screen" });
|
||||
}
|
||||
}
|
||||
|
||||
class XPointerMovedEvent extends XMotionEvent {
|
||||
@@ -1424,8 +1482,11 @@ public interface X11 extends Library {
|
||||
* NotifyNonlinear,NotifyNonlinearVirtual
|
||||
*/
|
||||
public int same_screen; // same screen flag
|
||||
public int focus; // intean focus
|
||||
public int focus; // boolean focus
|
||||
public int state; // key or button mask
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "root", "subwindow", "time", "x", "y", "x_root", "y_root", "mode", "detail", "same_screen", "focus", "state" });
|
||||
}
|
||||
}
|
||||
|
||||
class XEnterWindowEvent extends XCrossingEvent {
|
||||
@@ -1447,6 +1508,9 @@ public interface X11 extends Library {
|
||||
* NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
|
||||
* NotifyPointerRoot, NotifyDetailNone
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "mode", "detail" });
|
||||
}
|
||||
}
|
||||
|
||||
class XFocusInEvent extends XFocusChangeEvent {
|
||||
@@ -1464,6 +1528,9 @@ public interface X11 extends Library {
|
||||
public int x, y;
|
||||
public int width, height;
|
||||
public int count; // if non-zero, at least this many more
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "x", "y", "width", "height", "count" });
|
||||
}
|
||||
}
|
||||
|
||||
class XGraphicsExposeEvent extends Structure {
|
||||
@@ -1477,6 +1544,9 @@ public interface X11 extends Library {
|
||||
public int count; // if non-zero, at least this many more
|
||||
public int major_code; // core is CopyArea or CopyPlane
|
||||
public int minor_code; // not defined in the core
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "drawable", "x", "y", "width", "height", "count", "major_code", "minor_code" });
|
||||
}
|
||||
}
|
||||
|
||||
class XNoExposeEvent extends Structure {
|
||||
@@ -1487,6 +1557,9 @@ public interface X11 extends Library {
|
||||
public Drawable drawable;
|
||||
public int major_code; // core is CopyArea or CopyPlane
|
||||
public int minor_code; // not defined in the core
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "drawable", "major_code", "minor_code" });
|
||||
}
|
||||
}
|
||||
|
||||
class XVisibilityEvent extends Structure {
|
||||
@@ -1496,6 +1569,9 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window window;
|
||||
public int state; // Visibility state
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "state" });
|
||||
}
|
||||
}
|
||||
|
||||
class XCreateWindowEvent extends Structure {
|
||||
@@ -1509,6 +1585,9 @@ public interface X11 extends Library {
|
||||
public int width, height; // size of window
|
||||
public int border_width; // border width
|
||||
public int override_redirect; // creation should be overridden
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "override_redirect" });
|
||||
}
|
||||
}
|
||||
|
||||
class XDestroyWindowEvent extends Structure {
|
||||
@@ -1518,6 +1597,8 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window event;
|
||||
public Window window;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window" }); }
|
||||
}
|
||||
|
||||
class XUnmapEvent extends Structure {
|
||||
@@ -1528,6 +1609,9 @@ public interface X11 extends Library {
|
||||
public Window event;
|
||||
public Window window;
|
||||
public int from_configure;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "from_configure" });
|
||||
}
|
||||
}
|
||||
|
||||
class XMapEvent extends Structure {
|
||||
@@ -1537,7 +1621,10 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window event;
|
||||
public Window window;
|
||||
public int override_redirect; // intean, is override set...
|
||||
public int override_redirect; // boolean, is override set...
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "override_redirect" });
|
||||
}
|
||||
}
|
||||
|
||||
class XMapRequestEvent extends Structure {
|
||||
@@ -1547,6 +1634,9 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window parent;
|
||||
public Window window;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window" });
|
||||
}
|
||||
}
|
||||
|
||||
class XReparentEvent extends Structure {
|
||||
@@ -1559,6 +1649,9 @@ public interface X11 extends Library {
|
||||
public Window parent;
|
||||
public int x, y;
|
||||
public int override_redirect;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "parent", "x", "y", "override_redirect" });
|
||||
}
|
||||
}
|
||||
|
||||
class XConfigureEvent extends Structure {
|
||||
@@ -1573,6 +1666,9 @@ public interface X11 extends Library {
|
||||
public int border_width;
|
||||
public Window above;
|
||||
public int override_redirect;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y", "width", "height", "border_width", "above", "override_redirect" });
|
||||
}
|
||||
}
|
||||
|
||||
class XGravityEvent extends Structure {
|
||||
@@ -1583,6 +1679,9 @@ public interface X11 extends Library {
|
||||
public Window event;
|
||||
public Window window;
|
||||
public int x, y;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "x", "y" });
|
||||
}
|
||||
}
|
||||
|
||||
class XResizeRequestEvent extends Structure {
|
||||
@@ -1592,6 +1691,9 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window window;
|
||||
public int width, height;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "width", "height" });
|
||||
}
|
||||
}
|
||||
|
||||
class XConfigureRequestEvent extends Structure {
|
||||
@@ -1607,6 +1709,9 @@ public interface X11 extends Library {
|
||||
public Window above;
|
||||
public int detail; // Above, Below, TopIf, BottomIf, Opposite
|
||||
public NativeLong value_mask;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "x", "y", "width", "height", "border_width", "above", "detail", "value_mask" });
|
||||
}
|
||||
}
|
||||
|
||||
class XCirculateEvent extends Structure {
|
||||
@@ -1617,6 +1722,9 @@ public interface X11 extends Library {
|
||||
public Window event;
|
||||
public Window window;
|
||||
public int place; // PlaceOnTop, PlaceOnBottom
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "event", "window", "place" });
|
||||
}
|
||||
}
|
||||
|
||||
class XCirculateRequestEvent extends Structure {
|
||||
@@ -1627,6 +1735,9 @@ public interface X11 extends Library {
|
||||
public Window parent;
|
||||
public Window window;
|
||||
public int place; // PlaceOnTop, PlaceOnBottom
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "parent", "window", "place" });
|
||||
}
|
||||
}
|
||||
|
||||
class XPropertyEvent extends Structure {
|
||||
@@ -1638,6 +1749,9 @@ public interface X11 extends Library {
|
||||
public Atom atom;
|
||||
public NativeLong time;
|
||||
public int state; // NewValue, Deleted
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "atom", "time", "state" });
|
||||
}
|
||||
}
|
||||
|
||||
class XSelectionClearEvent extends Structure {
|
||||
@@ -1648,6 +1762,9 @@ public interface X11 extends Library {
|
||||
public Window window;
|
||||
public Atom selection;
|
||||
public NativeLong time;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "selection", "time" });
|
||||
}
|
||||
}
|
||||
|
||||
class XSelectionRequestEvent extends Structure {
|
||||
@@ -1659,8 +1776,11 @@ public interface X11 extends Library {
|
||||
public Window requestor;
|
||||
public Atom selection;
|
||||
public Atom target;
|
||||
Atom property;
|
||||
public Atom property;
|
||||
public NativeLong time;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "owner", "requestor", "selection", "target", "property", "time" });
|
||||
}
|
||||
}
|
||||
|
||||
class XSelectionEvent extends Structure {
|
||||
@@ -1673,6 +1793,9 @@ public interface X11 extends Library {
|
||||
public Atom target;
|
||||
public Atom property; // ATOM or None
|
||||
public NativeLong time;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "requestor", "selection", "target", "property", "time" });
|
||||
}
|
||||
}
|
||||
|
||||
class XColormapEvent extends Structure {
|
||||
@@ -1684,6 +1807,9 @@ public interface X11 extends Library {
|
||||
public Colormap colormap; // COLORMAP or None
|
||||
public int c_new; // C++
|
||||
public int state; // ColormapInstalled, ColormapUninstalled
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "colormap", "c_new", "state" });
|
||||
}
|
||||
}
|
||||
|
||||
class XMappingEvent extends Structure {
|
||||
@@ -1695,16 +1821,22 @@ public interface X11 extends Library {
|
||||
public int request; // one of MappingModifier, MappingKeyboard, MappingPointer
|
||||
public int first_keycode; // first keycode
|
||||
public int count; // defines range of change w. first_keycode*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "request", "first_keycode", "count" });
|
||||
}
|
||||
}
|
||||
|
||||
class XErrorEvent extends Structure {
|
||||
public int type;
|
||||
public Display display; // Display the event was read from
|
||||
public XID resourceid; // resource id
|
||||
public NativeLong serial; // serial number of failed request
|
||||
public byte error_code; // error code of failed request
|
||||
public byte request_code; // Major op-code of failed request
|
||||
public byte minor_code; // Minor op-code of failed request
|
||||
public XID resourceid; // resource id
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "display", "serial", "error_code", "request_code", "minor_code", "resourceid" });
|
||||
}
|
||||
}
|
||||
|
||||
// generated on EnterWindow and FocusIn when KeyMapState selected
|
||||
@@ -1715,6 +1847,9 @@ public interface X11 extends Library {
|
||||
public Display display; // Display the event was read from
|
||||
public Window window;
|
||||
public byte key_vector[] = new byte[32];
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "type", "serial", "send_event", "display", "window", "key_vector" });
|
||||
}
|
||||
}
|
||||
|
||||
int XSelectInput(Display display, Window window, NativeLong eventMask);
|
||||
@@ -1859,6 +1994,9 @@ public interface X11 extends Library {
|
||||
class XModifierKeymapRef extends Structure implements Structure.ByReference{
|
||||
public int max_keypermod; /* The server's max # of keys per modifier */
|
||||
public Pointer modifiermap; /* An 8 by max_keypermod array of modifiers */
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "max_keypermod", "modifiermap" });
|
||||
}
|
||||
}
|
||||
|
||||
class XKeyboardControlRef extends Structure implements Structure.ByReference {
|
||||
@@ -1879,6 +2017,10 @@ public interface X11 extends Library {
|
||||
/** AutoRepeatModeOff, AutoRepeatModeOn, AutoRepeatModeDefault. */
|
||||
public int auto_repeat_mode;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led", "led_mode", "key", "auto_repeat_mode" });
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "XKeyboardControlByReference{" +
|
||||
"key_click_percent=" + key_click_percent +
|
||||
@@ -1909,6 +2051,10 @@ public interface X11 extends Library {
|
||||
/** Bit vector. Each bit set to 1 indicates that auto-repeat is enabled for the corresponding key. The vector is represented as 32 bytes. Byte N (from 0) contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. */
|
||||
public byte auto_repeats[] = new byte[32];
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "key_click_percent", "bell_percent", "bell_pitch", "bell_duration", "led_mask", "global_auto_repeat", "auto_repeats" });
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "XKeyboardStateByReference{" +
|
||||
"key_click_percent=" + key_click_percent +
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -35,6 +35,10 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +63,11 @@ public interface BaseTSD extends StdCallLibrary {
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
super(Pointer.SIZE, value, true);
|
||||
}
|
||||
|
||||
public Pointer toPointer() {
|
||||
return Pointer.createConstant(longValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Exception class for all COM related classes.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMException extends RuntimeException {
|
||||
|
||||
/** The p excep info. */
|
||||
private EXCEPINFO pExcepInfo;
|
||||
|
||||
/** The pu arg err. */
|
||||
private IntByReference puArgErr;
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*/
|
||||
public COMException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public COMException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public COMException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public COMException(String message, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
super(message);
|
||||
this.pExcepInfo = pExcepInfo;
|
||||
this.puArgErr = puArgErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new automation exception.
|
||||
*
|
||||
* @param cause
|
||||
* the cause
|
||||
*/
|
||||
public COMException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the excep info.
|
||||
*
|
||||
* @return the excep info
|
||||
*/
|
||||
public EXCEPINFO getExcepInfo() {
|
||||
return pExcepInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the arg err.
|
||||
*
|
||||
* @return the arg err
|
||||
*/
|
||||
public IntByReference getArgErr() {
|
||||
return puArgErr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.OaIdl;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.Ole32;
|
||||
import com.sun.jna.platform.win32.OleAuto;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.Variant.VariantArg;
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Helper class to provide basic COM support.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class COMObject {
|
||||
|
||||
public final static LCID LOCALE_USER_DEFAULT = Kernel32.INSTANCE
|
||||
.GetUserDefaultLCID();
|
||||
public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
|
||||
.GetSystemDefaultLCID();
|
||||
|
||||
protected IUnknown iUnknown;
|
||||
|
||||
protected IDispatch iDispatch;
|
||||
|
||||
private PointerByReference pDispatch = new PointerByReference();
|
||||
|
||||
private PointerByReference pUnknown = new PointerByReference();
|
||||
|
||||
public COMObject(IDispatch iDispatch) {
|
||||
this.iDispatch = iDispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new cOM object.
|
||||
*
|
||||
* @param progId
|
||||
* the prog id
|
||||
* @param useActiveInstance
|
||||
* the use active instance
|
||||
* @throws COMException
|
||||
* the automation exception
|
||||
*/
|
||||
public COMObject(String progId, boolean useActiveInstance)
|
||||
throws COMException {
|
||||
// enable JNA protected mode
|
||||
Native.setProtected(true);
|
||||
|
||||
// Initialize COM for this thread...
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
this.release();
|
||||
throw new COMException("CoInitialize() failed!");
|
||||
}
|
||||
|
||||
// Get CLSID for Word.Application...
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
throw new COMException("CLSIDFromProgID() failed!");
|
||||
}
|
||||
|
||||
if (useActiveInstance) {
|
||||
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
|
||||
|
||||
if (COMUtils.SUCCEEDED(hr)) {
|
||||
this.iUnknown = new IUnknown(this.pUnknown.getValue());
|
||||
hr = iUnknown.QueryInterface(IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
|
||||
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
}
|
||||
} else {
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
|
||||
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
}
|
||||
|
||||
if (COMUtils.FAILED(hr)) {
|
||||
throw new COMException("COM object with ProgID '" + progId
|
||||
+ "' and CLSID " + clsid.toGuidString() + " not registered properly!");
|
||||
}
|
||||
|
||||
this.iDispatch = new IDispatch(this.pDispatch.getValue());
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name, VARIANT[] pArgs) throws COMException {
|
||||
|
||||
if (pDisp == null)
|
||||
throw new COMException("pDisp (IDispatch) parameter is null!");
|
||||
|
||||
WString[] ptName = new WString[] { new WString(name) };
|
||||
DISPPARAMS dp = new DISPPARAMS();
|
||||
DISPIDbyReference pdispID = new DISPIDbyReference();
|
||||
VariantArg.ByReference variantArg = new VariantArg.ByReference();
|
||||
variantArg.variantArg = pArgs;
|
||||
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
|
||||
IntByReference puArgErr = new IntByReference();
|
||||
|
||||
// Get DISPID for name passed...
|
||||
HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
|
||||
LOCALE_USER_DEFAULT, pdispID);
|
||||
|
||||
COMUtils.checkAutoRC(hr);
|
||||
|
||||
// Handle special-case for property-puts!
|
||||
if (nType == OleAuto.DISPATCH_PROPERTYPUT) {
|
||||
dp.cNamedArgs = new UINT(pArgs.length);
|
||||
dp.rgdispidNamedArgs = new DISPIDbyReference(
|
||||
OaIdl.DISPID_PROPERTYPUT);
|
||||
}
|
||||
|
||||
// Build DISPPARAMS
|
||||
if ((pArgs != null) && (pArgs.length > 0)) {
|
||||
dp.cArgs = new UINT(pArgs.length);
|
||||
dp.rgvarg = variantArg;
|
||||
|
||||
// write 'DISPPARAMS' structure to memory
|
||||
dp.write();
|
||||
}
|
||||
|
||||
// Make the call!
|
||||
hr = pDisp.Invoke(pdispID.getValue(), Guid.IID_NULL,
|
||||
LOCALE_SYSTEM_DEFAULT, new DISPID(nType), dp, pvResult,
|
||||
pExcepInfo, puArgErr);
|
||||
|
||||
COMUtils.checkAutoRC(hr, pExcepInfo, puArgErr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name, VARIANT pArg) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, name,
|
||||
new VARIANT[] { pArg });
|
||||
}
|
||||
|
||||
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
|
||||
IDispatch pDisp, String name) throws COMException {
|
||||
|
||||
return this.oleMethod(nType, pvResult, pDisp, name, (VARIANT[]) null);
|
||||
}
|
||||
|
||||
protected void checkFailed(HRESULT hr) {
|
||||
COMUtils.checkAutoRC(hr, null, null);
|
||||
}
|
||||
|
||||
public IDispatch getIDispatch() {
|
||||
return iDispatch;
|
||||
}
|
||||
|
||||
public PointerByReference getIDispatchPointer() {
|
||||
return pDispatch;
|
||||
}
|
||||
|
||||
public IUnknown getIUnknown() {
|
||||
return iUnknown;
|
||||
}
|
||||
|
||||
public PointerByReference getIUnknownPointer() {
|
||||
return pUnknown;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
if (this.iDispatch != null)
|
||||
this.iDispatch.Release();
|
||||
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Advapi32;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.InfoKey;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.W32Errors;
|
||||
import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinError;
|
||||
import com.sun.jna.platform.win32.WinNT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class COMUtils.
|
||||
*/
|
||||
public abstract class COMUtils {
|
||||
|
||||
/** The Constant CO_E_NOTINITIALIZED. */
|
||||
public static final int S_OK = 0, S_FALSE = 1,
|
||||
REGDB_E_CLASSNOTREG = 0x80040154,
|
||||
CLASS_E_NOAGGREGATION = 0x80040110,
|
||||
CO_E_NOTINITIALIZED = 0x800401F0;
|
||||
|
||||
/** The Constant E_UNEXPECTED. */
|
||||
public static final int E_UNEXPECTED = 0x8000FFFF;
|
||||
|
||||
/** The Constant E_NOTIMPL. */
|
||||
public static final int E_NOTIMPL = 0x80004001;
|
||||
|
||||
/** The Constant E_OUTOFMEMORY. */
|
||||
public static final int E_OUTOFMEMORY = 0x8007000E;
|
||||
|
||||
/** The Constant E_INVALIDARG. */
|
||||
public static final int E_INVALIDARG = 0x80070057;
|
||||
|
||||
/** The Constant E_NOINTERFACE. */
|
||||
public static final int E_NOINTERFACE = 0x80004002;
|
||||
|
||||
/** The Constant E_POINTER. */
|
||||
public static final int E_POINTER = 0x80004003;
|
||||
|
||||
/** The Constant E_HANDLE. */
|
||||
public static final int E_HANDLE = 0x80070006;
|
||||
|
||||
/** The Constant E_ABORT. */
|
||||
public static final int E_ABORT = 0x80004004;
|
||||
|
||||
/** The Constant E_FAIL. */
|
||||
public static final int E_FAIL = 0x80004005;
|
||||
|
||||
/** The Constant E_ACCESSDENIED. */
|
||||
public static final int E_ACCESSDENIED = 0x80070005;
|
||||
|
||||
/** The Constant DISP_E_BADVARTYPE. */
|
||||
public static final int DISP_E_BADVARTYPE = -2147352568;
|
||||
|
||||
/** The Constant DISP_E_NOTACOLLECTION. */
|
||||
public static final int DISP_E_NOTACOLLECTION = -2147352559;
|
||||
|
||||
/** The Constant DISP_E_MEMBERNOTFOUND. */
|
||||
public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
|
||||
|
||||
/** The Constant DISP_E_ARRAYISLOCKED. */
|
||||
public static final int DISP_E_ARRAYISLOCKED = -2147352563;
|
||||
|
||||
/** The Constant DISP_E_EXCEPTION. */
|
||||
public static final int DISP_E_EXCEPTION = -2147352567;
|
||||
|
||||
/** The Constant DISP_E_TYPEMISMATCH. */
|
||||
public static final int DISP_E_TYPEMISMATCH = -2147352571;
|
||||
|
||||
/** The Constant DISP_E_BADINDEX. */
|
||||
public static final int DISP_E_BADINDEX = -2147352565;
|
||||
|
||||
/** The Constant DISP_E_BADCALLEE. */
|
||||
public static final int DISP_E_BADCALLEE = -2147352560;
|
||||
|
||||
/** The Constant DISP_E_OVERFLOW. */
|
||||
public static final int DISP_E_OVERFLOW = -2147352566;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNINTERFACE. */
|
||||
public static final int DISP_E_UNKNOWNINTERFACE = -2147352575;
|
||||
|
||||
/** The Constant DISP_E_DIVBYZERO. */
|
||||
public static final int DISP_E_DIVBYZERO = -2147352558;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNLCID. */
|
||||
public static final int DISP_E_UNKNOWNLCID = -2147352564;
|
||||
|
||||
/** The Constant DISP_E_PARAMNOTOPTIONAL. */
|
||||
public static final int DISP_E_PARAMNOTOPTIONAL = -2147352561;
|
||||
|
||||
/** The Constant DISP_E_PARAMNOTFOUND. */
|
||||
public static final int DISP_E_PARAMNOTFOUND = -2147352572;
|
||||
|
||||
/** The Constant DISP_E_BADPARAMCOUNT. */
|
||||
public static final int DISP_E_BADPARAMCOUNT = -2147352562;
|
||||
|
||||
/** The Constant DISP_E_BUFFERTOOSMALL. */
|
||||
public static final int DISP_E_BUFFERTOOSMALL = -2147352557;
|
||||
|
||||
/** The Constant DISP_E_UNKNOWNNAME. */
|
||||
public static final int DISP_E_UNKNOWNNAME = -2147352570;
|
||||
|
||||
/** The Constant DISP_E_NONAMEDARGS. */
|
||||
public static final int DISP_E_NONAMEDARGS = -2147352569;
|
||||
|
||||
/** The Constant CO_E_OBJNOTCONNECTED. */
|
||||
public static final int CO_E_OBJNOTCONNECTED = -2147220995;
|
||||
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(HRESULT hr) {
|
||||
return SUCCEEDED(hr.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean SUCCEEDED(int hr) {
|
||||
if (hr == S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(HRESULT hr) {
|
||||
return FAILED(hr.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static boolean FAILED(int hr) {
|
||||
if (hr != S_OK)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
*/
|
||||
public static void checkAutoRC(HRESULT hr) {
|
||||
checkAutoRC(hr, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw new exception.
|
||||
*
|
||||
* @param hr
|
||||
* the hr
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
*/
|
||||
public static void checkAutoRC(HRESULT hr, EXCEPINFO pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
switch (hr.intValue()) {
|
||||
case S_OK:
|
||||
return;
|
||||
case E_NOTIMPL:
|
||||
throw new COMException("Not implemented!");
|
||||
case E_INVALIDARG:
|
||||
throw new COMException("Invalid argument!");
|
||||
case E_OUTOFMEMORY:
|
||||
throw new COMException("Out of memory!");
|
||||
case E_UNEXPECTED:
|
||||
throw new COMException("Error "
|
||||
+ Integer.toHexString(hr.intValue()));
|
||||
case CO_E_NOTINITIALIZED:
|
||||
throw new COMException("CoInitialized wasn't called!");
|
||||
case E_NOINTERFACE:
|
||||
throw new COMException("Interface does not inherit from class!");
|
||||
case E_POINTER:
|
||||
throw new COMException("Allocated pointer pointer is null!");
|
||||
case DISP_E_UNKNOWNNAME:
|
||||
throw new COMException(
|
||||
"One or more of the names were not known. The returned array of DISPIDs contains DISPID_UNKNOWN for each entry that corresponds to an unknown name!");
|
||||
case DISP_E_UNKNOWNLCID:
|
||||
throw new COMException(
|
||||
"The locale identifier (LCID) was not recognized!");
|
||||
case DISP_E_BADPARAMCOUNT:
|
||||
throw new COMException(
|
||||
"The number of elements provided to DISPPARAMS is different from the number of arguments accepted by the method or property!");
|
||||
case DISP_E_BADVARTYPE:
|
||||
throw new COMException(
|
||||
"One of the arguments in DISPPARAMS is not a valid variant type!");
|
||||
case DISP_E_EXCEPTION:
|
||||
throw new COMException(
|
||||
"The application needs to raise an exception. In this case, the structure passed in pexcepinfo should be filled in!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_MEMBERNOTFOUND:
|
||||
throw new COMException("The requested member does not exist!");
|
||||
case DISP_E_NONAMEDARGS:
|
||||
throw new COMException(
|
||||
"This implementation of IDispatch does not support named arguments!");
|
||||
case DISP_E_OVERFLOW:
|
||||
throw new COMException(
|
||||
"One of the arguments in DISPPARAMS could not be coerced to the specified type!");
|
||||
case DISP_E_PARAMNOTFOUND:
|
||||
throw new COMException(
|
||||
"One of the parameter IDs does not correspond to a parameter on the method. In this case, puArgErr is set to the first argument that contains the error!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_TYPEMISMATCH:
|
||||
throw new COMException(
|
||||
"One or more of the arguments could not be coerced. The index of the first parameter with the incorrect type within rgvarg is returned in puArgErr!",
|
||||
pExcepInfo, puArgErr);
|
||||
case DISP_E_UNKNOWNINTERFACE:
|
||||
throw new COMException(
|
||||
"The interface identifier passed in riid is not IID_NULL!");
|
||||
case CO_E_OBJNOTCONNECTED:
|
||||
throw new COMException(
|
||||
"The method is not connected to the Dispatch pointer!");
|
||||
default:
|
||||
throw new COMException("Unexpected COM error code : "
|
||||
+ toHexStr(hr));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkTypeLibRC(HRESULT hr) {
|
||||
switch (hr.intValue()) {
|
||||
case S_OK:
|
||||
return;
|
||||
case WinError.E_INVALIDARG:
|
||||
throw new COMException("One or more of the arguments is not valid.");
|
||||
case WinError.E_OUTOFMEMORY:
|
||||
throw new COMException(
|
||||
"Insufficient memory to complete the operation.");
|
||||
case WinError.TYPE_E_IOERROR:
|
||||
throw new COMException("The function could not write to the file.");
|
||||
case WinError.TYPE_E_INVALIDSTATE:
|
||||
throw new COMException("The type library could not be opened.");
|
||||
case WinError.TYPE_E_INVDATAREAD:
|
||||
throw new COMException(
|
||||
"The function could not read from the file. ");
|
||||
case WinError.TYPE_E_UNSUPFORMAT:
|
||||
throw new COMException("The type library has an older format.");
|
||||
case WinError.TYPE_E_UNKNOWNLCID:
|
||||
throw new COMException(
|
||||
"The LCID could not be found in the OLE-supported DLLs.");
|
||||
case WinError.TYPE_E_CANTLOADLIBRARY:
|
||||
throw new COMException(
|
||||
"The type library or DLL could not be loaded.");
|
||||
case WinError.TYPE_E_ELEMENTNOTFOUND:
|
||||
throw new COMException(
|
||||
"No type description was found in the library with the specified GUID.");
|
||||
default:
|
||||
throw new COMException("Unexpected Typelib error code : "
|
||||
+ toHexStr(hr));
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
|
||||
HKEYByReference phkResult = new HKEYByReference();
|
||||
HKEYByReference phkResult2 = new HKEYByReference();
|
||||
String subKey;
|
||||
ArrayList<COMInfo> comInfos = new ArrayList<COMUtils.COMInfo>();
|
||||
|
||||
try {
|
||||
// open root key
|
||||
phkResult = Advapi32Util.registryGetKey(WinReg.HKEY_CLASSES_ROOT, "CLSID", WinNT.KEY_ALL_ACCESS);
|
||||
// open subkey
|
||||
InfoKey infoKey = Advapi32Util.registryQueryInfoKey(phkResult.getValue(), WinNT.KEY_ALL_ACCESS);
|
||||
|
||||
for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
|
||||
EnumKey enumKey = Advapi32Util.registryRegEnumKey(phkResult.getValue(), i);
|
||||
subKey = Native.toString(enumKey.lpName);
|
||||
|
||||
COMInfo comInfo = new COMInfo(subKey);
|
||||
|
||||
phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(), subKey, WinNT.KEY_ALL_ACCESS);
|
||||
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
|
||||
|
||||
for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++)
|
||||
{
|
||||
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(phkResult2.getValue(), y);
|
||||
String subKey2 = Native.toString(enumKey2.lpName);
|
||||
|
||||
if(subKey2.equals("InprocHandler32")) {
|
||||
comInfo.inprocHandler32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
|
||||
}else if(subKey2.equals("InprocServer32")) {
|
||||
comInfo.inprocServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
|
||||
}else if(subKey2.equals("LocalServer32")) {
|
||||
comInfo.localServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
|
||||
}else if(subKey2.equals("ProgID")) {
|
||||
comInfo.progID = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
|
||||
}else if(subKey2.equals("TypeLib")) {
|
||||
comInfo.typeLib = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
|
||||
}
|
||||
}
|
||||
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
comInfos.add(comInfo);
|
||||
}
|
||||
} finally {
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
|
||||
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
|
||||
}
|
||||
|
||||
return comInfos;
|
||||
}
|
||||
|
||||
public static class COMInfo {
|
||||
public String clsid;
|
||||
public String inprocHandler32;
|
||||
public String inprocServer32;
|
||||
public String localServer32;
|
||||
public String progID;
|
||||
public String typeLib;
|
||||
|
||||
public COMInfo() {
|
||||
}
|
||||
|
||||
public COMInfo(String clsid) {
|
||||
this.clsid = clsid;
|
||||
}
|
||||
}
|
||||
|
||||
private static String toHexStr(HRESULT hr) {
|
||||
return "0x" + Integer.toHexString(hr.intValue()).toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Wrapper class for the IDispatch interface
|
||||
*
|
||||
* IDispatch.GetTypeInfoCount 12 IDispatch.GetTypeInfo 16
|
||||
* IDispatch.GetIDsOfNames 20 IDispatch.Invoke 24
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IDispatch extends IUnknown {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends IDispatch implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/** The Constant IID_IDispatch. */
|
||||
public final static IID IID_IDispatch = new IID(
|
||||
"00020400-0000-0000-C000-000000000046");
|
||||
|
||||
/**
|
||||
* Instantiates a new i dispatch.
|
||||
*/
|
||||
public IDispatch() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i dispatch.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IDispatch(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info count.
|
||||
*
|
||||
* @param pctinfo
|
||||
* the pctinfo
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfoCount(IntByReference pctinfo) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pctinfo });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param iTInfo
|
||||
* the i t info
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param ppTInfo
|
||||
* the pp t info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(UINT iTInfo, LCID lcid,
|
||||
PointerByReference ppTInfo) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), iTInfo, lcid,
|
||||
ppTInfo });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the i ds of names.
|
||||
*
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param rgszNames
|
||||
* the rgsz names
|
||||
* @param cNames
|
||||
* the c names
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param rgDispId
|
||||
* the rg disp id
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetIDsOfNames(IID riid, WString[] rgszNames, int cNames,
|
||||
LCID lcid, DISPIDbyReference rgDispId) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), riid,
|
||||
rgszNames, cNames, lcid, rgDispId });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke.
|
||||
*
|
||||
* @param dispIdMember
|
||||
* the disp id member
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param lcid
|
||||
* the lcid
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pDispParams
|
||||
* the disp params
|
||||
* @param pVarResult
|
||||
* the var result
|
||||
* @param pExcepInfo
|
||||
* the excep info
|
||||
* @param puArgErr
|
||||
* the pu arg err
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT Invoke(DISPID dispIdMember, IID riid, LCID lcid,
|
||||
DISPID wFlags, DISPPARAMS pDispParams,
|
||||
VARIANT.ByReference pVarResult, EXCEPINFO.ByReference pExcepInfo,
|
||||
IntByReference puArgErr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), dispIdMember,
|
||||
riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo,
|
||||
puArgErr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOL;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Wrapper class for the IRecordInfo interface
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IRecordInfo extends IUnknown {
|
||||
|
||||
/** The Constant IID_IRecordInfo. */
|
||||
public final static IID IID_IRecordInfo = new IID(
|
||||
"{0000002F-0000-0000-C000-000000000046}");
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*/
|
||||
public IRecordInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i record info.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IRecordInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record init.
|
||||
*
|
||||
* @param pvNew
|
||||
* the pv new
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordInit(/* [out] */PVOID pvNew) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record clear.
|
||||
*
|
||||
* @param pvExisting
|
||||
* the pv existing
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordClear(
|
||||
/* [in] */PVOID pvExisting) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record copy.
|
||||
*
|
||||
* @param pvExisting
|
||||
* the pv existing
|
||||
* @param pvNew
|
||||
* the pv new
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordCopy(
|
||||
/* [in] */PVOID pvExisting,
|
||||
/* [out] */PVOID pvNew) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the guid.
|
||||
*
|
||||
* @param pguid
|
||||
* the pguid
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetGuid(
|
||||
/* [out] */GUID pguid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @param pbstrName
|
||||
* the pbstr name
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetName(
|
||||
/* [out] */BSTR pbstrName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the size.
|
||||
*
|
||||
* @param pcbSize
|
||||
* the pcb size
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetSize(
|
||||
/* [out] */ULONG pcbSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type info.
|
||||
*
|
||||
* @param ppTypeInfo
|
||||
* the pp type info
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [out] */ITypeInfo ppTypeInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field.
|
||||
*
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetField(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field no copy.
|
||||
*
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @param ppvDataCArray
|
||||
* the ppv data c array
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetFieldNoCopy(
|
||||
/* [in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [out] */VARIANT pvarField,
|
||||
/* [out] */PVOID ppvDataCArray) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put field.
|
||||
*
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT PutField(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put field no copy.
|
||||
*
|
||||
* @param wFlags
|
||||
* the w flags
|
||||
* @param pvData
|
||||
* the pv data
|
||||
* @param szFieldName
|
||||
* the sz field name
|
||||
* @param pvarField
|
||||
* the pvar field
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT PutFieldNoCopy(
|
||||
/* [in] */ULONG wFlags,
|
||||
/* [out][in] */PVOID pvData,
|
||||
/* [in] */WString szFieldName,
|
||||
/* [in] */VARIANT pvarField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the field names.
|
||||
*
|
||||
* @param pcNames
|
||||
* the pc names
|
||||
* @param rgBstrNames
|
||||
* the rg bstr names
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT GetFieldNames(
|
||||
/* [out][in] */ULONG pcNames,
|
||||
/* [length_is][size_is][out] */BSTR rgBstrNames) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is matching type.
|
||||
*
|
||||
* @param pRecordInfo
|
||||
* the record info
|
||||
* @return the bool
|
||||
*/
|
||||
public BOOL IsMatchingType(
|
||||
/* [in] */IRecordInfo pRecordInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record create.
|
||||
*
|
||||
* @return the pvoid
|
||||
*/
|
||||
public PVOID RecordCreate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record create copy.
|
||||
*
|
||||
* @param pvSource
|
||||
* the pv source
|
||||
* @param ppvDest
|
||||
* the ppv dest
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordCreateCopy(
|
||||
/* [in] */PVOID pvSource,
|
||||
/* [out] */PVOID ppvDest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record destroy.
|
||||
*
|
||||
* @param pvRecord
|
||||
* the pv record
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT RecordDestroy(
|
||||
/* [in] */PVOID pvRecord) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.OaIdl.BINDPTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.DESCKIND;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Wrapper class for the ITypeComp interface
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeComp extends IUnknown {
|
||||
|
||||
public static class ByReference extends ITypeComp implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public ITypeComp() {
|
||||
}
|
||||
|
||||
public ITypeComp(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
public HRESULT Bind(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [out] */DESCKIND.ByReference pDescKind,
|
||||
/* [out] */BINDPTR.ByReference pBindPtr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
|
||||
lHashVal, wFlags, ppTInfo, pDescKind, pBindPtr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT BindType(
|
||||
/* [annotation][in] */
|
||||
WString szName,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [out] */ITypeComp.ByReference ppTComp) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szName,
|
||||
lHashVal, ppTInfo, ppTComp });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.REFIID;
|
||||
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinDef.WORDbyReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeInfo extends IUnknown {
|
||||
|
||||
public static class ByReference extends ITypeInfo implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public ITypeInfo() {
|
||||
}
|
||||
|
||||
public ITypeInfo(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeAttr(
|
||||
/* [out] */TYPEATTR.ByReference pTypeAttr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
|
||||
pTypeAttr.read();
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */ITypeComp.ByReference pTComp) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
PointerByReference ppTComp = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
|
||||
pTComp.setPointer(ppTComp.getValue());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetFuncDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */FUNCDESC.ByReference pFuncDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pFuncDesc });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetVarDesc(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */VARDESC.ByReference pVarDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pVarDesc });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetNames(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [length_is][size_is][out] */BSTR[] rgBstrNames,
|
||||
/* [in] */UINT cMaxNames,
|
||||
/* [out] */UINTbyReference pcNames) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(28));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
rgBstrNames, cMaxNames, pcNames });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetRefTypeOfImplType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */HREFTYPEbyReference pRefType) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(32));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pRefType });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetImplTypeFlags(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pImplTypeFlags) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(36));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pImplTypeFlags });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetIDsOfNames(
|
||||
/* [size_is][in] */WString[] rgszNames,
|
||||
/* [in] */UINT cNames,
|
||||
/* [size_is][out] */MEMBERID[] pMemId) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(40));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), rgszNames,
|
||||
cNames, pMemId });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT Invoke(
|
||||
/* [in] */PVOID pvInstance,
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */WORD wFlags,
|
||||
/* [out][in] */DISPPARAMS.ByReference pDispParams,
|
||||
/* [out] */VARIANT.ByReference pVarResult,
|
||||
/* [out] */EXCEPINFO.ByReference pExcepInfo,
|
||||
/* [out] */UINTbyReference puArgErr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(44));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pvInstance,
|
||||
memid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetDocumentation(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */BSTR pBstrDocString,
|
||||
/* [out] */DWORDbyReference pdwHelpContext,
|
||||
/* [out] */BSTR pBstrHelpFile) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(48));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetDllEntry(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */BSTR pBstrDllName,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */WORDbyReference pwOrdinal) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(52));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
invKind, pBstrDllName, pBstrName, pwOrdinal });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetRefTypeInfo(
|
||||
/* [in] */HREFTYPE hRefType,
|
||||
/* [out] */ITypeInfo.ByReference ppTInfo) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(56));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), hRefType,
|
||||
ppTInfo });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT AddressOfMember(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [in] */INVOKEKIND invKind,
|
||||
/* [out] */PointerByReference ppv) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(60));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
invKind, ppv });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT CreateInstance(
|
||||
/* [in] */IUnknown pUnkOuter,
|
||||
/* [in] */REFIID riid,
|
||||
/* [iid_is][out] */PointerByReference ppvObj) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(64));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), pUnkOuter,
|
||||
riid, ppvObj });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetMops(
|
||||
/* [in] */MEMBERID memid,
|
||||
/* [out] */BSTR pBstrMops) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(68));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), memid,
|
||||
pBstrMops });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */HRESULT GetContainingTypeLib(
|
||||
/* [out] */ITypeLib.ByReference pTLib,
|
||||
/* [out] */UINTbyReference pIndex) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(72));
|
||||
PointerByReference ppTLib = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLib,
|
||||
pIndex });
|
||||
pTLib.setPointer(ppTLib.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseTypeAttr(
|
||||
/* [in] */TYPEATTR pTypeAttr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(76));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pTypeAttr });
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseFuncDesc(
|
||||
/* [in] */FUNCDESC pFuncDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(80));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pFuncDesc });
|
||||
}
|
||||
|
||||
public/* [local] */void ReleaseVarDesc(
|
||||
/* [in] */VARDESC pVarDesc) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(84));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pVarDesc });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.BOOLbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORTbyReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Wrapper class for the ITypeLib interface
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class ITypeLib extends IUnknown {
|
||||
|
||||
public static class ByReference extends IUnknown implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public ITypeLib() {
|
||||
}
|
||||
|
||||
public ITypeLib(Pointer pvInstance) {
|
||||
super(pvInstance);
|
||||
}
|
||||
|
||||
public UINT GetTypeInfoCount() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(12));
|
||||
int count = func.invokeInt(new Object[] { this.getPointer() });
|
||||
|
||||
return new UINT(count);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeInfo(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */ITypeInfo.ByReference pTInfo) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(16));
|
||||
PointerByReference ppTInfo = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index, ppTInfo });
|
||||
pTInfo.setPointer(ppTInfo.getValue());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeInfoType(
|
||||
/* [in] */UINT index,
|
||||
/* [out] */IntByReference pTKind) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(20));
|
||||
int hr = func
|
||||
.invokeInt(new Object[] { this.getPointer(), index, pTKind });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeInfoOfGuid(
|
||||
/* [in] */GUID guid,
|
||||
/* [out] */ITypeInfo.ByReference pTinfo) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(24));
|
||||
PointerByReference ppTinfo = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), guid, ppTinfo });
|
||||
pTinfo.setPointer(ppTinfo.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetLibAttr(
|
||||
/* [out] */TLIBATTR.ByReference ppTLibAttr) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(28));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTLibAttr });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetTypeComp(
|
||||
/* [out] */ITypeComp.ByReference pTComp) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(32));
|
||||
PointerByReference ppTComp = new PointerByReference();
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), ppTComp });
|
||||
pTComp.setPointer(ppTComp.getPointer());
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT GetDocumentation(
|
||||
/* [in] */int index,
|
||||
/* [out] */BSTR pBstrName,
|
||||
/* [out] */BSTR pBstrDocString,
|
||||
/* [out] */DWORDbyReference pdwHelpContext,
|
||||
/* [out] */BSTR pBstrHelpFile) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(36));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), index,
|
||||
pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT IsName(
|
||||
/* [annotation][out][in] */
|
||||
WString szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [out] */BOOLbyReference pfName) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(40));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
|
||||
lHashVal, pfName });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public HRESULT FindName(
|
||||
/* [annotation][out][in] */
|
||||
WString szNameBuf,
|
||||
/* [in] */ULONG lHashVal,
|
||||
/* [length_is][size_is][out] */ITypeInfo.ByReference ppTInfo,
|
||||
/* [length_is][size_is][out] */MEMBERIDbyReference rgMemId,
|
||||
/* [out][in] */USHORTbyReference pcFound) {
|
||||
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(44));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), szNameBuf,
|
||||
lHashVal, ppTInfo, rgMemId, pcFound });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
public void ReleaseTLibAttr(/* [in] */TLIBATTR pTLibAttr) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(48));
|
||||
func.invokeInt(new Object[] { this.getPointer(), pTLibAttr });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import com.sun.jna.Function;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.Guid.IID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Wrapper class for the ITypeInfo interface
|
||||
*
|
||||
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
|
||||
* IUnknown.Release 8
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class IUnknown extends PointerType {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends IUnknown implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/** The Constant IID_IDispatch. */
|
||||
public final static IID IID_IDispatch = new IID(
|
||||
"{00000000-0000-0000-C000-000000000046}");
|
||||
|
||||
/**
|
||||
* Instantiates a new i unknown.
|
||||
*/
|
||||
public IUnknown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new i unknown.
|
||||
*
|
||||
* @param pvInstance
|
||||
* the pv instance
|
||||
*/
|
||||
public IUnknown(Pointer pvInstance) {
|
||||
this.setPointer(pvInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query interface.
|
||||
*
|
||||
* @param riid
|
||||
* the riid
|
||||
* @param ppvObject
|
||||
* the ppv object
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(0));
|
||||
int hr = func.invokeInt(new Object[] { this.getPointer(), riid,
|
||||
ppvObject });
|
||||
|
||||
return new HRESULT(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the ref.
|
||||
*
|
||||
* @return the ulong
|
||||
*/
|
||||
public int AddRef() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(4));
|
||||
|
||||
return func.invokeInt(new Object[] { this.getPointer() });
|
||||
}
|
||||
|
||||
/**
|
||||
* Release.
|
||||
*
|
||||
* @return the ulong
|
||||
*/
|
||||
public int Release() {
|
||||
Pointer vptr = this.getPointer().getPointer(0);
|
||||
Function func = Function.getFunction(vptr.getPointer(8));
|
||||
|
||||
return func.invokeInt(new Object[] { this.getPointer() });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,530 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Based on dbt.h (various types)
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface DBT extends StdCallLibrary {
|
||||
|
||||
/** The dbt no disk space. */
|
||||
int DBT_NO_DISK_SPACE = 0x0047;
|
||||
|
||||
/** The dbt low disk space. */
|
||||
int DBT_LOW_DISK_SPACE = 0x0048;
|
||||
|
||||
/** The dbt configmgprivate. */
|
||||
int DBT_CONFIGMGPRIVATE = 0x7FFF;
|
||||
|
||||
/** The dbt devicearrival. */
|
||||
int DBT_DEVICEARRIVAL = 0x8000;
|
||||
|
||||
/** The dbt devicequeryremove. */
|
||||
int DBT_DEVICEQUERYREMOVE = 0x8001;
|
||||
|
||||
/** The dbt devicequeryremovefailed. */
|
||||
int DBT_DEVICEQUERYREMOVEFAILED = 0x8002;
|
||||
|
||||
/** The dbt deviceremovepending. */
|
||||
int DBT_DEVICEREMOVEPENDING = 0x8003;
|
||||
|
||||
/** The dbt deviceremovecomplete. */
|
||||
int DBT_DEVICEREMOVECOMPLETE = 0x8004;
|
||||
|
||||
/** A device has been added to or removed from the system. */
|
||||
int DBT_DEVNODES_CHANGED = 0x0007;
|
||||
|
||||
/** The dbt devicetypespecific. */
|
||||
int DBT_DEVICETYPESPECIFIC = 0x8005;
|
||||
|
||||
/** The dbt customevent. */
|
||||
int DBT_CUSTOMEVENT = 0x8006;
|
||||
|
||||
/** The guid devinterface usb device. */
|
||||
public GUID GUID_DEVINTERFACE_USB_DEVICE = new GUID(
|
||||
"{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
|
||||
|
||||
/** The guid devinterface hid. */
|
||||
public GUID GUID_DEVINTERFACE_HID = new GUID(
|
||||
"{4D1E55B2-F16F-11CF-88CB-001111000030}");
|
||||
|
||||
/** The guid devinterface volume. */
|
||||
public GUID GUID_DEVINTERFACE_VOLUME = new GUID(
|
||||
"{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}");
|
||||
|
||||
/** The guid devinterface keyboard. */
|
||||
public GUID GUID_DEVINTERFACE_KEYBOARD = new GUID(
|
||||
"{884b96c3-56ef-11d1-bc8c-00a0c91405dd}");
|
||||
|
||||
/** The guid devinterface mouse. */
|
||||
public GUID GUID_DEVINTERFACE_MOUSE = new GUID(
|
||||
"{378DE44C-56EF-11D1-BC8C-00A0C91405DD}");
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_HDR.
|
||||
*/
|
||||
public class DEV_BROADCAST_HDR extends Structure {
|
||||
|
||||
/** The dbch_size. */
|
||||
public int dbch_size = size();
|
||||
|
||||
/** The dbch_devicetype. */
|
||||
public int dbch_devicetype;
|
||||
|
||||
/** The dbch_reserved. */
|
||||
public int dbch_reserved;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast hdr.
|
||||
*/
|
||||
public DEV_BROADCAST_HDR() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast hdr.
|
||||
*
|
||||
* @param pointer
|
||||
* the pointer
|
||||
*/
|
||||
public DEV_BROADCAST_HDR(long pointer) {
|
||||
this(new Pointer(pointer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast hdr.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_HDR(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
|
||||
"dbch_reserved" });
|
||||
}
|
||||
}
|
||||
|
||||
/** The dbt devtyp oem. */
|
||||
int DBT_DEVTYP_OEM = 0x00000000;
|
||||
|
||||
/** The dbt devtyp devnode. */
|
||||
int DBT_DEVTYP_DEVNODE = 0x00000001;
|
||||
|
||||
/** The dbt devtyp volume. */
|
||||
int DBT_DEVTYP_VOLUME = 0x00000002;
|
||||
|
||||
/** The dbt devtyp port. */
|
||||
int DBT_DEVTYP_PORT = 0x00000003;
|
||||
|
||||
/** The dbt devtyp net. */
|
||||
int DBT_DEVTYP_NET = 0x00000004;
|
||||
|
||||
/** The dbt devtyp deviceinterface. */
|
||||
int DBT_DEVTYP_DEVICEINTERFACE = 0x00000005;
|
||||
|
||||
/** The dbt devtyp handle. */
|
||||
int DBT_DEVTYP_HANDLE = 0x00000006;
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_OEM.
|
||||
*/
|
||||
public class DEV_BROADCAST_OEM extends Structure {
|
||||
|
||||
/** The dbco_size. */
|
||||
public int dbco_size = size();
|
||||
|
||||
/** The dbco_devicetype. */
|
||||
public int dbco_devicetype;
|
||||
|
||||
/** The dbco_reserved. */
|
||||
public int dbco_reserved;
|
||||
|
||||
/** The dbco_identifier. */
|
||||
public int dbco_identifier;
|
||||
|
||||
/** The dbco_suppfunc. */
|
||||
public int dbco_suppfunc;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast oem.
|
||||
*/
|
||||
public DEV_BROADCAST_OEM() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast oem.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_OEM(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbco_size", "dbco_devicetype",
|
||||
"dbco_reserved", "dbco_identifier", "dbco_suppfunc" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_DEVNODE.
|
||||
*/
|
||||
public class DEV_BROADCAST_DEVNODE extends Structure {
|
||||
|
||||
/** The dbcd_size. */
|
||||
public int dbcd_size = size();
|
||||
|
||||
/** The dbcd_devicetype. */
|
||||
public int dbcd_devicetype;
|
||||
|
||||
/** The dbcd_reserved. */
|
||||
public int dbcd_reserved;
|
||||
|
||||
/** The dbcd_devnode. */
|
||||
public int dbcd_devnode;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast devnode.
|
||||
*/
|
||||
public DEV_BROADCAST_DEVNODE() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast devnode.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_DEVNODE(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbcd_size", "dbcd_devicetype",
|
||||
"dbcd_reserved", "dbcd_devnode" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_VOLUME.
|
||||
*/
|
||||
public class DEV_BROADCAST_VOLUME extends Structure {
|
||||
|
||||
/** The dbcv_size. */
|
||||
public int dbcv_size = size();
|
||||
|
||||
/** The dbcv_devicetype. */
|
||||
public int dbcv_devicetype;
|
||||
|
||||
/** The dbcv_reserved. */
|
||||
public int dbcv_reserved;
|
||||
|
||||
/** The dbcv_unitmask. */
|
||||
public int dbcv_unitmask;
|
||||
|
||||
/** The dbcv_flags. */
|
||||
public short dbcv_flags;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast volume.
|
||||
*/
|
||||
public DEV_BROADCAST_VOLUME() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast volume.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_VOLUME(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbcv_size", "dbcv_devicetype",
|
||||
"dbcv_reserved", "dbcv_unitmask", "dbcv_flags" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_PORT.
|
||||
*/
|
||||
public class DEV_BROADCAST_PORT extends Structure {
|
||||
|
||||
/** The dbcp_size. */
|
||||
public int dbcp_size = size();
|
||||
|
||||
/** The dbcp_devicetype. */
|
||||
public int dbcp_devicetype;
|
||||
|
||||
/** The dbcp_reserved. */
|
||||
public int dbcp_reserved;
|
||||
|
||||
/** The dbcp_name. */
|
||||
public char[] dbcp_name = new char[1];
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast port.
|
||||
*/
|
||||
public DEV_BROADCAST_PORT() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast port.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_PORT(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbcp_size", "dbcp_devicetype",
|
||||
"dbcp_reserved", "dbcp_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_NET.
|
||||
*/
|
||||
public class DEV_BROADCAST_NET extends Structure {
|
||||
|
||||
/** The dbcn_size. */
|
||||
public int dbcn_size = size();
|
||||
|
||||
/** The dbcn_devicetype. */
|
||||
public int dbcn_devicetype;
|
||||
|
||||
/** The dbcn_reserved. */
|
||||
public int dbcn_reserved;
|
||||
|
||||
/** The dbcn_resource. */
|
||||
public int dbcn_resource;
|
||||
|
||||
/** The dbcn_flags. */
|
||||
public int dbcn_flags;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast net.
|
||||
*/
|
||||
public DEV_BROADCAST_NET() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast net.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_NET(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbcn_size", "dbcn_devicetype",
|
||||
"dbcn_reserved", "dbcn_resource", "dbcn_flags" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_DEVICEINTERFACE.
|
||||
*/
|
||||
public class DEV_BROADCAST_DEVICEINTERFACE extends Structure {
|
||||
|
||||
/** The dbcc_size. */
|
||||
public int dbcc_size;
|
||||
|
||||
/** The dbcc_devicetype. */
|
||||
public int dbcc_devicetype;
|
||||
|
||||
/** The dbcc_reserved. */
|
||||
public int dbcc_reserved;
|
||||
|
||||
/** The dbcc_classguid. */
|
||||
public GUID dbcc_classguid;
|
||||
|
||||
/** The dbcc_name. */
|
||||
public char[] dbcc_name = new char[1];
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast deviceinterface.
|
||||
*/
|
||||
public DEV_BROADCAST_DEVICEINTERFACE() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Dev broadcast hdr.
|
||||
*
|
||||
* @param pointer
|
||||
* the pointer
|
||||
*/
|
||||
public DEV_BROADCAST_DEVICEINTERFACE(long pointer) {
|
||||
this(new Pointer(pointer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast deviceinterface.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_DEVICEINTERFACE(Pointer memory) {
|
||||
super(memory);
|
||||
this.dbcc_size = (Integer) this.readField("dbcc_size");
|
||||
// figure out how long dbcc_name should be based on the size
|
||||
int len = 1 + this.dbcc_size - size();
|
||||
this.dbcc_name = new char[len];
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dbcc_name.
|
||||
*
|
||||
* @return the dbcc_name
|
||||
*/
|
||||
public String getDbcc_name() {
|
||||
return Native.toString(this.dbcc_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbcc_size", "dbcc_devicetype",
|
||||
"dbcc_reserved", "dbcc_classguid", "dbcc_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class DEV_BROADCAST_HANDLE.
|
||||
*/
|
||||
public class DEV_BROADCAST_HANDLE extends Structure {
|
||||
|
||||
/** The dbch_size. */
|
||||
public int dbch_size = size();
|
||||
|
||||
/** The dbch_devicetype. */
|
||||
public int dbch_devicetype;
|
||||
|
||||
/** The dbch_reserved. */
|
||||
public int dbch_reserved;
|
||||
|
||||
/** The dbch_handle. */
|
||||
public HANDLE dbch_handle;
|
||||
|
||||
/** The dbch_hdevnotify. */
|
||||
public HDEVNOTIFY dbch_hdevnotify;
|
||||
|
||||
/** The dbch_eventguid. */
|
||||
public GUID dbch_eventguid;
|
||||
|
||||
/** The dbch_nameoffset. */
|
||||
public LONG dbch_nameoffset;
|
||||
|
||||
/** The dbch_data. */
|
||||
public byte[] dbch_data;
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast handle.
|
||||
*/
|
||||
public DEV_BROADCAST_HANDLE() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dev broadcast handle.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DEV_BROADCAST_HANDLE(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
|
||||
"dbch_reserved", "dbch_handle", "dbch_hdevnotify",
|
||||
"dbch_eventguid", "dbch_nameoffset", "dbch_data" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
@@ -34,14 +36,10 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() { }
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
@@ -105,6 +103,10 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
* subnet that the computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +119,10 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dci" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +167,6 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,20 +180,20 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
public int Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
*/
|
||||
public NativeLong ParentIndex;
|
||||
public int ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustType;
|
||||
public int TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustAttributes;
|
||||
public int TrustAttributes;
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
@@ -199,27 +204,17 @@ public interface DsGetDC extends StdCallLibrary {
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
};
|
||||
|
||||
/**
|
||||
* A pointer to an array of DS_DOMAIN_TRUSTS.
|
||||
*/
|
||||
public static class PDS_DOMAIN_TRUSTS extends Structure {
|
||||
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS() {
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS.ByReference t;
|
||||
|
||||
/**
|
||||
* Returns domain trusts.
|
||||
* @param count
|
||||
* Number of domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
|
||||
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
|
||||
|
||||
public DS_DOMAIN_TRUSTS(Pointer p) {
|
||||
super(p);
|
||||
read();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,93 +1,476 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* Ported from Guid.h. Microsoft Windows SDK 6.0A.
|
||||
*
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Guid {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public static class ByReference extends GUID implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
public final static IID IID_NULL = new IID();
|
||||
|
||||
/**
|
||||
* The Class GUID.
|
||||
*/
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public ByReference(GUID guid) {
|
||||
super(guid.getPointer());
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends GUID implements
|
||||
Structure.ByReference {
|
||||
|
||||
Data1 = guid.Data1;
|
||||
Data2 = guid.Data2;
|
||||
Data3 = guid.Data3;
|
||||
Data4 = guid.Data4;
|
||||
}
|
||||
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public GUID() {
|
||||
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
public GUID(byte[] data) {
|
||||
if (data.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: " + data.length);
|
||||
}
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid.getPointer());
|
||||
|
||||
long data1Temp = data[3] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[0] & 0xff;
|
||||
Data1 = (int) data1Temp;
|
||||
Data1 = guid.Data1;
|
||||
Data2 = guid.Data2;
|
||||
Data3 = guid.Data3;
|
||||
Data4 = guid.Data4;
|
||||
}
|
||||
|
||||
int data2Temp = data[5] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= data[4] & 0xff;
|
||||
Data2 = (short) data2Temp;
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
int data3Temp = data[7] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= data[6] & 0xff;
|
||||
Data3 = (short) data3Temp;
|
||||
/** The Data1. */
|
||||
public int Data1;
|
||||
|
||||
Data4[0] = data[8];
|
||||
Data4[1] = data[9];
|
||||
Data4[2] = data[10];
|
||||
Data4[3] = data[11];
|
||||
Data4[4] = data[12];
|
||||
Data4[5] = data[13];
|
||||
Data4[6] = data[14];
|
||||
Data4[7] = data[15];
|
||||
}
|
||||
/** The Data2. */
|
||||
public short Data2;
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
}
|
||||
/** The Data3. */
|
||||
public short Data3;
|
||||
|
||||
/** The Data4. */
|
||||
public byte[] Data4 = new byte[8];
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*/
|
||||
public GUID() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(GUID guid) {
|
||||
this.Data1 = guid.Data1;
|
||||
this.Data2 = guid.Data2;
|
||||
this.Data3 = guid.Data3;
|
||||
this.Data4 = guid.Data4;
|
||||
|
||||
this.writeFieldsToMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public GUID(String guid) {
|
||||
this(fromString(guid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public GUID(byte[] data) {
|
||||
this(fromBinary(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public GUID(Pointer memory) {
|
||||
super(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* From binary.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromBinary(byte[] data) {
|
||||
if (data.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ data.length);
|
||||
}
|
||||
|
||||
GUID newGuid = new GUID();
|
||||
long data1Temp = data[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= data[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = data[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= data[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = data[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= data[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = data[8];
|
||||
newGuid.Data4[1] = data[9];
|
||||
newGuid.Data4[2] = data[10];
|
||||
newGuid.Data4[3] = data[11];
|
||||
newGuid.Data4[4] = data[12];
|
||||
newGuid.Data4[5] = data[13];
|
||||
newGuid.Data4[6] = data[14];
|
||||
newGuid.Data4[7] = data[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* From string.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID fromString(String guid) {
|
||||
int y = 0;
|
||||
char[] _cnewguid = new char[32];
|
||||
char[] _cguid = guid.toCharArray();
|
||||
byte[] bdata = new byte[16];
|
||||
GUID newGuid = new GUID();
|
||||
|
||||
// we not accept a string longer than 38 chars
|
||||
if (guid.length() > 38) {
|
||||
throw new IllegalArgumentException("Invalid guid length: "
|
||||
+ guid.length());
|
||||
}
|
||||
|
||||
// remove '{', '}' and '-' from guid string
|
||||
for (int i = 0; i < _cguid.length; i++) {
|
||||
if ((_cguid[i] != '{') && (_cguid[i] != '-')
|
||||
&& (_cguid[i] != '}'))
|
||||
_cnewguid[y++] = _cguid[i];
|
||||
}
|
||||
|
||||
// convert char to byte
|
||||
for (int i = 0; i < 32; i += 2) {
|
||||
bdata[i / 2] = (byte) ((Character.digit(_cnewguid[i], 16) << 4)
|
||||
+ Character.digit(_cnewguid[i + 1], 16) & 0xff);
|
||||
}
|
||||
|
||||
if (bdata.length != 16) {
|
||||
throw new IllegalArgumentException("Invalid data length: "
|
||||
+ bdata.length);
|
||||
}
|
||||
|
||||
long data1Temp = bdata[0] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[1] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[2] & 0xff;
|
||||
data1Temp <<= 8;
|
||||
data1Temp |= bdata[3] & 0xff;
|
||||
newGuid.Data1 = (int) data1Temp;
|
||||
|
||||
int data2Temp = bdata[4] & 0xff;
|
||||
data2Temp <<= 8;
|
||||
data2Temp |= bdata[5] & 0xff;
|
||||
newGuid.Data2 = (short) data2Temp;
|
||||
|
||||
int data3Temp = bdata[6] & 0xff;
|
||||
data3Temp <<= 8;
|
||||
data3Temp |= bdata[7] & 0xff;
|
||||
newGuid.Data3 = (short) data3Temp;
|
||||
|
||||
newGuid.Data4[0] = bdata[8];
|
||||
newGuid.Data4[1] = bdata[9];
|
||||
newGuid.Data4[2] = bdata[10];
|
||||
newGuid.Data4[3] = bdata[11];
|
||||
newGuid.Data4[4] = bdata[12];
|
||||
newGuid.Data4[5] = bdata[13];
|
||||
newGuid.Data4[6] = bdata[14];
|
||||
newGuid.Data4[7] = bdata[15];
|
||||
|
||||
newGuid.writeFieldsToMemory();
|
||||
|
||||
return newGuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new guid. Code taken from the standard jdk
|
||||
* implementation (see UUID class).
|
||||
*
|
||||
* @return the guid
|
||||
*/
|
||||
public static GUID newGuid() {
|
||||
SecureRandom ng = new SecureRandom();
|
||||
byte[] randomBytes = new byte[16];
|
||||
|
||||
ng.nextBytes(randomBytes);
|
||||
randomBytes[6] &= 0x0f;
|
||||
randomBytes[6] |= 0x40;
|
||||
randomBytes[8] &= 0x3f;
|
||||
randomBytes[8] |= 0x80;
|
||||
|
||||
return new GUID(randomBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* To byte array.
|
||||
*
|
||||
* @return the byte[]
|
||||
*/
|
||||
public byte[] toByteArray() {
|
||||
byte[] guid = new byte[16];
|
||||
|
||||
byte[] bytes1 = new byte[4];
|
||||
bytes1[0] = (byte) (Data1 >> 24);
|
||||
bytes1[1] = (byte) (Data1 >> 16);
|
||||
bytes1[2] = (byte) (Data1 >> 8);
|
||||
bytes1[3] = (byte) (Data1 >> 0);
|
||||
|
||||
byte[] bytes2 = new byte[4];
|
||||
bytes2[0] = (byte) (Data2 >> 24);
|
||||
bytes2[1] = (byte) (Data2 >> 16);
|
||||
bytes2[2] = (byte) (Data2 >> 8);
|
||||
bytes2[3] = (byte) (Data2 >> 0);
|
||||
|
||||
byte[] bytes3 = new byte[4];
|
||||
bytes3[0] = (byte) (Data3 >> 24);
|
||||
bytes3[1] = (byte) (Data3 >> 16);
|
||||
bytes3[2] = (byte) (Data3 >> 8);
|
||||
bytes3[3] = (byte) (Data3 >> 0);
|
||||
|
||||
System.arraycopy(bytes1, 0, guid, 0, 4);
|
||||
System.arraycopy(bytes2, 2, guid, 4, 2);
|
||||
System.arraycopy(bytes3, 2, guid, 6, 2);
|
||||
System.arraycopy(Data4, 0, guid, 8, 8);
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of this Guid, formatted as follows:
|
||||
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String toGuidString() {
|
||||
final String HEXES = "0123456789ABCDEF";
|
||||
byte[] bGuid = toByteArray();
|
||||
|
||||
final StringBuilder hexStr = new StringBuilder(2 * bGuid.length);
|
||||
hexStr.append("{");
|
||||
|
||||
for (int i = 0; i < bGuid.length; i++) {
|
||||
char ch1 = HEXES.charAt((bGuid[i] & 0xF0) >> 4);
|
||||
char ch2 = HEXES.charAt(bGuid[i] & 0x0F);
|
||||
hexStr.append(ch1).append(ch2);
|
||||
|
||||
if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
|
||||
hexStr.append("-");
|
||||
}
|
||||
|
||||
hexStr.append("}");
|
||||
return hexStr.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write fields to backing memory.
|
||||
*/
|
||||
protected void writeFieldsToMemory() {
|
||||
this.writeField("Data1");
|
||||
this.writeField("Data2");
|
||||
this.writeField("Data3");
|
||||
this.writeField("Data4");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Data1", "Data2", "Data3",
|
||||
"Data4" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class CLSID.
|
||||
*/
|
||||
public static class CLSID extends GUID {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*/
|
||||
public ByReference() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param guid
|
||||
* the guid
|
||||
*/
|
||||
public ByReference(GUID guid) {
|
||||
super(guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new by reference.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public ByReference(Pointer memory) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new clsid.
|
||||
*/
|
||||
public CLSID() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class REFIID.
|
||||
*/
|
||||
public class REFIID extends IID {
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*/
|
||||
public REFIID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public REFIID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new refiid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public REFIID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class IID.
|
||||
*/
|
||||
public class IID extends GUID {
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*/
|
||||
public IID() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public IID(Pointer memory) {
|
||||
super(memory);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public IID(String iid) {
|
||||
super(iid);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new iid.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
*/
|
||||
public IID(byte[] data) {
|
||||
super(data);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -19,15 +19,16 @@ import java.util.List;
|
||||
|
||||
import com.sun.jna.LastErrorException;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Kernel32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
* @author markus[at]headcrashing[dot]eu
|
||||
*/
|
||||
public abstract class Kernel32Util implements WinDef {
|
||||
|
||||
@@ -176,7 +177,7 @@ public abstract class Kernel32Util implements WinDef {
|
||||
case WinNT.FILE_TYPE_UNKNOWN:
|
||||
int err = Kernel32.INSTANCE.GetLastError();
|
||||
switch(err) {
|
||||
case W32Errors.NO_ERROR:
|
||||
case WinError.NO_ERROR:
|
||||
break;
|
||||
default:
|
||||
throw new Win32Exception(err);
|
||||
@@ -196,9 +197,95 @@ public abstract class Kernel32Util implements WinDef {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns One of the WinBase.DRIVE_* constants.
|
||||
* @return One of the WinBase.DRIVE_* constants.
|
||||
*/
|
||||
public static int getDriveType(String rootName) {
|
||||
return Kernel32.INSTANCE.GetDriveType(rootName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of an environment variable.
|
||||
* @param name
|
||||
* Name of the environment variable.
|
||||
* @return
|
||||
* Value of an environment variable.
|
||||
*/
|
||||
public static String getEnvironmentVariable(String name) {
|
||||
// obtain the buffer size
|
||||
int size = Kernel32.INSTANCE.GetEnvironmentVariable(name, null, 0);
|
||||
if (size == 0) {
|
||||
return null;
|
||||
} else if (size < 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
// obtain the value
|
||||
char[] buffer = new char[size];
|
||||
size = Kernel32.INSTANCE.GetEnvironmentVariable(name, buffer, buffer.length);
|
||||
if (size <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an integer associated with a key in the specified section of an initialization file.
|
||||
*
|
||||
* @param appName
|
||||
* The name of the section in the initialization file.
|
||||
* @param keyName
|
||||
* The name of the key whose value is to be retrieved. This value is in the form of a string; the {@link Kernel32#GetPrivateProfileInt} function converts
|
||||
* the string into an integer and returns the integer.
|
||||
* @param defaultValue
|
||||
* The default value to return if the key name cannot be found in the initialization file.
|
||||
* @param fileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
|
||||
* Windows directory.
|
||||
* @return The retrieved integer, or the default if not found.
|
||||
*/
|
||||
public static final int getPrivateProfileInt(final String appName, final String keyName, final int defaultValue, final String fileName) {
|
||||
return Kernel32.INSTANCE.GetPrivateProfileInt(appName, keyName, defaultValue, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string from the specified section in an initialization file.
|
||||
*
|
||||
* @param lpAppName
|
||||
* The name of the section containing the key name. If this parameter is {@code null}, the {@link Kernel32#GetPrivateProfileString} function copies all
|
||||
* section names in the file to the supplied buffer.
|
||||
* @param lpKeyName
|
||||
* The name of the key whose associated string is to be retrieved. If this parameter is {@code null}, all key names in the section specified by
|
||||
* the {@code lpAppName} parameter are returned.
|
||||
* @param lpDefault
|
||||
* A default string. If the {@code lpKeyName} key cannot be found in the initialization file, {@link Kernel32#GetPrivateProfileString} returns the
|
||||
* default. If this parameter is {@code null}, the default is an empty string, {@code ""}.
|
||||
* <p>
|
||||
* Avoid specifying a default string with trailing blank characters. The function inserts a {@code null} character in the
|
||||
* {@code lpReturnedString} buffer to strip any trailing blanks.
|
||||
* </p>
|
||||
* @param lpFileName
|
||||
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
|
||||
* Windows directory.
|
||||
* @return <p>
|
||||
* If neither {@code lpAppName} nor {@code lpKeyName} is {@code null} and the destination buffer is too small to hold the requested string, the
|
||||
* string is truncated.
|
||||
* </p>
|
||||
* <p>
|
||||
* If either {@code lpAppName} or {@code lpKeyName} is {@code null} and the destination buffer is too small to hold all the strings, the last string
|
||||
* is truncated and followed by two {@code null} characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* In the event the initialization file specified by {@code lpFileName} is not found, or contains invalid values, this function will set errorno
|
||||
* with a value of '0x2' (File Not Found). To retrieve extended error information, call {@link Kernel32#GetLastError}.
|
||||
* </p>
|
||||
*/
|
||||
public static final String getPrivateProfileString(final String lpAppName, final String lpKeyName, final String lpDefault, final String lpFileName) {
|
||||
final char buffer[] = new char[1024];
|
||||
Kernel32.INSTANCE.GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buffer, new DWORD(buffer.length), lpFileName);
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) {
|
||||
if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName))
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
@@ -36,6 +39,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
}
|
||||
|
||||
public WString lgrui0_name;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lgrui0_name" });
|
||||
}
|
||||
}
|
||||
|
||||
public static class LOCALGROUP_INFO_1 extends Structure {
|
||||
@@ -50,6 +57,9 @@ public interface LMAccess extends StdCallLibrary {
|
||||
|
||||
public WString lgrui1_name;
|
||||
public WString lgrui1_comment;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lgrui1_name", "lgrui1_comment" });
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -80,6 +90,9 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* Pointer to a Unicode string that specifies the name of the user account.
|
||||
*/
|
||||
public WString usri0_name;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "usri0_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,6 +149,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* logon script file.
|
||||
*/
|
||||
public WString usri1_script_path;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +223,11 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* A pointer to a SID structure that contains the security identifier (SID)
|
||||
* that uniquely identifies the user. The NetUserAdd and NetUserSetInfo functions ignore this member.
|
||||
*/
|
||||
public PSID.ByReference usri23_user_sid;
|
||||
public PSID.ByReference usri23_user_sid;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,6 +247,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* Pointer to a null-terminated Unicode character string that specifies a name.
|
||||
*/
|
||||
public WString grui0_name;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "grui0_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,6 +270,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
|
||||
*/
|
||||
public WString lgrui0_name;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "lgrui0_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,6 +296,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi0_name;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "grpi0_name" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,6 +327,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi1_comment;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "grpi1_name", "grpi1_comment" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,6 +368,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* and SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi2_attributes;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,6 +409,10 @@ public interface LMAccess extends StdCallLibrary {
|
||||
* SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi3_attributes;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes" });
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
@@ -53,6 +55,10 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
*/
|
||||
public Pointer Buffer;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" });
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the buffer.
|
||||
* @return
|
||||
@@ -98,11 +104,18 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
public PSID.ByReference Sid;
|
||||
public LSA_UNICODE_STRING DnsName;
|
||||
public LSA_UNICODE_STRING NetbiosName;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" });
|
||||
}
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
|
||||
public NativeLong Length;
|
||||
public int Length;
|
||||
public Pointer Buffer;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Length", "Buffer" });
|
||||
}
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_RECORD extends Structure {
|
||||
@@ -124,7 +137,7 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
/**
|
||||
* Flags that control the behavior of the operation.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
public int Flags;
|
||||
|
||||
/**
|
||||
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
|
||||
@@ -146,6 +159,10 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
*/
|
||||
public UNION u;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" });
|
||||
}
|
||||
|
||||
public void read() {
|
||||
super.read();
|
||||
|
||||
@@ -171,7 +188,11 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_RECORD.ByReference tr;
|
||||
public LSA_FOREST_TRUST_RECORD.ByReference tr;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "tr" });
|
||||
}
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
@@ -184,20 +205,24 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
|
||||
* Entries member.
|
||||
*/
|
||||
public NativeLong RecordCount;
|
||||
public int RecordCount;
|
||||
/**
|
||||
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
|
||||
* each of which contains one piece of forest trust information.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "RecordCount", "Entries" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of LSA_FOREST_TRUST_RECORD entries.
|
||||
* @return
|
||||
* An array of forest trust records.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -210,6 +235,10 @@ public interface NTSecApi extends StdCallLibrary {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
|
||||
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "fti" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
@@ -390,7 +387,7 @@ public interface Netapi32 extends StdCallLibrary {
|
||||
* @param Flags
|
||||
* Contains a set of flags that determines which domain trusts to enumerate.
|
||||
* @param Domains
|
||||
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
|
||||
* Receives a pointer which points to an array of DS_DOMAIN_TRUSTS structures.
|
||||
* Each structure in this array contains trust data about a domain. The caller must free this
|
||||
* memory when it is no longer required by calling NetApiBufferFree.
|
||||
* @param DomainCount
|
||||
@@ -398,8 +395,8 @@ public interface Netapi32 extends StdCallLibrary {
|
||||
* @return
|
||||
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
|
||||
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
|
||||
public int DsEnumerateDomainTrusts(String serverName, int Flags,
|
||||
PointerByReference Domains, IntByReference DomainCount);
|
||||
|
||||
/**
|
||||
* The NetUserGetInfo function retrieves information about a particular user account on a server.
|
||||
|
||||
@@ -14,11 +14,9 @@ package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
|
||||
@@ -27,7 +25,6 @@ import com.sun.jna.platform.win32.LMAccess.USER_INFO_23;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
@@ -209,8 +206,12 @@ public abstract class Netapi32Util {
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LOCALGROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui1_name.toString();
|
||||
lgp.comment = lgpi.lgrui1_comment.toString();;
|
||||
if (lgpi.lgrui1_name != null) {
|
||||
lgp.name = lgpi.lgrui1_name.toString();
|
||||
}
|
||||
if (lgpi.lgrui1_comment != null) {
|
||||
lgp.comment = lgpi.lgrui1_comment.toString();
|
||||
}
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
@@ -254,8 +255,12 @@ public abstract class Netapi32Util {
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.grpi1_name.toString();
|
||||
lgp.comment = lgpi.grpi1_comment.toString();;
|
||||
if (lgpi.grpi1_name != null) {
|
||||
lgp.name = lgpi.grpi1_name.toString();
|
||||
}
|
||||
if (lgpi.grpi1_comment != null) {
|
||||
lgp.comment = lgpi.grpi1_comment.toString();
|
||||
}
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
@@ -287,19 +292,21 @@ public abstract class Netapi32Util {
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
int rc = Netapi32.INSTANCE.NetUserEnum(
|
||||
serverName, 1, 0, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
|
||||
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<User> result = new ArrayList<User>();
|
||||
for(LMAccess.USER_INFO_1 lu : users) {
|
||||
User auser = new User();
|
||||
auser.name = lu.usri1_name.toString();
|
||||
if (lu.usri1_name != null) {
|
||||
auser.name = lu.usri1_name.toString();
|
||||
}
|
||||
result.add(auser);
|
||||
}
|
||||
return result.toArray(new User[0]);
|
||||
@@ -318,8 +325,7 @@ public abstract class Netapi32Util {
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserLocalGroups() {
|
||||
return getUserLocalGroups(Secur32Util.getUserNameEx(
|
||||
EXTENDED_NAME_FORMAT.NameSamCompatible));
|
||||
return getUserLocalGroups(Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,8 +348,9 @@ public abstract class Netapi32Util {
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
|
||||
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(
|
||||
serverName, userName,
|
||||
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
@@ -352,7 +359,9 @@ public abstract class Netapi32Util {
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui0_name.toString();
|
||||
if (lgpi.lgrui0_name != null) {
|
||||
lgp.name = lgpi.lgrui0_name.toString();
|
||||
}
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
@@ -386,8 +395,9 @@ public abstract class Netapi32Util {
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
|
||||
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
int rc = Netapi32.INSTANCE.NetUserGetGroups(
|
||||
serverName, userName,
|
||||
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
@@ -396,7 +406,9 @@ public abstract class Netapi32Util {
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
Group lgp = new Group();
|
||||
lgp.name = lgpi.grui0_name.toString();
|
||||
if (lgpi.grui0_name != null) {
|
||||
lgp.name = lgpi.grui0_name.toString();
|
||||
}
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
@@ -462,14 +474,24 @@ public abstract class Netapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
DomainController dc = new DomainController();
|
||||
dc.address = pdci.dci.DomainControllerAddress.toString();
|
||||
if (pdci.dci.DomainControllerAddress != null) {
|
||||
dc.address = pdci.dci.DomainControllerAddress.toString();
|
||||
}
|
||||
dc.addressType = pdci.dci.DomainControllerAddressType;
|
||||
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
|
||||
dc.dnsForestName = pdci.dci.DnsForestName.toString();
|
||||
if (pdci.dci.ClientSiteName != null) {
|
||||
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
|
||||
}
|
||||
if (pdci.dci.DnsForestName != null) {
|
||||
dc.dnsForestName = pdci.dci.DnsForestName.toString();
|
||||
}
|
||||
dc.domainGuid = pdci.dci.DomainGuid;
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
if (pdci.dci.DomainName != null) {
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
}
|
||||
dc.flags = pdci.dci.Flags;
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
if (pdci.dci.DomainControllerName != null) {
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
}
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
@@ -594,30 +616,39 @@ public abstract class Netapi32Util {
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts(String serverName) {
|
||||
NativeLongByReference domainCount = new NativeLongByReference();
|
||||
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
|
||||
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
|
||||
IntByReference domainTrustCount = new IntByReference();
|
||||
PointerByReference domainsPointerRef = new PointerByReference();
|
||||
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(serverName,
|
||||
DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount);
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
int domainCountValue = domainCount.getValue().intValue();
|
||||
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
|
||||
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
|
||||
DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
|
||||
DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
|
||||
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainTrustCount.getValue());
|
||||
for(DS_DOMAIN_TRUSTS domainTrust : domainTrusts) {
|
||||
DomainTrust t = new DomainTrust();
|
||||
t.DnsDomainName = trust.DnsDomainName.toString();
|
||||
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
|
||||
t.DomainSid = trust.DomainSid;
|
||||
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
|
||||
t.DomainGuid = trust.DomainGuid;
|
||||
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
|
||||
t.flags = trust.Flags.intValue();
|
||||
if (domainTrust.DnsDomainName != null) {
|
||||
t.DnsDomainName = domainTrust.DnsDomainName.toString();
|
||||
}
|
||||
if (domainTrust.NetbiosDomainName != null) {
|
||||
t.NetbiosDomainName = domainTrust.NetbiosDomainName.toString();
|
||||
}
|
||||
t.DomainSid = domainTrust.DomainSid;
|
||||
if (domainTrust.DomainSid != null) {
|
||||
t.DomainSidString = Advapi32Util.convertSidToStringSid(domainTrust.DomainSid);
|
||||
}
|
||||
t.DomainGuid = domainTrust.DomainGuid;
|
||||
if (domainTrust.DomainGuid != null) {
|
||||
t.DomainGuidString = Ole32Util.getStringFromGUID(domainTrust.DomainGuid);
|
||||
}
|
||||
t.flags = domainTrust.Flags;
|
||||
trusts.add(t);
|
||||
}
|
||||
return trusts.toArray(new DomainTrust[0]);
|
||||
} finally {
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(domainsPointerRef.getValue());
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
@@ -636,11 +667,19 @@ public abstract class Netapi32Util {
|
||||
if (rc == LMErr.NERR_Success) {
|
||||
USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue());
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.comment = info_23.usri23_comment.toString();
|
||||
if (info_23.usri23_comment != null) {
|
||||
userInfo.comment = info_23.usri23_comment.toString();
|
||||
}
|
||||
userInfo.flags = info_23.usri23_flags;
|
||||
userInfo.fullName = info_23.usri23_full_name.toString();
|
||||
userInfo.name = info_23.usri23_name.toString();
|
||||
userInfo.sidString = Advapi32Util.convertSidToStringSid(info_23.usri23_user_sid);
|
||||
if (info_23.usri23_full_name != null) {
|
||||
userInfo.fullName = info_23.usri23_full_name.toString();
|
||||
}
|
||||
if (info_23.usri23_name != null) {
|
||||
userInfo.name = info_23.usri23_name.toString();
|
||||
}
|
||||
if (info_23.usri23_user_sid != null) {
|
||||
userInfo.sidString = Advapi32Util.convertSidToStringSid(info_23.usri23_user_sid);
|
||||
}
|
||||
userInfo.sid = info_23.usri23_user_sid;
|
||||
return userInfo;
|
||||
} else {
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,37 +1,59 @@
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
|
||||
/**
|
||||
* Definitions from ObjBase.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface ObjBase {
|
||||
|
||||
int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
|
||||
|
||||
// With DCOM, CLSCTX_REMOTE_SERVER should be included
|
||||
int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_INPROC_HANDLER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
|
||||
int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Definitions from ObjBase.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface ObjBase {
|
||||
|
||||
|
||||
/** The clsctx inproc. */
|
||||
int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
|
||||
|
||||
// With DCOM, CLSCTX_REMOTE_SERVER should be included
|
||||
/** The clsctx all. */
|
||||
int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_INPROC_HANDLER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
|
||||
|
||||
/** The clsctx server. */
|
||||
int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,93 +14,196 @@ package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinDef.LPVOID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Ole32.dll Interface.
|
||||
*
|
||||
* @author dblock[at]dblock.org
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public interface Ole32 extends StdCallLibrary {
|
||||
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
|
||||
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
|
||||
/** The instance. */
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary("Ole32", Ole32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface
|
||||
* identifiers.
|
||||
*
|
||||
* @param pguid
|
||||
* A pointer to the requested GUID.
|
||||
* @return
|
||||
* S_OK if the GUID was successfully created.
|
||||
* A pointer to the requested GUID.
|
||||
* @return S_OK if the GUID was successfully created.
|
||||
*/
|
||||
HRESULT CoCreateGuid(GUID.ByReference pguid);
|
||||
|
||||
|
||||
/**
|
||||
* Converts a globally unique identifier (GUID) into a string of printable characters.
|
||||
* Converts a globally unique identifier (GUID) into a string of printable
|
||||
* characters.
|
||||
*
|
||||
* @param rguid
|
||||
* The GUID to be converted.
|
||||
* The GUID to be converted.
|
||||
* @param lpsz
|
||||
* A pointer to a caller-allocated string variable to receive the resulting string.
|
||||
* A pointer to a caller-allocated string variable to receive the
|
||||
* resulting string.
|
||||
* @param cchMax
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of characters in the
|
||||
* returned string, including the null terminator. If the buffer is too small to contain
|
||||
* the string, the return value is 0.
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return If the function succeeds, the return value is the number of
|
||||
* characters in the returned string, including the null terminator.
|
||||
* If the buffer is too small to contain the string, the return
|
||||
* value is 0.
|
||||
*/
|
||||
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
|
||||
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* original interface identifier (IID).
|
||||
*
|
||||
* @param lpsz
|
||||
* A pointer to the string representation of the IID.
|
||||
* A pointer to the string representation of the IID.
|
||||
* @param lpiid
|
||||
* A pointer to the requested IID on return.
|
||||
* @return
|
||||
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
|
||||
* and S_OK.
|
||||
* A pointer to the requested IID on return.
|
||||
* @return This function can return the standard return values E_INVALIDARG,
|
||||
* E_OUTOFMEMORY, and S_OK.
|
||||
*/
|
||||
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
|
||||
|
||||
/**
|
||||
* Initializes the COM library for use by the calling thread, sets the thread's
|
||||
* concurrency model, and creates a new apartment for the thread if one is required.
|
||||
* @param reserved This parameter is reserved and must be NULL.
|
||||
* @param dwCoInit The concurrency model and initialization options for the
|
||||
* thread. Values for this parameter are taken from the COINIT enumeration.
|
||||
* Any combination of values from COINIT can be used, except that the
|
||||
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
|
||||
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
|
||||
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
|
||||
*/
|
||||
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
|
||||
|
||||
/**
|
||||
* Closes the COM library on the current thread, unloads all DLLs loaded by
|
||||
* the thread, frees any other resources that the thread maintains, and
|
||||
* forces all RPC connections on the thread to close.
|
||||
*
|
||||
*/
|
||||
void CoUninitialize();
|
||||
/**
|
||||
* Initializes the COM library on the current thread and identifies the
|
||||
* concurrency model as single-thread apartment (STA).
|
||||
*
|
||||
* New applications should call CoInitializeEx instead of CoInitialize.
|
||||
*
|
||||
* pvReserved [in, optional] This parameter is reserved and must be NULL.
|
||||
*
|
||||
* @param pvReserved
|
||||
* the pv reserved
|
||||
* @return S_OK The COM library was initialized successfully on this thread.
|
||||
*
|
||||
* S_FALSE The COM library is already initialized on this thread.
|
||||
*
|
||||
* RPC_E_CHANGED_MODE A previous call to CoInitializeEx specified
|
||||
* the concurrency model for this thread as multithread apartment
|
||||
* (MTA). This could also indicate that a change from
|
||||
* neutral-threaded apartment to single-threaded apartment has
|
||||
* occurred.
|
||||
*/
|
||||
HRESULT CoInitialize(LPVOID pvReserved);
|
||||
|
||||
/**
|
||||
* Creates a single uninitialized object of the class associated with a specified CLSID.
|
||||
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
|
||||
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
|
||||
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
|
||||
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
|
||||
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
|
||||
* @return an HRESULT
|
||||
*/
|
||||
HRESULT CoCreateInstance(
|
||||
GUID rclsid,
|
||||
Pointer pUnkOuter,
|
||||
int dwClsContext,
|
||||
GUID riid,
|
||||
PointerByReference ppv);
|
||||
/**
|
||||
* Initializes the COM library for use by the calling thread, sets the
|
||||
* thread's concurrency model, and creates a new apartment for the thread if
|
||||
* one is required.
|
||||
*
|
||||
* @param reserved
|
||||
* This parameter is reserved and must be NULL.
|
||||
* @param dwCoInit
|
||||
* The concurrency model and initialization options for the
|
||||
* thread. Values for this parameter are taken from the COINIT
|
||||
* enumeration. Any combination of values from COINIT can be
|
||||
* used, except that the COINIT_APARTMENTTHREADED and
|
||||
* COINIT_MULTITHREADED flags cannot both be set. The default
|
||||
* (and only sane choice) is COINIT_MULTITHREADED.
|
||||
* @return This function can return the standard return values E_INVALIDARG,
|
||||
* E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.
|
||||
* S_OK, S_FALSE, RPC_E_CHANGED_MODE
|
||||
*/
|
||||
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
|
||||
|
||||
/**
|
||||
* Closes the COM library on the current thread, unloads all DLLs loaded by
|
||||
* the thread, frees any other resources that the thread maintains, and
|
||||
* forces all RPC connections on the thread to close.
|
||||
*
|
||||
*/
|
||||
void CoUninitialize();
|
||||
|
||||
/**
|
||||
* Creates a single uninitialized object of the class associated with a
|
||||
* specified CLSID.
|
||||
*
|
||||
* @param rclsid
|
||||
* The CLSID associated with the data and code that will be used
|
||||
* to create the object.
|
||||
* @param pUnkOuter
|
||||
* If NULL, indicates that the object is not being created as
|
||||
* part of an aggregate. If non-NULL, pointer to the aggregate
|
||||
* object's IUnknown interface (the controlling IUnknown).
|
||||
* @param dwClsContext
|
||||
* Context in which the code that manages the newly created
|
||||
* object will run. The values are taken from the enumeration
|
||||
* CLSCTX defined in WTypes.
|
||||
* @param riid
|
||||
* A reference to the identifier of the interface to be used to
|
||||
* communicate with the object.
|
||||
* @param ppv
|
||||
* Address of pointer variable that receives the interface
|
||||
* pointer requested in riid. Upon successful return, *ppv
|
||||
* contains the requested interface pointer. Upon failure, *ppv
|
||||
* contains NULL.
|
||||
* @return an HRESULT
|
||||
*/
|
||||
HRESULT CoCreateInstance(GUID rclsid, Pointer pUnkOuter, int dwClsContext,
|
||||
GUID riid, PointerByReference ppv);
|
||||
|
||||
/**
|
||||
* Looks up a CLSID in the registry, given a ProgID.
|
||||
*
|
||||
* @param lpszProgID
|
||||
* [in] A pointer to the ProgID whose CLSID is requested.
|
||||
* @param lpclsid
|
||||
* [out] Receives a pointer to the retrieved CLSID on return.
|
||||
*
|
||||
* @return S_OK The CLSID was retrieved successfully.
|
||||
*
|
||||
* CO_E_CLASSSTRING The registered CLSID for the ProgID is invalid.
|
||||
*
|
||||
* REGDB_E_WRITEREGDB An error occurred writing the CLSID to the
|
||||
* registry. See Remarks below.
|
||||
*
|
||||
* Remarks Given a ProgID, CLSIDFromProgID looks up its associated
|
||||
* CLSID in the registry. If the ProgID cannot be found in the
|
||||
* registry, CLSIDFromProgID creates an OLE 1 CLSID for the ProgID
|
||||
* and a CLSID entry in the registry. Because of the restrictions
|
||||
* placed on OLE 1 CLSID values, CLSIDFromProgID and CLSIDFromString
|
||||
* are the only two functions that can be used to generate a CLSID
|
||||
* for an OLE 1 object.
|
||||
*/
|
||||
HRESULT CLSIDFromProgID(String lpszProgID, CLSID.ByReference lpclsid);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromCLSID function back into the
|
||||
* original CLSID.
|
||||
*
|
||||
* @param lpsz
|
||||
* [in] The string representation of the CLSID.
|
||||
*
|
||||
* @param pclsid
|
||||
* [out] A pointer to the CLSID.
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* This function can return the standard return value E_INVALIDARG,
|
||||
* as well as the following values.
|
||||
*
|
||||
* NOERROR The CLSID was obtained successfully.
|
||||
*
|
||||
* CO_E_CLASSSTRING The class string was improperly formatted.
|
||||
*
|
||||
* REGDB_E_CLASSNOTREG The CLSID corresponding to the class string
|
||||
* was not found in the registry.
|
||||
*
|
||||
* REGDB_E_READREGDB The registry could not be opened for reading.
|
||||
*/
|
||||
HRESULT CLSIDFromString(WString lpsz, CLSID.ByReference pclsid);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,489 @@
|
||||
/* copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.OaIdl.DISPIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.Variant.VariantArg;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.VARTYPE;
|
||||
import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.ITypeLib;
|
||||
import com.sun.jna.ptr.DoubleByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
*
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface OleAuto extends StdCallLibrary {
|
||||
|
||||
/* Flags for IDispatch::Invoke */
|
||||
/** The Constant DISPATCH_METHOD. */
|
||||
public final static int DISPATCH_METHOD = 0x1;
|
||||
|
||||
/** The Constant DISPATCH_PROPERTYGET. */
|
||||
public final static int DISPATCH_PROPERTYGET = 0x2;
|
||||
|
||||
/** The Constant DISPATCH_PROPERTYPUT. */
|
||||
public final static int DISPATCH_PROPERTYPUT = 0x4;
|
||||
|
||||
/** The Constant DISPATCH_PROPERTYPUTREF. */
|
||||
public final static int DISPATCH_PROPERTYPUTREF = 0x8;
|
||||
|
||||
/** An array that is allocated on the stac. */
|
||||
public final static int FADF_AUTO = 0x0001;
|
||||
|
||||
/** An array that is statically allocated. */
|
||||
public final static int FADF_STATIC = 0x0002;
|
||||
|
||||
/** An array that is embedded in a structure. */
|
||||
public final static int FADF_EMBEDDED = 0x0004;
|
||||
|
||||
/** An array that is embedded in a structure. */
|
||||
public final static int FADF_FIXEDSIZE = 0x0010;
|
||||
|
||||
/** An array that is embedded in a structure. */
|
||||
public final static int FADF_RECORD = 0x0020;
|
||||
|
||||
/** An array that is embedded in a structure. */
|
||||
public final static int FADF_HAVEIID = 0x0040;
|
||||
|
||||
/**
|
||||
* An array that has a variant type. The variant type can be retrieved with
|
||||
* SafeArrayGetVartype.
|
||||
*/
|
||||
public final static int FADF_HAVEVARTYPE = 0x0080;
|
||||
|
||||
/** An array of BSTRs. */
|
||||
public final static int FADF_BSTR = 0x0100;
|
||||
|
||||
/** An array of IUnknown*. */
|
||||
public final static int FADF_UNKNOWN = 0x0200;
|
||||
|
||||
/** An array of IDispatch*. */
|
||||
public final static int FADF_DISPATCH = 0x0400;
|
||||
|
||||
/** An array of VARIANTs. */
|
||||
public final static int FADF_VARIANT = 0x0800;
|
||||
|
||||
/** Bits reserved for future use. */
|
||||
public final static int FADF_RESERVED = 0xF008;
|
||||
|
||||
/** The instance. */
|
||||
OleAuto INSTANCE = (OleAuto) Native.loadLibrary("OleAut32", OleAuto.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function allocates a new string and copies the passed string into
|
||||
* it.
|
||||
*
|
||||
* @param sz
|
||||
* Null-terminated UNICODE string to copy.
|
||||
* @return Null if there is insufficient memory or if a null pointer is
|
||||
* passed in.
|
||||
*/
|
||||
public BSTR SysAllocString(String sz);
|
||||
|
||||
/**
|
||||
* This function frees a string allocated previously by SysAllocString,
|
||||
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
|
||||
* SysReAllocStringLen.
|
||||
*
|
||||
* @param bstr
|
||||
* Unicode string that was allocated previously, or NULL. Setting
|
||||
* this parameter to NULL causes the function to simply return.
|
||||
*/
|
||||
public void SysFreeString(BSTR bstr);
|
||||
|
||||
/**
|
||||
* The VariantInit function initializes the VARIANTARG by setting the vt
|
||||
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
|
||||
* the current contents of the VARIANTARG. Use VariantInit to initialize new
|
||||
* local variables of type VARIANTARG (or VARIANT).
|
||||
*
|
||||
* @param pvarg
|
||||
* The variant to initialize.
|
||||
*/
|
||||
public void VariantInit(VARIANT.ByReference pvarg);
|
||||
|
||||
/**
|
||||
* The VariantInit function initializes the VARIANTARG by setting the vt
|
||||
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
|
||||
* the current contents of the VARIANTARG. Use VariantInit to initialize new
|
||||
* local variables of type VARIANTARG (or VARIANT).
|
||||
*
|
||||
* @param pvarg
|
||||
* The variant to initialize.
|
||||
*/
|
||||
public void VariantInit(VARIANT pvarg);
|
||||
|
||||
/**
|
||||
* First, free any memory that is owned by pvargDest, such as VariantClear
|
||||
* (pvargDest must point to a valid initialized variant, and not simply to
|
||||
* an uninitialized memory location). Then pvargDest receives an exact copy
|
||||
* of the contents of pvargSrc.
|
||||
*
|
||||
* If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrcis a
|
||||
* VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or
|
||||
* VT_UNKNOWN, AddRef is called to increment the object's reference count.
|
||||
*
|
||||
* If the variant to be copied is a COM object that is passed by reference,
|
||||
* the vtfield of the pvargSrcparameter is VT_DISPATCH | VT_BYREF or
|
||||
* VT_UNKNOWN | VT_BYREF. In this case, VariantCopy does not increment the
|
||||
* reference count on the referenced object. Because the variant being
|
||||
* copied is a pointer to a reference to an object, VariantCopy has no way
|
||||
* to determine if it is necessary to increment the reference count of the
|
||||
* object. It is therefore the responsibility of the caller to call
|
||||
* IUnknown::AddRef on the object or not, as appropriate.
|
||||
*
|
||||
* Note The VariantCopy method is not threadsafe.
|
||||
*
|
||||
* @param pvargDest
|
||||
* [out] The destination variant.
|
||||
* @param pvargSrc
|
||||
* [in] The source variant.
|
||||
* @return the hresult
|
||||
*/
|
||||
public HRESULT VariantCopy(Pointer pvargDest, VARIANT pvargSrc);
|
||||
|
||||
/**
|
||||
* Use this function to clear variables of type VARIANTARG (or VARIANT)
|
||||
* before the memory containing the VARIANTARG is freed (as when a local
|
||||
* variable goes out of scope).
|
||||
*
|
||||
* The function clears a VARIANTARG by setting the vt field to VT_EMPTY. The
|
||||
* current contents of the VARIANTARG are released first. If the vtfield is
|
||||
* VT_BSTR, the string is freed. If the vtfield is VT_DISPATCH, the object
|
||||
* is released. If the vt field has the VT_ARRAY bit set, the array is
|
||||
* freed.
|
||||
*
|
||||
* If the variant to be cleared is a COM object that is passed by reference,
|
||||
* the vtfield of the pvargparameter is VT_DISPATCH | VT_BYREF or VT_UNKNOWN
|
||||
* | VT_BYREF. In this case, VariantClear does not release the object.
|
||||
* Because the variant being cleared is a pointer to a reference to an
|
||||
* object, VariantClear has no way to determine if it is necessary to
|
||||
* release the object. It is therefore the responsibility of the caller to
|
||||
* release the object or not, as appropriate.
|
||||
*
|
||||
* In certain cases, it may be preferable to clear a variant in code without
|
||||
* calling VariantClear. For example, you can change the type of a VT_I4
|
||||
* variant to another type without calling this function. Safearrays of BSTR
|
||||
* will have SysFreeString called on each element not VariantClear. However,
|
||||
* you must call VariantClear if a VT_type is received but cannot be
|
||||
* handled. Safearrays of variant will also have VariantClear called on each
|
||||
* member. Using VariantClear in these cases ensures that code will continue
|
||||
* to work if Automation adds new variant types in the future.
|
||||
*
|
||||
* Do not use VariantClear on unitialized variants; use VariantInit to
|
||||
* initialize a new VARIANTARG or VARIANT.
|
||||
*
|
||||
* Variants containing arrays with outstanding references cannot be cleared.
|
||||
* Attempts to do so will return an HRESULT containing DISP_E_ARRAYISLOCKED.
|
||||
*
|
||||
* @param pvarg
|
||||
* [in, out] The variant to clear.
|
||||
* @return the hresult
|
||||
*/
|
||||
HRESULT VariantClear(Pointer pvarg);
|
||||
|
||||
/**
|
||||
* Creates a new array descriptor, allocates and initializes the data for
|
||||
* the array, and returns a pointer to the new array descriptor.
|
||||
*
|
||||
* @param vt
|
||||
* [in] The base type of the array (the VARTYPE of each element
|
||||
* of the array). The VARTYPE is restricted to a subset of the
|
||||
* variant types. Neither the VT_ARRAY nor the VT_BYREF flag can
|
||||
* be set. VT_EMPTY and VT_NULL are not valid base types for the
|
||||
* array. All other types are legal. cDims
|
||||
*
|
||||
* @param cDims
|
||||
* the c dims
|
||||
* @param rgsabound
|
||||
* the rgsabound
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* A safe array descriptor, or null if the array could not be
|
||||
* created.
|
||||
*/
|
||||
public SAFEARRAY.ByReference SafeArrayCreate(VARTYPE vt, int cDims,
|
||||
SAFEARRAYBOUND[] rgsabound);
|
||||
|
||||
/**
|
||||
* Stores the data element at the specified location in the array.
|
||||
*
|
||||
* @param psa
|
||||
* [in] An array descriptor created by SafeArrayCreate.
|
||||
* @param idx
|
||||
* the idx
|
||||
* @param pv
|
||||
* [in] The data to assign to the array. The variant types
|
||||
* VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not
|
||||
* require another level of indirection.
|
||||
* @return Return value
|
||||
*
|
||||
* This function can return one of these values.
|
||||
*
|
||||
* S_OK Success.
|
||||
*
|
||||
* DISP_E_BADINDEX The specified index is not valid.
|
||||
*
|
||||
* E_INVALIDARG One of the arguments is not valid.
|
||||
*
|
||||
* E_OUTOFMEMORY Memory could not be allocated for the element.
|
||||
*/
|
||||
public HRESULT SafeArrayPutElement(SAFEARRAY psa, long[] idx, VARIANT pv);
|
||||
|
||||
/**
|
||||
* Retrieves a single element of the array.
|
||||
*
|
||||
* @param psa
|
||||
* [in] An array descriptor created by SafeArrayCreate.
|
||||
* @param rgIndices
|
||||
* [in] A vector of indexes for each dimension of the array. The
|
||||
* right-most (least significant) dimension is rgIndices[0]. The
|
||||
* left-most dimension is stored at rgIndices[psa->cDims - 1].
|
||||
* @param pv
|
||||
* [out] The element of the array.
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* This function can return one of these values.
|
||||
*
|
||||
* S_OK Success.
|
||||
*
|
||||
* DISP_E_BADINDEX The specified index is not valid.
|
||||
*
|
||||
* E_INVALIDARG One of the arguments is not valid.
|
||||
*
|
||||
* E_OUTOFMEMORY Memory could not be allocated for the element.
|
||||
*/
|
||||
public HRESULT SafeArrayGetElement(SAFEARRAY psa, long[] rgIndices,
|
||||
Pointer pv);
|
||||
|
||||
/**
|
||||
* Increments the lock count of an array, and places a pointer to the array
|
||||
* data in pvData of the array descriptor.
|
||||
*
|
||||
* @param psa
|
||||
* [in] An array descriptor created by SafeArrayCreate.
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* This function can return one of these values.
|
||||
*
|
||||
* S_OK Success.
|
||||
*
|
||||
* E_INVALIDARG The argument psa is not valid.
|
||||
*
|
||||
* E_UNEXPECTED The array could not be locked.
|
||||
*/
|
||||
public HRESULT SafeArrayLock(SAFEARRAY psa);
|
||||
|
||||
/**
|
||||
* Decrements the lock count of an array so it can be freed or resized.
|
||||
*
|
||||
* @param psa
|
||||
* [in] An array descriptor created by SafeArrayCreate.
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* This function can return one of these values.
|
||||
*
|
||||
* S_OK Success.
|
||||
*
|
||||
* E_INVALIDARG The argument psa is not valid.
|
||||
*
|
||||
* E_UNEXPECTED The array could not be locked.
|
||||
*/
|
||||
public HRESULT SafeArrayUnLock(SAFEARRAY psa);
|
||||
|
||||
/**
|
||||
* Retrieves a pointer to a running object that has been registered with
|
||||
* OLE.
|
||||
*
|
||||
* @param rclsid
|
||||
* [in] The class identifier (CLSID) of the active object from
|
||||
* the OLE registration database.
|
||||
* @param pvReserved
|
||||
* Reserved for future use. Must be null.
|
||||
* @param ppunk
|
||||
* [out] The requested active object.
|
||||
*
|
||||
* @return Return value
|
||||
*
|
||||
* If this function succeeds, it returns S_OK. Otherwise, it returns
|
||||
* an HRESULT error code.
|
||||
*/
|
||||
HRESULT GetActiveObject(GUID rclsid, PVOID pvReserved,
|
||||
PointerByReference ppunk);
|
||||
|
||||
/**
|
||||
* The Class DISPPARAMS.
|
||||
*/
|
||||
public class DISPPARAMS extends Structure {
|
||||
|
||||
/**
|
||||
* The Class ByReference.
|
||||
*/
|
||||
public static class ByReference extends DISPPARAMS implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
/** The rgvarg. */
|
||||
public VariantArg.ByReference rgvarg;
|
||||
|
||||
/** The rgdispid named args. */
|
||||
public DISPIDbyReference rgdispidNamedArgs;
|
||||
|
||||
/** The c args. */
|
||||
public UINT cArgs;
|
||||
|
||||
/** The c named args. */
|
||||
public UINT cNamedArgs;
|
||||
|
||||
/**
|
||||
* Instantiates a new dispparams.
|
||||
*/
|
||||
public DISPPARAMS() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new dispparams.
|
||||
*
|
||||
* @param memory
|
||||
* the memory
|
||||
*/
|
||||
public DISPPARAMS(Pointer memory) {
|
||||
super(memory);
|
||||
this.read();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.sun.jna.Structure#getFieldOrder()
|
||||
*/
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "rgvarg", "rgdispidNamedArgs",
|
||||
"cArgs", "cNamedArgs" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses registry information to load a type library.
|
||||
*
|
||||
* @param rguid
|
||||
* The GUID of the library.
|
||||
* @param wVerMajor
|
||||
* The major version of the library.
|
||||
* @param wVerMinor
|
||||
* The minor version of the library.
|
||||
* @param lcid
|
||||
* The national language code of the library.
|
||||
* @param pptlib
|
||||
* The loaded type library.
|
||||
*
|
||||
* This function can return one of these values: S_OK Success.
|
||||
*
|
||||
* E_INVALIDARG One or more of the arguments is not valid.
|
||||
*
|
||||
* E_OUTOFMEMORY Insufficient memory to complete the operation.
|
||||
*
|
||||
* TYPE_E_IOERROR The function could not write to the file.
|
||||
*
|
||||
* TYPE_E_INVALIDSTATE The type library could not be opened.
|
||||
*
|
||||
* TYPE_E_INVDATAREAD The function could not read from the file.
|
||||
*
|
||||
* TYPE_E_UNSUPFORMAT The type library has an older format.
|
||||
*
|
||||
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
|
||||
* OLE-supported DLLs.
|
||||
*
|
||||
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
|
||||
* loaded.
|
||||
*/
|
||||
public HRESULT LoadRegTypeLib(GUID rguid, int wVerMajor, int wVerMinor,
|
||||
LCID lcid, PointerByReference pptlib);
|
||||
|
||||
/**
|
||||
* Loads and registers a type library.
|
||||
*
|
||||
* @param szFile
|
||||
* The name of the file from which the method should attempt to
|
||||
* load a type library.
|
||||
*
|
||||
* @param pptlib
|
||||
* The loaded type library. Return value
|
||||
*
|
||||
* This function can return one of these values.
|
||||
*
|
||||
* S_OK Success.
|
||||
*
|
||||
* E_INVALIDARG One or more of the arguments is not valid.
|
||||
*
|
||||
* E_OUTOFMEMORY Insufficient memory to complete the operation.
|
||||
*
|
||||
* TYPE_E_IOERROR The function could not write to the file.
|
||||
*
|
||||
* TYPE_E_INVALIDSTATE The type library could not be opened.
|
||||
*
|
||||
* TYPE_E_INVDATAREAD The function could not read from the file.
|
||||
*
|
||||
* TYPE_E_UNSUPFORMAT The type library has an older format.
|
||||
*
|
||||
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
|
||||
* OLE-supported DLLs.
|
||||
*
|
||||
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
|
||||
* loaded.
|
||||
*/
|
||||
HRESULT LoadTypeLib(WString szFile, ITypeLib pptlib);
|
||||
|
||||
/**
|
||||
* Converts a system time to a variant representation.
|
||||
*
|
||||
* @param lpSystemTime
|
||||
* [in] The system time.
|
||||
*
|
||||
* @param pvtime
|
||||
* [out] The variant time.
|
||||
*
|
||||
* @return The function returns TRUE on success and FALSE otherwise.
|
||||
*/
|
||||
int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime,
|
||||
DoubleByReference pvtime);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.VARTYPE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OleAut32Util.
|
||||
*
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public abstract class OleAutoUtil {
|
||||
|
||||
/**
|
||||
* Creates a new the variant array.
|
||||
*
|
||||
* @param size the size
|
||||
* @return the sAFEARRA y. by reference
|
||||
*/
|
||||
public static SAFEARRAY.ByReference createVarArray(int size) {
|
||||
SAFEARRAY.ByReference psa;
|
||||
SAFEARRAYBOUND[] rgsabound = new SAFEARRAYBOUND[1];
|
||||
rgsabound[0] = new SAFEARRAYBOUND(size, 0);
|
||||
|
||||
psa = OleAuto.INSTANCE.SafeArrayCreate(
|
||||
new VARTYPE(Variant.VT_VARIANT), 1, rgsabound);
|
||||
|
||||
return psa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe array put element.
|
||||
*
|
||||
* @param array the array
|
||||
* @param index the index
|
||||
* @param arg the arg
|
||||
*/
|
||||
public static void SafeArrayPutElement(SAFEARRAY array, long index,
|
||||
VARIANT arg) {
|
||||
long[] idx = new long[1];
|
||||
idx[0] = index;
|
||||
HRESULT hr = OleAuto.INSTANCE.SafeArrayPutElement(array, idx, arg);
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe array get element.
|
||||
*
|
||||
* @param array the array
|
||||
* @param index the index
|
||||
* @return the variant
|
||||
*/
|
||||
public static VARIANT SafeArrayGetElement(SAFEARRAY array, long index) {
|
||||
long[] idx = new long[1];
|
||||
idx[0] = index;
|
||||
VARIANT result = new VARIANT();
|
||||
HRESULT hr = OleAuto.INSTANCE.SafeArrayGetElement(array, idx,
|
||||
result.getPointer());
|
||||
COMUtils.SUCCEEDED(hr);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Digital Rapids Corp., All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface Oleaut32 extends StdCallLibrary {
|
||||
|
||||
Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary(
|
||||
"Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function allocates a new string and copies the passed string into it.
|
||||
* @param sz
|
||||
* Null-terminated UNICODE string to copy.
|
||||
* @return
|
||||
* Null if there is insufficient memory or if a null pointer is passed in.
|
||||
*/
|
||||
Pointer SysAllocString(String sz);
|
||||
|
||||
/**
|
||||
* This function frees a string allocated previously by SysAllocString,
|
||||
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
|
||||
* SysReAllocStringLen.
|
||||
* @param bstr
|
||||
* Unicode string that was allocated previously, or NULL. Setting this parameter
|
||||
* to NULL causes the function to simply return.
|
||||
*/
|
||||
void SysFreeString(Pointer bstr);
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Sspi.CredHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
|
||||
@@ -23,7 +22,6 @@ import com.sun.jna.platform.win32.Sspi.TimeStamp;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LUID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
@@ -97,7 +95,7 @@ public interface Secur32 extends StdCallLibrary {
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
|
||||
NativeLong fCredentialUse, LUID pvLogonID,
|
||||
int fCredentialUse, LUID pvLogonID,
|
||||
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
|
||||
Pointer pvGetKeyArgument, CredHandle phCredential,
|
||||
TimeStamp ptsExpiry);
|
||||
@@ -164,9 +162,9 @@ public interface Secur32 extends StdCallLibrary {
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
|
||||
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
String pszTargetName, int fContextReq, int Reserved1,
|
||||
int TargetDataRep, SecBufferDesc pInput, int Reserved2,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, IntByReference pfContextAttr,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
@@ -238,15 +236,15 @@ public interface Secur32 extends StdCallLibrary {
|
||||
* This function returns one of SEC_* values.
|
||||
*/
|
||||
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
SecBufferDesc pInput, int fContextReq, int TargetDataRep,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, IntByReference pfContextAttr,
|
||||
TimeStamp ptsTimeStamp);
|
||||
|
||||
/**
|
||||
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
|
||||
* describe the security packages available to the client.
|
||||
* @param pcPackages
|
||||
* A pointer to a ULONG variable that receives the number of packages returned.
|
||||
* A pointer to a int variable that receives the number of packages returned.
|
||||
* @param ppPackageInfo
|
||||
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
|
||||
* Each structure contains information from the security support provider (SSP) that
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
@@ -282,6 +285,10 @@ public interface SetupApi extends StdCallLibrary {
|
||||
* Reserved. Do not use.
|
||||
*/
|
||||
public Pointer Reserved;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "Flags", "Reserved" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,5 +337,9 @@ public interface SetupApi extends StdCallLibrary {
|
||||
* Reserved. For internal use only.
|
||||
*/
|
||||
public Pointer Reserved;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "DevInst", "Reserved" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2007, 2013 Timothy Wall, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -13,9 +13,9 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinDef.INT_PTR;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
@@ -128,6 +128,9 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
|
||||
* that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility
|
||||
* with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and
|
||||
* compared to either 32 or the following error codes below.
|
||||
* <p/>
|
||||
* NOTE: {@link WinDef.INT_PTR} is used instead of HINSTANCE here, since
|
||||
* the former fits the reutrn type's actual usage more closely.
|
||||
*
|
||||
* 0 The operating system is out of memory or resources.
|
||||
* ERROR_FILE_NOT_FOUND The specified file was not found.
|
||||
@@ -146,6 +149,23 @@ public interface Shell32 extends ShellAPI, StdCallLibrary {
|
||||
* SE_ERR_PNF The specified path was not found.
|
||||
* SE_ERR_SHARE A sharing violation occurred.
|
||||
*/
|
||||
WinDef.HINSTANCE ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory,
|
||||
INT_PTR ShellExecute(HWND hwnd, String lpOperation, String lpFile, String lpParameters, String lpDirectory,
|
||||
int nShowCmd);
|
||||
|
||||
/**
|
||||
* Retrieves the path of a special folder, identified by its CSIDL.
|
||||
*
|
||||
* @param owner
|
||||
* Reserved.
|
||||
* @param path
|
||||
* A pointer to a null-terminated string that receives the drive and path of the specified folder. This buffer must be at least MAX_PATH
|
||||
* characters in size.
|
||||
* @param csidl
|
||||
* A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
|
||||
* @param create
|
||||
* Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is
|
||||
* zero, the folder is not created.
|
||||
* @return {@code true} if successful; otherwise, {@code false}.
|
||||
*/
|
||||
boolean SHGetSpecialFolderPath(HWND owner, char[] path, int csidl, boolean create);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,6 +20,7 @@ import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
/**
|
||||
* Shell32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
* @author markus[at]headcrashing[dot]eu
|
||||
*/
|
||||
public abstract class Shell32Util {
|
||||
|
||||
@@ -55,4 +56,21 @@ public abstract class Shell32Util {
|
||||
public static String getFolderPath(int nFolder) {
|
||||
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the path of a special folder, identified by its CSIDL.
|
||||
*
|
||||
* @param csidl
|
||||
* A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
|
||||
* @param create
|
||||
* Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is
|
||||
* zero, the folder is not created.
|
||||
* @return The drive and path of the specified folder
|
||||
*/
|
||||
public static final String getSpecialFolderPath(final int csidl, final boolean create) {
|
||||
final char[] pszPath = new char[WinDef.MAX_PATH];
|
||||
if (!Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, csidl, create))
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
return Native.toString(pszPath);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
@@ -98,6 +101,10 @@ public interface ShellAPI extends StdCallLibrary {
|
||||
* A pointer to the title of a progress dialog box. This is a null-terminated string.
|
||||
*/
|
||||
public WString lpszProgressTitle;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" });
|
||||
}
|
||||
|
||||
/** Use this to encode <code>pFrom/pTo</code> paths. */
|
||||
public String encodePaths(String[] paths) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from ShlObj.h.
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
@@ -137,17 +139,18 @@ public interface Sspi extends StdCallLibrary {
|
||||
public static class SecHandle extends Structure {
|
||||
public Pointer dwLower;
|
||||
public Pointer dwUpper;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
|
||||
}
|
||||
|
||||
public static class ByReference extends SecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty SecHandle.
|
||||
*/
|
||||
public SecHandle() {
|
||||
dwLower = null;
|
||||
dwUpper = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,16 +169,18 @@ public interface Sspi extends StdCallLibrary {
|
||||
public static class PSecHandle extends Structure {
|
||||
|
||||
public static class ByReference extends PSecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first entry in an array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecHandle.ByReference secHandle;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "secHandle" });
|
||||
}
|
||||
|
||||
public PSecHandle() {
|
||||
|
||||
}
|
||||
|
||||
public PSecHandle(SecHandle h) {
|
||||
@@ -210,7 +215,6 @@ public interface Sspi extends StdCallLibrary {
|
||||
* Create a SECBUFFER_EMPTY SecBuffer.
|
||||
*/
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,24 +245,25 @@ public interface Sspi extends StdCallLibrary {
|
||||
/**
|
||||
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
|
||||
*/
|
||||
public NativeLong cbBuffer;
|
||||
public int cbBuffer;
|
||||
/**
|
||||
* Bit flags that indicate the type of buffer. Must be one of the values of
|
||||
* the SecBufferType enumeration.
|
||||
*/
|
||||
public NativeLong BufferType;
|
||||
public int BufferType = SECBUFFER_EMPTY;
|
||||
/**
|
||||
* A pointer to a buffer.
|
||||
*/
|
||||
public Pointer pvBuffer;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cbBuffer", "BufferType", "pvBuffer" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBuffer() {
|
||||
cbBuffer = new NativeLong(0);
|
||||
pvBuffer = null;
|
||||
BufferType = new NativeLong(SECBUFFER_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,10 +274,9 @@ public interface Sspi extends StdCallLibrary {
|
||||
* Buffer size, eg. MAX_TOKEN_SIZE.
|
||||
*/
|
||||
public SecBuffer(int type, int size) {
|
||||
cbBuffer = new NativeLong(size);
|
||||
cbBuffer = size;
|
||||
pvBuffer = new Memory(size);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
BufferType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,11 +287,10 @@ public interface Sspi extends StdCallLibrary {
|
||||
* Existing token.
|
||||
*/
|
||||
public SecBuffer(int type, byte[] token) {
|
||||
cbBuffer = new NativeLong(token.length);
|
||||
cbBuffer = token.length;
|
||||
pvBuffer = new Memory(token.length);
|
||||
pvBuffer.write(0, token, 0, token.length);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
BufferType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,7 +299,7 @@ public interface Sspi extends StdCallLibrary {
|
||||
* Raw buffer bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return pvBuffer.getByteArray(0, cbBuffer.intValue());
|
||||
return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,22 +308,26 @@ public interface Sspi extends StdCallLibrary {
|
||||
/**
|
||||
* Version number.
|
||||
*/
|
||||
public NativeLong ulVersion;
|
||||
public int ulVersion;
|
||||
/**
|
||||
* Number of buffers.
|
||||
*/
|
||||
public NativeLong cBuffers;
|
||||
public int cBuffers;
|
||||
/**
|
||||
* Pointer to array of buffers.
|
||||
*/
|
||||
public SecBuffer.ByReference[] pBuffers;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "ulVersion", "cBuffers", "pBuffers" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBufferDesc() {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
ulVersion = SECBUFFER_VERSION;
|
||||
cBuffers = 1;
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
@@ -334,8 +341,8 @@ public interface Sspi extends StdCallLibrary {
|
||||
* Initial token data.
|
||||
*/
|
||||
public SecBufferDesc(int type, byte[] token) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
ulVersion = SECBUFFER_VERSION;
|
||||
cBuffers = 1;
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
@@ -347,18 +354,18 @@ public interface Sspi extends StdCallLibrary {
|
||||
* @param tokenSize
|
||||
*/
|
||||
public SecBufferDesc(int type, int tokenSize) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
ulVersion = SECBUFFER_VERSION;
|
||||
cBuffers = 1;
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
if (pBuffers == null || cBuffers == null) {
|
||||
if (pBuffers == null || cBuffers == 0) {
|
||||
throw new RuntimeException("pBuffers | cBuffers");
|
||||
}
|
||||
if (cBuffers.intValue() == 1) {
|
||||
if (cBuffers == 1) {
|
||||
return pBuffers[0].getBytes();
|
||||
}
|
||||
throw new RuntimeException("cBuffers > 1");
|
||||
@@ -369,15 +376,17 @@ public interface Sspi extends StdCallLibrary {
|
||||
* A security integer.
|
||||
*/
|
||||
public static class SECURITY_INTEGER extends Structure {
|
||||
public NativeLong dwLower;
|
||||
public NativeLong dwUpper;
|
||||
public int dwLower;
|
||||
public int dwUpper;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
|
||||
}
|
||||
|
||||
/**
|
||||
* An security integer of 0.
|
||||
*/
|
||||
public SECURITY_INTEGER() {
|
||||
dwLower = new NativeLong(0);
|
||||
dwUpper = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +394,6 @@ public interface Sspi extends StdCallLibrary {
|
||||
* A timestamp.
|
||||
*/
|
||||
public static class TimeStamp extends SECURITY_INTEGER {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,8 +410,11 @@ public interface Sspi extends StdCallLibrary {
|
||||
*/
|
||||
public SecPkgInfo.ByReference pPkgInfo;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "pPkgInfo" });
|
||||
}
|
||||
|
||||
public PSecPkgInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,17 +435,16 @@ public interface Sspi extends StdCallLibrary {
|
||||
* A reference pointer to a SecPkgInfo structure.
|
||||
*/
|
||||
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of bit flags that describes the capabilities of the security package.
|
||||
*/
|
||||
public NativeLong fCapabilities;
|
||||
public int fCapabilities;
|
||||
/**
|
||||
* Specifies the version of the package protocol. Must be 1.
|
||||
*/
|
||||
public short wVersion;
|
||||
public short wVersion = 1;
|
||||
/**
|
||||
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
|
||||
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
|
||||
@@ -443,7 +453,7 @@ public interface Sspi extends StdCallLibrary {
|
||||
/**
|
||||
* Specifies the maximum size, in bytes, of the token.
|
||||
*/
|
||||
public NativeLong cbMaxToken;
|
||||
public int cbMaxToken;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the name of the security package.
|
||||
*/
|
||||
@@ -454,14 +464,14 @@ public interface Sspi extends StdCallLibrary {
|
||||
*/
|
||||
public WString Comment;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new package info.
|
||||
*/
|
||||
public SecPkgInfo() {
|
||||
fCapabilities = new NativeLong(0);
|
||||
wVersion = 1;
|
||||
wRPCID = 0;
|
||||
cbMaxToken = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
@@ -135,5 +138,9 @@ public interface Tlhelp32 extends StdCallLibrary {
|
||||
* retrieve the full path of the executable file for a 64-bit process.
|
||||
*/
|
||||
public char[] szExeFile = new char[WinDef.MAX_PATH];
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwSize", "cntUsage", "th32ProcessID", "th32DefaultHeapID", "th32ModuleID", "cntThreads", "th32ParentProcessID", "pcPriClassBase", "dwFlags", "szExeFile" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Ralf Hamberger, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.win32;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
|
||||
import com.sun.jna.platform.win32.WinDef.HMENU;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinDef.LPVOID;
|
||||
|
||||
|
||||
/**
|
||||
* Provides convenient usage of functions defined by {@code User32.dll}.
|
||||
*
|
||||
* @author Ralf HAMBERGER
|
||||
* @author Markus KARG (markus[at]headcrashing[dot]eu)
|
||||
*/
|
||||
public final class User32Util {
|
||||
public static final int registerWindowMessage(final String lpString) {
|
||||
final int messageId = User32.INSTANCE.RegisterWindowMessage(lpString);
|
||||
if (messageId == 0)
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public static final HWND createWindow(final String className, final String windowName, final int style, final int x, final int y, final int width,
|
||||
final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) {
|
||||
return User32Util.createWindowEx(0, className, windowName, style, x, y, width, height, parent, menu, instance, param);
|
||||
}
|
||||
|
||||
public static final HWND createWindowEx(final int exStyle, final String className, final String windowName, final int style, final int x, final int y,
|
||||
final int width, final int height, final HWND parent, final HMENU menu, final HINSTANCE instance, final LPVOID param) {
|
||||
final HWND hWnd = User32.INSTANCE
|
||||
.CreateWindowEx(exStyle, new WString(className), windowName, style, x, y, width, height, parent, menu, instance, param);
|
||||
if (hWnd == null)
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
public static final void destroyWindow(final HWND hWnd) {
|
||||
if (!User32.INSTANCE.DestroyWindow(hWnd))
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.platform.win32.OaIdl.CURRENCY;
|
||||
import com.sun.jna.platform.win32.OaIdl.DATE;
|
||||
import com.sun.jna.platform.win32.OaIdl.DECIMAL;
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOLbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl._VARIANT_BOOLbyReference;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.VARTYPE;
|
||||
import com.sun.jna.platform.win32.WinDef.BYTE;
|
||||
import com.sun.jna.platform.win32.WinDef.CHAR;
|
||||
import com.sun.jna.platform.win32.WinDef.CHARbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.LONG;
|
||||
import com.sun.jna.platform.win32.WinDef.LONGLONG;
|
||||
import com.sun.jna.platform.win32.WinDef.LONGLONGbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.LONGbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.PVOID;
|
||||
import com.sun.jna.platform.win32.WinDef.SCODE;
|
||||
import com.sun.jna.platform.win32.WinDef.SCODEbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.SHORT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONG;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONGLONG;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONGLONGbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.ULONGbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORT;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORTbyReference;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
import com.sun.jna.platform.win32.COM.IRecordInfo;
|
||||
import com.sun.jna.platform.win32.COM.IUnknown;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.DoubleByReference;
|
||||
import com.sun.jna.ptr.FloatByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.ShortByReference;
|
||||
|
||||
public interface Variant {
|
||||
|
||||
public static int VT_EMPTY = 0;
|
||||
public static int VT_NULL = 1;
|
||||
public static int VT_I2 = 2;
|
||||
public static int VT_I4 = 3;
|
||||
public static int VT_R4 = 4;
|
||||
public static int VT_R8 = 5;
|
||||
public static int VT_CY = 6;
|
||||
public static int VT_DATE = 7;
|
||||
public static int VT_BSTR = 8;
|
||||
public static int VT_DISPATCH = 9;
|
||||
public static int VT_ERROR = 10;
|
||||
public static int VT_BOOL = 11;
|
||||
public static int VT_VARIANT = 12;
|
||||
public static int VT_UNKNOWN = 13;
|
||||
public static int VT_DECIMAL = 14;
|
||||
public static int VT_I1 = 16;
|
||||
public static int VT_UI1 = 17;
|
||||
public static int VT_UI2 = 18;
|
||||
public static int VT_UI4 = 19;
|
||||
public static int VT_I8 = 20;
|
||||
public static int VT_UI8 = 21;
|
||||
public static int VT_INT = 22;
|
||||
public static int VT_UINT = 23;
|
||||
public static int VT_VOID = 24;
|
||||
public static int VT_HRESULT = 25;
|
||||
public static int VT_PTR = 26;
|
||||
public static int VT_SAFEARRAY = 27;
|
||||
public static int VT_CARRAY = 28;
|
||||
public static int VT_USERDEFINED = 29;
|
||||
public static int VT_LPSTR = 30;
|
||||
public static int VT_LPWSTR = 31;
|
||||
public static int VT_RECORD = 36;
|
||||
public static int VT_INT_PTR = 37;
|
||||
public static int VT_UINT_PTR = 38;
|
||||
public static int VT_FILETIME = 64;
|
||||
public static int VT_BLOB = 65;
|
||||
public static int VT_STREAM = 66;
|
||||
public static int VT_STORAGE = 67;
|
||||
public static int VT_STREAMED_OBJECT = 68;
|
||||
public static int VT_STORED_OBJECT = 69;
|
||||
public static int VT_BLOB_OBJECT = 70;
|
||||
public static int VT_CF = 71;
|
||||
public static int VT_CLSID = 72;
|
||||
public static int VT_VERSIONED_STREAM = 73;
|
||||
public static int VT_BSTR_BLOB = 0xfff;
|
||||
public static int VT_VECTOR = 0x1000;
|
||||
public static int VT_ARRAY = 0x2000;
|
||||
public static int VT_BYREF = 0x4000;
|
||||
public static int VT_RESERVED = 0x8000;
|
||||
public static int VT_ILLEGAL = 0xffff;
|
||||
public static int VT_ILLEGALMASKED = 0xfff;
|
||||
public static int VT_TYPEMASK = 0xfff;
|
||||
|
||||
public static VARIANT_BOOL VARIANT_TRUE = new VARIANT_BOOL(0xFFFF);
|
||||
public static VARIANT_BOOL VARIANT_FALSE = new VARIANT_BOOL(0x0000);
|
||||
|
||||
public static class VARIANT extends Union {
|
||||
|
||||
public static class ByReference extends VARIANT implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public _VARIANT _variant;
|
||||
|
||||
public DECIMAL decVal;
|
||||
|
||||
public VARIANT() {
|
||||
this.setType("_variant");
|
||||
this.read();
|
||||
}
|
||||
|
||||
public VARIANT(Pointer pointer) {
|
||||
super(pointer);
|
||||
this.setType("_variant");
|
||||
this.read();
|
||||
}
|
||||
|
||||
public VARIANT(BSTR value) {
|
||||
this();
|
||||
this.setValue(VT_BSTR, value);
|
||||
}
|
||||
|
||||
public VARIANT(VARIANT_BOOL value) {
|
||||
this();
|
||||
this.setValue(VT_BOOL, value);
|
||||
}
|
||||
|
||||
public VARIANT(LONG value) {
|
||||
this();
|
||||
this.setValue(VT_I4, value);
|
||||
}
|
||||
|
||||
public VARIANT(SHORT value) {
|
||||
this();
|
||||
this.setValue(VT_I2, value);
|
||||
}
|
||||
|
||||
public VARIANT(DATE value) {
|
||||
this();
|
||||
this.setValue(VT_DATE, value);
|
||||
}
|
||||
|
||||
public VARTYPE getVarType() {
|
||||
this.read();
|
||||
return _variant.vt;
|
||||
}
|
||||
|
||||
public void setVarType(short vt) {
|
||||
this._variant.vt = new VARTYPE(vt);
|
||||
}
|
||||
|
||||
public void setValue(int vt, Object value) {
|
||||
this.setValue(new VARTYPE(vt), value);
|
||||
}
|
||||
|
||||
public void setValue(VARTYPE vt, Object value) {
|
||||
switch (vt.intValue()) {
|
||||
case VT_I2:
|
||||
this._variant.__variant.writeField("iVal", value);
|
||||
break;
|
||||
case VT_I4:
|
||||
this._variant.__variant.writeField("lVal", value);
|
||||
break;
|
||||
case VT_I8:
|
||||
this._variant.__variant.writeField("llVal", value);
|
||||
break;
|
||||
case VT_R4:
|
||||
this._variant.__variant.writeField("fltVal", value);
|
||||
break;
|
||||
case VT_R8:
|
||||
this._variant.__variant.writeField("dblVal", value);
|
||||
break;
|
||||
case VT_BOOL:
|
||||
this._variant.__variant.writeField("boolVal", value);
|
||||
break;
|
||||
case VT_ERROR:
|
||||
this._variant.__variant.writeField("scode", value);
|
||||
break;
|
||||
case VT_CY:
|
||||
this._variant.__variant.writeField("cyVal", value);
|
||||
break;
|
||||
case VT_DATE:
|
||||
this._variant.__variant.writeField("date", value);
|
||||
break;
|
||||
case VT_BSTR:
|
||||
this._variant.__variant.writeField("bstrVal", value);
|
||||
break;
|
||||
case VT_DISPATCH:
|
||||
this._variant.__variant.writeField("pdispVal", value);
|
||||
break;
|
||||
case VT_SAFEARRAY:
|
||||
this._variant.__variant.writeField("parray", value);
|
||||
break;
|
||||
case VT_ARRAY:
|
||||
this._variant.__variant.writeField("parray", value);
|
||||
break;
|
||||
}
|
||||
|
||||
this._variant.writeField("vt", vt);
|
||||
this.write();
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
this.read();
|
||||
switch (this.getVarType().intValue()) {
|
||||
case VT_I2:
|
||||
return this._variant.__variant.readField("iVal");
|
||||
case VT_I4:
|
||||
return this._variant.__variant.readField("lVal");
|
||||
case VT_I8:
|
||||
return this._variant.__variant.readField("llVal");
|
||||
case VT_R4:
|
||||
return this._variant.__variant.readField("fltVal");
|
||||
case VT_R8:
|
||||
return this._variant.__variant.readField("dblVal");
|
||||
case VT_BOOL:
|
||||
return this._variant.__variant.readField("boolVal");
|
||||
case VT_ERROR:
|
||||
return this._variant.__variant.readField("scode");
|
||||
case VT_CY:
|
||||
return this._variant.__variant.readField("cyVal");
|
||||
case VT_DATE:
|
||||
return this._variant.__variant.readField("date");
|
||||
case VT_BSTR:
|
||||
return this._variant.__variant.readField("bstrVal");
|
||||
case VT_DISPATCH:
|
||||
return this._variant.__variant.readField("pdispVal");
|
||||
case VT_SAFEARRAY:
|
||||
return this._variant.__variant.readField("parray");
|
||||
case VT_ARRAY:
|
||||
return this._variant.__variant.readField("parray");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class _VARIANT extends Structure {
|
||||
|
||||
public VARTYPE vt;
|
||||
public short wReserved1;
|
||||
public short wReserved2;
|
||||
public short wReserved3;
|
||||
public __VARIANT __variant;
|
||||
|
||||
public _VARIANT() {
|
||||
}
|
||||
|
||||
public _VARIANT(Pointer pointer) {
|
||||
super(pointer);
|
||||
this.read();
|
||||
}
|
||||
|
||||
public static class __VARIANT extends Union {
|
||||
// LONGLONG VT_I8
|
||||
public LONGLONG llVal;
|
||||
// LONG VT_I4
|
||||
public LONG lVal;
|
||||
// BYTE VT_UI1
|
||||
public BYTE bVal;
|
||||
// SHORT VT_I2
|
||||
public SHORT iVal;
|
||||
// FLOAT VT_R4
|
||||
public Float fltVal;
|
||||
// DOUBLE VT_R8
|
||||
public Double dblVal;
|
||||
// VARIANT_BOOL VT_BOOL
|
||||
public VARIANT_BOOL boolVal;
|
||||
// SCODE VT_ERROR
|
||||
public SCODE scode;
|
||||
// CY VT_CY
|
||||
public CURRENCY cyVal;
|
||||
// DATE VT_DATE
|
||||
public DATE date;
|
||||
// BSTR VT_BSTR
|
||||
public BSTR bstrVal;
|
||||
// IUnknown * VT_UNKNOWN
|
||||
public IUnknown punkVal;
|
||||
// IDispatch * VT_DISPATCH
|
||||
public IDispatch pdispVal;
|
||||
// SAFEARRAY * VT_ARRAY
|
||||
public SAFEARRAY.ByReference parray;
|
||||
// BYTE * VT_BYREF|VT_UI1
|
||||
public ByteByReference pbVal;
|
||||
// SHORT * VT_BYREF|VT_I2
|
||||
public ShortByReference piVal;
|
||||
// LONG * VT_BYREF|VT_I4
|
||||
public LONGbyReference plVal;
|
||||
// LONGLONG * VT_BYREF|VT_I8
|
||||
public LONGLONGbyReference pllVal;
|
||||
// FLOAT * VT_BYREF|VT_R4
|
||||
public FloatByReference pfltVal;
|
||||
// DOUBLE * VT_BYREF|VT_R8
|
||||
public DoubleByReference pdblVal;
|
||||
// VARIANT_BOOL * VT_BYREF|VT_BOOL
|
||||
public VARIANT_BOOLbyReference pboolVal;
|
||||
// VARIANT_BOOL * VT_BYREF|VT_BOOL
|
||||
public _VARIANT_BOOLbyReference pbool;
|
||||
// SCODE * VT_BYREF|VT_ERROR
|
||||
public SCODEbyReference pscode;
|
||||
// CY * VT_BYREF|VT_CY
|
||||
public CURRENCY.ByReference pcyVal;
|
||||
// DATE * VT_BYREF|VT_DATE
|
||||
public DATE.ByReference pdate;
|
||||
// BSTR * VT_BYREF|VT_BSTR
|
||||
public BSTR pbstrVal;
|
||||
// IUnknown ** VT_BYREF|VT_UNKNOWN
|
||||
public IUnknown.ByReference ppunkVal;
|
||||
// IDispatch ** VT_BYREF|VT_DISPATCH
|
||||
public IDispatch.ByReference ppdispVal;
|
||||
// SAFEARRAY ** VT_BYREF|VT_ARRAY
|
||||
public SAFEARRAY.ByReference pparray;
|
||||
// VARIANT * VT_BYREF|VT_VARIANT
|
||||
public VARIANT.ByReference pvarVal;
|
||||
// PVOID VT_BYREF (Generic ByRef)
|
||||
public PVOID byref;
|
||||
// CHAR VT_I1
|
||||
public CHAR cVal;
|
||||
// USHORT VT_UI2
|
||||
public USHORT uiVal;
|
||||
// ULONG VT_UI4
|
||||
public ULONG ulVal;
|
||||
// ULONGLONG VT_UI8
|
||||
public ULONGLONG ullVal;
|
||||
// INT VT_INT
|
||||
public Integer intVal;
|
||||
// UINT VT_UINT
|
||||
public UINT uintVal;
|
||||
// DECIMAL * VT_BYREF|VT_DECIMAL
|
||||
public DECIMAL.ByReference pdecVal;
|
||||
// CHAR * VT_BYREF|VT_I1
|
||||
public CHARbyReference pcVal;
|
||||
// USHORT * VT_BYREF|VT_UI2
|
||||
public USHORTbyReference puiVal;
|
||||
// ULONG * VT_BYREF|VT_UI4
|
||||
public ULONGbyReference pulVal;
|
||||
// ULONGLONG * VT_BYREF|VT_UI8
|
||||
public ULONGLONGbyReference pullVal;
|
||||
// INT * VT_BYREF|VT_INT
|
||||
public IntByReference pintVal;
|
||||
// UINT * VT_BYREF|VT_UINT
|
||||
public UINTbyReference puintVal;
|
||||
|
||||
public static class BRECORD extends Structure {
|
||||
public static class ByReference extends BRECORD implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public PVOID pvRecord;
|
||||
|
||||
public IRecordInfo pRecInfo;
|
||||
|
||||
public BRECORD() {
|
||||
}
|
||||
|
||||
public BRECORD(Pointer pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "pvRecord",
|
||||
"pRecInfo" });
|
||||
}
|
||||
}
|
||||
|
||||
public __VARIANT() {
|
||||
super();
|
||||
this.read();
|
||||
}
|
||||
|
||||
public __VARIANT(Pointer pointer) {
|
||||
super(pointer);
|
||||
this.read();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "vt", "wReserved1",
|
||||
"wReserved2", "wReserved3", "__variant" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class VariantArg extends Structure {
|
||||
|
||||
public static class ByReference extends VariantArg implements
|
||||
Structure.ByReference {
|
||||
}
|
||||
|
||||
public VARIANT[] variantArg;
|
||||
|
||||
public VariantArg() {
|
||||
}
|
||||
|
||||
public VariantArg(VARIANT[] variantArg) {
|
||||
this.variantArg = variantArg;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "variantArg" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
@@ -113,5 +116,9 @@ public interface VerRsrc extends StdCallLibrary {
|
||||
* The least significant 32 bits of the file's 64-bit binary creation date and time stamp.
|
||||
*/
|
||||
public WinDef.DWORD dwFileDateLS;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwSignature", "dwStrucVersion", "dwFileVersionMS", "dwFileVersionLS", "dwProductVersionMS", "dwProductVersionLS", "dwFileFlagsMask", "dwFileFlags", "dwFileOS", "dwFileType", "dwFileSubtype", "dwFileDateMS", "dwFileDateLS" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,181 @@
|
||||
/* Copyright (c) 2010,2011 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Utility class for some common error functions.
|
||||
*/
|
||||
public abstract class W32Errors implements WinError {
|
||||
/**
|
||||
* Generic test for success on any status value (non-negative numbers
|
||||
* indicate success).
|
||||
*/
|
||||
public static final boolean SUCCEEDED(int hr) {
|
||||
return hr >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* and the inverse
|
||||
*/
|
||||
public static final boolean FAILED(int hr) {
|
||||
return hr < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract error code from HRESULT
|
||||
*/
|
||||
public static final int HRESULT_CODE(int hr) {
|
||||
return hr & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract error code from SCODE
|
||||
*/
|
||||
public static final int SCODE_CODE(int sc) {
|
||||
return sc & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the facility
|
||||
*/
|
||||
public static final int HRESULT_FACILITY(int hr) {
|
||||
return (hr >>= 16) & 0x1fff;
|
||||
}
|
||||
|
||||
public static final int SCODE_FACILITY(short sc) {
|
||||
return (sc >>= 16) & 0x1fff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the severity
|
||||
*/
|
||||
public static short HRESULT_SEVERITY(int hr) {
|
||||
return (short) ((hr >>= 31) & 0x1);
|
||||
}
|
||||
|
||||
public static short SCODE_SEVERITY(short sc) {
|
||||
return (short) ((sc >>= 31) & 0x1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an HRESULT value from component pieces
|
||||
*/
|
||||
public static int MAKE_HRESULT(short sev, short fac, short code) {
|
||||
return ((sev << 31) | (fac << 16) | code);
|
||||
}
|
||||
|
||||
public static final int MAKE_SCODE(short sev, short fac, short code) {
|
||||
return ((sev << 31) | (fac << 16) | code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a WIN32 error value into a HRESULT
|
||||
* Note: This assumes that WIN32 errors fall in the range -32k to=32k.
|
||||
* @param x original w32 error code
|
||||
* @return the converted value
|
||||
*/
|
||||
public static final HRESULT HRESULT_FROM_WIN32(int x) {
|
||||
int f = FACILITY_WIN32;
|
||||
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16) | 0x80000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* FACILITY_USERMODE_FILTER_MANAGER
|
||||
*
|
||||
* Translation macro for converting:
|
||||
* NTSTATUS --> HRESULT
|
||||
*/
|
||||
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
|
||||
int f = FACILITY_USERMODE_FILTER_MANAGER;
|
||||
return (((x) & 0x8000FFFF) | (f <<= 16));
|
||||
}
|
||||
|
||||
}
|
||||
/* Copyright (c) 2010,2011 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Utility class for some common error functions.
|
||||
*/
|
||||
public abstract class W32Errors implements WinError {
|
||||
|
||||
/**
|
||||
* Generic test for success on any status value (non-negative numbers
|
||||
* indicate success).
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static final boolean SUCCEEDED(int hr) {
|
||||
return hr >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* and the inverse.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static final boolean FAILED(int hr) {
|
||||
return hr < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Succeeded.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static final boolean SUCCEEDED(HRESULT hr) {
|
||||
if (hr != null)
|
||||
return SUCCEEDED(hr.intValue());
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return true, if successful
|
||||
*/
|
||||
public static final boolean FAILED(HRESULT hr) {
|
||||
if (hr != null)
|
||||
return FAILED(hr.intValue());
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract error code from HRESULT.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return the int
|
||||
*/
|
||||
public static final int HRESULT_CODE(int hr) {
|
||||
return hr & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract error code from SCODE.
|
||||
*
|
||||
* @param sc the sc
|
||||
* @return the int
|
||||
*/
|
||||
public static final int SCODE_CODE(int sc) {
|
||||
return sc & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the facility.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return the int
|
||||
*/
|
||||
public static final int HRESULT_FACILITY(int hr) {
|
||||
return (hr >>= 16) & 0x1fff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scode facility.
|
||||
*
|
||||
* @param sc the sc
|
||||
* @return the int
|
||||
*/
|
||||
public static final int SCODE_FACILITY(short sc) {
|
||||
return (sc >>= 16) & 0x1fff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the severity.
|
||||
*
|
||||
* @param hr the hr
|
||||
* @return the short
|
||||
*/
|
||||
public static short HRESULT_SEVERITY(int hr) {
|
||||
return (short) ((hr >>= 31) & 0x1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scode severity.
|
||||
*
|
||||
* @param sc the sc
|
||||
* @return the short
|
||||
*/
|
||||
public static short SCODE_SEVERITY(short sc) {
|
||||
return (short) ((sc >>= 31) & 0x1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an HRESULT value from component pieces.
|
||||
*
|
||||
* @param sev the sev
|
||||
* @param fac the fac
|
||||
* @param code the code
|
||||
* @return the int
|
||||
*/
|
||||
public static int MAKE_HRESULT(short sev, short fac, short code) {
|
||||
return ((sev << 31) | (fac << 16) | code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make scode.
|
||||
*
|
||||
* @param sev the sev
|
||||
* @param fac the fac
|
||||
* @param code the code
|
||||
* @return the int
|
||||
*/
|
||||
public static final int MAKE_SCODE(short sev, short fac, short code) {
|
||||
return ((sev << 31) | (fac << 16) | code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a WIN32 error value into a HRESULT Note: This assumes that WIN32
|
||||
* errors fall in the range -32k to=32k.
|
||||
*
|
||||
* @param x
|
||||
* original w32 error code
|
||||
* @return the converted value
|
||||
*/
|
||||
public static final HRESULT HRESULT_FROM_WIN32(int x) {
|
||||
int f = FACILITY_WIN32;
|
||||
return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16)
|
||||
| 0x80000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* FACILITY_USERMODE_FILTER_MANAGER
|
||||
*
|
||||
* Translation macro for converting: NTSTATUS --> HRESULT.
|
||||
*
|
||||
* @param x the x
|
||||
* @return the int
|
||||
*/
|
||||
public static final int FILTER_HRESULT_FROM_FLT_NTSTATUS(int x) {
|
||||
int f = FACILITY_USERMODE_FILTER_MANAGER;
|
||||
return (((x) & 0x8000FFFF) | (f <<= 16));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.FileMonitor;
|
||||
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTRByReference;
|
||||
import com.sun.jna.platform.win32.WinBase.OVERLAPPED;
|
||||
import com.sun.jna.platform.win32.WinNT.FILE_NOTIFY_INFORMATION;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTRByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
@@ -110,14 +109,14 @@ public class W32FileMonitor extends FileMonitor {
|
||||
}
|
||||
|
||||
private FileInfo waitForChange() {
|
||||
Kernel32 klib = Kernel32.INSTANCE;
|
||||
IntByReference rcount = new IntByReference();
|
||||
ULONG_PTRByReference rkey = new ULONG_PTRByReference();
|
||||
PointerByReference roverlap = new PointerByReference();
|
||||
klib.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE);
|
||||
|
||||
if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) {
|
||||
return null;
|
||||
}
|
||||
synchronized (this) {
|
||||
return handleMap.get(rkey.getValue());
|
||||
return handleMap.get(new HANDLE(rkey.getValue().toPointer()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,29 +15,95 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
import com.sun.jna.platform.win32.WinDef.USHORT;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
|
||||
/**
|
||||
* Constant defined in WTypes.h
|
||||
*
|
||||
* @author scott.palmer
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
|
||||
public interface WTypes {
|
||||
int CLSCTX_INPROC_SERVER = 0x1;
|
||||
int CLSCTX_INPROC_HANDLER = 0x2;
|
||||
int CLSCTX_LOCAL_SERVER = 0x4;
|
||||
int CLSCTX_INPROC_SERVER16 = 0x8;
|
||||
int CLSCTX_REMOTE_SERVER = 0x10;
|
||||
int CLSCTX_INPROC_HANDLER16 = 0x20;
|
||||
int CLSCTX_RESERVED1 = 0x40;
|
||||
int CLSCTX_RESERVED2 = 0x80;
|
||||
int CLSCTX_RESERVED3 = 0x100;
|
||||
int CLSCTX_RESERVED4 = 0x200;
|
||||
int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
|
||||
int CLSCTX_RESERVED5 = 0x800;
|
||||
int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
|
||||
int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
|
||||
int CLSCTX_NO_FAILURE_LOG = 0x4000;
|
||||
int CLSCTX_DISABLE_AAA = 0x8000;
|
||||
int CLSCTX_ENABLE_AAA = 0x10000;
|
||||
int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
|
||||
int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
|
||||
int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
|
||||
|
||||
public static int CLSCTX_INPROC_SERVER = 0x1;
|
||||
public static int CLSCTX_INPROC_HANDLER = 0x2;
|
||||
public static int CLSCTX_LOCAL_SERVER = 0x4;
|
||||
public static int CLSCTX_INPROC_SERVER16 = 0x8;
|
||||
public static int CLSCTX_REMOTE_SERVER = 0x10;
|
||||
public static int CLSCTX_INPROC_HANDLER16 = 0x20;
|
||||
public static int CLSCTX_RESERVED1 = 0x40;
|
||||
public static int CLSCTX_RESERVED2 = 0x80;
|
||||
public static int CLSCTX_RESERVED3 = 0x100;
|
||||
public static int CLSCTX_RESERVED4 = 0x200;
|
||||
public static int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
|
||||
public static int CLSCTX_RESERVED5 = 0x800;
|
||||
public static int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
|
||||
public static int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
|
||||
public static int CLSCTX_NO_FAILURE_LOG = 0x4000;
|
||||
public static int CLSCTX_DISABLE_AAA = 0x8000;
|
||||
public static int CLSCTX_ENABLE_AAA = 0x10000;
|
||||
public static int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
|
||||
public static int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
|
||||
public static int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
|
||||
public static int CLSCTX_ENABLE_CLOAKING = 0x100000;
|
||||
public static int CLSCTX_APPCONTAINER = 0x400000;
|
||||
public static int CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000;
|
||||
public static int CLSCTX_PS_DLL = 0x80000000;
|
||||
public static int CLSCTX_SERVER = CLSCTX_INPROC_SERVER
|
||||
| CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER;
|
||||
public static int CLSCTX_ALL = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER
|
||||
| CLSCTX_LOCAL_SERVER;
|
||||
|
||||
public static class BSTR extends PointerType {
|
||||
public BSTR() {
|
||||
super(Pointer.NULL);
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.getPointer().setString(0, value, true);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.getPointer().getString(0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public class BSTRByReference extends ByReference {
|
||||
|
||||
public BSTRByReference() {
|
||||
super(Pointer.SIZE);
|
||||
}
|
||||
|
||||
public BSTRByReference(String value) {
|
||||
super(Pointer.SIZE);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
getPointer().setString(0, value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return getPointer().getString(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static class VARTYPE extends USHORT {
|
||||
public VARTYPE() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public VARTYPE(int value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
@@ -61,6 +64,10 @@ public interface Wdm extends StdCallLibrary {
|
||||
* The string is not null-terminated.
|
||||
*/
|
||||
public char[] Name;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "LastWriteTime", "TitleIndex", "NameLength", "Name" });
|
||||
}
|
||||
/**
|
||||
* Name of the key.
|
||||
* @return String.
|
||||
|
||||
@@ -12,20 +12,17 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.platform.win32.BaseTSD.DWORD_PTR;
|
||||
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDLONG;
|
||||
import com.sun.jna.platform.win32.WinDef.WORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Winbase.h (kernel32.dll/kernel services).
|
||||
@@ -174,7 +171,11 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
*/
|
||||
public static class FILETIME extends Structure {
|
||||
public int dwLowDateTime;
|
||||
public int dwHighDateTime;
|
||||
public int dwHighDateTime;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwLowDateTime", "dwHighDateTime" });
|
||||
}
|
||||
|
||||
public static class ByReference extends FILETIME implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
@@ -297,6 +298,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
public short wSecond;
|
||||
// The millisecond. The valid values for this member are 0 through 999.
|
||||
public short wMilliseconds;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "wYear", "wMonth", "wDayOfWeek", "wDay", "wHour", "wMinute", "wSecond", "wMilliseconds" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -385,6 +390,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
public int Offset;
|
||||
public int OffsetHigh;
|
||||
public HANDLE hEvent;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Internal", "InternalHigh", "Offset", "OffsetHigh", "hEvent" });
|
||||
}
|
||||
}
|
||||
|
||||
int INFINITE = 0xFFFFFFFF;
|
||||
@@ -417,6 +426,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
* Reserved for future use.
|
||||
*/
|
||||
public WORD wReserved;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "wProcessorArchitecture", "wReserved" });
|
||||
}
|
||||
}
|
||||
|
||||
/** Unnamed inner union. */
|
||||
@@ -487,6 +500,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
* Architecture-dependent processor revision.
|
||||
*/
|
||||
public WORD wProcessorRevision;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "processorArchitecture", "dwPageSize", "lpMinimumApplicationAddress", "lpMaximumApplicationAddress", "dwActiveProcessorMask", "dwNumberOfProcessors", "dwProcessorType", "dwAllocationGranularity", "wProcessorLevel", "wProcessorRevision"});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,6 +553,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
*/
|
||||
public DWORDLONG ullAvailExtendedVirtual;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwLength", "dwMemoryLoad", "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual" });
|
||||
}
|
||||
|
||||
public MEMORYSTATUSEX() {
|
||||
dwLength = new DWORD(size());
|
||||
}
|
||||
@@ -565,6 +586,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
*/
|
||||
public boolean bInheritHandle;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwLength", "lpSecurityDescriptor", "bInheritHandle" });
|
||||
}
|
||||
|
||||
public SECURITY_ATTRIBUTES() {
|
||||
dwLength = new DWORD(size());
|
||||
}
|
||||
@@ -737,6 +762,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
*/
|
||||
public HANDLE hStdError;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cb", "lpReserved", "lpDesktop", "lpTitle", "dwX", "dwY", "dwXSize", "dwYSize", "dwXCountChars", "dwYCountChars", "dwFillAttribute", "dwFlags", "wShowWindow", "cbReserved2", "lpReserved2", "hStdInput", "hStdOutput", "hStdError" });
|
||||
}
|
||||
|
||||
public STARTUPINFO() {
|
||||
cb = new DWORD(size());
|
||||
}
|
||||
@@ -778,6 +807,10 @@ public interface WinBase extends StdCallLibrary, WinDef, BaseTSD {
|
||||
* identifier may be reused.
|
||||
*/
|
||||
public DWORD dwThreadId;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "hProcess", "hThread", "dwProcessId", "dwThreadId" });
|
||||
}
|
||||
|
||||
public static class ByReference extends PROCESS_INFORMATION implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
@@ -59,6 +62,9 @@ public interface WinCrypt extends StdCallLibrary {
|
||||
*/
|
||||
public Pointer pbData;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cbData", "pbData" });
|
||||
}
|
||||
/**
|
||||
* Get byte data.
|
||||
* @return
|
||||
@@ -100,6 +106,10 @@ public interface WinCrypt extends StdCallLibrary {
|
||||
* A string containing the text of a prompt to be displayed.
|
||||
*/
|
||||
public String szPrompt;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "cbSize", "dwPromptFlags", "hwndApp", "szPrompt" });
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,97 +1,121 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from WinGDI.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface WinGDI extends StdCallLibrary {
|
||||
public int RDH_RECTANGLES = 1;
|
||||
|
||||
public class RGNDATAHEADER extends Structure {
|
||||
public int dwSize = size();
|
||||
public int iType = RDH_RECTANGLES; // required
|
||||
public int nCount;
|
||||
public int nRgnSize;
|
||||
public RECT rcBound;
|
||||
}
|
||||
|
||||
public class RGNDATA extends Structure {
|
||||
public RGNDATAHEADER rdh;
|
||||
public byte[] Buffer;
|
||||
public RGNDATA(int bufferSize) {
|
||||
Buffer = new byte[bufferSize];
|
||||
allocateMemory();
|
||||
}
|
||||
}
|
||||
|
||||
public int RGN_AND = 1;
|
||||
public int RGN_OR = 2;
|
||||
public int RGN_XOR = 3;
|
||||
public int RGN_DIFF = 4;
|
||||
public int RGN_COPY = 5;
|
||||
|
||||
public int ERROR = 0;
|
||||
public int NULLREGION = 1;
|
||||
public int SIMPLEREGION = 2;
|
||||
public int COMPLEXREGION = 3;
|
||||
|
||||
public int ALTERNATE = 1;
|
||||
public int WINDING = 2;
|
||||
|
||||
public int BI_RGB = 0;
|
||||
public int BI_RLE8 = 1;
|
||||
public int BI_RLE4 = 2;
|
||||
public int BI_BITFIELDS = 3;
|
||||
public int BI_JPEG = 4;
|
||||
public int BI_PNG = 5;
|
||||
|
||||
public class BITMAPINFOHEADER extends Structure {
|
||||
public int biSize = size();
|
||||
public int biWidth;
|
||||
public int biHeight;
|
||||
public short biPlanes;
|
||||
public short biBitCount;
|
||||
public int biCompression;
|
||||
public int biSizeImage;
|
||||
public int biXPelsPerMeter;
|
||||
public int biYPelsPerMeter;
|
||||
public int biClrUsed;
|
||||
public int biClrImportant;
|
||||
}
|
||||
|
||||
public class RGBQUAD extends Structure {
|
||||
public byte rgbBlue;
|
||||
public byte rgbGreen;
|
||||
public byte rgbRed;
|
||||
public byte rgbReserved = 0;
|
||||
}
|
||||
|
||||
public class BITMAPINFO extends Structure {
|
||||
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
|
||||
public RGBQUAD[] bmiColors = new RGBQUAD[1];
|
||||
public BITMAPINFO() { this(1); }
|
||||
public BITMAPINFO(int size) {
|
||||
bmiColors = new RGBQUAD[size];
|
||||
}
|
||||
}
|
||||
|
||||
public int DIB_RGB_COLORS = 0;
|
||||
public int DIB_PAL_COLORS = 1;
|
||||
}
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from WinGDI.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface WinGDI extends StdCallLibrary {
|
||||
public int RDH_RECTANGLES = 1;
|
||||
|
||||
public class RGNDATAHEADER extends Structure {
|
||||
public int dwSize = size();
|
||||
public int iType = RDH_RECTANGLES; // required
|
||||
public int nCount;
|
||||
public int nRgnSize;
|
||||
public RECT rcBound;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwSize", "iType", "nCount", "nRgnSize", "rcBound" });
|
||||
}
|
||||
}
|
||||
|
||||
public class RGNDATA extends Structure {
|
||||
public RGNDATAHEADER rdh;
|
||||
public byte[] Buffer;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "rdh", "Buffer" });
|
||||
}
|
||||
|
||||
public RGNDATA() {
|
||||
this(1);
|
||||
}
|
||||
public RGNDATA(int bufferSize) {
|
||||
Buffer = new byte[bufferSize];
|
||||
allocateMemory();
|
||||
}
|
||||
}
|
||||
|
||||
public int RGN_AND = 1;
|
||||
public int RGN_OR = 2;
|
||||
public int RGN_XOR = 3;
|
||||
public int RGN_DIFF = 4;
|
||||
public int RGN_COPY = 5;
|
||||
|
||||
public int ERROR = 0;
|
||||
public int NULLREGION = 1;
|
||||
public int SIMPLEREGION = 2;
|
||||
public int COMPLEXREGION = 3;
|
||||
|
||||
public int ALTERNATE = 1;
|
||||
public int WINDING = 2;
|
||||
|
||||
public int BI_RGB = 0;
|
||||
public int BI_RLE8 = 1;
|
||||
public int BI_RLE4 = 2;
|
||||
public int BI_BITFIELDS = 3;
|
||||
public int BI_JPEG = 4;
|
||||
public int BI_PNG = 5;
|
||||
|
||||
public class BITMAPINFOHEADER extends Structure {
|
||||
public int biSize = size();
|
||||
public int biWidth;
|
||||
public int biHeight;
|
||||
public short biPlanes;
|
||||
public short biBitCount;
|
||||
public int biCompression;
|
||||
public int biSizeImage;
|
||||
public int biXPelsPerMeter;
|
||||
public int biYPelsPerMeter;
|
||||
public int biClrUsed;
|
||||
public int biClrImportant;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "biSize", "biWidth", "biHeight", "biPlanes", "biBitCount", "biCompression", "biSizeImage", "biXPelsPerMeter", "biYPelsPerMeter", "biClrUsed", "biClrImportant" });
|
||||
}
|
||||
}
|
||||
|
||||
public class RGBQUAD extends Structure {
|
||||
public byte rgbBlue;
|
||||
public byte rgbGreen;
|
||||
public byte rgbRed;
|
||||
public byte rgbReserved = 0;
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "rgbBlue", "rgbGreen", "rgbRed", "rgbReserved" });
|
||||
}
|
||||
}
|
||||
|
||||
public class BITMAPINFO extends Structure {
|
||||
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
|
||||
public RGBQUAD[] bmiColors = new RGBQUAD[1];
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "bmiHeader", "bmiColors" });
|
||||
}
|
||||
public BITMAPINFO() { this(1); }
|
||||
public BITMAPINFO(int size) {
|
||||
bmiColors = new RGBQUAD[size];
|
||||
}
|
||||
}
|
||||
|
||||
public int DIB_RGB_COLORS = 0;
|
||||
public int DIB_PAL_COLORS = 1;
|
||||
}
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
@@ -61,5 +64,9 @@ public interface Winioctl extends StdCallLibrary {
|
||||
* The partition number of the device, if the device can be partitioned. Otherwise, this member is -1.
|
||||
*/
|
||||
public int PartitionNumber;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "DeviceType", "DeviceNumber", "PartitionNumber" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
@@ -87,9 +89,12 @@ public interface Winspool extends StdCallLibrary {
|
||||
public String pDescription;
|
||||
public String pName;
|
||||
public String pComment;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "Flags", "pDescription", "pName", "pComment" });
|
||||
}
|
||||
|
||||
public PRINTER_INFO_1() {
|
||||
|
||||
}
|
||||
|
||||
public PRINTER_INFO_1(int size) {
|
||||
@@ -101,9 +106,12 @@ public interface Winspool extends StdCallLibrary {
|
||||
public String pPrinterName;
|
||||
public String pServerName;
|
||||
public DWORD Attributes;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "pPrinterName", "pServerName", "Attributes" });
|
||||
}
|
||||
|
||||
public PRINTER_INFO_4() {
|
||||
|
||||
}
|
||||
|
||||
public PRINTER_INFO_4(int size) {
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
@@ -97,6 +100,10 @@ public interface Winsvc extends StdCallLibrary {
|
||||
*/
|
||||
public int dwWaitHint;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
|
||||
}
|
||||
|
||||
public SERVICE_STATUS() {
|
||||
super();
|
||||
}
|
||||
@@ -181,6 +188,10 @@ public interface Winsvc extends StdCallLibrary {
|
||||
*/
|
||||
public int dwServiceFlags;
|
||||
|
||||
protected List getFieldOrder() {
|
||||
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint", "dwProcessId", "dwServiceFlags" });
|
||||
}
|
||||
|
||||
public SERVICE_STATUS_PROCESS() {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
public interface Wtsapi32 extends StdCallLibrary {
|
||||
|
||||
Wtsapi32 INSTANCE = (Wtsapi32) Native.loadLibrary("Wtsapi32",
|
||||
Wtsapi32.class, W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
int NOTIFY_FOR_ALL_SESSIONS = 1;
|
||||
|
||||
int NOTIFY_FOR_THIS_SESSION = 0;
|
||||
|
||||
/**
|
||||
* The session identified by lParam was connected to the console terminal or
|
||||
* RemoteFX session.
|
||||
*/
|
||||
public static final int WTS_CONSOLE_CONNECT = 0x1;
|
||||
|
||||
/**
|
||||
* The session identified by lParam was disconnected from the console
|
||||
* terminal or RemoteFX session.
|
||||
*/
|
||||
public static final int WTS_CONSOLE_DISCONNECT = 0x2;
|
||||
|
||||
/**
|
||||
* The session identified by lParam was connected to the remote terminal.
|
||||
*/
|
||||
public static final int WTS_REMOTE_CONNECT = 0x3;
|
||||
|
||||
/**
|
||||
* The session identified by lParam was disconnected from the remote
|
||||
* terminal.
|
||||
*/
|
||||
public static final int WTS_REMOTE_DISCONNECT = 0x4;
|
||||
|
||||
/**
|
||||
* A user has logged on to the session identified by lParam.
|
||||
*/
|
||||
public static final int WTS_SESSION_LOGON = 0x5;
|
||||
|
||||
/**
|
||||
* A user has logged off the session identified by lParam.
|
||||
*/
|
||||
public static final int WTS_SESSION_LOGOFF = 0x6;
|
||||
|
||||
/**
|
||||
* The session identified by lParam has been locked.
|
||||
*/
|
||||
public static final int WTS_SESSION_LOCK = 0x7;
|
||||
|
||||
/**
|
||||
* The session identified by lParam has been unlocked.
|
||||
*/
|
||||
public static final int WTS_SESSION_UNLOCK = 0x8;
|
||||
|
||||
/**
|
||||
* The session identified by lParam has changed its remote controlled
|
||||
* status. To determine the status, call GetSystemMetrics and check the
|
||||
* SM_REMOTECONTROL metric.
|
||||
*/
|
||||
public static final int WTS_SESSION_REMOTE_CONTROL = 0x9;
|
||||
|
||||
/**
|
||||
* Registers the specified window to receive session change notifications.
|
||||
*
|
||||
* @param hWnd
|
||||
* [in] Handle of the window to receive session change
|
||||
* notifications.
|
||||
*
|
||||
* @param dwFlags
|
||||
* [in] Specifies which session notifications are to be received.
|
||||
* This parameter can be one of the following values.
|
||||
*
|
||||
* @return If the function succeeds, the return value is TRUE. Otherwise, it
|
||||
* is FALSE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean WTSRegisterSessionNotification(HWND hWnd, int dwFlags);
|
||||
|
||||
/**
|
||||
* Unregisters the specified window so that it receives no further session
|
||||
* change notifications.
|
||||
*
|
||||
* @param hWnd
|
||||
* [in] Handle of the window to be unregistered from receiving
|
||||
* session notifications.
|
||||
*
|
||||
* @return If the function succeeds, the return value is TRUE. Otherwise, it
|
||||
* is FALSE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean WTSUnRegisterSessionNotification(HWND hWnd);
|
||||
}
|
||||
@@ -13,9 +13,8 @@
|
||||
package com.sun.jna.platform.wince;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.platform.win32.WinNT;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition <code>coredll.dll</code>.
|
||||
Add other win32 interface mappings as needed.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -24,8 +25,8 @@ public class FileUtilsTest extends TestCase {
|
||||
if (!utils.hasTrash())
|
||||
return;
|
||||
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File file = File.createTempFile(getName(), ".tmp", home);
|
||||
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
|
||||
File file = File.createTempFile(getName(), ".tmp", tmpdir);
|
||||
try {
|
||||
assertTrue("File should exist", file.exists());
|
||||
try {
|
||||
@@ -43,6 +44,39 @@ public class FileUtilsTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testMoveSymlinkToTrash() throws Exception {
|
||||
if (Platform.isWindows()) {
|
||||
return;
|
||||
}
|
||||
FileUtils utils = FileUtils.getInstance();
|
||||
if (!utils.hasTrash())
|
||||
return;
|
||||
|
||||
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
|
||||
File file = File.createTempFile(getName(), ".tmp", tmpdir);
|
||||
File symlink = new File(tmpdir, file.getName() + ".link");
|
||||
Runtime.getRuntime().exec(new String[] { "ln", "-s", file.getAbsolutePath(), symlink.getAbsolutePath() });
|
||||
try {
|
||||
assertTrue("File should exist", symlink.exists());
|
||||
try {
|
||||
utils.moveToTrash(new File[] { symlink });
|
||||
}
|
||||
catch(IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
assertFalse("Symlink still exists after move to trash: " + symlink, symlink.exists());
|
||||
assertTrue("Original file should still exist after move to trash: " + file, file.exists());
|
||||
}
|
||||
finally {
|
||||
if (symlink.exists()) {
|
||||
symlink.delete();
|
||||
}
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(FileUtilsTest.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.win32.DBT;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.StructureFieldOrderInspector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StructureFieldOrderTest extends TestCase {
|
||||
|
||||
private String origPropJNANoSys;
|
||||
|
||||
protected void setUp() {
|
||||
origPropJNANoSys = System.getProperty("jna.nosys");
|
||||
System.setProperty("jna.nosys", "true"); // would be set by ant script, set here for IDE usage
|
||||
}
|
||||
|
||||
protected void tearDown() {
|
||||
if (origPropJNANoSys == null) {
|
||||
System.getProperties().remove("jna.nosys");
|
||||
} else {
|
||||
System.setProperty("jna.nosys", origPropJNANoSys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testMethodGetFieldOrder() {
|
||||
final List<String> ignoreConstructorError = new ArrayList<String>();
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
ignoreConstructorError.add(X11.class.getName() + "$");
|
||||
} else {
|
||||
ignoreConstructorError.add(com.sun.jna.platform.win32.Winspool.PRINTER_INFO_1.class.getName());
|
||||
ignoreConstructorError.add(com.sun.jna.platform.win32.Winspool.PRINTER_INFO_4.class.getName());
|
||||
ignoreConstructorError.add(com.sun.jna.platform.win32.SetupApi.SP_DEVICE_INTERFACE_DATA.class.getName());
|
||||
ignoreConstructorError.add(com.sun.jna.platform.win32.SetupApi.SP_DEVINFO_DATA.class.getName());
|
||||
}
|
||||
|
||||
ignoreConstructorError.add(DBT.DEV_BROADCAST_HANDLE.class.getName()); // manually validated by wolftobias
|
||||
ignoreConstructorError.add(DBT.DEV_BROADCAST_PORT.class.getName()); // manually validated by wolftobias
|
||||
|
||||
StructureFieldOrderInspector.batchCheckStructureGetFieldOrder(FileUtils.class, ignoreConstructorError);
|
||||
}
|
||||
|
||||
// test below is helpful when investigating failure cause of a specific Structure class, it shows full causes and traces.
|
||||
/*
|
||||
public void testMethodGetFieldOrderSingleClass() {
|
||||
final List<String> ignoreConstructorError = new ArrayList<String>();
|
||||
|
||||
if (Platform.isWindows()) {
|
||||
ignoreConstructorError.add(X11.class.getName() + "$");
|
||||
}
|
||||
|
||||
StructureFieldOrderInspector.checkMethodGetFieldOrder(com.sun.jna.platform.win32.SetupApi.SP_DEVICE_INTERFACE_DATA.class, ignoreConstructorError);
|
||||
}
|
||||
//*/
|
||||
|
||||
|
||||
}
|
||||
@@ -47,8 +47,7 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
public class Advapi32Test extends TestCase {
|
||||
|
||||
private static final String EVERYONE = "S-1-1-0";
|
||||
private static final String NOBODY = "S-1-0-0";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(Advapi32Test.class);
|
||||
}
|
||||
@@ -274,7 +273,10 @@ public class Advapi32Test extends TestCase {
|
||||
userInfo.usri1_name = new WString("JNAAdvapi32TestImp");
|
||||
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
|
||||
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null));
|
||||
// ignore test if not able to add user (need to be administrator to do this).
|
||||
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
HANDLEByReference phUser = new HANDLEByReference();
|
||||
try {
|
||||
@@ -517,7 +519,16 @@ public class Advapi32Test extends TestCase {
|
||||
String applicationEventLog = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application";
|
||||
String jnaEventSource = "JNADevEventSource";
|
||||
String jnaEventSourceRegistryPath = applicationEventLog + "\\" + jnaEventSource;
|
||||
Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
|
||||
// ignore test if not able to create key (need to be administrator to do this).
|
||||
try {
|
||||
final boolean keyCreated = Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
|
||||
if (!keyCreated) {
|
||||
return;
|
||||
}
|
||||
} catch (Win32Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, jnaEventSource);
|
||||
IntByReference before = new IntByReference();
|
||||
assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, before));
|
||||
@@ -733,7 +744,10 @@ public class Advapi32Test extends TestCase {
|
||||
assertTrue(Advapi32.INSTANCE.CloseServiceHandle(handle));
|
||||
|
||||
assertNull(Advapi32.INSTANCE.OpenSCManager("invalidMachineName", null, Winsvc.SC_MANAGER_CONNECT));
|
||||
assertEquals(W32Errors.RPC_S_SERVER_UNAVAILABLE, Kernel32.INSTANCE.GetLastError());
|
||||
int err = Kernel32.INSTANCE.GetLastError();
|
||||
assertTrue("Unexpected error in OpenSCManager: " + err,
|
||||
err == W32Errors.RPC_S_SERVER_UNAVAILABLE
|
||||
|| err == W32Errors.RPC_S_INVALID_NET_ADDR);
|
||||
|
||||
assertNull(Advapi32.INSTANCE.OpenSCManager(null, "invalidDatabase", Winsvc.SC_MANAGER_CONNECT));
|
||||
assertEquals(W32Errors.ERROR_INVALID_NAME, Kernel32.INSTANCE.GetLastError());
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -23,14 +22,12 @@ import com.sun.jna.platform.win32.Advapi32Util.Account;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.EventLogIterator;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.EventLogRecord;
|
||||
import com.sun.jna.platform.win32.LMAccess.USER_INFO_1;
|
||||
import com.sun.jna.platform.win32.WinNT.ACCESS_ACEStructure;
|
||||
import com.sun.jna.platform.win32.WinNT.ACCESS_ALLOWED_ACE;
|
||||
import com.sun.jna.platform.win32.WinNT.ACCESS_DENIED_ACE;
|
||||
import com.sun.jna.platform.win32.WinNT.ACEStructure;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.platform.win32.WinNT.SID_NAME_USE;
|
||||
import com.sun.jna.platform.win32.WinNT.WELL_KNOWN_SID_TYPE;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
@@ -112,10 +109,11 @@ public class Advapi32UtilTest extends TestCase {
|
||||
userInfo.usri1_name = new WString("JNANetapi32TestUser");
|
||||
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
|
||||
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
|
||||
// ignore test if not able to add user (need to be administrator to do this).
|
||||
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
assertEquals("Error in NetUserAdd",
|
||||
LMErr.NERR_Success,
|
||||
Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null));
|
||||
HANDLEByReference phUser = new HANDLEByReference();
|
||||
try {
|
||||
assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
|
||||
@@ -145,9 +143,11 @@ public class Advapi32UtilTest extends TestCase {
|
||||
userInfo.usri1_name = new WString("JNANetapi32TestUser");
|
||||
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
|
||||
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
|
||||
// ignore test if not able to add user (need to be administrator to do this).
|
||||
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
|
||||
null, 1, userInfo, null));
|
||||
HANDLEByReference phUser = new HANDLEByReference();
|
||||
try {
|
||||
assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
|
||||
@@ -301,8 +301,9 @@ public class Advapi32UtilTest extends TestCase {
|
||||
Advapi32Util.registrySetStringArray(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "StringArray", stringsWritten);
|
||||
String[] emptyArray = new String[0];
|
||||
Advapi32Util.registrySetStringArray(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyStringArray", emptyArray);
|
||||
Advapi32Util.registrySetBinaryValue(WinReg.HKEY_CURRENT_USER, "Software\\JNA", "EmptyBinary", new byte[0]);
|
||||
TreeMap<String, Object> values = Advapi32Util.registryGetValues(WinReg.HKEY_CURRENT_USER, "Software\\JNA");
|
||||
assertEquals(6, values.keySet().size());
|
||||
assertEquals(7, values.keySet().size());
|
||||
assertEquals("FourtyTwo" + uu, values.get("42" + uu));
|
||||
assertEquals(42, values.get("FourtyTwo" + uu));
|
||||
assertEquals("%TEMP%", values.get("ExpandableString"));
|
||||
@@ -320,6 +321,46 @@ public class Advapi32UtilTest extends TestCase {
|
||||
assertEquals(0, stringsRead.length);
|
||||
Advapi32Util.registryDeleteKey(WinReg.HKEY_CURRENT_USER, "Software", "JNA");
|
||||
}
|
||||
|
||||
public void testRegistryGetEmptyValues() {
|
||||
HKEY root = WinReg.HKEY_CURRENT_USER;
|
||||
String keyPath = "Software\\JNA";
|
||||
Advapi32Util.registryCreateKey(root, "Software", "JNA");
|
||||
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_BINARY);
|
||||
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_EXPAND_SZ);
|
||||
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_MULTI_SZ);
|
||||
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_NONE);
|
||||
doTestRegistryGetEmptyValues(root, keyPath, WinNT.REG_SZ);
|
||||
Advapi32Util.registryDeleteKey(root, "Software", "JNA");
|
||||
}
|
||||
|
||||
private void doTestRegistryGetEmptyValues(HKEY root, String keyPath, int valueType) {
|
||||
String valueName = "EmptyValue";
|
||||
registrySetEmptyValue(root, keyPath, valueName, valueType);
|
||||
Map<String, Object> values = Advapi32Util.registryGetValues(root, keyPath);
|
||||
assertEquals(1, values.size());
|
||||
assertTrue(values.containsKey(valueName));
|
||||
}
|
||||
|
||||
private static void registrySetEmptyValue(HKEY root, String keyPath, String name, final int valueType) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
char[] data = new char[0];
|
||||
rc = Advapi32.INSTANCE.RegSetValueEx(phkKey.getValue(), name, 0, valueType, data, 0);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testIsWellKnownSid() {
|
||||
String everyoneString = "S-1-1-0";
|
||||
@@ -410,135 +451,5 @@ public class Advapi32UtilTest extends TestCase {
|
||||
String block = Advapi32Util.getEnvironmentBlock(mockEnvironment);
|
||||
assertEquals("Environment block must comprise key=value pairs separated by NUL characters", expected, block);
|
||||
}
|
||||
|
||||
public void testGetFileSecurity() {
|
||||
//final String userUnderTest = "iFinder";
|
||||
final String userUnderTest = Advapi32Util.getUserName();
|
||||
final Account userUnderTestAccount = Advapi32Util.getAccountByName(userUnderTest);
|
||||
final String userUnderTestSID = userUnderTestAccount.sidString;
|
||||
//final String groupUnderTest = "Sales";
|
||||
final String groupUnderTest = "Everybody";
|
||||
final Account groupUnderTestAccount = Advapi32Util.getAccountByName(groupUnderTest);
|
||||
final String groupUnderTestSID = groupUnderTestAccount.sidString;
|
||||
|
||||
//final String testRootDir = "C:\\Projekte\\JNA-fileAccessRights\\";
|
||||
final String testRootDir = System.getProperty("java.io.tmpdir");
|
||||
|
||||
// User rights "modify" (Um) - includes some others: read, execute, write
|
||||
// Traverse Folder/Execute File (WinNT.FILE_TRAVERSE, WinNT.FILE_READ_DATA)
|
||||
// List Folder/Read Data (WinNT.FILE_LIST_DIRECTORY, WinNT.FILE_READ_DATA)
|
||||
// Read Attributes (WinNT.FILE_READ_ATTRIBUTES)
|
||||
// Read Extended Attributes (WinNT.FILE_READ_EA)
|
||||
// Create Files/Write Data (WinNT.FILE_ADD_FILE, WinNT.FILE_WRITE_DATA)
|
||||
// Create Folders/Append Data (WinNT.FILE_ADD_SUBDIRECTORY, WinNT.FILE_APPEND_DATA)
|
||||
// Write Attributes (WinNT.FILE_WRITE_ATTRIBUTES)
|
||||
// Write Extended Attributes (WinNT.FILE_WRITE_EA)
|
||||
// Delete (WinNT.DELETE)
|
||||
// Read Permissions (WinNT.FILE_READ_ATTRIBUTES)
|
||||
// Synchronize (WinNT.SYNCHRONIZE)
|
||||
// Group rights allowed:"read" denied:"write" (Gr-w)
|
||||
// List Folder/Read Data (WinNT.FILE_LIST_DIRECTORY, WinNT.FILE_READ_DATA)
|
||||
// Read Attributes (WinNT.FILE_READ_ATTRIBUTES)
|
||||
// Read Extended Attributes (WinNT.FILE_READ_EA)
|
||||
// Read Permissions (WinNT.FILE_READ_ATTRIBUTES)
|
||||
ACCESS_ACEStructure[] fileSecurity_UmGr = Advapi32Util.getFileSecurity(testRootDir + "/UmGr-w.txt", false);
|
||||
System.out.println("UmGr-w.txt");
|
||||
checkFileSecurity(fileSecurity_UmGr,
|
||||
userUnderTestSID,
|
||||
new String[] {
|
||||
"0 0 DELETE READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_READ_EA FILE_WRITE_EA FILE_EXECUTE FILE_TRAVERSE FILE_READ_ATTRIBUTES FILE_WRITE_ATTRIBUTES"
|
||||
},
|
||||
groupUnderTestSID,
|
||||
new String[] {
|
||||
"0 1 FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_WRITE_EA FILE_WRITE_ATTRIBUTES"
|
||||
, "0 0 READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_READ_EA FILE_READ_ATTRIBUTES"
|
||||
});
|
||||
|
||||
// User full access
|
||||
ACCESS_ACEStructure[] fileSecurity_Uf = Advapi32Util.getFileSecurity(testRootDir + "/Uf.txt", false);
|
||||
//System.out.println("Uf.txt");
|
||||
checkFileSecurity(fileSecurity_Uf, userUnderTestSID,
|
||||
new String[] {"0 0 DELETE READ_CONTROL WRITE_DAC WRITE_OWNER SYNCHRONIZE STANDARD_RIGHTS_REQUIRED STANDARD_RIGHTS_ALL FILE_READ_DATA FILE_LIST_DIRECTORY FILE_WRITE_DATA FILE_ADD_FILE FILE_APPEND_DATA FILE_ADD_SUBDIRECTORY FILE_CREATE_PIPE_INSTANCE FILE_READ_EA FILE_WRITE_EA FILE_EXECUTE FILE_TRAVERSE FILE_DELETE_CHILD FILE_READ_ATTRIBUTES FILE_WRITE_ATTRIBUTES"}, null, null);
|
||||
|
||||
// file in directory - access rights copied
|
||||
ACCESS_ACEStructure[] fileSecurity_Grw_Cp = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/Grw.txt", false);
|
||||
//System.out.println("UrwGr.dir/Grw.txt");
|
||||
checkFileSecurity(fileSecurity_Grw_Cp, null, null,
|
||||
groupUnderTestSID,
|
||||
new String[]{"16 0 READ_CONTROL SYNCHRONIZE FILE_READ_DATA FILE_LIST_DIRECTORY FILE_READ_EA FILE_READ_ATTRIBUTES"}
|
||||
);
|
||||
|
||||
/*
|
||||
// User rights: read, execute, list folder, write
|
||||
// Group rights: read
|
||||
ACCESS_ACEStructure[] fileSecurity_UrwGr_Dir = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/", false);
|
||||
System.out.println("UrwGr.dir/");
|
||||
|
||||
|
||||
// file in directory - access rights inherited
|
||||
// User rights: read, execute, write
|
||||
ACCESS_ACEStructure[] fileSecurity_UrI_Inh = Advapi32Util.getFileSecurity(testRootDir + "/UrwGr.dir/UrI.txt", false);
|
||||
System.out.println("UrwGr.dir/UrI.txt");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
private void checkFileSecurity(ACCESS_ACEStructure[] fileSecurity, String userUnderTestSID, String[] expectedUsrMasks, String groupUnderTestSID, String[] expectedGrpMasks) {
|
||||
int remainingUsr = userUnderTestSID == null ? 0 : expectedUsrMasks.length;
|
||||
int remainingGrp = groupUnderTestSID == null ? 0 : expectedGrpMasks.length;
|
||||
for (ACCESS_ACEStructure aces : fileSecurity) {
|
||||
if (userUnderTestSID != null && aces.getSidString().equals(userUnderTestSID)) {
|
||||
String start = (aces.AceFlags & WinNT.VALID_INHERIT_FLAGS) + " " + aces.AceType + " ";
|
||||
for (String expected : expectedUsrMasks) {
|
||||
if (expected.startsWith(start)) {
|
||||
String gotMask = start + getFileSecurityAsString(aces.Mask);
|
||||
System.out.println(expected);
|
||||
remainingUsr--;
|
||||
assertEquals(expected, gotMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (groupUnderTestSID != null && aces.getSidString().equals(groupUnderTestSID)) {
|
||||
String start = (aces.AceFlags & WinNT.VALID_INHERIT_FLAGS) + " " + aces.AceType + " ";
|
||||
for (String expected : expectedGrpMasks) {
|
||||
if (expected.startsWith(start)) {
|
||||
String gotMask = start + getFileSecurityAsString(aces.Mask);
|
||||
System.out.println(expected);
|
||||
remainingGrp--;
|
||||
assertEquals(expected, gotMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assertEquals("Not all ACLs found for user ", 0, remainingUsr);
|
||||
assertEquals("Not all ACLs found for group ", 0, remainingGrp);
|
||||
}
|
||||
|
||||
private String getFileSecurityAsString(int accessMask) {
|
||||
final String[] FLAGS = {"DELETE", "READ_CONTROL", "WRITE_DAC", "WRITE_OWNER", "SYNCHRONIZE",
|
||||
"STANDARD_RIGHTS_REQUIRED", "STANDARD_RIGHTS_ALL", "SPECIFIC_RIGHTS_ALL",
|
||||
"GENERIC_ALL", "GENERIC_EXECUTE", "GENERIC_WRITE", "GENERIC_READ",
|
||||
"FILE_READ_DATA", "FILE_LIST_DIRECTORY", "FILE_WRITE_DATA", "FILE_ADD_FILE",
|
||||
"FILE_APPEND_DATA", "FILE_ADD_SUBDIRECTORY", "FILE_CREATE_PIPE_INSTANCE",
|
||||
"FILE_READ_EA", "FILE_WRITE_EA", "FILE_EXECUTE", "FILE_TRAVERSE",
|
||||
"FILE_DELETE_CHILD", "FILE_READ_ATTRIBUTES", "FILE_WRITE_ATTRIBUTES"};
|
||||
|
||||
String asString = "";
|
||||
|
||||
for (String flag : FLAGS) {
|
||||
try {
|
||||
Field field = WinNT.class.getDeclaredField(flag);
|
||||
int int1 = field.getInt(null);
|
||||
if ((int1 & accessMask) == int1) {
|
||||
asString += flag + " ";
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchFieldException e) {
|
||||
}
|
||||
}
|
||||
return asString.trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32.COM;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Ole32;
|
||||
import com.sun.jna.platform.win32.W32Errors;
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
import com.sun.jna.platform.win32.COM.IDispatch;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
public class IUnknownTest extends TestCase {
|
||||
|
||||
private IDispatch iDispatch = new IDispatch();
|
||||
|
||||
private PointerByReference pDispatch = new PointerByReference();
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
Native.setProtected(true);
|
||||
System.out.println("JNA protected mode: " + Native.isProtected());
|
||||
|
||||
// Initialize COM for this thread...
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitialize(null);
|
||||
|
||||
if (W32Errors.FAILED(hr)) {
|
||||
this.tearDown();
|
||||
throw new COMException("CoInitialize() failed");
|
||||
}
|
||||
|
||||
// Get CLSID for Word.Application...
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
hr = Ole32.INSTANCE.CLSIDFromProgID("InternetExplorer.Application",
|
||||
clsid);
|
||||
|
||||
if (W32Errors.FAILED(hr)) {
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
throw new COMException("CLSIDFromProgID() failed!");
|
||||
}
|
||||
|
||||
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
|
||||
WTypes.CLSCTX_LOCAL_SERVER, IDispatch.IID_IDispatch,
|
||||
this.pDispatch);
|
||||
|
||||
if (W32Errors.FAILED(hr)) {
|
||||
throw new COMException("Internet Explorer not registered properly!");
|
||||
}
|
||||
|
||||
this.iDispatch = new IDispatch(pDispatch.getPointer());
|
||||
}
|
||||
|
||||
public void testQueryInterface() {
|
||||
System.out.println("start 'testQueryInterface'");
|
||||
PointerByReference ppvObject = new PointerByReference();
|
||||
this.iDispatch.QueryInterface(IDispatch.IID_IDispatch, ppvObject);
|
||||
|
||||
System.out.println("ppvObject:" + ppvObject.toString());
|
||||
System.out.println("end 'testQueryInterface'");
|
||||
}
|
||||
|
||||
public void testAddRef() {
|
||||
System.out.println("start 'testAddRef'");
|
||||
int addRef = this.iDispatch.AddRef();
|
||||
|
||||
System.out.println("addRef:" + addRef);
|
||||
System.out.println("end 'testAddRef'");
|
||||
}
|
||||
|
||||
public void testRelease() {
|
||||
System.out.println("start 'testQueryInterface'");
|
||||
int release = this.iDispatch.Release();
|
||||
|
||||
System.out.println("release:" + release);
|
||||
System.out.println("end 'testRelease'");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(IUnknownTest.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class GuidTest.
|
||||
*/
|
||||
public class GuidTest extends TestCase {
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args
|
||||
* the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(GuidTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new guid test.
|
||||
*/
|
||||
public GuidTest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a GUID from string and verify that the guid returned has the
|
||||
* expected values in each byte.
|
||||
*/
|
||||
public void testGUIDFromString() {
|
||||
String sourceGuidStr = "{A5DCBF10-6530-11D2-901F-00C04FB951ED}";
|
||||
// test loading via static method
|
||||
GUID targetGuid = GUID.fromString(sourceGuidStr);
|
||||
|
||||
assertEquals(targetGuid.toGuidString(), sourceGuidStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a GUID from string via the constructor and verify that the guid
|
||||
* returned has the expected values in each byte.
|
||||
*/
|
||||
public void testGUIDFromString2() {
|
||||
String sourceGuidStr = "{A5DCBF10-6530-11D2-901F-00C04FB951ED}";
|
||||
// test loading via constructor
|
||||
GUID targetGuid = new GUID(sourceGuidStr);
|
||||
|
||||
assertEquals(targetGuid.toGuidString(), sourceGuidStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a GUID from a byte array and verify that the guid returned has the
|
||||
* expected values in each byte.
|
||||
*/
|
||||
public void testGUIDFromBinary() {
|
||||
byte[] sourceGuidBArr = new byte[] { (byte) 0xA5, (byte) 0xDC,
|
||||
(byte) 0xBF, (byte) 0x10, (byte) 0x65, (byte) 0x30,
|
||||
(byte) 0x11, (byte) 0xD2, (byte) 0x90, (byte) 0x1F,
|
||||
(byte) 0x00, (byte) 0xC0, (byte) 0x4F, (byte) 0xB9,
|
||||
(byte) 0x51, (byte) 0xED };
|
||||
|
||||
// test loading via static method
|
||||
GUID targetGuid = GUID.fromBinary(sourceGuidBArr);
|
||||
byte[] targetGuidBArr = targetGuid.toByteArray();
|
||||
|
||||
for (int i = 0; i < sourceGuidBArr.length; i++) {
|
||||
assertEquals(targetGuidBArr[i], sourceGuidBArr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a GUID from a byte array via the constructor and verify that the
|
||||
* guid returned has the expected values in each byte.
|
||||
*/
|
||||
public void testGUIDFromBinary2() {
|
||||
byte[] sourceGuidBArr = new byte[] { (byte) 0xA5, (byte) 0xDC,
|
||||
(byte) 0xBF, (byte) 0x10, (byte) 0x65, (byte) 0x30,
|
||||
(byte) 0x11, (byte) 0xD2, (byte) 0x90, (byte) 0x1F,
|
||||
(byte) 0x00, (byte) 0xC0, (byte) 0x4F, (byte) 0xB9,
|
||||
(byte) 0x51, (byte) 0xED };
|
||||
|
||||
// test loading via constructor
|
||||
GUID targetGuid = new GUID(sourceGuidBArr);
|
||||
byte[] targetGuidBArr = targetGuid.toByteArray();
|
||||
|
||||
for (int i = 0; i < sourceGuidBArr.length; i++) {
|
||||
assertEquals(targetGuidBArr[i], sourceGuidBArr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates two guids, one with windows build-in function and one via
|
||||
* jna and compares it.
|
||||
*/
|
||||
public void testBehaviourWithOle32() {
|
||||
GUID ole32Guid = Ole32Util.getGUIDFromString("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
|
||||
GUID jnaGuid = new GUID("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
|
||||
|
||||
assertEquals(ole32Guid, jnaGuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test with the windows build-in function, compares the result of the
|
||||
* methods.
|
||||
*/
|
||||
public void testBehaviourWithOle32_2() {
|
||||
GUID ole32Guid = Ole32Util
|
||||
.getGUIDFromString("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
|
||||
GUID jnaGuid = new GUID("{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
|
||||
|
||||
String ole32Guidstr = Ole32Util.getStringFromGUID(ole32Guid);
|
||||
String jnaGuidStr = jnaGuid.toGuidString();
|
||||
|
||||
assertEquals(ole32Guidstr, jnaGuidStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the new guid with the build-in function coming with windows.
|
||||
*/
|
||||
public void testNewGuid() {
|
||||
GUID newGuid = GUID.newGuid();
|
||||
String guidString = newGuid.toGuidString();
|
||||
GUID guidFromString = Ole32Util.getGUIDFromString(guidString);
|
||||
|
||||
assertEquals(guidFromString.toGuidString(), guidString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.OaIdl.FUNCDESC;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPE;
|
||||
import com.sun.jna.platform.win32.OaIdl.HREFTYPEbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.INVOKEKIND;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
|
||||
import com.sun.jna.platform.win32.OaIdl.MEMBERIDbyReference;
|
||||
import com.sun.jna.platform.win32.OaIdl.TYPEATTR;
|
||||
import com.sun.jna.platform.win32.OaIdl.VARDESC;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTRByReference;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORDbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinDef.UINTbyReference;
|
||||
import com.sun.jna.platform.win32.WinDef.WORDbyReference;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMObject;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.ITypeComp;
|
||||
import com.sun.jna.platform.win32.COM.ITypeInfo;
|
||||
import com.sun.jna.platform.win32.COM.ITypeLib;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
public class ITypeInfoTest extends TestCase {
|
||||
|
||||
private COMObject comObj = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(ITypeInfoTest.class);
|
||||
}
|
||||
|
||||
public ITypeInfoTest() {
|
||||
Native.setProtected(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
if (this.comObj == null) {
|
||||
// create a shell COM object
|
||||
this.comObj = new COMObject("Shell.Application", false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (this.comObj != null) {
|
||||
this.comObj.release();
|
||||
}
|
||||
}
|
||||
|
||||
public ITypeInfo getTypeInfo() {
|
||||
// get user default lcid
|
||||
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
|
||||
// create a IUnknown pointer
|
||||
PointerByReference ppTInfo = new PointerByReference();
|
||||
|
||||
comObj.getIDispatch().GetTypeInfo(new UINT(0), lcid, ppTInfo);
|
||||
|
||||
return new ITypeInfo(ppTInfo.getValue());
|
||||
}
|
||||
|
||||
public void testGetTypeAttr() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
TYPEATTR.ByReference pTypeAttr = new TYPEATTR.ByReference();
|
||||
HRESULT hr = typeInfo.GetTypeAttr(pTypeAttr);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetTypeAttr: " + pTypeAttr.toString(true));
|
||||
}
|
||||
|
||||
public void testGetTypeComp() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
ITypeComp.ByReference pTComp = new ITypeComp.ByReference();
|
||||
HRESULT hr = typeInfo.GetTypeComp(pTComp);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetTypeComp: " + pTComp.toString());
|
||||
}
|
||||
|
||||
public void testGetFuncDesc() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
FUNCDESC.ByReference pFuncDesc = new FUNCDESC.ByReference();
|
||||
HRESULT hr = typeInfo.GetFuncDesc(new UINT(1), pFuncDesc);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetFuncDesc: " + pFuncDesc.toString(true));
|
||||
}
|
||||
|
||||
public void testGetVarDesc() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
VARDESC.ByReference pVarDesc = new VARDESC.ByReference();
|
||||
HRESULT hr = typeInfo.GetVarDesc(new UINT(0), pVarDesc);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetVarDesc: " + pVarDesc.toString());
|
||||
}
|
||||
|
||||
public void testGetNames() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
MEMBERID memid = new MEMBERID(1);
|
||||
BSTR[] rgBstrNames = new BSTR[1];
|
||||
UINT cMaxNames = new UINT(1);
|
||||
UINTbyReference pcNames = new UINTbyReference();
|
||||
HRESULT hr = typeInfo.GetNames(memid, rgBstrNames, cMaxNames, pcNames);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("rgBstrNames: " + rgBstrNames[0].getValue());
|
||||
System.out.println("pcNames: " + pcNames.getValue().intValue());
|
||||
}
|
||||
|
||||
public void testGetRefTypeOfImplType() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
HREFTYPEbyReference pRefType = new HREFTYPEbyReference();
|
||||
HRESULT hr = typeInfo.GetRefTypeOfImplType(new UINT(0), pRefType);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetRefTypeOfImplType: " + pRefType.toString());
|
||||
}
|
||||
|
||||
public void testGetImplTypeFlags() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
IntByReference pImplTypeFlags = new IntByReference();
|
||||
HRESULT hr = typeInfo.GetImplTypeFlags(new UINT(0), pImplTypeFlags);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetImplTypeFlags: " + pImplTypeFlags.toString());
|
||||
}
|
||||
|
||||
public void testGetIDsOfNames() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
WString[] rgszNames = { new WString("Visible") };
|
||||
UINT cNames = new UINT(1);
|
||||
MEMBERID[] pMemId = new MEMBERID[1];
|
||||
HRESULT hr = typeInfo.GetIDsOfNames(rgszNames, cNames, pMemId);
|
||||
|
||||
COMUtils.checkAutoRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("pMemId: " + pMemId.toString());
|
||||
}
|
||||
|
||||
public void testInvoke() {
|
||||
fail("not implemented due complexity.");
|
||||
}
|
||||
|
||||
public void testGetDocumentation() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
MEMBERID memid = new MEMBERID(0);
|
||||
BSTR pBstrName = new BSTR();
|
||||
BSTR pBstrDocString = new BSTR();
|
||||
DWORDbyReference pdwHelpContext = new DWORDbyReference();
|
||||
BSTR pBstrHelpFile = new BSTR();
|
||||
HRESULT hr = typeInfo.GetDocumentation(memid, pBstrName,
|
||||
pBstrDocString, pdwHelpContext, pBstrHelpFile);
|
||||
|
||||
COMUtils.checkAutoRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("memid: " + memid.intValue());
|
||||
System.out.println("pBstrName: " + pBstrName.getValue());
|
||||
System.out.println("pBstrDocString: " + pBstrDocString.getValue());
|
||||
System.out.println("pdwHelpContext: " + pdwHelpContext.getValue());
|
||||
System.out.println("pBstrHelpFile: " + pBstrHelpFile.getValue());
|
||||
}
|
||||
|
||||
public void testGetDllEntry() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
MEMBERID memid = new MEMBERID(0);
|
||||
BSTR pBstrDllName = new BSTR();
|
||||
BSTR pBstrName = new BSTR();
|
||||
WORDbyReference pwOrdinal = new WORDbyReference();
|
||||
HRESULT hr = typeInfo.GetDllEntry(memid, INVOKEKIND.INVOKE_FUNC,
|
||||
pBstrDllName, pBstrName, pwOrdinal);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("memid: " + memid.intValue());
|
||||
System.out.println("pBstrDllName: " + pBstrDllName.getValue());
|
||||
System.out.println("pBstrName: " + pBstrName.getValue());
|
||||
System.out.println("pwOrdinal: " + pwOrdinal.getValue());
|
||||
}
|
||||
|
||||
public void testGetRefTypeInfo() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
HREFTYPE hRefType = new HREFTYPE();
|
||||
ITypeInfo.ByReference ppTInfo = new ITypeInfo.ByReference();
|
||||
HRESULT hr = typeInfo.GetRefTypeInfo(hRefType, ppTInfo);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("GetRefTypeInfo: " + ppTInfo.toString());
|
||||
}
|
||||
|
||||
public void testAddressOfMember() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
MEMBERID memid = new MEMBERID();
|
||||
PointerByReference ppv = new PointerByReference();
|
||||
HRESULT hr = typeInfo.AddressOfMember(memid, INVOKEKIND.INVOKE_FUNC,
|
||||
ppv);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("AddressOfMember: " + ppv.toString());
|
||||
}
|
||||
|
||||
public void testCreateInstance() {
|
||||
fail("not implemented due complexity.");
|
||||
}
|
||||
|
||||
public void testGetMops() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
MEMBERID memid = new MEMBERID(0);
|
||||
BSTR pBstrMops = new BSTR();
|
||||
HRESULT hr = typeInfo.GetMops(memid, pBstrMops);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("pBstrMops: " + pBstrMops.toString());
|
||||
}
|
||||
|
||||
public void testGetContainingTypeLib() {
|
||||
ITypeInfo typeInfo = getTypeInfo();
|
||||
ITypeLib.ByReference pTLib = new ITypeLib.ByReference();
|
||||
UINTbyReference pIndex = new UINTbyReference();
|
||||
HRESULT hr = typeInfo.GetContainingTypeLib(pTLib, pIndex);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("pTLib: " + pTLib.toString());
|
||||
System.out.println("pTLib: " + pIndex.toString());
|
||||
}
|
||||
|
||||
public void testReleaseTypeAttr() {
|
||||
fail("not implemented due complexity.");
|
||||
}
|
||||
|
||||
public void testReleaseFuncDesc() {
|
||||
fail("not implemented due complexity.");
|
||||
}
|
||||
|
||||
public void testReleaseVarDesc() {
|
||||
fail("not implemented due complexity.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.OaIdl.TLIBATTR;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinDef.UINT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.platform.win32.COM.ITypeComp;
|
||||
import com.sun.jna.platform.win32.COM.ITypeInfo;
|
||||
import com.sun.jna.platform.win32.COM.ITypeLib;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
public class ITypeLibTest extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(ITypeLibTest.class);
|
||||
}
|
||||
|
||||
public ITypeLibTest() {
|
||||
Native.setProtected(true);
|
||||
}
|
||||
|
||||
public ITypeLib loadShellTypeLib() {
|
||||
// Microsoft Shell Controls And Automation
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
// get CLSID from string
|
||||
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(
|
||||
"{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}"), clsid);
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
|
||||
// get user default lcid
|
||||
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
|
||||
// create a IUnknown pointer
|
||||
PointerByReference pShellTypeLib = new PointerByReference();
|
||||
// load typelib
|
||||
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 1, 0, lcid, pShellTypeLib);
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
|
||||
return new ITypeLib(pShellTypeLib.getValue());
|
||||
}
|
||||
|
||||
public void testGetTypeInfoCount() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
UINT typeInfoCount = shellTypeLib.GetTypeInfoCount();
|
||||
System.out.println("GetTypeInfoCount: " + typeInfoCount);
|
||||
}
|
||||
|
||||
public void testGetTypeInfo() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
|
||||
ITypeInfo.ByReference pTInfo = new ITypeInfo.ByReference();
|
||||
HRESULT hr = shellTypeLib.GetTypeInfo(new UINT(0), pTInfo);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("ITypeInfo: " + pTInfo.toString());
|
||||
}
|
||||
|
||||
public void testGetTypeInfoType() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
|
||||
IntByReference pTKind = new IntByReference();
|
||||
HRESULT hr = shellTypeLib.GetTypeInfoType(new UINT(0), pTKind);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("TYPEKIND: " + pTKind);
|
||||
}
|
||||
|
||||
public void testGetTypeInfoOfGuid() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
|
||||
GUID shellGuid = new GUID("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}");
|
||||
ITypeInfo.ByReference pTInfo = new ITypeInfo.ByReference();
|
||||
HRESULT hr = shellTypeLib.GetTypeInfoOfGuid(shellGuid, pTInfo);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("ITypeInfo: " + pTInfo.toString());
|
||||
}
|
||||
|
||||
public void testGetLibAttr() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
|
||||
TLIBATTR.ByReference ppTLibAttr = new TLIBATTR.ByReference();
|
||||
HRESULT hr = shellTypeLib.GetLibAttr(ppTLibAttr);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("ppTLibAttr: " + ppTLibAttr.toString());
|
||||
}
|
||||
|
||||
public void testGetTypeComp() {
|
||||
ITypeLib shellTypeLib = loadShellTypeLib();
|
||||
|
||||
ITypeComp.ByReference pTComp = new ITypeComp.ByReference();
|
||||
HRESULT hr = shellTypeLib.GetTypeComp(pTComp);
|
||||
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
System.out.println("pTComp: " + pTComp.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,24 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -24,11 +28,11 @@ import java.util.TimeZone;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeMappedConverter;
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX;
|
||||
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
@@ -41,24 +45,24 @@ import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
public class Kernel32Test extends TestCase {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
|
||||
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
|
||||
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
|
||||
System.out.println("Operating system: "
|
||||
System.out.println("Operating system: "
|
||||
+ lpVersionInfo.dwMajorVersion.longValue() + "." + lpVersionInfo.dwMinorVersion.longValue()
|
||||
+ " (" + lpVersionInfo.dwBuildNumber + ")"
|
||||
+ " [" + Native.toString(lpVersionInfo.szCSDVersion) + "]");
|
||||
junit.textui.TestRunner.run(Kernel32Test.class);
|
||||
}
|
||||
|
||||
|
||||
public void testGetDriveType() {
|
||||
if (!Platform.isWindows()) return;
|
||||
|
||||
|
||||
Kernel32 kernel = Kernel32.INSTANCE;
|
||||
assertEquals("Wrong drive type.", WinBase.DRIVE_FIXED, kernel.GetDriveType("c:"));
|
||||
}
|
||||
|
||||
|
||||
public void testStructureOutArgument() {
|
||||
Kernel32 kernel = Kernel32.INSTANCE;
|
||||
WinBase.SYSTEMTIME time = new WinBase.SYSTEMTIME();
|
||||
@@ -69,18 +73,18 @@ public class Kernel32Test extends TestCase {
|
||||
assertEquals("Day not properly set",
|
||||
cal.get(Calendar.DAY_OF_WEEK)-1,
|
||||
time.wDayOfWeek);
|
||||
assertEquals("Year not properly set",
|
||||
assertEquals("Year not properly set",
|
||||
cal.get(Calendar.YEAR), time.wYear);
|
||||
}
|
||||
|
||||
|
||||
public void testGetLastError() {
|
||||
Kernel32 kernel = Kernel32.INSTANCE;
|
||||
int ERRCODE = 8;
|
||||
|
||||
|
||||
kernel.SetLastError(ERRCODE);
|
||||
int code = kernel.GetLastError();
|
||||
assertEquals("Wrong error value after SetLastError", ERRCODE, code);
|
||||
|
||||
|
||||
if (kernel.GetProcessVersion(-1) == 0) {
|
||||
final int INVALID_PARAMETER = 87;
|
||||
code = kernel.GetLastError();
|
||||
@@ -90,16 +94,16 @@ public class Kernel32Test extends TestCase {
|
||||
fail("GetProcessId(NULL) should fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testConvertHWND_BROADCAST() {
|
||||
HWND hwnd = WinUser.HWND_BROADCAST;
|
||||
NativeMappedConverter.getInstance(hwnd.getClass()).toNative(hwnd, null);
|
||||
}
|
||||
|
||||
|
||||
public void testGetComputerName() {
|
||||
IntByReference lpnSize = new IntByReference(0);
|
||||
assertFalse(Kernel32.INSTANCE.GetComputerName(null, lpnSize));
|
||||
assertEquals(W32Errors.ERROR_BUFFER_OVERFLOW, Kernel32.INSTANCE.GetLastError());
|
||||
assertEquals(WinError.ERROR_BUFFER_OVERFLOW, Kernel32.INSTANCE.GetLastError());
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
|
||||
lpnSize.setValue(buffer.length);
|
||||
assertTrue(Kernel32.INSTANCE.GetComputerName(buffer, lpnSize));
|
||||
@@ -107,87 +111,87 @@ public class Kernel32Test extends TestCase {
|
||||
|
||||
public void testWaitForSingleObject() {
|
||||
HANDLE handle = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
|
||||
// handle runs into timeout since it is not triggered
|
||||
// WAIT_TIMEOUT = 0x00000102
|
||||
assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForSingleObject(
|
||||
handle, 1000));
|
||||
|
||||
Kernel32.INSTANCE.CloseHandle(handle);
|
||||
}
|
||||
|
||||
public void testWaitForMultipleObjects(){
|
||||
HANDLE[] handles = new HANDLE[2];
|
||||
|
||||
handles[0] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
|
||||
|
||||
// handle runs into timeout since it is not triggered
|
||||
// WAIT_TIMEOUT = 0x00000102
|
||||
assertEquals(W32Errors.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForMultipleObjects(
|
||||
assertEquals(WinError.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForSingleObject(
|
||||
handle, 1000));
|
||||
|
||||
Kernel32.INSTANCE.CloseHandle(handle);
|
||||
}
|
||||
|
||||
public void testWaitForMultipleObjects(){
|
||||
HANDLE[] handles = new HANDLE[2];
|
||||
|
||||
handles[0] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
|
||||
// handle runs into timeout since it is not triggered
|
||||
// WAIT_TIMEOUT = 0x00000102
|
||||
assertEquals(WinError.WAIT_TIMEOUT, Kernel32.INSTANCE.WaitForMultipleObjects(
|
||||
handles.length, handles, false, 1000));
|
||||
|
||||
|
||||
Kernel32.INSTANCE.CloseHandle(handles[0]);
|
||||
Kernel32.INSTANCE.CloseHandle(handles[1]);
|
||||
|
||||
|
||||
// invalid Handle
|
||||
handles[0] = WinBase.INVALID_HANDLE_VALUE;
|
||||
handles[1] = Kernel32.INSTANCE.CreateEvent(null, false, false, null);
|
||||
|
||||
|
||||
// returns WAIT_FAILED since handle is invalid
|
||||
assertEquals(WinBase.WAIT_FAILED, Kernel32.INSTANCE.WaitForMultipleObjects(
|
||||
handles.length, handles, false, 5000));
|
||||
|
||||
Kernel32.INSTANCE.CloseHandle(handles[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testGetCurrentThreadId() {
|
||||
assertTrue(Kernel32.INSTANCE.GetCurrentThreadId() > 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetCurrentThread() {
|
||||
HANDLE h = Kernel32.INSTANCE.GetCurrentThread();
|
||||
assertNotNull(h);
|
||||
assertFalse(h.equals(0));
|
||||
// CloseHandle does not need to be called for a thread handle
|
||||
assertFalse(Kernel32.INSTANCE.CloseHandle(h));
|
||||
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
public void testOpenThread() {
|
||||
HANDLE h = Kernel32.INSTANCE.OpenThread(WinNT.THREAD_ALL_ACCESS, false,
|
||||
HANDLE h = Kernel32.INSTANCE.OpenThread(WinNT.THREAD_ALL_ACCESS, false,
|
||||
Kernel32.INSTANCE.GetCurrentThreadId());
|
||||
assertNotNull(h);
|
||||
assertFalse(h.equals(0));
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(h));
|
||||
}
|
||||
|
||||
|
||||
public void testGetCurrentProcessId() {
|
||||
assertTrue(Kernel32.INSTANCE.GetCurrentProcessId() > 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetCurrentProcess() {
|
||||
HANDLE h = Kernel32.INSTANCE.GetCurrentProcess();
|
||||
assertNotNull(h);
|
||||
assertFalse(h.equals(0));
|
||||
// CloseHandle does not need to be called for a process handle
|
||||
assertFalse(Kernel32.INSTANCE.CloseHandle(h));
|
||||
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
public void testOpenProcess() {
|
||||
HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false,
|
||||
HANDLE h = Kernel32.INSTANCE.OpenProcess(0, false,
|
||||
Kernel32.INSTANCE.GetCurrentProcessId());
|
||||
assertNull(h);
|
||||
// opening your own process fails with access denied
|
||||
assertEquals(W32Errors.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
|
||||
assertEquals(WinError.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
|
||||
public void testGetTempPath() {
|
||||
char[] buffer = new char[WinDef.MAX_PATH];
|
||||
assertTrue(Kernel32.INSTANCE.GetTempPath(new DWORD(WinDef.MAX_PATH), buffer).intValue() > 0);
|
||||
char[] buffer = new char[WinDef.MAX_PATH];
|
||||
assertTrue(Kernel32.INSTANCE.GetTempPath(new DWORD(WinDef.MAX_PATH), buffer).intValue() > 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetTickCount() throws InterruptedException {
|
||||
// Tick count rolls over every 49.7 days, so to safeguard from
|
||||
// roll-over, we will get two time spans. At least one should
|
||||
@@ -200,15 +204,15 @@ public class Kernel32Test extends TestCase {
|
||||
|
||||
assertTrue(tick2 > tick1 || tick3 > tick2);
|
||||
}
|
||||
|
||||
|
||||
public void testGetVersion() {
|
||||
DWORD version = Kernel32.INSTANCE.GetVersion();
|
||||
assertTrue("Version high should be non-zero: 0x" + Integer.toHexString(version.getHigh().intValue()), version.getHigh().intValue() != 0);
|
||||
assertTrue("Version low should be >= 0: 0x" + Integer.toHexString(version.getLow().intValue()), version.getLow().intValue() >= 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetVersionEx_OSVERSIONINFO() {
|
||||
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
|
||||
OSVERSIONINFO lpVersionInfo = new OSVERSIONINFO();
|
||||
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
|
||||
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
|
||||
assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0);
|
||||
@@ -216,11 +220,11 @@ public class Kernel32Test extends TestCase {
|
||||
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
|
||||
assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0);
|
||||
assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0);
|
||||
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
|
||||
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetVersionEx_OSVERSIONINFOEX() {
|
||||
OSVERSIONINFOEX lpVersionInfo = new OSVERSIONINFOEX();
|
||||
OSVERSIONINFOEX lpVersionInfo = new OSVERSIONINFOEX();
|
||||
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
|
||||
assertTrue(Kernel32.INSTANCE.GetVersionEx(lpVersionInfo));
|
||||
assertTrue(lpVersionInfo.dwMajorVersion.longValue() > 0);
|
||||
@@ -228,16 +232,16 @@ public class Kernel32Test extends TestCase {
|
||||
assertEquals(lpVersionInfo.size(), lpVersionInfo.dwOSVersionInfoSize.longValue());
|
||||
assertTrue(lpVersionInfo.dwPlatformId.longValue() > 0);
|
||||
assertTrue(lpVersionInfo.dwBuildNumber.longValue() > 0);
|
||||
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
|
||||
assertTrue(Native.toString(lpVersionInfo.szCSDVersion).length() >= 0);
|
||||
assertTrue(lpVersionInfo.wProductType >= 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetSystemInfo() {
|
||||
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
|
||||
Kernel32.INSTANCE.GetSystemInfo(lpSystemInfo);
|
||||
assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0);
|
||||
}
|
||||
|
||||
|
||||
public void testIsWow64Process() {
|
||||
try {
|
||||
IntByReference isWow64 = new IntByReference(42);
|
||||
@@ -248,7 +252,7 @@ public class Kernel32Test extends TestCase {
|
||||
// IsWow64Process is not available on this OS
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testGetNativeSystemInfo() {
|
||||
try {
|
||||
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
|
||||
@@ -258,7 +262,7 @@ public class Kernel32Test extends TestCase {
|
||||
// only available under WOW64
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testGlobalMemoryStatusEx() {
|
||||
MEMORYSTATUSEX lpBuffer = new MEMORYSTATUSEX();
|
||||
assertTrue(Kernel32.INSTANCE.GlobalMemoryStatusEx(lpBuffer));
|
||||
@@ -273,45 +277,46 @@ public class Kernel32Test extends TestCase {
|
||||
char buf[] = new char[dwSize.intValue()];
|
||||
assertTrue(Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf).intValue() > 0);
|
||||
}
|
||||
|
||||
|
||||
public void testGetDiskFreeSpaceEx() {
|
||||
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference();
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference();
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference();
|
||||
assertTrue(Kernel32.INSTANCE.GetDiskFreeSpaceEx(null,
|
||||
LARGE_INTEGER.ByReference lpFreeBytesAvailable = new LARGE_INTEGER.ByReference();
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes = new LARGE_INTEGER.ByReference();
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes = new LARGE_INTEGER.ByReference();
|
||||
assertTrue(Kernel32.INSTANCE.GetDiskFreeSpaceEx(null,
|
||||
lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes));
|
||||
assertTrue(lpTotalNumberOfFreeBytes.getValue() > 0);
|
||||
assertTrue(lpTotalNumberOfFreeBytes.getValue() < lpTotalNumberOfBytes.getValue());
|
||||
}
|
||||
|
||||
|
||||
public void testDeleteFile() {
|
||||
String filename = Kernel32Util.getTempPath() + "\\FileDoesNotExist.jna";
|
||||
assertFalse(Kernel32.INSTANCE.DeleteFile(filename));
|
||||
assertEquals(W32Errors.ERROR_FILE_NOT_FOUND, Kernel32.INSTANCE.GetLastError());
|
||||
assertEquals(WinError.ERROR_FILE_NOT_FOUND, Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
|
||||
public void testReadFile() throws IOException {
|
||||
String expected = "jna - testReadFile";
|
||||
File tmp = File.createTempFile("testReadFile", "jna");
|
||||
tmp.deleteOnExit();
|
||||
|
||||
|
||||
FileWriter fw = new FileWriter(tmp);
|
||||
fw.append(expected);
|
||||
fw.close();
|
||||
|
||||
|
||||
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
|
||||
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
|
||||
assertFalse(hFile == WinBase.INVALID_HANDLE_VALUE);
|
||||
|
||||
|
||||
Memory m = new Memory(2048);
|
||||
IntByReference lpNumberOfBytesRead = new IntByReference(0);
|
||||
assertTrue(Kernel32.INSTANCE.ReadFile(hFile, m, (int)m.size(), lpNumberOfBytesRead, null));
|
||||
assertEquals(expected.length(), lpNumberOfBytesRead.getValue());
|
||||
assertEquals(expected, m.getString(0));
|
||||
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
|
||||
assertTrue(Kernel32.INSTANCE.ReadFile(hFile, m, (int) m.size(), lpNumberOfBytesRead, null));
|
||||
int read = lpNumberOfBytesRead.getValue();
|
||||
assertEquals(expected.length(), read);
|
||||
assertEquals(expected, new String(m.getByteArray(0, read)));
|
||||
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
|
||||
}
|
||||
|
||||
|
||||
public void testSetHandleInformation() throws IOException {
|
||||
File tmp = File.createTempFile("testSetHandleInformation", "jna");
|
||||
tmp.deleteOnExit();
|
||||
@@ -319,39 +324,39 @@ public class Kernel32Test extends TestCase {
|
||||
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
|
||||
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
|
||||
assertFalse(hFile == WinBase.INVALID_HANDLE_VALUE);
|
||||
|
||||
|
||||
assertTrue(Kernel32.INSTANCE.SetHandleInformation(hFile, WinBase.HANDLE_FLAG_PROTECT_FROM_CLOSE, 0));
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
|
||||
}
|
||||
|
||||
|
||||
public void testCreatePipe() {
|
||||
HANDLEByReference hReadPipe = new HANDLEByReference();
|
||||
HANDLEByReference hWritePipe = new HANDLEByReference();
|
||||
|
||||
|
||||
assertTrue(Kernel32.INSTANCE.CreatePipe(hReadPipe, hWritePipe, null, 0));
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hReadPipe.getValue()));
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hWritePipe.getValue()));
|
||||
}
|
||||
|
||||
|
||||
public void testGetExitCodeProcess() {
|
||||
IntByReference lpExitCode = new IntByReference(0);
|
||||
assertTrue(Kernel32.INSTANCE.GetExitCodeProcess(Kernel32.INSTANCE.GetCurrentProcess(), lpExitCode));
|
||||
assertEquals(WinBase.STILL_ACTIVE, lpExitCode.getValue());
|
||||
}
|
||||
|
||||
|
||||
public void testTerminateProcess() throws IOException {
|
||||
File tmp = File.createTempFile("testTerminateProcess", "jna");
|
||||
tmp.deleteOnExit();
|
||||
HANDLE hFile = Kernel32.INSTANCE.CreateFile(tmp.getAbsolutePath(), WinNT.GENERIC_READ, WinNT.FILE_SHARE_READ,
|
||||
new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
|
||||
|
||||
|
||||
assertFalse(Kernel32.INSTANCE.TerminateProcess(hFile, 1));
|
||||
assertEquals(W32Errors.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
assertEquals(WinError.ERROR_INVALID_HANDLE, Kernel32.INSTANCE.GetLastError());
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(hFile));
|
||||
}
|
||||
|
||||
|
||||
public void testGetFileAttributes() {
|
||||
assertTrue(WinBase.INVALID_FILE_ATTRIBUTES != Kernel32.INSTANCE.GetFileAttributes("."));
|
||||
assertTrue(WinBase.INVALID_FILE_ATTRIBUTES != Kernel32.INSTANCE.GetFileAttributes("."));
|
||||
}
|
||||
|
||||
public void testCopyFile() throws IOException {
|
||||
@@ -406,11 +411,19 @@ public class Kernel32Test extends TestCase {
|
||||
assertTrue(processInformation.dwProcessId.longValue() > 0);
|
||||
}
|
||||
|
||||
public void testGetEnvironmentVariable() {
|
||||
assertTrue(Kernel32.INSTANCE.SetEnvironmentVariable("jna-getenvironment-test", "42"));
|
||||
int size = Kernel32.INSTANCE.GetEnvironmentVariable("jna-getenvironment-test", null, 0);
|
||||
assertTrue(size == 3);
|
||||
char[] data = new char[size];
|
||||
assertEquals(size - 1, Kernel32.INSTANCE.GetEnvironmentVariable("jna-getenvironment-test", data, size));
|
||||
assertEquals(size - 1, Native.toString(data).length());
|
||||
}
|
||||
|
||||
public void testSetEnvironmentVariable() {
|
||||
int value = new Random().nextInt();
|
||||
Kernel32.INSTANCE.SetEnvironmentVariable("jna-setenvironment-test", Integer.toString(value));
|
||||
|
||||
assertEquals(System.getenv("jna-setenvironment-test"), Integer.toString(value));
|
||||
assertEquals(Integer.toString(value), Kernel32Util.getEnvironmentVariable("jna-setenvironment-test"));
|
||||
}
|
||||
|
||||
public void testGetSetFileTime() throws IOException {
|
||||
@@ -466,4 +479,50 @@ public class Kernel32Test extends TestCase {
|
||||
assertTrue(Kernel32.INSTANCE.CloseHandle(processEnumHandle));
|
||||
assertTrue(processIdList.size() > 4);
|
||||
}
|
||||
|
||||
public final void testGetPrivateProfileInt() throws IOException {
|
||||
final File tmp = File.createTempFile("testGetPrivateProfileInt", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = 123");
|
||||
writer.close();
|
||||
|
||||
assertEquals(123, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "existingKey", 456, tmp.getCanonicalPath()));
|
||||
assertEquals(456, Kernel32.INSTANCE.GetPrivateProfileInt("Section", "missingKey", 456, tmp.getCanonicalPath()));
|
||||
}
|
||||
|
||||
public final void testGetPrivateProfileString() throws IOException {
|
||||
final File tmp = File.createTempFile("testGetPrivateProfileString", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = ABC");
|
||||
writer.close();
|
||||
|
||||
final char[] buffer = new char[8];
|
||||
assertEquals("ABC", Kernel32.INSTANCE.GetPrivateProfileString("Section", "existingKey", "DEF", buffer, new DWORD(buffer.length), tmp.getCanonicalPath()));
|
||||
assertEquals("DEF", Kernel32.INSTANCE.GetPrivateProfileString("Section", "missingKey", "DEF", buffer, new DWORD(buffer.length), tmp.getCanonicalPath()));
|
||||
}
|
||||
|
||||
public final void testWritePrivateProfileString() throws IOException {
|
||||
final File tmp = File.createTempFile("testWritePrivateProfileString", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = ABC");
|
||||
writer.println("removedKey = JKL");
|
||||
writer.close();
|
||||
|
||||
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath()));
|
||||
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "addedKey", "GHI", tmp.getCanonicalPath()));
|
||||
assertTrue(Kernel32.INSTANCE.WritePrivateProfileString("Section", "removedKey", null, tmp.getCanonicalPath()));
|
||||
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(tmp));
|
||||
assertEquals(reader.readLine(), "[Section]");
|
||||
assertTrue(reader.readLine().matches("existingKey\\s*=\\s*DEF"));
|
||||
assertTrue(reader.readLine().matches("addedKey\\s*=\\s*GHI"));
|
||||
assertEquals(reader.readLine(), null);
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -12,15 +12,21 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
* @author markus[at]headcrashing[dot]eu
|
||||
*/
|
||||
public class Kernel32UtilTest extends TestCase {
|
||||
|
||||
@@ -123,4 +129,55 @@ public class Kernel32UtilTest extends TestCase {
|
||||
tempFile.delete();
|
||||
assertEquals(0, fileAttributes2 & WinNT.FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
public void testGetEnvironmentVariable() {
|
||||
assertEquals(null, Kernel32Util.getEnvironmentVariable("jna-getenvironment-test"));
|
||||
Kernel32.INSTANCE.SetEnvironmentVariable("jna-getenvironment-test", "42");
|
||||
assertEquals("42", Kernel32Util.getEnvironmentVariable("jna-getenvironment-test"));
|
||||
}
|
||||
|
||||
public final void testGetPrivateProfileInt() throws IOException {
|
||||
final File tmp = File.createTempFile("testGetPrivateProfileInt", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = 123");
|
||||
writer.close();
|
||||
|
||||
assertEquals(123, Kernel32Util.getPrivateProfileInt("Section", "existingKey", 456, tmp.getCanonicalPath()));
|
||||
assertEquals(456, Kernel32Util.getPrivateProfileInt("Section", "missingKey", 456, tmp.getCanonicalPath()));
|
||||
}
|
||||
|
||||
public final void testGetPrivateProfileString() throws IOException {
|
||||
final File tmp = File.createTempFile("testGetPrivateProfileString", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = ABC");
|
||||
writer.close();
|
||||
|
||||
assertEquals("ABC", Kernel32Util.getPrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath()));
|
||||
assertEquals("DEF", Kernel32Util.getPrivateProfileString("Section", "missingKey", "DEF", tmp.getCanonicalPath()));
|
||||
}
|
||||
|
||||
public final void testWritePrivateProfileString() throws IOException {
|
||||
final File tmp = File.createTempFile("testWritePrivateProfileString", "ini");
|
||||
tmp.deleteOnExit();
|
||||
final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(tmp)));
|
||||
writer.println("[Section]");
|
||||
writer.println("existingKey = ABC");
|
||||
writer.println("removedKey = JKL");
|
||||
writer.close();
|
||||
|
||||
Kernel32Util.writePrivateProfileString("Section", "existingKey", "DEF", tmp.getCanonicalPath());
|
||||
Kernel32Util.writePrivateProfileString("Section", "addedKey", "GHI", tmp.getCanonicalPath());
|
||||
Kernel32Util.writePrivateProfileString("Section", "removedKey", null, tmp.getCanonicalPath());
|
||||
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(tmp));
|
||||
assertEquals(reader.readLine(), "[Section]");
|
||||
assertTrue(reader.readLine().matches("existingKey\\s*=\\s*DEF"));
|
||||
assertTrue(reader.readLine().matches("addedKey\\s*=\\s*GHI"));
|
||||
assertEquals(reader.readLine(), null);
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,13 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_INFO_2;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
|
||||
@@ -29,7 +27,6 @@ import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_RECORD;
|
||||
import com.sun.jna.platform.win32.Netapi32Util.User;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
@@ -152,8 +149,10 @@ public class Netapi32Test extends TestCase {
|
||||
userInfo.usri1_name = new WString("JNANetapi32TestUser");
|
||||
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
|
||||
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
|
||||
Kernel32Util.getComputerName(), 1, userInfo, null));
|
||||
// ignore test if not able to add user (need to be administrator to do this).
|
||||
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) {
|
||||
return;
|
||||
}
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel(
|
||||
Kernel32Util.getComputerName(), userInfo.usri1_name.toString()));
|
||||
}
|
||||
@@ -163,8 +162,10 @@ public class Netapi32Test extends TestCase {
|
||||
userInfo.usri1_name = new WString("JNANetapi32TestUser");
|
||||
userInfo.usri1_password = new WString("!JNAP$$Wrd0");
|
||||
userInfo.usri1_priv = LMAccess.USER_PRIV_USER;
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserAdd(
|
||||
Kernel32Util.getComputerName(), 1, userInfo, null));
|
||||
// ignore test if not able to add user (need to be administrator to do this).
|
||||
if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(Kernel32Util.getComputerName(), 1, userInfo, null)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserChangePassword(
|
||||
Kernel32Util.getComputerName(), userInfo.usri1_name.toString(), userInfo.usri1_password.toString(),
|
||||
@@ -200,7 +201,7 @@ public class Netapi32Test extends TestCase {
|
||||
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsGetForestTrustInformation(
|
||||
domainController, null, 0, pfti));
|
||||
|
||||
assertTrue(pfti.fti.RecordCount.intValue() >= 0);
|
||||
assertTrue(pfti.fti.RecordCount >= 0);
|
||||
|
||||
for (PLSA_FOREST_TRUST_RECORD precord : pfti.fti.getEntries()) {
|
||||
LSA_FOREST_TRUST_RECORD.UNION data = precord.tr.u;
|
||||
@@ -236,23 +237,24 @@ public class Netapi32Test extends TestCase {
|
||||
if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
|
||||
return;
|
||||
|
||||
NativeLongByReference domainCount = new NativeLongByReference();
|
||||
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
|
||||
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(
|
||||
null, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount));
|
||||
IntByReference domainTrustCount = new IntByReference();
|
||||
PointerByReference domainsPointerRef = new PointerByReference();
|
||||
assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(null,
|
||||
DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount));
|
||||
assertTrue(domainTrustCount.getValue() >= 0);
|
||||
|
||||
assertTrue(domainCount.getValue().intValue() >= 0);
|
||||
|
||||
DS_DOMAIN_TRUSTS[] trusts = domains.getTrusts(domainCount.getValue().intValue());
|
||||
for(DS_DOMAIN_TRUSTS trust : trusts) {
|
||||
assertTrue(trust.NetbiosDomainName.length() > 0);
|
||||
DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
|
||||
DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
|
||||
|
||||
for(DS_DOMAIN_TRUSTS trust : domainTrusts) {
|
||||
assertTrue(trust.DnsDomainName.length() > 0);
|
||||
assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid));
|
||||
assertTrue(Advapi32Util.convertSidToStringSid(trust.DomainSid).startsWith("S-"));
|
||||
assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{"));
|
||||
}
|
||||
|
||||
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(
|
||||
domains.getPointer()));
|
||||
|
||||
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import junit.framework.TestCase;
|
||||
import com.sun.jna.platform.win32.Netapi32Util.DomainController;
|
||||
import com.sun.jna.platform.win32.Netapi32Util.DomainTrust;
|
||||
import com.sun.jna.platform.win32.Netapi32Util.UserInfo;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -22,78 +22,89 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
* @author markus[at]headcrashing[dot]eu
|
||||
*/
|
||||
public class Ole32Test extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(Ole32Test.class);
|
||||
}
|
||||
|
||||
public void testCoCreateGUID() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.CoCreateGuid(pguid));
|
||||
assertTrue(pguid.Data1 != 0 || pguid.Data2 != 0 || pguid.Data3 != 0 && pguid.Data4 != null);
|
||||
}
|
||||
|
||||
public void testIIDFromString() {
|
||||
GUID.ByReference lpiid = new GUID.ByReference();
|
||||
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.IIDFromString(
|
||||
"{13709620-C279-11CE-A49E-444553540000}", lpiid)); // Shell.Application.1
|
||||
assertEquals(0x13709620, lpiid.Data1);
|
||||
assertEquals(0xFFFFC279, lpiid.Data2);
|
||||
assertEquals(0x11CE, lpiid.Data3);
|
||||
assertEquals(0xFFFFFFA4, lpiid.Data4[0]);
|
||||
assertEquals(0xFFFFFF9E, lpiid.Data4[1]);
|
||||
assertEquals(0x44, lpiid.Data4[2]);
|
||||
assertEquals(0x45, lpiid.Data4[3]);
|
||||
assertEquals(0x53, lpiid.Data4[4]);
|
||||
assertEquals(0x54, lpiid.Data4[5]);
|
||||
assertEquals(0, lpiid.Data4[6]);
|
||||
assertEquals(0, lpiid.Data4[7]);
|
||||
}
|
||||
|
||||
public void testStringFromGUID2() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
pguid.Data1 = 0;
|
||||
pguid.Data2 = 0;
|
||||
pguid.Data3 = 0;
|
||||
for (int i = 0; i < pguid.Data4.length; i++) {
|
||||
pguid.Data4[i] = 0;
|
||||
}
|
||||
int max = 39;
|
||||
char[] lpsz = new char[max];
|
||||
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
|
||||
assertTrue(len > 1);
|
||||
lpsz[len - 1] = 0;
|
||||
assertEquals("{00000000-0000-0000-0000-000000000000}", Native.toString(lpsz));
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(Ole32Test.class);
|
||||
}
|
||||
|
||||
public void testCoInitializeEx() {
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
|
||||
assertTrue(W32Errors.SUCCEEDED(hr.intValue()) || hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
|
||||
if (W32Errors.SUCCEEDED(hr.intValue()))
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
public void testCoCreateGUID() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.CoCreateGuid(pguid));
|
||||
assertTrue(pguid.Data1 != 0 || pguid.Data2 != 0 || pguid.Data3 != 0
|
||||
&& pguid.Data4 != null);
|
||||
}
|
||||
|
||||
public void testCoCreateInstance() {
|
||||
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
|
||||
public void testIIDFromString() {
|
||||
GUID.ByReference lpiid = new GUID.ByReference();
|
||||
assertEquals(W32Errors.S_OK, Ole32.INSTANCE.IIDFromString(
|
||||
"{13709620-C279-11CE-A49E-444553540000}", lpiid)); // Shell.Application.1
|
||||
assertEquals(0x13709620, lpiid.Data1);
|
||||
assertEquals(0xFFFFC279, lpiid.Data2);
|
||||
assertEquals(0x11CE, lpiid.Data3);
|
||||
assertEquals(0xFFFFFFA4, lpiid.Data4[0]);
|
||||
assertEquals(0xFFFFFF9E, lpiid.Data4[1]);
|
||||
assertEquals(0x44, lpiid.Data4[2]);
|
||||
assertEquals(0x45, lpiid.Data4[3]);
|
||||
assertEquals(0x53, lpiid.Data4[4]);
|
||||
assertEquals(0x54, lpiid.Data4[5]);
|
||||
assertEquals(0, lpiid.Data4[6]);
|
||||
assertEquals(0, lpiid.Data4[7]);
|
||||
}
|
||||
|
||||
GUID guid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); //Shell object
|
||||
GUID riid = Ole32Util.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); //IShellDispatch
|
||||
public void testStringFromGUID2() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
pguid.Data1 = 0;
|
||||
pguid.Data2 = 0;
|
||||
pguid.Data3 = 0;
|
||||
for (int i = 0; i < pguid.Data4.length; i++) {
|
||||
pguid.Data4[i] = 0;
|
||||
}
|
||||
int max = 39;
|
||||
char[] lpsz = new char[max];
|
||||
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
|
||||
assertTrue(len > 1);
|
||||
lpsz[len - 1] = 0;
|
||||
assertEquals("{00000000-0000-0000-0000-000000000000}",
|
||||
Native.toString(lpsz));
|
||||
}
|
||||
|
||||
PointerByReference iUnknown = new PointerByReference();
|
||||
public void testCoInitializeEx() {
|
||||
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
|
||||
assertTrue(W32Errors.SUCCEEDED(hr.intValue())
|
||||
|| hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
|
||||
if (W32Errors.SUCCEEDED(hr.intValue()))
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
|
||||
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(
|
||||
guid,
|
||||
null, // pOuter = null, no aggregation
|
||||
ObjBase.CLSCTX_ALL,
|
||||
riid,
|
||||
iUnknown);
|
||||
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
|
||||
assertTrue(!iUnknown.getValue().equals(Pointer.NULL));
|
||||
// We leak this iUnknown reference because we don't have the JNACOM lib
|
||||
// here to wrap the native iUnknown pointer and call iUnknown.release()
|
||||
if (W32Errors.SUCCEEDED(hrCI.intValue()))
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
public void testCoCreateInstance() {
|
||||
HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);
|
||||
|
||||
GUID guid = Ole32Util
|
||||
.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); // Shell
|
||||
// object
|
||||
GUID riid = Ole32Util
|
||||
.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); // IShellDispatch
|
||||
|
||||
PointerByReference pDispatch = new PointerByReference();
|
||||
|
||||
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(guid, null, // pOuter =
|
||||
// null, no
|
||||
// aggregation
|
||||
WTypes.CLSCTX_LOCAL_SERVER, riid, pDispatch);
|
||||
assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
|
||||
assertTrue(!pDispatch.equals(Pointer.NULL));
|
||||
// We leak this iUnknown reference because we don't have the JNACOM lib
|
||||
// here to wrap the native iUnknown pointer and call iUnknown.release()
|
||||
if (W32Errors.SUCCEEDED(hrCI.intValue()))
|
||||
Ole32.INSTANCE.CoUninitialize();
|
||||
}
|
||||
|
||||
public final void testCLSIDFromProgID() {
|
||||
final Guid.CLSID.ByReference clsid = new Guid.CLSID.ByReference();
|
||||
assertEquals(WinError.S_OK, Ole32.INSTANCE.CLSIDFromProgID("jpegfile", clsid));
|
||||
assertEquals("{25336920-03F9-11CF-8FD0-00AA00686F13}", clsid.toGuidString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.CLSID;
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WTypes.BSTR;
|
||||
import com.sun.jna.platform.win32.WinDef.LCID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.platform.win32.COM.COMUtils;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
public class OleAutoTest extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Native.setProtected(true);
|
||||
junit.textui.TestRunner.run(OleAutoTest.class);
|
||||
}
|
||||
|
||||
public OleAutoTest() {
|
||||
Native.setProtected(true);
|
||||
}
|
||||
|
||||
public void testSysAllocString() {
|
||||
assertEquals(null, OleAuto.INSTANCE.SysAllocString(null));
|
||||
BSTR p = OleAuto.INSTANCE.SysAllocString("hello world");
|
||||
assertEquals("hello world", p.getValue());
|
||||
OleAuto.INSTANCE.SysFreeString(p);
|
||||
}
|
||||
|
||||
public void testSysFreeString() {
|
||||
OleAuto.INSTANCE.SysFreeString(null);
|
||||
}
|
||||
|
||||
public void testDISPPARAMS() {
|
||||
// Build DISPPARAMS
|
||||
SAFEARRAY.ByReference safeArg = OleAutoUtil.createVarArray(1);
|
||||
OleAutoUtil.SafeArrayPutElement(safeArg, 0, new VARIANT(
|
||||
Variant.VARIANT_TRUE));
|
||||
System.out.println(safeArg.toString(true));
|
||||
}
|
||||
|
||||
public void testLoadRegTypeLib() {
|
||||
// MS Word typelib guid
|
||||
CLSID.ByReference clsid = new CLSID.ByReference();
|
||||
// get CLSID from string
|
||||
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(
|
||||
"{00020905-0000-0000-C000-000000000046}"), clsid);
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
|
||||
// get user default lcid
|
||||
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
|
||||
PointerByReference pWordTypeLib = new PointerByReference();
|
||||
// get typelib based on Word 8.3 (v11)
|
||||
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 8, 3, lcid, pWordTypeLib);
|
||||
COMUtils.checkTypeLibRC(hr);
|
||||
assertEquals(0, hr.intValue());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* Copyright (c) 2013 Tobias Wolf, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
|
||||
import com.sun.jna.platform.win32.Variant.VARIANT;
|
||||
import com.sun.jna.platform.win32.WinDef.SHORT;
|
||||
import com.sun.jna.platform.win32.COM.COMException;
|
||||
|
||||
/**
|
||||
* @author Tobias Wolf, wolf.tobias@gmx.net
|
||||
*/
|
||||
public class OleAutoUtilTest extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(OleAutoUtilTest.class);
|
||||
}
|
||||
|
||||
public void testCreateVarArray() {
|
||||
SAFEARRAY varArray = OleAutoUtil.createVarArray(1);
|
||||
assertTrue(varArray != null);
|
||||
}
|
||||
|
||||
public void testSafeArrayPutGetElement() {
|
||||
SAFEARRAY varArray = OleAutoUtil.createVarArray(10);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
try {
|
||||
VARIANT variant = new VARIANT(new SHORT(i + i*100));
|
||||
System.out.println(variant.toString(true));
|
||||
OleAutoUtil.SafeArrayPutElement(varArray, i, variant);
|
||||
} catch (COMException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(varArray != null);
|
||||
|
||||
System.out
|
||||
.println("\n\n\n-------------------------------------------------------------");
|
||||
System.out
|
||||
.println("-------------------------------------------------------------\n\n\n");
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
try {
|
||||
VARIANT element = OleAutoUtil.SafeArrayGetElement(varArray, i);
|
||||
System.out.println(element.toString(true));
|
||||
System.out.println("variant type: " + element.getVarType());
|
||||
System.out.println("value: " + element.getValue());
|
||||
} catch (COMException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
public class Oleaut32Test extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(Oleaut32Test.class);
|
||||
}
|
||||
|
||||
public void testSysAllocString() {
|
||||
assertEquals(null, Oleaut32.INSTANCE.SysAllocString(null));
|
||||
Pointer p = Oleaut32.INSTANCE.SysAllocString("hello world");
|
||||
assertEquals("hello world", p.getString(0, true));
|
||||
Oleaut32.INSTANCE.SysFreeString(p);
|
||||
}
|
||||
|
||||
public void testSysFreeString() {
|
||||
Oleaut32.INSTANCE.SysFreeString(null);
|
||||
}
|
||||
}
|
||||
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário