Comparar commits

..

4 Commits

Autor SHA1 Mensagem Data
Timothy Wall 9629d0bd4e add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/tags/3.0.6@721 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:17:53 +00:00
Timothy Wall 01be23234e add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/tags/3.0.6@720 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:17:40 +00:00
Timothy Wall 42052a110c add win64 target
git-svn-id: https://svn.java.net/svn/jna~svn/tags/3.0.6@719 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-17 18:17:30 +00:00
Timothy Wall 95ceb2a2e0 tag release 3.0.6
git-svn-id: https://svn.java.net/svn/jna~svn/tags/3.0.6@713 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
2008-09-16 18:17:31 +00:00
1320 arquivos alterados com 76614 adições e 444852 exclusões
-21
Ver Arquivo
@@ -1,21 +0,0 @@
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
native/libffi/doc/libffi.info
junit-*
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jnalib</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>
-202
Ver Arquivo
@@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-678
Ver Arquivo
@@ -1,678 +0,0 @@
Release 4.0
===========
NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and ASL (see LICENSE).
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.
Features
--------
* Added ASL licensing to facilitate distribution - [@twall](https://github.com/twall).
* [#109](https://github.com/twall/jna/issues/109): Set default Java compatibility level to 1.6 - [@twall](https://github.com/twall).
* [#209](https://github.com/twall/jna/issues/209): Improved default performance saving last error results - [@twall](https://github.com/twall).
* Use predictable names for CPU architecture prefix (namely x86, x86-64); names correspond to OSGI processor values - [@twall](https://github.com/twall).
* Avoid superfluous Structure memory allocation from native - [@twall](https://github.com/twall).
* Added `Library.OPTION_CLASSLOADER`, which enables loading native libraries from any class loader (including JNA's native library). This enables parallel dependencies on JNA (e.g. within a tomcat deployment without having to include JNA in the app server environment) - [@twall](https://github.com/twall).
* Use per-library String encoding settings (see `Native.getDefaultStringEncoding()` and `Structure.getStringEncoding()`) - [@twall](https://github.com/twall).
* Added memory dump for debugging (see `com.sun.jna.Memory`) - [@twall](https://github.com/twall).
* Improved caching of Structure alignment, type mapping, and encoding information - [@twall](https://github.com/twall).
* [#225](https://github.com/twall/jna/pull/225): Added `platform.win32.Kernel32.GetLogicalProcessorInformation` and `platform.win32.Kernel32Util.getLogicalProcessorInformation` - [@trejkaz](https://github.com/trejkaz).
* [#236](https://github.com/twall/jna/issues/236): Auto-strip profiler native method prefix specified by `jna.profiler.prefix`, which defaults to $$YJP$$ - [@twall](https://github.com/twall).
* Added `jna.debug_load` property to diagnose library loading issues - [@twall](https://github.com/twall).
* Throw explicit `IllegalArgumentException` when `Structure.ByReference` is used where it shouldn't be (can result in multiply freed memory or other unexpected behavior) - [@twall](https://github.com/twall).
* [#243](https://github.com/twall/jna/issues/243): Automatically accommodate long library paths on Windows which would otherwise fail - [@twall](https://github.com/twall).
* [#241](https://github.com/twall/jna/issues/241) - Added `com.sun.jna.platform.win32.Shell32.SHAppBarMessage` - [@bsorrentino](https://github.com/bsorrentino).
* Make `Structure.read/writeField()` protected to facilitate per-field overrides - [@twall](https://github.com/twall).
* Speed up callback lookup where large numbers of native function pointers are in use - [@twall](https://github.com/twall).
Bug Fixes
---------
* [#213](https://github.com/twall/jna/pull/213): Fixed `Structure.toString()` not to dump memory when `jna.dump_memory` is false - [@tomohiron](https://github.com/tomohiron).
* Use dedicated TLS to indicate callback detach state, to avoid any potential conflicts with last error storage - [@twall](https://github.com/twall).
* [#173](https://github.com/twall/jna/issues/173): Fixed OSX 10.8/Xcode 4+ builds, web start path with Oracle 1.7 JDK - [@mkjellman](https://github.com/mkjellman).
* [#215](https://github.com/twall/jna/issues/215): Forced use of XSI `strerror_r` on linux - [LionelCons](https://github.com/LionelCons).
* [#214](https://github.com/twall/jna/issues/214): Don't map library names when an absolute path is provided - [@twall](https://github.com/twall).
* [#218](https://github.com/twall/jna/issues/218): Explicitly handled broken Android `SecurityManager` implementation - [@twall](https://github.com/twall).
* [#223](https://github.com/twall/jna/issues/223): Fixed layout/size derivation for unions - [@twall](https://github.com/twall).
* [#229](https://github.com/twall/jna/issues/229): Added `CreateProcessW` (Unicode version) - [@twall](https://github.com/twall).
* Avoid solaris/x86 JVM bug w/library open flags - [@twall](https://github.com/twall).
* Fixed NPE returning wide string from a direct-mapped function - [@twall](https://github.com/twall).
* [#237](https://github.com/twall/jna/issues/237): Fix LastErrorException/getLastError on AIX - [@skissane](https://github.com/skissane).
* [#228](https://github.com/twall/jna/issues/228): Fix win32/win64 crashes due to LastErrorException buffer overruns (`snprintf` on windows is broken) - [@davidhoyt](https://github.com/davidhoyt).
Release 3.5.2
=============
Features
--------
* Basic [COM support](https://github.com/twall/jna/blob/master/www/PlatformLibrary.md) for w32 - [@wolftobias](https://github.com/wolftobias).
* Avoid superfluous Structure memory allocation by using Structure(Pointer) ctors if available - [@twall](https://github.com/twall).
* [PR#120](https://github.com/twall/jna/pull/120): Provide methods for extracting native libraries from the class path for use by JNA - [@Zlika](https://github.com/Zlika).
* [PR#163](https://github.com/twall/jna/pull/163): The Java `GUID` structure can be used directly as alternative to `Ole32Util.getGUIDFromString()` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Ported Win32 `dbt.h` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `WTSRegisterSessionNotification()` and `WTSUnRegisterSessionNotification()` from `Wtsapi32.dll` - [@wolftobias](https://github.com/wolftobias).
* [PR#163](https://github.com/twall/jna/pull/163): Added Win32 `native_window_msg` that creates windows, registers for USB device and logon/logoff notifications - [@wolftobias](https://github.com/wolftobias).
* [PR#178](https://github.com/twall/jna/pull/178): Added Win32 `USER_INFO_10` structure from `LMAccess.h` - [@davidmc24](https://github.com/davidmc24).
* [PR#192](https://github.com/twall/jna/pull/192): Added Win32 `SHGetSpecialFolderPath()` and initialization file (.ini) API functions from `kernel32.dll` - [@headcrashing](https://github.com/headcrashing).
* [PR#194](https://github.com/twall/jna/pull/194): Added Unit Test for `CLSIDFromProgID()` - [@headcrashing](https://github.com/headcrashing).
* [PR#196](https://github.com/twall/jna/pull/196): Added Win32 `RegisterWindowMessage()` and new wrapper `User32Util` for convenient use of `RegisterWindowMessage`, `CreateWindow` and `CreateWindowEx` - [@headcrashing](https://github.com/headcrashing).
* [PR#187](https://github.com/twall/jna/pull/187): Allow StructureFieldOrderTest unit test in platform project to run on Linux. - [@bhamail](https://github.com/bhamail).
Bug Fixes
---------
* [PR#180](https://github.com/twall/jna/pull/180): Fix: added missing fields in `XEvents.getFieldOrder()` - [@xwizard](https://github.com/xwizard).
* [PR#183](https://github.com/twall/jna/pull/183): Fix `LMAccess.GROUP_INFO_3.getFieldOrder()` to return correct fields names - [@bhamail](https://github.com/bhamail).
* [PR#187](https://github.com/twall/jna/pull/187): Fix `getFieldOrder()` to return correct field names for some X11 structures - [@bhamail](https://github.com/bhamail).
* Remove deprecated methods on Memory (getSize,isValid) and Structure (getSize) - [@twall](https://github.com/twall).
* Remove problematic AWT check via `Class.forName("java.awt.Component")` (see [here](https://bugs.eclipse.org/bugs/show_bug.cgi?id=388170)) - [@twall](https://github.com/twall).
* [PR#210](https://github.com/twall/jna/pull/210) Add OSGI processor specs for Mac OS X - [@bertfrees](https://github.com/bertfrees).
* [PR#174](https://github.com/twall/jna/pull/174): Recompile linux-amd64 natives to remove glibc-2.11 dependencies, now requires only 2.2.5 or better - [@twall](https://github.com/twall).
* [PR#183](https://github.com/twall/jna/pull/183): Added `StructureFieldOrderInspector` unit test utility to scan for `Structure` field issues; see: `com.sun.jna.platform.StructureFieldOrderTest.testMethodGetFieldOrder` - [@bhamail](https://github.com/bhamail).
* [PR#187](https://github.com/twall/jna/pull/187): Allow `StructureFieldOrderTest` unit test in platform project to run on Linux - [@bhamail](https://github.com/bhamail).
* [#206](https://github.com/twall/jna/issues/206): Fix `moveToTrash()` on OSX to work with symlinks - [@twall](https://github.com/twall).
* Fix NPE if `Thread.getContextClassLoader()` returns `null` - [@twall](https://github.com/twall).
Release 3.5.1
=============
Bug Fixes
---------
* Fix bug where string fields sometimes failed to be writtern - [@twall](https://github.com/twall) (roman kisluhin).
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32Util.getDomainTrusts()` returns "empty" domain object - [@aikidojohn](https://github.com/aikidojohn).
* [PR#145](https://github.com/twall/jna/pull/145): Fix `Netapi32.getDC()` - added missing fields in `DOMAIN_CONTROLLER_INFO` - [@aikidojohn](https://github.com/aikidojohn).
* [PR#151](https://github.com/twall/jna/pull/151): 'platform.jar' in the dist directory was not updated for release 3.5.0. (The 'platform.jar' published to maven central was correct.)
Release 3.5.0
=============
Features
--------
* [#62](https://github.com/twall/jna/issues/62) If a callback is required to reside in a DLL, use [`DLLCallback`](http://twall.github.com/jna/3.5.1/javadoc/com/sun/jna/win32/DLLCallback.html) to tag your Callback object - [@twall](https://github.com/twall).
* `Structure.getFieldOrder()` supersedes `Structure.setFieldOrder()` and is now required - [@twall](https://github.com/twall).
* Search `~/Library/Frameworks` and `/Library/Frameworks` on OSX - [@shaneholloway](https://github.com/shaneholloway).
* Automatic cleanup of native threads (based on suggestions from neil smith) - [@twall](https://github.com/twall).
* 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
=============
Features
--------
* Add 'unsigned' modifier to IntegerType.
* Add to `platform.win32.User32`: `GetLastInputInfo`.
* Add `platform.win32.WinNT.GetFileType` and `platform.win32.Kernel32Util.getFileType`.
* Add to `platform.win32.Kernel32Util`: `getFileType`.
Bug Fixes
---------
* Re-build linux-amd and linux-i386 against older versions of glibc (2.2.5 and
2.1.3 respectively).
* Properly initialize first printer info struct in winspool library.
* Properly support getting and setting zero-array-length `REG_MULTI_SZ` values on Win32.
* Fixed SID in Win32 `USER_INFO_23` and `GROUP_INFO_3`.
* Fixed passing domain name into Win32 `Netapi32Util.getUserInfo`.
Release 3.4.0
=============
Features
--------
* Provide `jna.nosys=true` to avoid loading any system-provided JNA (useful for local build/development).
* Allow override of default jnidispatch library name with `jna.boot.library.name` system property.
* Throw an Error if a system install of JNA is incompatible or if JNA's JNI library does not match.
* Disable automatic jnidispatch unpacking with `jna.nounpack=true`.
* Automatically look up system error messages for LastErrorException.
* Improved callback thread-mapping support; re-use, rename, and group callback
threads.
* Cache structure layout results, improving performance of structure creation.
* linux/arm 32-bit support (hardware provided by Alex Lam).
* linux/ppc 32-bit support (hardware provided by Fritiof Hedman).
* Preliminary linux/ia64, linux/ppc64 support (thanks to Laurent Guerby and the GCC compile farm).
* Windows CE/Mobile support (w32ce-arm) (resources provided by andrea antonello and Hydrologis SRL).
* linux multi-arch support (kohsuke).
* Added REG_QWORD registry type support
* Add to `platform.unix.x11`: `XGrabKey`, `XUngrabKey`, `XSetErrorHandler`.
* Add to `platform.mac.Carbon`: `GetEventDispatcherTarget`, `InstallEventHandler`, `RegisterEventHotKey`, `GetEventParameter`, `RemoveEventHandler`, `UnregisterEventHotKey`.
* Add to `platform.win32.Kernel32`: `CopyFile`, `MoveFile`, `MoveFileEx`, `CreateProcess`, `SetEnvironmentVariables`, `GetFileTime`, `SetFileTime`, `SetFileAttributes`, `DeviceIoControl`, `GetDiskFreeSpaceEx`, `CreateToolhelp32Snapshot`, `Process32First`, `Process32Next`.
* Add to `platform.win32.Msi`: `MsiGetComponentPath`, `MsiLocateComponent`, `MsiGetProductCode`, `MsiEnumComponents`.
* Add to `platform.win32.User32`: `RegisterHotKey`, `UnregisterHotKey`
* Add to `platform.win32.SetupApi`: `SetupDiGetClassDevs`, `SetupDiDestroyDeviceInfoList`, `SetupDiEnumDeviceInterfaces`, `SetupDiGetDeviceInterfaceDetail`, `SetupDiGetDeviceRegistryProperty`.
* Add `platform.win32.Shell32.ShellExecute`.
* Add to `platform.win32.User32`: `SetParent`, `IsWindowVisible`, `MoveWindow`, `SetWindowPos`, `AttachInputThread`, `SetForegroundWindow`, `GetForegroundWindow`, `SetFocus`, `SendInput`, `WaitForInputIdle`, `InvalidateRect`, `RedrawWindow`, `GetWindow`, `UpdateWindow`, `ShowWindow`, `CloseWindow`.
* Add to `platform.win32.Version`: `GetFileVersionInfoSize`, `GetFileVersionInfo`, `VerQueryValue`.
* Add to `platform.win32.Advapi32`: `GetFileSecurity`, `RegQueryValueEx(...Long...)`.
* Add to `platform.win32.Netapi32`: `NetUserGetInfo`.
Bug Fixes
--------
* Revise cleanup of in-use temporary files on win32 (issue 6).
* Fix structure alignment issues on linux/ppc.
* Fix structure alignment issues on linux/arm.
* Account for NIO Buffer position (JIRA issue 185).
* Avoid crash with very long Strings (> 150k in length).
* Fix bug tracking Memory with an associated direct ByteBuffer.
* Fix bug handling structs by value when type mappers are in effect (JIRA issue 188).
Release 3.3.0
=============
Features
--------
* Facilitate `Memory` subclasses (jbellis).
* Allow multiple fields of the same type in Unions (Francis Barber).
* Add `platform.win32.Advapi32.AdjustTokenPrivileges`, `platform.win32.Advapi32.LookupPrivilegeName`, `platform.win32.Advapi32.LookupPrivilegeValue`, `platform.win32.Advapi32.ImpersonateSelf`.
* Add `platform.win32.Advapi32.DuplicateTokenEx`, `platform.win32.Advapi32.CreateProcessAsUser`, `platform.win32.Kernel32.GetExitCodeProcess`, `platform.win32.Kernel32.TerminateProcess`, `platform.win32.Kernel32.ReadFile`, `platform.win32.Kernel32.CreatePipe`, `platform.win32.Kernel32.SetHandleInformation` and related constants / structures in `platform.win32.WinBase` and `platform.win32.WinNT`. Please note that the `SECURITY_ATTRIBUTES` structure has been moved from `platform.win32.WinNT` to `platform.win32.WinBase`.
* Add `platform.win32.Kernel32.DeleteFile` and `platform.win32.Kernel32Util.deleteFile`.
* Add `platform.win32.Kernel32.GetFileAttributes` and `platform.win32.Kernel32Util.getFileAttributes`.
* Add `platform.win32.Kernel32.GetTickCount`.
* Add Win32 Service functions to `platform.win32.Advapi32`.
* Add `platform.win32.W32ServiceManager` and `W32Service`.
* Add Win32 Event Logging functions to `platform.win32.Advapi32` and `platform.win32.Advapi32Util.EventLogIterator`.
* `platform.win32.Advapi32Util.registryCreateKey` returns `true` if key was created, `false` if it already exists.
* Add `REG_BINARY`, `REG_EXPAND_SZ` and `REG_MULTI_SZ` support to `platform.win32.Advapi32Util` registry functions.
* Reduce JNI crossings in a number of native methods, moving object creation out into pure Java code.
Bug Fixes
---------
* Move all native functions into `com.sun.jna.Native`, to ensure that all dependent classes must be disposed before the `Native` class is unloaded. Note that this change is incompatible with all previous JNA native libraries.
* Fix `platform.win32.Kernel32.GetNativeSystemInfo` and `GetSystemInfo` AV on Win64.
* Fix several potential minor bugs as reported by TvT.
* Fix bug in Structure.StructureSet.toString (Blair Zajac), exposed by Tomcat ThreadLocal cleanup.
* Fix several bugs when using Structure(Pointer) ctor and array fields (Samuel Audet).
Release 3.2.7
=============
Features
--------
* Add native peer value accessors for Pointer
* The `jna.library.path` property is now re-evaluated whenever a native library is loaded. Previously this value was cached when the JNA classes loaded.
* `Native.loadLibrary` can now load `.drv` files.
* Refactor `com.sun.jna.platform.win32.WINBASE` into `WinDef`, `WinNT` and `BaseTSD`, matching Windows SDK headers.
* Refactor constants from `com.sun.jna.platform.win32.GDI32` into `WinGDI`, matching Windows SDK headers.
* Refactor constants from `com.sun.jna.platform.win32.User32` into `WinUser`, matching Windows SDK headers.
* Refactor `platform.win32.WinNT.LARGE_INTEGER` into a union.
* Add `platform.win32.ObjBase`, `com.sun.jna.platform.win32.Ole32.CoInitializeEx`, `CoUninitialize`, and `CoCreateInstance`.
* Add `platform.win32.Oleaut32.SysAllocString` and `SysFreeString`.
* Add `platform.win32.Secur32.ImpersonateSecurityContext` and `RevertSecurityContext`.
* Add `platform.win32.WinNT.WELL_KNOWN_SID_TYPE`, `SECURITY_MAX_SID_SIZE` and other related SID-related constants.
* Add `platform.win32.Advapi32.CreateWellKnownSid` and `IsWellKnownSid` and `com.sun.jna.platform.win32.Advapi32Util.isWellKnownSid`.
* Add `platform.win32.Kernel32.GetVersion`, `GetVersionEx`, `GetSystemInfo`, `GetNativeSystemInfo`, `GlobalMemoryStatusEx`, `GetLogicalDriveStrings` and `IsWow64Process`.
* Add `platform.win32.Kernel32Util.getLogicalDriveStrings`.
* Add `platform.win32.User32.GetSystemMetrics`.
* Add `platform.win32.BaseTSD.DWORD_PTR`.
* Add `platform.win32.WinBase.SYSTEM_INFO` and `MEMORYSTATUSEX`.
* Add `platform.win32.WinNT.OSVERSIONINFOEX`, `VER` constants.
* Add `platform.win32.WinDef.ULONGLONG` and `DWORDLONG`.
* Add `platform.win32.Shell32.SHGetDesktopFolder` (prep work for Com4JNA).
* Add `platform.win32.Winspool.GetPrinterInfo`.
* Add `platform.win32.WinspoolUtil.getPrinterInfo1`.
* Add `platform.win32.GDI32.GetDeviceCaps`.
* Add `platform.win32.GDI32.GetDIBits`.
Bug Fixes
---------
* Fix `ClassCastException` in `Structure.equals` (issue 152).
* Fix bug initializing a structure object from existing memory when the structure has initialized fields (issue 133).
* Fix NPE reading an array of string from a pointer when an element of the array is `NULL` (issue 151).
* Avoid calling `UnregisterNatives` in native code (issue 154).
* Compare unpacked library path against canonical (long) filename (issue 156).
* Fix `read()` of uninitialized memory in `platform.win32.Advapi32Util.getTokenGroups` and `getTokenAccount`.
* Fix `com.sun.jna.platform.win32.Secur32.QuerySecurityContextToken` to take a `CtxtHandle` instead of `PSecHandle`.
* Fix definition of BITMAPINFO (platform/win32).
Release 3.2.5
=============
Features
--------
* Split code in examples.jar into a contrib platform.jar package and individual packages for demos.
* Fix Eclipse build and added Eclipse projects for all contrib samples, import projects from jnalib and contrib.
* Ensure Structure fields correctly ordered when inherited.
* Use explicit Structure field whenever provided, regardless of whether the VM requires it.
* Add Win32 mappings for two dozen functions from Kernel32.dll, Advapi32.dll, Netapi32.dll, Secur32.dll, NtDll.dll, Ole32.dll, Shell32.dll and Crypt32.dll to com.sun.jna.platform.win32.
* Port parts of WinError.h, WinNT.h, LMAccess.h, LMCons.h, LMErr.h, LMJoin.h, NTStatus.h, ShlObj.h, WinDef.h, ShellApi.h, Wdm.h, WinReg.h, WinCrypt.h, Sspi.h, Guid.h, NtSecApi.h and DsGetDc.h.
* Add Win32 simplified utility interfaces Kernel32Util, Advapi32Util, Netapi32Util, Crypt32Util, NtDllUtil, Shell32Util, Ole32Util and Secur32Util to com.sun.jna.platform.win32.
* Support unicode paths in W32FileUtils.
* Fix exception during dispose in W32FileMonitor.
Bug Fixes
---------
* Provide String.replace for 1.4 compatibility.
* Avoid allocating memory when Structure is provided a pointer in the ctor.
* Ensure proper value returned in Pointer.getValue() for non-null, unchanged NIO Buffer values.
* Use 1.4-compatible URI generation (issue 149).
Release 3.2.4
=============
Features
--------
* Make Pointer ctor public.
* Provide access to Function objects for arbitrary Pointer values.
* Add linux/ia64 binaries (bpiwowar). See issue 134 patch.
Bug Fixes
---------
* Use a more robust method to decode a file-based URL (issue 135).
Release 3.2.3
=============
Features
--------
* Include version information in code in case package information lost.
Bug Fixes
---------
* Fix WindowUtils exception on mouse over TrayIcon.
* Fix bug toggling windows transparent/opaque (win32/OSX).
* Avoid overwriting unchanged Pointer values in arrays (function calls with Pointer[] and Structure.read).
* Ensure Structure fields marked `final` are never written.
* Fix bug preventing proper population Structure.ByReference fields on Structure read.
* Ensure double buffering is disabled in components added to a transparent window.
* Fix UnsatisfiedLinkError attempting to load system libraries under Web Start.
* Fix loading Web Start-provided libraries on OSX (libraries must have a .jnilib suffix under Web Start).
* Properly include sources in Maven zip file (Issue 129).
Release 3.2.2
=============
Features
--------
* Provide length-specified Pointer.getStringArray()
Bug Fixes
---------
* Fix crash with direct mapping if NULL struct* used (Issue 125).
* Fix case where null-valued Structure fields would get non-null values on write.
* Synch callback Structure/Structure[] arguments on callback return.
* Fix NPE when mapping an interface to the current process.
* Automatically load proper C library version from current process on Linux (avoids crashing bug on Ubuntu with libc-i686 packages active).
* Avoid scanning structure contents in Structure.toString if contents aren't actually used.
Release 3.2.1
==========
Features
--------
* Add HRESULT, LONG mapping to W32API (marc strapetz).
Bug Fixes
---------
* Fix definition of HWND_BROADCAST in W32API.
* Fix memory alignment checking (Issue 121).
* Fix Structure equals/hashCode implementation, based on current Java fields rather than strictly native memory contents. Avoid using equals/hashCode when avoiding recursive reads/writes.
Release 3.2.0
=============
Features
--------
* Handle String, Structure, Callback, Buffer, and primitive arrays in direct mappings. Handle NativeMapped and TypeMapper, with optimized paths for IntegerType and PointerType.
* Optionally throw errno/GetLastError as an exception. This is preferred to (and more efficient than) calling Native.getLastError().
* Unload/delete native library unpacked from jna.jar if Native class is garbage collected. Only install shutdown hook if using the system class loader.
* Auto-write contiguous Structure arrays when first element is written.
* Support NativeMapped[] as function arguments for interface-mapped libraries (Issue 90).
* Enable function lookup within current process on Windows.
Bug Fixes
---------
* Restrict recursive structure reads/writes by thread instead of globally. This avoids potentially missed reads/writes with concurrent access (Issue 120).
* Ensure Memory is not GC'd and freed if direct NIO buffers mapped to it are extant.
* Allow types derived from java.nio.Buffer as Structure fields.
Release 3.1.0
=============
Features
--------
* Add raw JNI mapping of static Java methods. Performance is about 10X that of traditional JNA interface mapping, although with less type conversion functionality.
* Add library option to allow passing/return of Java Objects.
* Allow handling of uncaught callback exceptions (Issue 63).
* Object oriented interface to X server (see contrib/x11)
* Make Memory class more accessible.
* Provide Structure ctor with Pointer argument (issue 102).
* Allow implicit library access to current process on linux (issue 98).
* Open all shared libraries with RTLD_GLOBAL, if applicable. This was the default behavior on OSX and changes the default behavior on linux.
* Allow NIO Buffer as Structure field (with limitations) (Issue 57)
* Add `size_t` size.
Bug Fixes
---------
* Run tests with libjsig.so, if available, which fixes some crashes when running tests on 64-bit platforms.
* Fix Issue 104.
* Fix Issue 94 (Java 1.6 update 10 regression).
* Fix Issue 51 (Java 1.6 update 10 regression).
* Fix Issue 95.
* Fix Issue 101.
* Fix Issue 111, memory leak with String-returning Callback.
* Fix missing storage of union type information (affects usage of struct/union by value as argument and return type).
* Remove non-functional Structure ctors requiring explicit size.
Release 3.0.9
=============
Bug Fixes
---------
* Fix issue 93 by only manually searching jna.library.path, then falling back to passing the mapped library name to dlopen/LoadLibrary. This fixes an issue in JRUBY where the incorrect libc.so.6 was being loaded.
Release 3.0.8
==========
Features
--------
* Auto-map Pointer[]/String[]/WString[] return values.
* Provide utility functions to convert String to primitive array.
* Add jna.library.boot.path property to define the directory that the native stub library is loaded from
Release 3.0.7
==========
Features
--------
* Improve Win32 loading of libraries with dependencies.
Bug Fixes
---------
* Fix bug reading structures with PointerType fields, introduced with Pointer field preservation fix.
Release 3.0.6
=============
Features
--------
* Allow arbitrary callback method names if only one method is defined in the class which implements Callback (colinwalters).
* Allow specification of callback type mappers by using a TYPE_MAPPER field (colinwalters).
* Allow uninitialized (null-valued) boxed primitives in Structures (colinwalters).
* Add convenience methods to set active Union field and value simultaneously (xylo).
* Augment Union read/writeField to set the active field.
* Allow Structure auto-synch across native calls to be disabled.
* Win64 support.
Bug Fixes
---------
* Avoid overwriting unchanged Structure fields of type Pointer.
* Avoid more content dragging on OSX or warn if it's too late.
* Fix UnsatisfiedLinkError using transparent window on Win2K.
* Fix memory leak with callbacks called from native threads with no Java context (johnwallace).
* Defer structure size calculation if type mapper not yet set, allowing type mapper to be set in derived constructors (colinwalters).
* Ensure structure memory is allocated in Structure.read/writeField.
Release 3.0.5
=============
Features
--------
* Allow explicit declaration of field order for VMs which have an unpredictable field order.
* Check for w32 libraries with a "lib" prefix in addition to normal lookup.
* Allow String[]/WString[] as callback argument/return value (assume NULL-terminated array).
* Add Solaris8 compatibility to sunos-sparc build (Corey Puffalt).
* Look up libraries using web start library path, if appropriate (Corey Puffalt).
* Use constants to return integer boolean values.
Bug Fixes
---------
* Properly track cursor on alpha-masked windows.
* Avoid searching /lib or /usr/lib on 64-bit Linux.
* Avoid using incorrect version of a library when both 32- and 64-bit versions are found.
* Avoid transparent window events always dragging window bug on OSX.
* Fix division by zero error calculating structure size on OSX/ppc.
* Avoid overwriting initialized NativeMapped Structure fields when calculating structure size.
* Fix NPE reading back into StringArray.
Release 3.0.4
=============
Features
--------
* Automatically write contents of Structure.ByReference fields on Structure.write().
* Use the actual parameter type in Function invocations if no parameter type information is available (whether method is missing or untyped varargs).
* Augmented X11 library mappings (xylo).
* Support read/write of NativeMapped arrays within Structure (notably NativeLong).
Bug Fixes
---------
* Fix library load error when /usr/lib32 and /usr/lib both exist (linux) (Marek Slama).
* Avoid incorrect matches against libraries named with the same prefix (e.g. libc-client.so vs libc.so) (xylo).
* Properly handle arrays of NativeMapped (e.g. NativeLong) as a Structure field (stefan endrullis).
* Ensure structure size calculated prior to setting union active type.
* XID is 64-bits on 64-bit X clients (xylo).
* Ensure proper arch name is used on Debian (amd64 instead of x86_64).
Release 3.0.3
=============
Features
--------
* Enable build/run using IBM's J9 VM (leonardo).
* Make StdCallFunctionMapper attempt a leading underscore if the simpler mapping doesn't work.
* Allow Structure.read to overwrite final fields (may not work on some 1.4 VMs).
Bug Fixes
---------
* Fix NPE when passing an array of Structure.ByReference.
* Compare entire linux library version when finding a match.
* Don't pass struct by value unless the method signature declares it.
* Restrict custom first element structure alignment to OSX/ppc.
* Improve performance and reduce memory footprint for window masks. Optimize polygon-based masks on w32. Use XFillRectangles on X11.
* Fix linkage settings on sunos-amd64 to avoid relocation errors.
* Fix callback allocation code on w32, solaris, freebsd, darwin (libffi was misconfigured).
* Fix bug when NativeMapped fields are used in a Structure.ByValue instance.
* Fix NPE calling Structure.read() before memory is initialized.
* Fix NPE calling Structure.read/write with uninitialized NativeMapped fields.
Release 3.0.2
=============
Features
--------
* Attempt to force unload of jnidispatch library prior to deleting it (w32).
* Added amd64 targets for OSX, FreeBSD, and Solaris.
Bug Fixes
---------
* Reduce space allocated for invocation arguments.
* Fix NPE when NativeMapped type is used in a Structure.
* Fix some X11 type mappings for 64-bit.
* Fix OSX Leopard/JRE1.5+ window transparency.
* Fix window alpha compositing on X11.
* Fix loading of libraries with unicode names on OSX.
Release 3.0.1
=============
Features
--------
* Improve transparent window drawing performance on w32
* Use closure allocation from libffi
Bug Fixes
---------
* Ensure nested structure arrays initialized with Structure.toArray use the appropriate native memory.
* Ensure structure size is calculated prior to converting to array
* Avoid creating new windows when setting a window mask
* Fix bug in Pointer.setChar.
Release 3.0
===========
Features
--------
* More supported platforms, via GCC's libffi (wmeissner)
* Support struct by value as parameter and return value (duncan)
* Support struct by reference within structures
* Provide access to native peer for java.awt.Component
* Provide access to native peer on OS X.
* Support MINGW32 builds (fullung)
* Allow per-field Structure read/write by field name
* Avoid writing Structure fields marked 'volatile'
* Read and wrap function pointers in Structure fields when read with a Java proxy to allow easy Java-side invocation (Ken Larson)
* Support array-backed Buffers as arguments (wmeissner)
* Auto-conversion of custom types (wmeissner)
* Allow pointer type-safety
* Optional VM crash protection, via Native.setProtected(boolean)
* Auto-convert WString[]
* Provide library synchronization wrapper similar to Collections.synchronizedX
* Support lookup of OSX framework libraries by name
* Explicit access to shared library global data
* Invocation interception to facilitate translation of C preprocessor macros and inline functions
* Provide utility to determine Web Start native library cache location; auto-include this path if jnidispatch is included as a &lt;nativelib&gt; (robertengels)
* Provide access to aligned memory
* Versioning information embedded in jna.jar and native library
Bug Fixes
---------
* Avoid attempts to free native library if it failed to load (wmeissner)
* Explicitly check method signatures for varargs instead of heuristically guessing (wmeissner)
* Disallow declaring Pointer-derived fields in Structures (Function, Memory)
* Ensure Object.toString/hashCode/equals methods are intercepted on proxyied interfaces
* Update X11 library for 64-bit use (wmeissner)
* Properly map arrays of char*/wchar_t* under w32
* Allow Pointer[] as a Structure field and Function argument
* Fix some misleading Structure error messages
* Properly preserve/return GetLastError/errno after native calls
* Allocate executable memory on w32 to avoid errors with hardware-enforced data execution protection (DEP)
* Fix VM crash on w32 stdcall callbacks
* Use long offsets and sizes rather than ints (64-bit safe)
* Properly clean up references and release closure memory on JNI_Unload
* Use simpler AWT/JAWT library loading workaround
* Avoid changing array references within a Structure on read
Release 2.5
===========
Features
--------
* Unions
* Optimized shaped windows (chris deckers & olivier chafik); instantiation time improved by about 2-3 orders of magnitude for large, mostly contiguous shapes
* Provide type mapping in callback arguments/results
* Provide access to ByteBuffer direct address as a Pointer
* Provide customization of native string encoding with jna.encoding system property
Bug Fixes
---------
* Properly handle VMs with reversed Structure member storage
* Avoid making window undecorated when clearing window mask on X11
* Fix structure alignment bug on OSX/PPC when first element is > 4 bytes in size
* Clearing OSX window mask by setting to MASK_NONE now works properly
* Avoid index exceptions if native buffers are not NUL-terminated on string conversions
* Write initialized Structure[] argument memory prior to function calls
* Fix IllegalArgumentException reading WString into a Structure
* Clear memory when allocating a structure block (fixes VM crash)
* Remove versioned JAWT dependency on OSX, allowing use on 10.3/JRE1.4.
Release 2.4
===========
Features
--------
* Explicitly support unaligned structures
* Auto-reallocate structure arrays
* Automatic handling of w32 UNICODE/ASCII variants
* Automatic mapping of decorated w32 stdcall function names
* Customizable, automatic type conversion of arguments and results (wmeissner)
* Support char*[] arguments as Java String[]
* Structure supports Callback members (wmeissner)
* getByteBuffer from Pointer/Memory (wmeissner)
* Allow GC of native libraries
* Facilitate use from non-Java contexts (JRuby et al.) (wmeissner)
* Improve library path searching (wmeissner)
* Handle Structure[] arguments
* Handle native long arguments and return values
* Handle direct and array-based ByteBuffer arguments (wmeissner)
* Change default w32 build to use GCC (it's free, yo)
Bug Fixes
---------
* Structure.toArray failed to initialize members
* Disallow explicit free of Structure/Memory
* Ensure native libraries are only loaded once until released
* Properly handle NULL when the return value is a Structure
* Proper conversion to wchar_t on linux
* Copy full length of Java strings to C strings instead of stopping when a NUL character is encountered
-25
Ver Arquivo
@@ -1,25 +0,0 @@
JNA is dual-licensed under 2 alternative Open Source/Free
licenses: LGPL 2.1 and Apache License 2.0. (starting with
JNA version 4.0.0).
What this means is that one can choose either one of these
licenses (for purposes of re-distributing JNA; usually by
including it as one of jars another application or
library uses) by downloading corresponding jar file,
using it, and living happily everafter.
You may obtain a copy of the LGPL License at:
http://www.gnu.org/licenses/licenses.html
A copy is also included in the downloadable source code package
containing JNA, in file "LGPL2.1", under the same directory
as this file.
You may obtain a copy of the ASL License at:
http://www.apache.org/licenses/
A copy is also included in the downloadable source code package
containing JNA, in file "ASL2.0", under the same directory
as this file.
-12
Ver Arquivo
@@ -1,12 +0,0 @@
This copy of JNA is licensed under the
Apache (Software) License, version 2.0 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.
You may obtain a copy of the License at:
http://www.apache.org/licenses/
A copy is also included in the downloadable source code package
containing JNA, in file "ASL2.0", under the same directory
as this file.
-13
Ver Arquivo
@@ -1,13 +0,0 @@
This copy of JNA is licensed under the
Lesser General Public License (LGPL), version 2.1 ("the License").
See the License for details about distribution rights, and the
specific rights regarding derivate works.
You may obtain a copy of the License at:
http://www.gnu.org/licenses/licenses.html
A copy is also included in the downloadable source code package
containing JNA, in file "LGPL2.1", under the same directory
as this file.
-115
Ver Arquivo
@@ -1,115 +0,0 @@
![Java Native Access - JNA](https://github.com/twall/jna/raw/master/www/images/jnalogo.jpg "Java Native Access - JNA")
Java Native Access (JNA)
========================
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://twall.github.com/jna/4.0/javadoc/). Please read the [overview](http://twall.github.com/jna/4.0/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
JNA allows you to call directly into native functions using natural Java method invocation. The Java call looks just like it does in native code. Most calls require no special handling or configuration; no boilerplate or generated code is required.
The JNA library uses a small native library stub to dynamically invoke native code. The developer uses a Java interface to describe functions and structures in the target native library. This makes it quite easy to take advantage of native platform features without incurring the high overhead of configuring and building JNI code for multiple platforms.
While some attention is paid to performance, correctness and ease of use take priority.
JNA includes a platform library with many native functions already mapped as well as a set of utility interfaces that simplify native access.
Download
========
Version 4.0
* [jna.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/jna/4.0.0/jna-4.0.0.jar)
* [jna-platform.jar](https://maven.java.net/content/repositories/releases/net/java/dev/jna/platform/4.0.0/jna-platform-4.0.0.jar)
Features
========
* Automatic mapping from Java to native functions, with simple mappings for all primitive data types
* Runs on most platforms which support Java
* Automatic conversion between C and Java strings, with customizable encoding/decoding
* Structure and Union arguments/return values, by reference and by value
* Function Pointers, (callbacks from native code to Java) as arguments and/or members of a struct
* Auto-generated Java proxies for native function pointers
* By-reference (pointer-to-type) arguments
* Java array and NIO Buffer arguments (primitive types and pointers) as pointer-to-buffer
* Nested structures and arrays
* Wide (wchar_t-based) strings
* Native long support (32- or 64-bit as appropriate)
* [Demo applications/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
* Support for automatic Windows ASCII/UNICODE function mappings
* Varargs support
* Type-safety for native pointers
* VM crash protection (optional)
* Optimized direct mapping for high-performance applications.
Community and Support
=====================
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:
* What OS/CPU/architecture you're using (e.g. Windows 7 64-bit)
* Reference to your native interface definitions (i.e. C headers), if available
* The JNA mapping you're trying to use
* VM crash logs, if any
* Example native usage, and your attempted Java usage
It's nearly impossible to indicate proper Java usage when there's no native
reference to work from.
For commercial support, please contact twalljava [at] java [dot] net.
Using the Library
=================
* [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/4.0.0/javadoc/overview-summary.html#crash-protection)
Primary Documentation (JavaDoc)
===============================
The definitive JNA reference is in the [JavaDoc](http://twall.github.com/jna/4.0.0/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 [https://github.com/twall/jna](https://github.com/twall/jna) and submit pull requests.
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.
License
=======
This library is licensed under the LGPL, version 2.1 or later, and (from
version 4.0 onward) the Apache Software License, version 2.0. Commercial
license arrangements are negotiable.
*NOTE: Oracle is not sponsoring this project, even though the package name (com.sun.jna) might imply otherwise.*
-1152
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
-8
Ver Arquivo
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>alphamaskdemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-66
Ver Arquivo
@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.alphamaskdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.alphamaskdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../dist"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-alphamask.jar"/>
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
<path id="classpath">
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
</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>
</copy>
<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>
-7
Ver Arquivo
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>balloonmanagerdemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-68
Ver Arquivo
@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.balloonmanagerdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.balloonmanagerdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../dist"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
<path id="classpath">
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
</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>
</copy>
<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>
-7
Ver Arquivo
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>balloontips</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-68
Ver Arquivo
@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.balloontipsdemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.balloontipsdemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../dist"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-balloontips.jar"/>
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
<path id="classpath">
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
</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>
</copy>
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
-8
Ver Arquivo
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="src" path="/platform"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>dnddemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-68
Ver Arquivo
@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="jnacontrib.dnddemo" default="jar" basedir=".">
<description>Builds, tests, and runs the project jnacontrib.dnddemo.</description>
<!-- Locations -->
<property name="src" location="."/>
<property name="build" location="build"/>
<property name="jna-dist" location="../../dist"/>
<property name="classes" location="${build}/classes"/>
<property name="jar" location="${build}/demo-dnd.jar"/>
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
<path id="classpath">
<fileset file="${file.reference.jna.jar}"/>
<fileset dir="../platform/dist" includes="jna-platform.jar"/>
</path>
<!-- Run Demo. -->
<target name="run" depends="compile">
<java classname="${main-class}" fork="true">
<classpath>
<pathelement location="${classes}" />
<path refid="classpath"/>
</classpath>
</java>
</target>
<!-- Delete class and jar files. -->
<target name="clean">
<delete dir="${classes}"/>
<delete file="${jar}"/>
<delete dir="${build}"/>
</target>
<!-- Compile all classes. -->
<target name="compile">
<mkdir dir="${classes}"/>
<!-- Compile the project. -->
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
encoding="UTF-8" debug="on" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
</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>
</copy>
<jar jarfile="${jar}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
<!-- platform -->
<fileset dir="../platform/build/classes/com"/>
<!-- jna -->
<zipfileset src="${file.reference.jna.jar}"/>
</jar>
</target>
</project>
-8
Ver Arquivo
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?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>
@@ -1,2 +0,0 @@
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.
@@ -1,36 +0,0 @@
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();
}
}
}
@@ -1,162 +0,0 @@
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);
}
}
}
@@ -1,80 +0,0 @@
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();
}
}
}
@@ -1,145 +0,0 @@
package com.sun.jna.platform.win32.office;
import com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.Variant;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMException;
import com.sun.jna.platform.win32.COM.COMObject;
import com.sun.jna.platform.win32.COM.COMUtils;
import com.sun.jna.platform.win32.COM.IDispatch;
public class MSWord extends COMObject {
public MSWord() throws COMException {
super("Word.Application", false);
}
public MSWord(boolean visible) throws COMException {
this();
this.setVisible(Variant.VARIANT_TRUE);
}
public void setVisible(VARIANT_BOOL bVisible) throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYPUT, result, this.iDispatch,
"Visible", new VARIANT(bVisible));
}
public String getVersion() throws COMException {
VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Version");
return result.getValue().toString();
}
public HRESULT newDocument() throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getDocuments().getIDispatch(), "Add");
return hr;
}
public HRESULT openDocument(String filename, boolean bVisible)
throws COMException {
// OpenDocument
BSTR bstrFilename = OleAuto.INSTANCE.SysAllocString(filename);
VARIANT varFilename = new VARIANT(bstrFilename);
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getDocuments().getIDispatch(), "Open", varFilename);
return hr;
}
public HRESULT closeActiveDocument(VARIANT_BOOL bSave)
throws COMException {
HRESULT hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
getActiveDocument().getIDispatch(), "Close", new VARIANT(bSave));
return hr;
}
public HRESULT quit() throws COMException {
HRESULT hr = this.oleMethod(OleAuto.DISPATCH_METHOD, null,
this.iDispatch, "Quit");
COMUtils.SUCCEEDED(hr);
return hr;
}
public HRESULT insertText(String text) throws COMException {
HRESULT hr;
VARIANT.ByReference result = new VARIANT.ByReference();
hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.iDispatch, "Selection");
Selection pSelection = new Selection((IDispatch) result.getValue());
BSTR bstrText = OleAuto.INSTANCE.SysAllocString(text);
VARIANT varText = new VARIANT(bstrText);
hr = oleMethod(OleAuto.DISPATCH_METHOD, null,
pSelection.getIDispatch(), "TypeText", varText);
return hr;
}
public ActiveDocument getActiveDocument() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"ActiveDocument");
COMUtils.SUCCEEDED(hr);
return new ActiveDocument((IDispatch) result.getValue());
}
public Documents getDocuments() {
// GetDocuments
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Documents");
COMUtils.SUCCEEDED(hr);
return new Documents((IDispatch) result.getValue());
}
public Application getApplication() {
VARIANT.ByReference result = new VARIANT.ByReference();
HRESULT hr = oleMethod(OleAuto.DISPATCH_PROPERTYGET, result, this.iDispatch,
"Application");
COMUtils.SUCCEEDED(hr);
return new Application((IDispatch) result.getValue());
}
public class Application extends COMObject {
public Application(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Documents extends COMObject {
public Documents(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class ActiveDocument extends COMObject {
public ActiveDocument(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
public class Selection extends COMObject {
public Selection(IDispatch iDispatch) throws COMException {
super(iDispatch);
}
}
}
-8
Ver Arquivo
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="C:/GitHub/jna-3.5.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?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>
@@ -1,313 +0,0 @@
/* 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();
}
}
-10
Ver Arquivo
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ntservice</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-541
Ver Arquivo
@@ -1,541 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
For the purpose of easier reading the script
is divided into following sections:
- initialization
- compilation
- jar
- execution
- debugging
- javadoc
- junit compilation
- junit execution
- junit debugging
- applet
- cleanup
-->
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
<!--
======================
INITIALIZATION SECTION
======================
-->
<target name="-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-init-private" depends="-pre-init">
<property file="nbproject/private/private.properties"/>
</target>
<target name="-init-user" depends="-pre-init,-init-private">
<property file="${user.properties.file}"/>
<!-- The two properties below are usually overridden -->
<!-- by the active platform. Just a fallback. -->
<property name="default.javac.source" value="1.4"/>
<property name="default.javac.target" value="1.4"/>
</target>
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
<property file="nbproject/project.properties"/>
</target>
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
<available file="${manifest.file}" property="manifest.available"/>
<condition property="manifest.available+main.class">
<and>
<isset property="manifest.available"/>
<isset property="main.class"/>
<not>
<equals arg1="${main.class}" arg2="" trim="true"/>
</not>
</and>
</condition>
<condition property="manifest.available+main.class+mkdist.available">
<and>
<istrue value="${manifest.available+main.class}"/>
<isset property="libs.CopyLibs.classpath"/>
</and>
</condition>
<condition property="have.tests">
<or>
<available file="${test.src.dir}"/>
</or>
</condition>
<condition property="have.sources">
<or>
<available file="${src.dir}"/>
</or>
</condition>
<condition property="netbeans.home+have.tests">
<and>
<isset property="netbeans.home"/>
<isset property="have.tests"/>
</and>
</condition>
<condition property="no.javadoc.preview">
<isfalse value="${javadoc.preview}"/>
</condition>
<property name="run.jvmargs" value=""/>
<property name="javac.compilerargs" value=""/>
<property name="work.dir" value="${basedir}"/>
<condition property="no.deps">
<and>
<istrue value="${no.dependencies}"/>
</and>
</condition>
<property name="javac.debug" value="true"/>
<property name="javadoc.preview" value="true"/>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
<fail unless="dist.dir">Must set dist.dir</fail>
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
<fail unless="dist.jar">Must set dist.jar</fail>
</target>
<target name="-init-macrodef-property">
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-javac">
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="srcdir" default="${src.dir}"/>
<attribute name="destdir" default="${build.classes.dir}"/>
<attribute name="classpath" default="${javac.classpath}"/>
<attribute name="debug" default="${javac.debug}"/>
<element name="customize" optional="true"/>
<sequential>
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
<classpath>
<path path="@{classpath}"/>
</classpath>
<compilerarg line="${javac.compilerargs}"/>
<customize/>
</javac>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-junit">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="includes" default="**/*Test.java"/>
<sequential>
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" includes="@{includes}"/>
</batchtest>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper type="glob" from="test-sys-prop.*" to="*"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg line="${run.jvmargs}"/>
</junit>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="name" default="${main.class}"/>
<attribute name="classpath" default="${debug.classpath}"/>
<attribute name="stopclassname" default=""/>
<sequential>
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
<classpath>
<path path="@{classpath}"/>
</classpath>
</nbjpdastart>
</sequential>
</macrodef>
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="dir" default="${build.classes.dir}"/>
<sequential>
<nbjpdareload>
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
</nbjpdareload>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-debug">
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute name="classname" default="${main.class}"/>
<attribute name="classpath" default="${debug.classpath}"/>
<element name="customize" optional="true"/>
<sequential>
<java fork="true" classname="@{classname}" dir="${work.dir}">
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=none"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="@{classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper type="glob" from="run-sys-prop.*" to="*"/>
</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-java">
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute name="classname" default="${main.class}"/>
<element name="customize" optional="true"/>
<sequential>
<java fork="true" classname="@{classname}" dir="${work.dir}">
<jvmarg line="${run.jvmargs}"/>
<classpath>
<path path="${run.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="run-sys-prop."/>
<mapper type="glob" from="run-sys-prop.*" to="*"/>
</syspropertyset>
<customize/>
</java>
</sequential>
</macrodef>
</target>
<target name="-init-presetdef-jar">
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
<jar jarfile="${dist.jar}" compress="${jar.compress}">
<j2seproject1:fileset dir="${build.classes.dir}"/>
</jar>
</presetdef>
</target>
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
<!--
===================
COMPILATION SECTION
===================
-->
<target name="deps-jar" depends="init" unless="no.deps"/>
<target name="-pre-pre-compile" depends="init,deps-jar">
<mkdir dir="${build.classes.dir}"/>
</target>
<target name="-pre-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
<j2seproject3:javac/>
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
</copy>
</target>
<target name="-post-compile">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
<target name="-pre-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<j2seproject3:javac>
<customize>
<patternset includes="${javac.includes}"/>
</customize>
</j2seproject3:javac>
</target>
<target name="-post-compile-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
<!--
====================
JAR BUILDING SECTION
====================
-->
<target name="-pre-pre-jar" depends="init">
<dirname property="dist.jar.dir" file="${dist.jar}"/>
<mkdir dir="${dist.jar.dir}"/>
</target>
<target name="-pre-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
<j2seproject1:jar/>
</target>
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
<j2seproject1:jar manifest="${manifest.file}"/>
</target>
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
<j2seproject1:jar manifest="${manifest.file}">
<j2seproject1:manifest>
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
</j2seproject1:manifest>
</j2seproject1:jar>
<echo>To run this application from the command line without Ant, try:</echo>
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
<property name="dist.jar.resolved" location="${dist.jar}"/>
<pathconvert property="run.classpath.with.dist.jar">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
</pathconvert>
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
</target>
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
<pathconvert property="run.classpath.without.build.classes.dir">
<path path="${run.classpath}"/>
<map from="${build.classes.dir.resolved}" to=""/>
</pathconvert>
<pathconvert property="jar.classpath" pathsep=" ">
<path path="${run.classpath.without.build.classes.dir}"/>
<chainedmapper>
<flattenmapper/>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
</copylibs>
<echo>To run this application from the command line without Ant, try:</echo>
<property name="dist.jar.resolved" location="${dist.jar}"/>
<echo>java -jar "${dist.jar.resolved}"</echo>
</target>
<target name="-post-jar">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
<!--
=================
EXECUTION SECTION
=================
-->
<target name="run" depends="init,compile" description="Run a main class.">
<j2seproject1:java>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject1:java>
</target>
<target name="run-single" depends="init,compile-single">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<j2seproject1:java classname="${run.class}"/>
</target>
<!--
=================
DEBUGGING SECTION
=================
-->
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
<j2seproject1:nbjpdastart name="${debug.class}"/>
</target>
<target name="-debug-start-debuggee" depends="init,compile">
<j2seproject3:debug>
<customize>
<arg line="${application.args}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
</target>
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
<j2seproject3:debug classname="${debug.class}"/>
</target>
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
<target name="-pre-debug-fix" depends="init">
<fail unless="fix.includes">Must set fix.includes</fail>
<property name="javac.includes" value="${fix.includes}.java"/>
</target>
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
<j2seproject1:nbjpdareload/>
</target>
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
<!--
===============
JAVADOC SECTION
===============
-->
<target name="-javadoc-build" depends="init">
<mkdir dir="${dist.javadoc.dir}"/>
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<sourcepath>
<pathelement location="${src.dir}"/>
</sourcepath>
<packageset dir="${src.dir}" includes="*/**"/>
<fileset dir="${src.dir}" includes="*.java"/>
</javadoc>
</target>
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
</target>
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
<!--
=========================
JUNIT COMPILATION SECTION
=========================
-->
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
<mkdir dir="${build.test.classes.dir}"/>
</target>
<target name="-pre-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="-post-compile-test">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
<target name="-pre-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
<customize>
<patternset includes="${javac.includes}"/>
</customize>
</j2seproject3:javac>
<copy todir="${build.test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="-post-compile-test-single">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
<!--
=======================
JUNIT EXECUTION SECTION
=======================
-->
<target name="-pre-test-run" if="have.tests" depends="init">
<mkdir dir="${build.test.results.dir}"/>
</target>
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
<j2seproject3:junit/>
</target>
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
<target name="test-report" if="have.tests" depends="init"/>
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
<target name="-pre-test-run-single" if="have.tests" depends="init">
<mkdir dir="${build.test.results.dir}"/>
</target>
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
<j2seproject3:junit includes="${test.includes}"/>
</target>
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
<fail if="tests.failed">Some tests failed; see details above.</fail>
</target>
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
<!--
=======================
JUNIT DEBUGGING SECTION
=======================
-->
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
<customize>
<arg line="${test.class}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
</target>
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
</target>
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
<!--
=========================
APPLET EXECUTION SECTION
=========================
-->
<target name="run-applet" depends="init,compile-single">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject1:java classname="sun.applet.AppletViewer">
<customize>
<arg value="${applet.url}"/>
</customize>
</j2seproject1:java>
</target>
<!--
=========================
APPLET DEBUGGING SECTION
=========================
-->
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<j2seproject3:debug classname="sun.applet.AppletViewer">
<customize>
<arg value="${applet.url}"/>
</customize>
</j2seproject3:debug>
</target>
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
<!--
===============
CLEANUP SECTION
===============
-->
<target name="deps-clean" depends="init" unless="no.deps"/>
<target name="-do-clean" depends="init">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="-post-clean">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
</project>
@@ -1,196 +0,0 @@
/*
* Advapi32.java
*
* Created on 6. August 2007, 11:24
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
*
* @author TB
*/
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
/*
* SC_HANDLE WINAPI OpenSCManager( LPCTSTR lpMachineName, LPCTSTR
* lpDatabaseName, DWORD dwDesiredAccess );
*/
public Pointer OpenSCManager(String lpMachineName, WString lpDatabaseName,
int dwDesiredAccess);
/*
* BOOL WINAPI CloseServiceHandle( SC_HANDLE hSCObject );
*/
public boolean CloseServiceHandle(Pointer hSCObject);
/*
* SC_HANDLE WINAPI OpenService( SC_HANDLE hSCManager, LPCTSTR
* lpServiceName, DWORD dwDesiredAccess );
*/
public Pointer OpenService(Pointer hSCManager, String lpServiceName,
int dwDesiredAccess);
/*
* BOOL WINAPI StartService( SC_HANDLE hService, DWORD dwNumServiceArgs,
* LPCTSTR* lpServiceArgVectors );
*/
public boolean StartService(Pointer hService, int dwNumServiceArgs,
char[] lpServiceArgVectors);
/*
* BOOL WINAPI ControlService( SC_HANDLE hService, DWORD dwControl,
* LPSERVICE_STATUS lpServiceStatus );
*/
public boolean ControlService(Pointer hService, int dwControl,
SERVICE_STATUS lpServiceStatus);
/*
* BOOL WINAPI StartServiceCtrlDispatcher( const SERVICE_TABLE_ENTRY*
* lpServiceTable );
*/
public boolean StartServiceCtrlDispatcher(Structure[] lpServiceTable);
/*
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandler( LPCTSTR
* lpServiceName, LPHANDLER_FUNCTION lpHandlerProc );
*/
public Pointer RegisterServiceCtrlHandler(String lpServiceName,
Handler lpHandlerProc);
/*
* SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerEx( LPCTSTR
* lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext );
*/
public Pointer RegisterServiceCtrlHandlerEx(String lpServiceName,
HandlerEx lpHandlerProc, Pointer lpContext);
/*
* BOOL WINAPI SetServiceStatus( SERVICE_STATUS_HANDLE hServiceStatus,
* LPSERVICE_STATUS lpServiceStatus );
*/
public boolean SetServiceStatus(Pointer hServiceStatus,
SERVICE_STATUS lpServiceStatus);
/*
* SC_HANDLE WINAPI CreateService( SC_HANDLE hSCManager, LPCTSTR
* lpServiceName, LPCTSTR lpDisplayName, DWORD dwDesiredAccess, DWORD
* dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCTSTR
* lpBinaryPathName, LPCTSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCTSTR
* lpDependencies, LPCTSTR lpServiceStartName, LPCTSTR lpPassword );
*/
public Pointer CreateService(Pointer hSCManager, String lpServiceName,
String lpDisplayName, int dwDesiredAccess, int dwServiceType,
int dwStartType, int dwErrorControl, String lpBinaryPathName,
String lpLoadOrderGroup, IntByReference lpdwTagId,
String lpDependencies, String lpServiceStartName, String lpPassword);
/*
* BOOL WINAPI DeleteService( SC_HANDLE hService );
*/
public boolean DeleteService(Pointer hService);
/*
* BOOL WINAPI ChangeServiceConfig2( SC_HANDLE hService, DWORD dwInfoLevel,
* LPVOID lpInfo );
*/
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel,
ChangeServiceConfig2Info lpInfo);
/*
* LONG WINAPI RegEnumValue( HKEY hKey, DWORD dwIndex, LPTSTR lpValueName,
* LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE
* lpData, LPDWORD lpcbData );
*/
public int RegEnumValue(int hKey, int dwIndex, char[] lpValueName,
IntByReference lpcchValueName, IntByReference reserved,
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
interface SERVICE_MAIN_FUNCTION extends StdCallCallback {
/*
* VOID WINAPI ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv );
*/
public void callback(int dwArgc, Pointer lpszArgv);
}
interface Handler extends StdCallCallback {
/*
* VOID WINAPI Handler( DWORD fdwControl );
*/
public void callback(int fdwControl);
}
interface HandlerEx extends StdCallCallback {
/*
* DWORD WINAPI HandlerEx( DWORD dwControl, DWORD dwEventType, LPVOID
* lpEventData, LPVOID lpContext );
*/
public int callback(int dwControl, int dwEventType,
Pointer lpEventData, Pointer lpContext);
}
/*
* typedef struct _SERVICE_STATUS { DWORD dwServiceType; DWORD
* dwCurrentState; DWORD dwControlsAccepted; DWORD dwWin32ExitCode; DWORD
* dwServiceSpecificExitCode; DWORD dwCheckPoint; DWORD dwWaitHint; }
* SERVICE_STATUS,LPSERVICE_STATUS;
*/
public static class SERVICE_STATUS extends Structure {
public int dwServiceType;
public int dwCurrentState;
public int dwControlsAccepted;
public int dwWin32ExitCode;
public int dwServiceSpecificExitCode;
public int dwCheckPoint;
public int dwWaitHint;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwServiceType", "dwCurrentState", "dwControlsAccepted", "dwWin32ExitCode", "dwServiceSpecificExitCode", "dwCheckPoint", "dwWaitHint" });
}
}
/*
* typedef struct _SERVICE_TABLE_ENTRY { LPTSTR lpServiceName;
* LPSERVICE_MAIN_FUNCTION lpServiceProc; } SERVICE_TABLE_ENTRY,
* LPSERVICE_TABLE_ENTRY;
*/
public static class SERVICE_TABLE_ENTRY extends Structure {
public String lpServiceName;
public SERVICE_MAIN_FUNCTION lpServiceProc;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lpServiceName", "lpServiceProc" });
}
}
public static abstract class ChangeServiceConfig2Info extends Structure {
}
/*
* typedef struct _SERVICE_DESCRIPTION { LPTSTR lpDescription; }
* SERVICE_DESCRIPTION,LPSERVICE_DESCRIPTION;
*/
public static class SERVICE_DESCRIPTION extends ChangeServiceConfig2Info {
public String lpDescription;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lpDescription" });
}
}
}
@@ -1,36 +0,0 @@
/*
* WINNT.java
*
* Created on 8. August 2007, 13:41
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package jnacontrib.jna;
/**
*
* @author TB
*/
public interface WINNT {
public final static int DELETE = 0x00010000;
public final static int READ_CONTROL = 0x00020000;
public final static int WRITE_DAC = 0x00040000;
public final static int WRITE_OWNER = 0x00080000;
public final static int SYNCHRONIZE = 0x00100000;
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
public final static int GENERIC_EXECUTE = 0x20000000;
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
}
-2
Ver Arquivo
@@ -1,2 +0,0 @@
# placeholder
-10
Ver Arquivo
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/jnalib"/>
<classpathentry kind="lib" path="/jnalib/dist/jna.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="bin"/>
</classpath>
-17
Ver Arquivo
@@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>platform</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
-140
Ver Arquivo
@@ -1,140 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="platform" default="default" basedir=".">
<description>Builds and tests platform-specific code.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JnaContrib-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<target name="test" depends="init,compile,compile-test,-pre-test-run" description="Run platform unit tests.">
<echo>Running platform tests: ${test.src.dir}</echo>
<property name="test.fork" value="yes"/>
<property name="build.test.results.dir.abs" location="${build.test.results.dir}"/>
<mkdir dir="${build.test.results.dir.abs}"/>
<echo>Saving test results in ${build.test.results.dir.abs}</echo>
<condition property="tests.platform" value="**/mac/**">
<os family="mac"/>
</condition>
<condition property="tests.platform" value="**/win32/**">
<os family="windows"/>
</condition>
<condition property="tests.platform" value="**/unix/**">
<os family="unix"/>
</condition>
<property name="tests.platform" value=""/>
<property name="tests.exclude" value=""/>
<property name="tests.exclude-patterns" value=""/>
<condition property="java.awt.headless" value="true">
<isset property="headless"/>
</condition>
<condition property="vmopt.arch" value="-d64" else="-Dignore">
<and>
<!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
<not><os family="windows"/></not>
<equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
</and>
</condition>
<propertyset id="headless">
<propertyref prefix="java.awt.headless"/>
</propertyset>
<echo>tests.platform=${tests.platform}</echo>
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build.dir}">
<!-- optionally run headless -->
<syspropertyset refid="headless"/>
<!-- avoid VM conflicts with JNA protected mode -->
<env key="${ld.preload.name}" file="${libjsig}"/>
<!-- Ignore any system install of JNA -->
<sysproperty key="jna.nosys" value="true"/>
<!-- Avoid VM crashes, if possible -->
<sysproperty key="jna.protected" value="true"/>
<sysproperty key="jna.builddir" file="${file.reference.jna.build}"/>
<jvmarg value="${vmopt.arch}"/>
<classpath><path path="${run.test.classpath}"/></classpath>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" excludes="${tests.exclude-patterns}">
<!-- Until StructureFieldOrderTest gets fixed up a little -->
<exclude name="**/StructureFieldOrderTest.java"/>
<include name="com/sun/jna/platform/*Test.java"/>
<include name="${tests.platform}"/>
<exclude name="${tests.exclude}"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${build.test.results.dir}">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${build.test.results.dir}"/>
</junitreport>
<echo message="View test report in file://${build.test.results.dir.abs}/index.html" />
<fail if="testfailure">One or more tests failed</fail>
</target>
<!-- One-off test to check field order definitions -->
<target name="test-field-order" depends="-pre-test-run-single" >
<!-- @todo How to ensure sys prop: jna.nosys=true is seen in tests? -->
<!--<property name="test.includes" value="com/sun/jna/platform/**/*.java"/>-->
<property name="test.includes" value="com/sun/jna/platform/StructureFieldOrderTest.java"/>
<property name="javac.includes" value="**/*"/>
<antcall target="test-single"/>
</target>
</project>
-13
Ver Arquivo
@@ -1,13 +0,0 @@
<?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>
@@ -1,135 +0,0 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sun.jna.platform.win32.W32FileMonitor;
/** Provides notification of file system changes. Actual capabilities may
* vary slightly by platform.
* <p>
* Watched files which are removed from the filesystem are no longer watched.
* @author twall
*/
@SuppressWarnings("serial")
public abstract class FileMonitor {
public static final int FILE_CREATED = 0x1;
public static final int FILE_DELETED = 0x2;
public static final int FILE_MODIFIED = 0x4;
public static final int FILE_ACCESSED = 0x8;
public static final int FILE_NAME_CHANGED_OLD = 0x10;
public static final int FILE_NAME_CHANGED_NEW = 0x20;
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
public static final int FILE_SIZE_CHANGED = 0x40;
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
public static final int FILE_SECURITY_CHANGED = 0x100;
public static final int FILE_ANY = 0x1FF;
public interface FileListener {
public void fileChanged(FileEvent e);
}
public class FileEvent extends EventObject {
private final File file;
private final int type;
public FileEvent(File file, int type) {
super(FileMonitor.this);
this.file = file;
this.type = type;
}
public File getFile() { return file; }
public int getType() { return type; }
public String toString() {
return "FileEvent: " + file + ":" + type;
}
}
private final Map<File, Integer> watched = new HashMap<File, Integer>();
private List<FileListener> listeners = new ArrayList<FileListener>();
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
protected abstract void unwatch(File file);
public abstract void dispose();
public void addWatch(File dir) throws IOException {
addWatch(dir, FILE_ANY);
}
public void addWatch(File dir, int mask) throws IOException {
addWatch(dir, mask, dir.isDirectory());
}
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
watched.put(dir, new Integer(mask));
watch(dir, mask, recursive);
}
public void removeWatch(File file) {
if (watched.remove(file) != null) {
unwatch(file);
}
}
protected void notify(FileEvent e) {
for (FileListener listener : listeners) {
listener.fileChanged(e);
}
}
public synchronized void addFileListener(FileListener listener) {
List<FileListener> list = new ArrayList<FileListener>(listeners);
list.add(listener);
listeners = list;
}
public synchronized void removeFileListener(FileListener x) {
List<FileListener> list = new ArrayList<FileListener>(listeners);
list.remove(x);
listeners = list;
}
protected void finalize() {
for (File watchedFile : watched.keySet()) {
removeWatch(watchedFile);
}
dispose();
}
/** Canonical lazy loading of a singleton. */
private static class Holder {
public static final FileMonitor INSTANCE;
static {
String os = System.getProperty("os.name");
if (os.startsWith("Windows")) {
INSTANCE = new W32FileMonitor();
}
else {
throw new Error("FileMonitor not implemented for " + os);
}
}
}
public static FileMonitor getInstance() {
return Holder.INSTANCE;
}
}
@@ -1,14 +0,0 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides integrated, extended drag and drop functionality,
allowing ghosted drag images to be used on all platforms.
</body>
</html>
@@ -1,92 +0,0 @@
/*
* Copyright (c) 2011 Denis Tulskiy
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* Author: Denis Tulskiy
* Date: 7/25/11
*/
public interface Carbon extends Library {
public static Carbon INSTANCE = (Carbon) Native.loadLibrary("Carbon", Carbon.class);
public static final int cmdKey = 0x0100;
public static final int shiftKey = 0x0200;
public static final int optionKey = 0x0800;
public static final int controlKey = 0x1000;
/**
* Obtains the event target reference for the standard toolbox dispatcher
*/
public Pointer GetEventDispatcherTarget();
/**
* Installs an event handler on a specified event target.
*/
public int InstallEventHandler(Pointer inTarget, EventHandlerProcPtr inHandler, int inNumTypes, EventTypeSpec[] inList, Pointer inUserData, PointerByReference outRef);
/**
* Registers a global hot key.
*/
public int RegisterEventHotKey(int inHotKeyCode, int inHotKeyModifiers, EventHotKeyID.ByValue inHotKeyID, Pointer inTarget, int inOptions, PointerByReference outRef);
/**
* Obtains a parameter from the specified event.
*/
public int GetEventParameter(Pointer inEvent, int inName, int inDesiredType, Pointer outActualType, int inBufferSize, IntBuffer outActualSize, EventHotKeyID outData);
/**
* Removes the specified event handler
*/
public int RemoveEventHandler(Pointer inHandlerRef);
/**
* Unregisters a global hot key.
*/
public int UnregisterEventHotKey(Pointer inHotKey);
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 { }
protected List getFieldOrder() {
return Arrays.asList(new String[] { "signature", "id" }); }
}
public static interface EventHandlerProcPtr extends Callback {
public int callback(Pointer inHandlerCallRef, Pointer inEvent, Pointer inUserData);
}
}
@@ -1,86 +0,0 @@
/* Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.mac;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.platform.FileUtils;
public class MacFileUtils extends FileUtils {
public boolean hasTrash() { return true; }
public interface FileManager extends Library {
public FileManager INSTANCE = (FileManager)Native.loadLibrary("CoreServices", FileManager.class);
int kFSFileOperationDefaultOptions = 0;
int kFSFileOperationsOverwrite = 0x01;
int kFSFileOperationsSkipSourcePermissionErrors = 0x02;
int kFSFileOperationsDoNotMoveAcrossVolumes = 0x04;
int kFSFileOperationsSkipPreflight = 0x08;
int kFSPathDefaultOptions = 0x0;
int kFSPathMakeRefDoNotFollowLeafSymlink = 0x01;
class FSRef extends Structure {
public byte[] hidden = new byte[80];
protected List getFieldOrder() { return Arrays.asList(new String[] { "hidden" }); }
}
// Deprecated; use trashItemAtURL instead:
// https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/trashItemAtURL:resultingItemURL:error:
int FSRefMakePath(FSRef fsref, byte[] path, int maxPathSize);
int FSPathMakeRef(String source, int options, ByteByReference isDirectory);
int FSPathMakeRefWithOptions(String source, int options, FSRef fsref, ByteByReference isDirectory);
int FSPathMoveObjectToTrashSync(String source, PointerByReference target, int options);
int FSMoveObjectToTrashSync(FSRef source, FSRef target, int options);
}
public void moveToTrash(File[] files) throws IOException {
File home = new File(System.getProperty("user.home"));
File trash = new File(home, ".Trash");
if (!trash.exists()) {
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
}
List<String> failed = new ArrayList<String>();
for (int i=0;i < files.length;i++) {
File src = files[i];
FileManager.FSRef fsref = new FileManager.FSRef();
int status = FileManager.INSTANCE.FSPathMakeRefWithOptions(src.getAbsolutePath(),
FileManager.kFSPathMakeRefDoNotFollowLeafSymlink,
fsref, null);
if (status != 0) {
failed.add(src + " (FSRef: " + status + ")");
continue;
}
status = FileManager.INSTANCE.FSMoveObjectToTrashSync(fsref, null, 0);
if (status != 0) {
failed.add(src + " (" + status + ")");
}
}
if (failed.size() > 0) {
throw new IOException("The following files could not be trashed: " + failed);
}
}
}
@@ -1,13 +0,0 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides cross-platform utilities based on platform-specific libraries.
</body>
</html>
@@ -1,13 +0,0 @@
<html>
<head>
<!--
Copyright (c) 2010 Timothy Wall
-->
</head>
<body bgcolor="white">
<!-- One sentence summary -->
Provides common library mappings for Unix and X11-based platforms.
</body>
</html>
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,127 +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 com.sun.jna.IntegerType;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.ByReference;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on basetsd.h (various types)
* @author dblock[at]dblock[dot]org
*/
@SuppressWarnings("serial")
public interface BaseTSD extends StdCallLibrary {
/**
* Signed long type for pointer precision.
* Use when casting a pointer to a long to perform pointer arithmetic.
*/
public static class LONG_PTR extends IntegerType {
public LONG_PTR() {
this(0);
}
public LONG_PTR(long value) {
super(Pointer.SIZE, value);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* Signed SIZE_T.
*/
public static class SSIZE_T extends LONG_PTR {
public SSIZE_T() {
this(0);
}
public SSIZE_T(long value) {
super(value);
}
}
/**
* Unsigned LONG_PTR.
*/
public static class ULONG_PTR extends IntegerType {
public ULONG_PTR() {
this(0);
}
public ULONG_PTR(long value) {
super(Pointer.SIZE, value, true);
}
public Pointer toPointer() {
return Pointer.createConstant(longValue());
}
}
/**
* PULONG_PTR
*/
public static class ULONG_PTRByReference extends ByReference {
public ULONG_PTRByReference() {
this(new ULONG_PTR(0));
}
public ULONG_PTRByReference(ULONG_PTR value) {
super(Pointer.SIZE);
setValue(value);
}
public void setValue(ULONG_PTR value) {
if (Pointer.SIZE == 4) {
getPointer().setInt(0, value.intValue());
}
else {
getPointer().setLong(0, value.longValue());
}
}
public ULONG_PTR getValue() {
return new ULONG_PTR(Pointer.SIZE == 4
? getPointer().getInt(0)
: getPointer().getLong(0));
}
}
/**
* Unsigned DWORD_PTR.
*/
public static class DWORD_PTR extends IntegerType {
public DWORD_PTR() {
this(0);
}
public DWORD_PTR(long value) {
super(Pointer.SIZE, value);
}
}
/**
* The maximum number of bytes to which a pointer can point.
* Use for a count that must span the full range of a pointer.
*/
public static class SIZE_T extends ULONG_PTR {
public SIZE_T() {
this(0);
}
public SIZE_T(long value) {
super(value);
}
}
}
@@ -1,104 +0,0 @@
/* 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;
}
}
@@ -1,200 +0,0 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32.COM;
import com.sun.jna.Native;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.Kernel32Util;
import com.sun.jna.platform.win32.OaIdl;
import com.sun.jna.platform.win32.OaIdl.DISPID;
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.Ole32;
import com.sun.jna.platform.win32.OleAuto;
import com.sun.jna.platform.win32.OleAuto.DISPPARAMS;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.Variant.VariantArg;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Helper class to provide basic COM support.
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class COMObject {
public final static LCID LOCALE_USER_DEFAULT = Kernel32.INSTANCE
.GetUserDefaultLCID();
public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
.GetSystemDefaultLCID();
protected IUnknown iUnknown;
protected IDispatch iDispatch;
private PointerByReference pDispatch = new PointerByReference();
private PointerByReference pUnknown = new PointerByReference();
public COMObject(IDispatch iDispatch) {
this.iDispatch = iDispatch;
}
/**
* Instantiates a new cOM object.
*
* @param progId
* the prog id
* @param useActiveInstance
* the use active instance
* @throws COMException
* the automation exception
*/
public COMObject(String progId, boolean useActiveInstance)
throws COMException {
// Initialize COM for this thread...
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED);
if (COMUtils.FAILED(hr)) {
this.release();
throw new COMException("CoInitializeEx() failed: " + Kernel32Util.formatMessage(hr));
}
CLSID clsid = new CLSID();
hr = Ole32.INSTANCE.CLSIDFromProgID(progId, clsid);
if (COMUtils.FAILED(hr)) {
Ole32.INSTANCE.CoUninitialize();
throw new COMException("CLSIDFromProgID() failed: " + Kernel32Util.formatMessage(hr));
}
if (useActiveInstance) {
hr = OleAuto.INSTANCE.GetActiveObject(clsid, null, this.pUnknown);
if (COMUtils.SUCCEEDED(hr)) {
this.iUnknown = new IUnknown(this.pUnknown.getValue());
hr = iUnknown.QueryInterface(IDispatch.IID_IDispatch,
this.pDispatch);
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
this.pDispatch);
}
} else {
hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
WTypes.CLSCTX_SERVER, IDispatch.IID_IDispatch,
this.pDispatch);
}
if (COMUtils.FAILED(hr)) {
throw new COMException("COM object with ProgID '" + progId
+ "' and CLSID " + clsid.toGuidString() + " not registered properly!");
}
this.iDispatch = new IDispatch(this.pDispatch.getValue());
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name, VARIANT[] pArgs) throws COMException {
if (pDisp == null)
throw new COMException("pDisp (IDispatch) parameter is null!");
WString[] ptName = new WString[] { new WString(name) };
DISPPARAMS dp = new DISPPARAMS();
DISPIDByReference pdispID = new DISPIDByReference();
VariantArg.ByReference variantArg = new VariantArg.ByReference();
variantArg.variantArg = pArgs;
EXCEPINFO.ByReference pExcepInfo = new EXCEPINFO.ByReference();
IntByReference puArgErr = new IntByReference();
// Get DISPID for name passed...
HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
LOCALE_USER_DEFAULT, pdispID);
COMUtils.checkAutoRC(hr);
// Handle special-case for property-puts!
if (nType == OleAuto.DISPATCH_PROPERTYPUT) {
dp.cNamedArgs = new UINT(pArgs.length);
dp.rgdispidNamedArgs = new DISPIDByReference(
OaIdl.DISPID_PROPERTYPUT);
}
// Build DISPPARAMS
if ((pArgs != null) && (pArgs.length > 0)) {
dp.cArgs = new UINT(pArgs.length);
dp.rgvarg = variantArg;
// write 'DISPPARAMS' structure to memory
dp.write();
}
// Make the call!
hr = pDisp.Invoke(pdispID.getValue(), Guid.IID_NULL,
LOCALE_SYSTEM_DEFAULT, new DISPID(nType), dp, pvResult,
pExcepInfo, puArgErr);
COMUtils.checkAutoRC(hr, pExcepInfo, puArgErr);
return hr;
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name, VARIANT pArg) throws COMException {
return this.oleMethod(nType, pvResult, pDisp, name,
new VARIANT[] { pArg });
}
protected HRESULT oleMethod(int nType, VARIANT.ByReference pvResult,
IDispatch pDisp, String name) throws COMException {
return this.oleMethod(nType, pvResult, pDisp, name, (VARIANT[]) null);
}
protected void checkFailed(HRESULT hr) {
COMUtils.checkAutoRC(hr, null, null);
}
public IDispatch getIDispatch() {
return iDispatch;
}
public PointerByReference getIDispatchPointer() {
return pDispatch;
}
public IUnknown getIUnknown() {
return iUnknown;
}
public PointerByReference getIUnknownPointer() {
return pUnknown;
}
public void release() {
if (this.iDispatch != null)
this.iDispatch.Release();
Ole32.INSTANCE.CoUninitialize();
}
}
@@ -1,354 +0,0 @@
package com.sun.jna.platform.win32.COM;
import java.util.ArrayList;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Advapi32;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
import com.sun.jna.platform.win32.Advapi32Util.InfoKey;
import com.sun.jna.platform.win32.OaIdl.EXCEPINFO;
import com.sun.jna.platform.win32.W32Errors;
import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinError;
import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.WinReg;
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
import com.sun.jna.ptr.IntByReference;
/**
* The Class COMUtils.
*/
public abstract class COMUtils {
/** The Constant CO_E_NOTINITIALIZED. */
public static final int S_OK = 0, S_FALSE = 1,
REGDB_E_CLASSNOTREG = 0x80040154,
CLASS_E_NOAGGREGATION = 0x80040110,
CO_E_NOTINITIALIZED = 0x800401F0;
/** The Constant E_UNEXPECTED. */
public static final int E_UNEXPECTED = 0x8000FFFF;
/** The Constant E_NOTIMPL. */
public static final int E_NOTIMPL = 0x80004001;
/** The Constant E_OUTOFMEMORY. */
public static final int E_OUTOFMEMORY = 0x8007000E;
/** The Constant E_INVALIDARG. */
public static final int E_INVALIDARG = 0x80070057;
/** The Constant E_NOINTERFACE. */
public static final int E_NOINTERFACE = 0x80004002;
/** The Constant E_POINTER. */
public static final int E_POINTER = 0x80004003;
/** The Constant E_HANDLE. */
public static final int E_HANDLE = 0x80070006;
/** The Constant E_ABORT. */
public static final int E_ABORT = 0x80004004;
/** The Constant E_FAIL. */
public static final int E_FAIL = 0x80004005;
/** The Constant E_ACCESSDENIED. */
public static final int E_ACCESSDENIED = 0x80070005;
/** The Constant DISP_E_BADVARTYPE. */
public static final int DISP_E_BADVARTYPE = -2147352568;
/** The Constant DISP_E_NOTACOLLECTION. */
public static final int DISP_E_NOTACOLLECTION = -2147352559;
/** The Constant DISP_E_MEMBERNOTFOUND. */
public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
/** The Constant DISP_E_ARRAYISLOCKED. */
public static final int DISP_E_ARRAYISLOCKED = -2147352563;
/** The Constant DISP_E_EXCEPTION. */
public static final int DISP_E_EXCEPTION = -2147352567;
/** The Constant DISP_E_TYPEMISMATCH. */
public static final int DISP_E_TYPEMISMATCH = -2147352571;
/** The Constant DISP_E_BADINDEX. */
public static final int DISP_E_BADINDEX = -2147352565;
/** The Constant DISP_E_BADCALLEE. */
public static final int DISP_E_BADCALLEE = -2147352560;
/** The Constant DISP_E_OVERFLOW. */
public static final int DISP_E_OVERFLOW = -2147352566;
/** The Constant DISP_E_UNKNOWNINTERFACE. */
public static final int DISP_E_UNKNOWNINTERFACE = -2147352575;
/** The Constant DISP_E_DIVBYZERO. */
public static final int DISP_E_DIVBYZERO = -2147352558;
/** The Constant DISP_E_UNKNOWNLCID. */
public static final int DISP_E_UNKNOWNLCID = -2147352564;
/** The Constant DISP_E_PARAMNOTOPTIONAL. */
public static final int DISP_E_PARAMNOTOPTIONAL = -2147352561;
/** The Constant DISP_E_PARAMNOTFOUND. */
public static final int DISP_E_PARAMNOTFOUND = -2147352572;
/** The Constant DISP_E_BADPARAMCOUNT. */
public static final int DISP_E_BADPARAMCOUNT = -2147352562;
/** The Constant DISP_E_BUFFERTOOSMALL. */
public static final int DISP_E_BUFFERTOOSMALL = -2147352557;
/** The Constant DISP_E_UNKNOWNNAME. */
public static final int DISP_E_UNKNOWNNAME = -2147352570;
/** The Constant DISP_E_NONAMEDARGS. */
public static final int DISP_E_NONAMEDARGS = -2147352569;
/** The Constant CO_E_OBJNOTCONNECTED. */
public static final int CO_E_OBJNOTCONNECTED = -2147220995;
/**
* Succeeded.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean SUCCEEDED(HRESULT hr) {
return SUCCEEDED(hr.intValue());
}
/**
* Succeeded.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean SUCCEEDED(int hr) {
if (hr == S_OK)
return true;
else
return false;
}
/**
* Failed.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean FAILED(HRESULT hr) {
return FAILED(hr.intValue());
}
/**
* Failed.
*
* @param hr
* the hr
* @return true, if successful
*/
public static boolean FAILED(int hr) {
if (hr != S_OK)
return true;
else
return false;
}
/**
* Throw new exception.
*
* @param hr
* the hr
*/
public static void checkAutoRC(HRESULT hr) {
checkAutoRC(hr, null, null);
}
/**
* Throw new exception.
*
* @param hr
* the hr
* @param pExcepInfo
* the excep info
* @param puArgErr
* the pu arg err
*/
public static void checkAutoRC(HRESULT hr, EXCEPINFO pExcepInfo,
IntByReference puArgErr) {
switch (hr.intValue()) {
case S_OK:
return;
case E_NOTIMPL:
throw new COMException("Not implemented!");
case E_INVALIDARG:
throw new COMException("Invalid argument!");
case E_OUTOFMEMORY:
throw new COMException("Out of memory!");
case E_UNEXPECTED:
throw new COMException("Error "
+ Integer.toHexString(hr.intValue()));
case CO_E_NOTINITIALIZED:
throw new COMException("CoInitialized wasn't called!");
case E_NOINTERFACE:
throw new COMException("Interface does not inherit from class!");
case E_POINTER:
throw new COMException("Allocated pointer pointer is null!");
case DISP_E_UNKNOWNNAME:
throw new COMException(
"One or more of the names were not known. The returned array of DISPIDs contains DISPID_UNKNOWN for each entry that corresponds to an unknown name!");
case DISP_E_UNKNOWNLCID:
throw new COMException(
"The locale identifier (LCID) was not recognized!");
case DISP_E_BADPARAMCOUNT:
throw new COMException(
"The number of elements provided to DISPPARAMS is different from the number of arguments accepted by the method or property!");
case DISP_E_BADVARTYPE:
throw new COMException(
"One of the arguments in DISPPARAMS is not a valid variant type!");
case DISP_E_EXCEPTION:
throw new COMException(
"The application needs to raise an exception. In this case, the structure passed in pexcepinfo should be filled in!",
pExcepInfo, puArgErr);
case DISP_E_MEMBERNOTFOUND:
throw new COMException("The requested member does not exist!");
case DISP_E_NONAMEDARGS:
throw new COMException(
"This implementation of IDispatch does not support named arguments!");
case DISP_E_OVERFLOW:
throw new COMException(
"One of the arguments in DISPPARAMS could not be coerced to the specified type!");
case DISP_E_PARAMNOTFOUND:
throw new COMException(
"One of the parameter IDs does not correspond to a parameter on the method. In this case, puArgErr is set to the first argument that contains the error!",
pExcepInfo, puArgErr);
case DISP_E_TYPEMISMATCH:
throw new COMException(
"One or more of the arguments could not be coerced. The index of the first parameter with the incorrect type within rgvarg is returned in puArgErr!",
pExcepInfo, puArgErr);
case DISP_E_UNKNOWNINTERFACE:
throw new COMException(
"The interface identifier passed in riid is not IID_NULL!");
case CO_E_OBJNOTCONNECTED:
throw new COMException(
"The method is not connected to the Dispatch pointer!");
default:
throw new COMException("Unexpected COM error code : "
+ toHexStr(hr));
}
}
public static void checkTypeLibRC(HRESULT hr) {
switch (hr.intValue()) {
case S_OK:
return;
case WinError.E_INVALIDARG:
throw new COMException("One or more of the arguments is not valid.");
case WinError.E_OUTOFMEMORY:
throw new COMException(
"Insufficient memory to complete the operation.");
case WinError.TYPE_E_IOERROR:
throw new COMException("The function could not write to the file.");
case WinError.TYPE_E_INVALIDSTATE:
throw new COMException("The type library could not be opened.");
case WinError.TYPE_E_INVDATAREAD:
throw new COMException(
"The function could not read from the file. ");
case WinError.TYPE_E_UNSUPFORMAT:
throw new COMException("The type library has an older format.");
case WinError.TYPE_E_UNKNOWNLCID:
throw new COMException(
"The LCID could not be found in the OLE-supported DLLs.");
case WinError.TYPE_E_CANTLOADLIBRARY:
throw new COMException(
"The type library or DLL could not be loaded.");
case WinError.TYPE_E_ELEMENTNOTFOUND:
throw new COMException(
"No type description was found in the library with the specified GUID.");
default:
throw new COMException("Unexpected Typelib error code : "
+ toHexStr(hr));
}
}
public static ArrayList<COMInfo> getAllCOMInfoOnSystem() {
HKEYByReference phkResult = new HKEYByReference();
HKEYByReference phkResult2 = new HKEYByReference();
String subKey;
ArrayList<COMInfo> comInfos = new ArrayList<COMUtils.COMInfo>();
try {
// open root key
phkResult = Advapi32Util.registryGetKey(WinReg.HKEY_CLASSES_ROOT, "CLSID", WinNT.KEY_ALL_ACCESS);
// open subkey
InfoKey infoKey = Advapi32Util.registryQueryInfoKey(phkResult.getValue(), WinNT.KEY_ALL_ACCESS);
for (int i = 0; i < infoKey.lpcSubKeys.getValue(); i++) {
EnumKey enumKey = Advapi32Util.registryRegEnumKey(phkResult.getValue(), i);
subKey = Native.toString(enumKey.lpName);
COMInfo comInfo = new COMInfo(subKey);
phkResult2 = Advapi32Util.registryGetKey(phkResult.getValue(), subKey, WinNT.KEY_ALL_ACCESS);
InfoKey infoKey2 = Advapi32Util.registryQueryInfoKey(phkResult2.getValue(), WinNT.KEY_ALL_ACCESS);
for (int y = 0; y < infoKey2.lpcSubKeys.getValue(); y++)
{
EnumKey enumKey2 = Advapi32Util.registryRegEnumKey(phkResult2.getValue(), y);
String subKey2 = Native.toString(enumKey2.lpName);
if(subKey2.equals("InprocHandler32")) {
comInfo.inprocHandler32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("InprocServer32")) {
comInfo.inprocServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("LocalServer32")) {
comInfo.localServer32 = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("ProgID")) {
comInfo.progID = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}else if(subKey2.equals("TypeLib")) {
comInfo.typeLib = (String)Advapi32Util.registryGetValue(phkResult2.getValue(), subKey2, null);
}
}
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
comInfos.add(comInfo);
}
} finally {
Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
Advapi32.INSTANCE.RegCloseKey(phkResult2.getValue());
}
return comInfos;
}
public static class COMInfo {
public String clsid;
public String inprocHandler32;
public String inprocServer32;
public String localServer32;
public String progID;
public String typeLib;
public COMInfo() {
}
public COMInfo(String clsid) {
this.clsid = clsid;
}
}
private static String toHexStr(HRESULT hr) {
return "0x" + Integer.toHexString(hr.intValue()).toUpperCase();
}
}
@@ -1,164 +0,0 @@
/* 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);
}
}
@@ -1,282 +0,0 @@
/* 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;
}
}
@@ -1,74 +0,0 @@
/* 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);
}
}
@@ -1,293 +0,0 @@
/* 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 });
}
}
@@ -1,168 +0,0 @@
/* 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 });
}
}
@@ -1,101 +0,0 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32.COM;
import com.sun.jna.Function;
import com.sun.jna.Pointer;
import com.sun.jna.PointerType;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.Guid.IID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
/**
* Wrapper class for the ITypeInfo interface
*
* Method Name V-Table Offset IUnknown.QueryInterface 0 IUnknown.AddRef 4
* IUnknown.Release 8
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public class IUnknown extends PointerType {
/**
* The Class ByReference.
*/
public static class ByReference extends IUnknown implements
Structure.ByReference {
}
/** The Constant IID_IDispatch. */
public final static IID IID_IDispatch = new IID(
"{00000000-0000-0000-C000-000000000046}");
/**
* Instantiates a new i unknown.
*/
public IUnknown() {
}
/**
* Instantiates a new i unknown.
*
* @param pvInstance
* the pv instance
*/
public IUnknown(Pointer pvInstance) {
super(pvInstance);
}
/**
* Query interface.
*
* @param riid
* the riid
* @param ppvObject
* the ppv object
* @return the hresult
*/
public HRESULT QueryInterface(IID riid, PointerByReference ppvObject) {
Pointer base = this.getPointer();
Pointer vptr = base.getPointer(0);
Pointer root = vptr.getPointer(0);
Function func = Function.getFunction(root);
int hr = func.invokeInt(new Object[] { base, riid, ppvObject });
return new HRESULT(hr);
}
/**
* Adds the ref.
*
* @return the ulong
*/
public int AddRef() {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(4));
return func.invokeInt(new Object[] { this.getPointer() });
}
/**
* Release.
*
* @return the ulong
*/
public int Release() {
Pointer vptr = this.getPointer().getPointer(0);
Function func = Function.getFunction(vptr.getPointer(8));
return func.invokeInt(new Object[] { this.getPointer() });
}
}
@@ -1,112 +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 com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Crypt32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Crypt32 extends StdCallLibrary {
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
* structure. Typically, only a user with the same logon credential as the encrypter
* can decrypt the data. In addition, the encryption and decryption usually must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
* @param szDataDescr
* String with a readable description of the data to be encrypted. This description
* string is included with the encrypted data. This parameter is optional and can
* be set to NULL, except on Windows 2000.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
* phase must also be used in the decryption phase. This parameter can be set to NULL
* for no additional entropy.
* @param pvReserved
* Reserved for future use and must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL in both the encryption and decryption
* phases.
* @param dwFlags
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
* CRYPTPROTECT_VERIFY_PROTECTION.
* @param pDataOut
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
* finished using the DATA_BLOB structure, free its pbData member by calling the
* LocalFree function.
* @return
* If the function succeeds, the function returns TRUE. If the function fails,
* it returns FALSE. For extended error information, call GetLastError.
*/
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
/**
* The CryptUnprotectData function decrypts and does an integrity check of the data in
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
* encrypter can decrypt the data. In addition, the encryption and decryption must be
* done on the same computer.
* @param pDataIn
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
* structure's cbData member holds the length of the pbData member's byte string that
* contains the text to be encrypted.
* @param szDataDescr
* Pointer to a string-readable description of the encrypted data included with the
* encrypted data. This parameter can be set to NULL. When you have finished using
* ppszDataDescr, free it by calling the LocalFree function.
* @param pOptionalEntropy
* Pointer to a DATA_BLOB structure that contains a password or other additional
* entropy used when the data was encrypted. This parameter can be set to NULL;
* however, if an optional entropy DATA_BLOB structure was used in the encryption
* phase, that same DATA_BLOB structure must be used for the decryption phase.
* @param pvReserved
* Reserved for future use; must be set to NULL.
* @param pPromptStruct
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
* where and when prompts are to be displayed and what the content of those prompts
* should be. This parameter can be set to NULL.
* @param dwFlags
* DWORD value that specifies options for this function. This parameter can be zero,
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
* @param pDataOut
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
* When you have finished using the DATA_BLOB structure, free its pbData member by
* calling the LocalFree function.
* @return
* If the function succeeds, the return value is TRUE. If the function fails, the
* return value is FALSE.
*/
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
int dwFlags,
DATA_BLOB pDataOut);
}
@@ -1,140 +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 com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
import com.sun.jna.ptr.PointerByReference;
/**
* Crypt32 utility API.
* @author dblock[at]dblock.org
*/
public abstract class Crypt32Util {
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data) {
return cryptProtectData(data, 0);
}
/**
* Protect a blob of data with optional flags.
* @param data
* Data to protect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Protected data.
*/
public static byte[] cryptProtectData(byte[] data, int flags) {
return cryptProtectData(data, null, flags, "", null);
}
/**
* Protect a blob of data.
* @param data
* Data to protect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param description
* Optional description.
* @param prompt
* Prompt structure.
* @return
* Protected bytes.
*/
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataProtected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
try {
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
pEntropy, null, prompt, flags, pDataProtected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataProtected.getData();
} finally {
if (pDataProtected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
}
}
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data) {
return cryptUnprotectData(data, 0);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param flags
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, int flags) {
return cryptUnprotectData(data, null, flags, null);
}
/**
* Unprotect a blob of data.
* @param data
* Data to unprotect.
* @param entropy
* Optional entropy.
* @param flags
* Optional flags.
* @param prompt
* Optional prompt structure.
* @return
* Unprotected blob of data.
*/
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
CRYPTPROTECT_PROMPTSTRUCT prompt) {
DATA_BLOB pDataIn = new DATA_BLOB(data);
DATA_BLOB pDataUnprotected = new DATA_BLOB();
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
PointerByReference pDescription = new PointerByReference();
try {
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
pEntropy, null, prompt, flags, pDataUnprotected)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return pDataUnprotected.getData();
} finally {
if (pDataUnprotected.pbData != null) {
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
}
if (pDescription.getValue() != null) {
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
}
}
}
}
@@ -1,530 +0,0 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinDef.LONG;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
import com.sun.jna.win32.StdCallLibrary;
/**
* Based on dbt.h (various types)
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
@SuppressWarnings("serial")
public interface DBT extends StdCallLibrary {
/** The dbt no disk space. */
int DBT_NO_DISK_SPACE = 0x0047;
/** The dbt low disk space. */
int DBT_LOW_DISK_SPACE = 0x0048;
/** The dbt configmgprivate. */
int DBT_CONFIGMGPRIVATE = 0x7FFF;
/** The dbt devicearrival. */
int DBT_DEVICEARRIVAL = 0x8000;
/** The dbt devicequeryremove. */
int DBT_DEVICEQUERYREMOVE = 0x8001;
/** The dbt devicequeryremovefailed. */
int DBT_DEVICEQUERYREMOVEFAILED = 0x8002;
/** The dbt deviceremovepending. */
int DBT_DEVICEREMOVEPENDING = 0x8003;
/** The dbt deviceremovecomplete. */
int DBT_DEVICEREMOVECOMPLETE = 0x8004;
/** A device has been added to or removed from the system. */
int DBT_DEVNODES_CHANGED = 0x0007;
/** The dbt devicetypespecific. */
int DBT_DEVICETYPESPECIFIC = 0x8005;
/** The dbt customevent. */
int DBT_CUSTOMEVENT = 0x8006;
/** The guid devinterface usb device. */
public GUID GUID_DEVINTERFACE_USB_DEVICE = new GUID(
"{A5DCBF10-6530-11D2-901F-00C04FB951ED}");
/** The guid devinterface hid. */
public GUID GUID_DEVINTERFACE_HID = new GUID(
"{4D1E55B2-F16F-11CF-88CB-001111000030}");
/** The guid devinterface volume. */
public GUID GUID_DEVINTERFACE_VOLUME = new GUID(
"{53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}");
/** The guid devinterface keyboard. */
public GUID GUID_DEVINTERFACE_KEYBOARD = new GUID(
"{884b96c3-56ef-11d1-bc8c-00a0c91405dd}");
/** The guid devinterface mouse. */
public GUID GUID_DEVINTERFACE_MOUSE = new GUID(
"{378DE44C-56EF-11D1-BC8C-00A0C91405DD}");
/**
* The Class DEV_BROADCAST_HDR.
*/
public class DEV_BROADCAST_HDR extends Structure {
/** The dbch_size. */
public int dbch_size = size();
/** The dbch_devicetype. */
public int dbch_devicetype;
/** The dbch_reserved. */
public int dbch_reserved;
/**
* Instantiates a new dev broadcast hdr.
*/
public DEV_BROADCAST_HDR() {
}
/**
* Instantiates a new dev broadcast hdr.
*
* @param pointer
* the pointer
*/
public DEV_BROADCAST_HDR(long pointer) {
this(new Pointer(pointer));
}
/**
* Instantiates a new dev broadcast hdr.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_HDR(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
"dbch_reserved" });
}
}
/** The dbt devtyp oem. */
int DBT_DEVTYP_OEM = 0x00000000;
/** The dbt devtyp devnode. */
int DBT_DEVTYP_DEVNODE = 0x00000001;
/** The dbt devtyp volume. */
int DBT_DEVTYP_VOLUME = 0x00000002;
/** The dbt devtyp port. */
int DBT_DEVTYP_PORT = 0x00000003;
/** The dbt devtyp net. */
int DBT_DEVTYP_NET = 0x00000004;
/** The dbt devtyp deviceinterface. */
int DBT_DEVTYP_DEVICEINTERFACE = 0x00000005;
/** The dbt devtyp handle. */
int DBT_DEVTYP_HANDLE = 0x00000006;
/**
* The Class DEV_BROADCAST_OEM.
*/
public class DEV_BROADCAST_OEM extends Structure {
/** The dbco_size. */
public int dbco_size = size();
/** The dbco_devicetype. */
public int dbco_devicetype;
/** The dbco_reserved. */
public int dbco_reserved;
/** The dbco_identifier. */
public int dbco_identifier;
/** The dbco_suppfunc. */
public int dbco_suppfunc;
/**
* Instantiates a new dev broadcast oem.
*/
public DEV_BROADCAST_OEM() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast oem.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_OEM(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbco_size", "dbco_devicetype",
"dbco_reserved", "dbco_identifier", "dbco_suppfunc" });
}
}
/**
* The Class DEV_BROADCAST_DEVNODE.
*/
public class DEV_BROADCAST_DEVNODE extends Structure {
/** The dbcd_size. */
public int dbcd_size = size();
/** The dbcd_devicetype. */
public int dbcd_devicetype;
/** The dbcd_reserved. */
public int dbcd_reserved;
/** The dbcd_devnode. */
public int dbcd_devnode;
/**
* Instantiates a new dev broadcast devnode.
*/
public DEV_BROADCAST_DEVNODE() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast devnode.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_DEVNODE(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcd_size", "dbcd_devicetype",
"dbcd_reserved", "dbcd_devnode" });
}
}
/**
* The Class DEV_BROADCAST_VOLUME.
*/
public class DEV_BROADCAST_VOLUME extends Structure {
/** The dbcv_size. */
public int dbcv_size = size();
/** The dbcv_devicetype. */
public int dbcv_devicetype;
/** The dbcv_reserved. */
public int dbcv_reserved;
/** The dbcv_unitmask. */
public int dbcv_unitmask;
/** The dbcv_flags. */
public short dbcv_flags;
/**
* Instantiates a new dev broadcast volume.
*/
public DEV_BROADCAST_VOLUME() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast volume.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_VOLUME(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcv_size", "dbcv_devicetype",
"dbcv_reserved", "dbcv_unitmask", "dbcv_flags" });
}
}
/**
* The Class DEV_BROADCAST_PORT.
*/
public class DEV_BROADCAST_PORT extends Structure {
/** The dbcp_size. */
public int dbcp_size = size();
/** The dbcp_devicetype. */
public int dbcp_devicetype;
/** The dbcp_reserved. */
public int dbcp_reserved;
/** The dbcp_name. */
public char[] dbcp_name = new char[1];
/**
* Instantiates a new dev broadcast port.
*/
public DEV_BROADCAST_PORT() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast port.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_PORT(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcp_size", "dbcp_devicetype",
"dbcp_reserved", "dbcp_name" });
}
}
/**
* The Class DEV_BROADCAST_NET.
*/
public class DEV_BROADCAST_NET extends Structure {
/** The dbcn_size. */
public int dbcn_size = size();
/** The dbcn_devicetype. */
public int dbcn_devicetype;
/** The dbcn_reserved. */
public int dbcn_reserved;
/** The dbcn_resource. */
public int dbcn_resource;
/** The dbcn_flags. */
public int dbcn_flags;
/**
* Instantiates a new dev broadcast net.
*/
public DEV_BROADCAST_NET() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast net.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_NET(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcn_size", "dbcn_devicetype",
"dbcn_reserved", "dbcn_resource", "dbcn_flags" });
}
}
/**
* The Class DEV_BROADCAST_DEVICEINTERFACE.
*/
public class DEV_BROADCAST_DEVICEINTERFACE extends Structure {
/** The dbcc_size. */
public int dbcc_size;
/** The dbcc_devicetype. */
public int dbcc_devicetype;
/** The dbcc_reserved. */
public int dbcc_reserved;
/** The dbcc_classguid. */
public GUID dbcc_classguid;
/** The dbcc_name. */
public char[] dbcc_name = new char[1];
/**
* Instantiates a new dev broadcast deviceinterface.
*/
public DEV_BROADCAST_DEVICEINTERFACE() {
// TODO Auto-generated constructor stub
}
/**
* Dev broadcast hdr.
*
* @param pointer
* the pointer
*/
public DEV_BROADCAST_DEVICEINTERFACE(long pointer) {
this(new Pointer(pointer));
}
/**
* Instantiates a new dev broadcast deviceinterface.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_DEVICEINTERFACE(Pointer memory) {
super(memory);
this.dbcc_size = (Integer) this.readField("dbcc_size");
// figure out how long dbcc_name should be based on the size
int len = 1 + this.dbcc_size - size();
this.dbcc_name = new char[len];
read();
}
/**
* Gets the dbcc_name.
*
* @return the dbcc_name
*/
public String getDbcc_name() {
return Native.toString(this.dbcc_name);
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbcc_size", "dbcc_devicetype",
"dbcc_reserved", "dbcc_classguid", "dbcc_name" });
}
}
/**
* The Class DEV_BROADCAST_HANDLE.
*/
public class DEV_BROADCAST_HANDLE extends Structure {
/** The dbch_size. */
public int dbch_size = size();
/** The dbch_devicetype. */
public int dbch_devicetype;
/** The dbch_reserved. */
public int dbch_reserved;
/** The dbch_handle. */
public HANDLE dbch_handle;
/** The dbch_hdevnotify. */
public HDEVNOTIFY dbch_hdevnotify;
/** The dbch_eventguid. */
public GUID dbch_eventguid;
/** The dbch_nameoffset. */
public LONG dbch_nameoffset;
/** The dbch_data. */
public byte[] dbch_data;
/**
* Instantiates a new dev broadcast handle.
*/
public DEV_BROADCAST_HANDLE() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new dev broadcast handle.
*
* @param memory
* the memory
*/
public DEV_BROADCAST_HANDLE(Pointer memory) {
super(memory);
read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dbch_size", "dbch_devicetype",
"dbch_reserved", "dbch_handle", "dbch_hdevnotify",
"dbch_eventguid", "dbch_nameoffset", "dbch_data" });
}
}
}
@@ -1,220 +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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from DsGetDC.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface DsGetDC extends StdCallLibrary {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
* function to receive data about a domain controller.
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference { }
public DOMAIN_CONTROLLER_INFO() { }
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated WString that specifies the computer name
* of the discovered domain controller. The returned computer name is
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
* is returned, if available. If the DNS-style name is not available, the
* flat-style name (for example, "\\phoenix") is returned. This example would apply
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
* IP family of protocols.
*/
public WString DomainControllerName;
/**
* Pointer to a null-terminated WString that specifies the address of the discovered
* domain controller. The address is prefixed with "\\". This WString is one of the
* types defined by the DomainControllerAddressType member.
*/
public WString DomainControllerAddress;
/**
* Indicates the type of WString that is contained in the DomainControllerAddress member.
*/
public int DomainControllerAddressType;
/**
* The GUID of the domain. This member is zero if the domain controller does not have
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
* controller.
*/
public GUID DomainGuid;
/**
* Pointer to a null-terminated WString that specifies the name of the domain. The
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
* the flat-style name, for example, "fabrikam", is returned. This name may be different
* than the requested domain name if the domain has been renamed.
*/
public WString DomainName;
/**
* Pointer to a null-terminated WString that specifies the name of the domain at the root
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
*/
public WString DnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int Flags;
/**
* Pointer to a null-terminated WString that specifies the name of the site where the
* domain controller is located. This member may be NULL if the domain controller is
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
* controller.
*/
public WString DcSiteName;
/**
* Pointer to a null-terminated WString that specifies the name of the site that the
* computer belongs to. The computer is specified in the ComputerName parameter passed
* to DsGetDcName. This member may be NULL if the site that contains the computer
* cannot be found; for example, if the DS administrator has not associated the
* subnet that the computer is in with a valid site.
*/
public WString ClientSiteName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "DomainControllerName", "DomainControllerAddress", "DomainControllerAddressType", "DomainGuid", "DomainName", "DnsForestName", "Flags", "DcSiteName", "ClientSiteName"});
}
}
/**
* Pointer to DOMAIN_CONTROLLER_INFO.
*/
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dci" });
}
}
/**
* Domain is a member of the forest.
*/
int DS_DOMAIN_IN_FOREST = 0x0001;
/**
* Domain is directly trusted.
*/
int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
/**
* Domain is root of a tree in the forest.
*/
int DS_DOMAIN_TREE_ROOT = 0x0004;
/**
* Domain is the primary domain of queried server.
*/
int DS_DOMAIN_PRIMARY = 0x0008;
/**
* Primary domain is running in native mode.
*/
int DS_DOMAIN_NATIVE_MODE = 0x0010;
/**
* Domain is directly trusting.
*/
int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
/**
* Valid domain flags.
*/
int DS_DOMAIN_VALID_FLAGS =
DS_DOMAIN_IN_FOREST |
DS_DOMAIN_DIRECT_OUTBOUND |
DS_DOMAIN_TREE_ROOT |
DS_DOMAIN_PRIMARY |
DS_DOMAIN_NATIVE_MODE |
DS_DOMAIN_DIRECT_INBOUND;
/**
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
* contain trust data for a domain.
*/
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
*/
public WString NetbiosDomainName;
/**
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
*/
public WString DnsDomainName;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public int Flags;
/**
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
* corresponds to the parent domain of the domain represented by this structure.
*/
public int ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public int TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public int TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID.ByReference DomainSid;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "NetbiosDomainName", "DnsDomainName", "Flags", "ParentIndex", "TrustType", "TrustAttributes", "DomainSid", "DomainGuid" });
}
public DS_DOMAIN_TRUSTS() {
}
public DS_DOMAIN_TRUSTS(Pointer p) {
super(p);
read();
}
};
}
@@ -1,316 +0,0 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.HBITMAP;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.WinDef.HRGN;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/** Definition (incomplete) of <code>gdi32.dll</code>. */
public interface GDI32 extends StdCallLibrary {
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
W32APIOptions.DEFAULT_OPTIONS);
/**
* The ExtCreateRegion function creates a region from the specified region and transformation data.
* @param lpXform
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
* the identity transformation is used.
* @param nCount
* Specifies the number of bytes pointed to by lpRgnData.
* @param lpRgnData
* Pointer to a RGNDATA structure that contains the region data in logical units.
* @return
* If the function succeeds, the return value is the value of the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
/**
* The CombineRgn function combines two regions and stores the result in a third region.
* The two regions are combined according to the specified mode.
* @param hrgnDest
* Handle to a new region with dimensions defined by combining two other regions.
* @param hrgnSrc1
* Handle to the first of two regions to be combined.
* @param hrgnSrc2
* Handle to the second of two regions to be combined.
* @param fnCombineMode
* Specifies a mode indicating how the two regions will be combined.
* @return
* The return value specifies the type of the resulting region.
*/
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
int fnCombineMode);
/**
* The CreateRectRgn function creates a rectangular region.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
* @param nWidthEllipse
* Specifies the width of the ellipse used to create the rounded corners in logical units.
* @param nHeightEllipse
* Specifies the height of the ellipse used to create the rounded corners in logical units.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
/**
* The CreatePolyPolygonRgn function creates a region consisting of a series
* of polygons. The polygons can overlap.
* @param lppt
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
* specified only once.
* @param lpPolyCounts
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
* in the array pointed to by lppt.
* @param nCount
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
* @param fnPolyFillMode
* Specifies the fill mode used to determine which pixels are in the region.
* @return
* If the function succeeds, the return value is the handle to the region.
* If the function fails, the return value is zero.
* To get extended error information, call GetLastError.
*/
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
int nCount, int fnPolyFillMode);
/**
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
* @param hrgn
* Handle to the region.
* @param nLeftRect
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
* @param nTopRect
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
* @param nRightRect
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
* @param nBottomRect
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero.
* To get extended error information, call GetLastError.
*/
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
/**
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
* @param hDC
* Handle to the device context.
* @param x
* Specifies the x-coordinate, in logical units, of the point to be set.
* @param y
* Specifies the y-coordinate, in logical units, of the point to be set.
* @param crColor
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
* @return
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
* This value may differ from the color specified by crColor; that occurs when an exact match for the
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
* information, call GetLastError. This can be the following value.
*/
int SetPixel(HDC hDC, int x, int y, int crColor);
/**
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
* @param hDC
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
* application's current screen.
* @return
* If the function succeeds, the return value is the handle to a memory DC.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HDC CreateCompatibleDC(HDC hDC);
/**
* The DeleteDC function deletes the specified device context (DC).
* @param hDC
* Handle to the device context.
* @return
* If the function succeeds, the return value is nonzero.
* If the function fails, the return value is zero.
* To get extended error information, call GetLastError.
*/
boolean DeleteDC(HDC hDC);
/**
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
* sets the bitmap bits.
* @param hDC
* Handle to a device context.
* @param lpbmih
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
* @param fdwInit
* Specifies how the system initializes the bitmap bits.
* @param lpbInit
* Pointer to an array of bytes containing the initial bitmap data.
* @param lpbmi
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
* the array pointed to by the lpbInit parameter.
* @param fuUsage
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
* fuUsage parameter must be one of the following values.
* @return
* If the function succeeds, the return value is a handle to the compatible bitmap.
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
/**
* The CreateDIBSection function creates a DIB that applications can write to directly.
* The function gives you a pointer to the location of the bitmap bit values. You can supply
* a handle to a file-mapping object that the function will use to create the bitmap, or you
* can let the system allocate the memory for the bitmap.
* @param hDC
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
* device context's logical palette to initialize the DIB colors.
* @param pbmi
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
* the bitmap dimensions and colors.
* @param iUsage
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
* pointed to by pbmi (either logical palette indexes or literal RGB values).
* @param ppvBits
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
* @param hSection
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
* @param dwOffset
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
* for the bitmap bit values is to begin.
* @return
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
* for the bitmap bit values is to begin.
*/
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
PointerByReference ppvBits, Pointer hSection, int dwOffset);
/**
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
* associated with the specified device context.
* @param hDC
* Handle to a device context.
* @param width
* Specifies the bitmap width, in pixels.
* @param height
* Specifies the bitmap height, in pixels.
* @return
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
* If the function fails, the return value is NULL.
* To get extended error information, call GetLastError.
*/
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
/**
* The SelectObject function selects an object into the specified device context (DC).
* The new object replaces the previous object of the same type.
* @param hDC
* Handle to the DC.
* @param hGDIObj
* Handle to the object to be selected.
* @return
* If the selected object is not a region and the function succeeds, the return value
* is a handle to the object being replaced. If the selected object is a region and the
* function succeeds, the return value is one of the REGION values.
*/
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
/**
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
* freeing all system resources associated with the object. After the object is deleted, the
* specified handle is no longer valid.
* @param hObject
* Handle to a logical pen, brush, font, bitmap, region, or palette.
* @return
* If the function succeeds, the return value is nonzero.
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
* To get extended error information, call GetLastError.
*/
boolean DeleteObject(HANDLE hObject);
/** The GetDeviceCaps function retrieves device-specific information for
* the specified device.
* @param hdc A handle to the DC.
* @param nIndex The item to be returned.
* @return
* The return value specifies the value of the desired item. When
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
* 16bpp, the return value is 16.
*/
int GetDeviceCaps(HDC hdc, int nIndex);
/** The GetDIBits function retrieves the bits fo the specified compatible
* bitmap and copies them into a buffer as a DIB using the specified
* format.
* @param hdc A handle to the device context.
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
* (DDB).
* @param uStartScan The first scan line to retrieve
* @param cScanLines The number of scan lines to retrieve.
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
* this parameter is <code>null</code>, the function passes the dimensions
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
* by the <i>lpbi</i> parameter.
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
* the desired format for the DIB data.
* @param uUsage The format of the bmiColors member of the {@link
* BITMAPINFO} structure.
*/
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
}
@@ -1,475 +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 java.security.SecureRandom;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
/**
* Ported from Guid.h. Microsoft Windows SDK 6.0A.
*
* @author dblock[at]dblock.org
*/
public interface Guid {
public final static IID IID_NULL = new IID();
/**
* The Class GUID.
*/
public static class GUID extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends GUID implements
Structure.ByReference {
/**
* Instantiates a new by reference.
*/
public ByReference() {
}
/**
* Instantiates a new by reference.
*
* @param guid
* the guid
*/
public ByReference(GUID guid) {
super(guid.getPointer());
Data1 = guid.Data1;
Data2 = guid.Data2;
Data3 = guid.Data3;
Data4 = guid.Data4;
}
/**
* Instantiates a new by reference.
*
* @param memory
* the memory
*/
public ByReference(Pointer memory) {
super(memory);
}
}
/** The Data1. */
public int Data1;
/** The Data2. */
public short Data2;
/** The Data3. */
public short Data3;
/** The Data4. */
public byte[] Data4 = new byte[8];
/**
* Instantiates a new guid.
*/
public GUID() {
}
/**
* Instantiates a new guid.
*
* @param guid
* the guid
*/
public GUID(GUID guid) {
this.Data1 = guid.Data1;
this.Data2 = guid.Data2;
this.Data3 = guid.Data3;
this.Data4 = guid.Data4;
this.writeFieldsToMemory();
}
/**
* Instantiates a new guid.
*
* @param guid
* the guid
*/
public GUID(String guid) {
this(fromString(guid));
}
/**
* Instantiates a new guid.
*
* @param data
* the data
*/
public GUID(byte[] data) {
this(fromBinary(data));
}
/**
* Instantiates a new guid.
*
* @param memory
* the memory
*/
public GUID(Pointer memory) {
super(memory);
read();
}
/**
* From binary.
*
* @param data
* the data
* @return the guid
*/
public static GUID fromBinary(byte[] data) {
if (data.length != 16) {
throw new IllegalArgumentException("Invalid data length: "
+ data.length);
}
GUID newGuid = new GUID();
long data1Temp = data[0] & 0xff;
data1Temp <<= 8;
data1Temp |= data[1] & 0xff;
data1Temp <<= 8;
data1Temp |= data[2] & 0xff;
data1Temp <<= 8;
data1Temp |= data[3] & 0xff;
newGuid.Data1 = (int) data1Temp;
int data2Temp = data[4] & 0xff;
data2Temp <<= 8;
data2Temp |= data[5] & 0xff;
newGuid.Data2 = (short) data2Temp;
int data3Temp = data[6] & 0xff;
data3Temp <<= 8;
data3Temp |= data[7] & 0xff;
newGuid.Data3 = (short) data3Temp;
newGuid.Data4[0] = data[8];
newGuid.Data4[1] = data[9];
newGuid.Data4[2] = data[10];
newGuid.Data4[3] = data[11];
newGuid.Data4[4] = data[12];
newGuid.Data4[5] = data[13];
newGuid.Data4[6] = data[14];
newGuid.Data4[7] = data[15];
newGuid.writeFieldsToMemory();
return newGuid;
}
/**
* From string.
*
* @param guid
* the guid
* @return the guid
*/
public static GUID fromString(String guid) {
int y = 0;
char[] _cnewguid = new char[32];
char[] _cguid = guid.toCharArray();
byte[] bdata = new byte[16];
GUID newGuid = new GUID();
// we not accept a string longer than 38 chars
if (guid.length() > 38) {
throw new IllegalArgumentException("Invalid guid length: "
+ guid.length());
}
// remove '{', '}' and '-' from guid string
for (int i = 0; i < _cguid.length; i++) {
if ((_cguid[i] != '{') && (_cguid[i] != '-')
&& (_cguid[i] != '}'))
_cnewguid[y++] = _cguid[i];
}
// convert char to byte
for (int i = 0; i < 32; i += 2) {
bdata[i / 2] = (byte) ((Character.digit(_cnewguid[i], 16) << 4)
+ Character.digit(_cnewguid[i + 1], 16) & 0xff);
}
if (bdata.length != 16) {
throw new IllegalArgumentException("Invalid data length: "
+ bdata.length);
}
long data1Temp = bdata[0] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[1] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[2] & 0xff;
data1Temp <<= 8;
data1Temp |= bdata[3] & 0xff;
newGuid.Data1 = (int) data1Temp;
int data2Temp = bdata[4] & 0xff;
data2Temp <<= 8;
data2Temp |= bdata[5] & 0xff;
newGuid.Data2 = (short) data2Temp;
int data3Temp = bdata[6] & 0xff;
data3Temp <<= 8;
data3Temp |= bdata[7] & 0xff;
newGuid.Data3 = (short) data3Temp;
newGuid.Data4[0] = bdata[8];
newGuid.Data4[1] = bdata[9];
newGuid.Data4[2] = bdata[10];
newGuid.Data4[3] = bdata[11];
newGuid.Data4[4] = bdata[12];
newGuid.Data4[5] = bdata[13];
newGuid.Data4[6] = bdata[14];
newGuid.Data4[7] = bdata[15];
newGuid.writeFieldsToMemory();
return newGuid;
}
/**
* Generates a new guid. Code taken from the standard jdk
* implementation (see UUID class).
*
* @return the guid
*/
public static GUID newGuid() {
SecureRandom ng = new SecureRandom();
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f;
randomBytes[6] |= 0x40;
randomBytes[8] &= 0x3f;
randomBytes[8] |= 0x80;
return new GUID(randomBytes);
}
/**
* To byte array.
*
* @return the byte[]
*/
public byte[] toByteArray() {
byte[] guid = new byte[16];
byte[] bytes1 = new byte[4];
bytes1[0] = (byte) (Data1 >> 24);
bytes1[1] = (byte) (Data1 >> 16);
bytes1[2] = (byte) (Data1 >> 8);
bytes1[3] = (byte) (Data1 >> 0);
byte[] bytes2 = new byte[4];
bytes2[0] = (byte) (Data2 >> 24);
bytes2[1] = (byte) (Data2 >> 16);
bytes2[2] = (byte) (Data2 >> 8);
bytes2[3] = (byte) (Data2 >> 0);
byte[] bytes3 = new byte[4];
bytes3[0] = (byte) (Data3 >> 24);
bytes3[1] = (byte) (Data3 >> 16);
bytes3[2] = (byte) (Data3 >> 8);
bytes3[3] = (byte) (Data3 >> 0);
System.arraycopy(bytes1, 0, guid, 0, 4);
System.arraycopy(bytes2, 2, guid, 4, 2);
System.arraycopy(bytes3, 2, guid, 6, 2);
System.arraycopy(Data4, 0, guid, 8, 8);
return guid;
}
/**
* The value of this Guid, formatted as follows:
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
*
* @return the string
*/
public String toGuidString() {
final String HEXES = "0123456789ABCDEF";
byte[] bGuid = toByteArray();
final StringBuilder hexStr = new StringBuilder(2 * bGuid.length);
hexStr.append("{");
for (int i = 0; i < bGuid.length; i++) {
char ch1 = HEXES.charAt((bGuid[i] & 0xF0) >> 4);
char ch2 = HEXES.charAt(bGuid[i] & 0x0F);
hexStr.append(ch1).append(ch2);
if ((i == 3) || (i == 5) || (i == 7) || (i == 9))
hexStr.append("-");
}
hexStr.append("}");
return hexStr.toString();
}
/**
* Write fields to backing memory.
*/
protected void writeFieldsToMemory() {
this.writeField("Data1");
this.writeField("Data2");
this.writeField("Data3");
this.writeField("Data4");
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Data1", "Data2", "Data3",
"Data4" });
}
}
/**
* The Class CLSID.
*/
public static class CLSID extends GUID {
/**
* The Class ByReference.
*/
public static class ByReference extends GUID {
/**
* Instantiates a new by reference.
*/
public ByReference() {
}
/**
* Instantiates a new by reference.
*
* @param guid
* the guid
*/
public ByReference(GUID guid) {
super(guid);
}
/**
* Instantiates a new by reference.
*
* @param memory
* the memory
*/
public ByReference(Pointer memory) {
}
}
/**
* Instantiates a new clsid.
*/
public CLSID() {
}
}
/**
* The Class REFIID.
*/
public class REFIID extends IID {
/**
* Instantiates a new refiid.
*/
public REFIID() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new refiid.
*
* @param memory
* the memory
*/
public REFIID(Pointer memory) {
super(memory);
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new refiid.
*
* @param data
* the data
*/
public REFIID(byte[] data) {
super(data);
// TODO Auto-generated constructor stub
}
}
/**
* The Class IID.
*/
public class IID extends GUID {
/**
* Instantiates a new iid.
*/
public IID() {
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new iid.
*
* @param memory
* the memory
*/
public IID(Pointer memory) {
super(memory);
// TODO Auto-generated constructor stub
}
public IID(String iid) {
super(iid);
// TODO Auto-generated constructor stub
}
/**
* Instantiates a new iid.
*
* @param data
* the data
*/
public IID(byte[] data) {
super(data);
// TODO Auto-generated constructor stub
}
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,338 +0,0 @@
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.LastErrorException;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
/**
* Kernel32 utility API.
* @author dblock[at]dblock.org
* @author markus[at]headcrashing[dot]eu
*/
public abstract class Kernel32Util implements WinDef {
/**
* Get current computer NetBIOS name.
* @return
* Netbios name.
*/
public static String getComputerName() {
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH + 1];
IntByReference lpnSize = new IntByReference(buffer.length);
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Format a message from the value obtained from {@link
* Kernel32#GetLastError} or {@link Native#getLastError}.
* @param code
* int
* @return
* Formatted message.
*/
public static String formatMessage(int code) {
PointerByReference buffer = new PointerByReference();
if (0 == Kernel32.INSTANCE.FormatMessage(
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
null,
code,
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
buffer,
0,
null)) {
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
}
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
Kernel32.INSTANCE.LocalFree(buffer.getValue());
return s.trim();
}
/**
* Format a message from an HRESULT.
* @param code
* HRESULT
* @return
* Formatted message.
*/
public static String formatMessage(HRESULT code) {
return formatMessage(code.intValue());
}
/** @deprecated use {@link #formatMessage(WinNT.HRESULT)} instead. */
public static String formatMessageFromHR(HRESULT code) {
return formatMessage(code.intValue());
}
/**
* Format a system message from an error code.
* @param code
* Error code, typically a result of GetLastError.
* @return
* Formatted message.
*/
public static String formatMessageFromLastErrorCode(int code) {
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
}
/**
* Return the path designated for temporary files.
* @return
* Path.
*/
public static String getTempPath() {
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
char[] buffer = new char[nBufferLength.intValue()];
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
public static void deleteFile(String filename) {
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
/**
* Returns valid drives in the system.
* @return
* An array of valid drives.
*/
public static String[] getLogicalDriveStrings() {
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
char buf[] = new char[dwSize.intValue()];
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
if (dwSize.intValue() <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
List<String> drives = new ArrayList<String>();
String drive = "";
// the buffer is double-null-terminated
for(int i = 0; i < buf.length - 1; i++) {
if (buf[i] == 0) {
drives.add(drive);
drive = "";
} else {
drive += buf[i];
}
}
return drives.toArray(new String[0]);
}
/**
* Retrieves file system attributes for a specified file or directory.
* @param fileName
* The name of the file or directory.
* @return
* The attributes of the specified file or directory.
*/
public static int getFileAttributes(String fileName) {
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return fileAttributes;
}
/**
* Retrieves the result of GetFileType, provided the file exists.
*/
public static int getFileType(String fileName) throws FileNotFoundException {
File f = new File(fileName);
if (!f.exists()) {
throw new FileNotFoundException(fileName);
}
HANDLE hFile = null;
try {
hFile = Kernel32.INSTANCE.CreateFile(fileName,
WinNT.GENERIC_READ,
WinNT.FILE_SHARE_READ,
new WinBase.SECURITY_ATTRIBUTES(),
WinNT.OPEN_EXISTING,
WinNT.FILE_ATTRIBUTE_NORMAL,
new HANDLEByReference().getValue());
if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
int type = Kernel32.INSTANCE.GetFileType(hFile);
switch(type) {
case WinNT.FILE_TYPE_UNKNOWN:
int err = Kernel32.INSTANCE.GetLastError();
switch(err) {
case WinError.NO_ERROR:
break;
default:
throw new Win32Exception(err);
}
// fall-thru
default:
return type;
}
} finally {
if (hFile != null) {
if (! Kernel32.INSTANCE.CloseHandle(hFile)) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
}
/**
* @return One of the WinBase.DRIVE_* constants.
*/
public static int getDriveType(String rootName) {
return Kernel32.INSTANCE.GetDriveType(rootName);
}
/**
* Get the value of an environment variable.
* @param name
* Name of the environment variable.
* @return
* Value of an environment variable.
*/
public static String getEnvironmentVariable(String name) {
// obtain the buffer size
int size = Kernel32.INSTANCE.GetEnvironmentVariable(name, null, 0);
if (size == 0) {
return null;
} else if (size < 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
// obtain the value
char[] buffer = new char[size];
size = Kernel32.INSTANCE.GetEnvironmentVariable(name, buffer, buffer.length);
if (size <= 0) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
return Native.toString(buffer);
}
/**
* Retrieves an integer associated with a key in the specified section of an initialization file.
*
* @param appName
* The name of the section in the initialization file.
* @param keyName
* The name of the key whose value is to be retrieved. This value is in the form of a string; the {@link Kernel32#GetPrivateProfileInt} function converts
* the string into an integer and returns the integer.
* @param defaultValue
* The default value to return if the key name cannot be found in the initialization file.
* @param fileName
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
* Windows directory.
* @return The retrieved integer, or the default if not found.
*/
public static final int getPrivateProfileInt(final String appName, final String keyName, final int defaultValue, final String fileName) {
return Kernel32.INSTANCE.GetPrivateProfileInt(appName, keyName, defaultValue, fileName);
}
/**
* Retrieves a string from the specified section in an initialization file.
*
* @param lpAppName
* The name of the section containing the key name. If this parameter is {@code null}, the {@link Kernel32#GetPrivateProfileString} function copies all
* section names in the file to the supplied buffer.
* @param lpKeyName
* The name of the key whose associated string is to be retrieved. If this parameter is {@code null}, all key names in the section specified by
* the {@code lpAppName} parameter are returned.
* @param lpDefault
* A default string. If the {@code lpKeyName} key cannot be found in the initialization file, {@link Kernel32#GetPrivateProfileString} returns the
* default. If this parameter is {@code null}, the default is an empty string, {@code ""}.
* <p>
* Avoid specifying a default string with trailing blank characters. The function inserts a {@code null} character in the
* {@code lpReturnedString} buffer to strip any trailing blanks.
* </p>
* @param lpFileName
* The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the
* Windows directory.
* @return <p>
* If neither {@code lpAppName} nor {@code lpKeyName} is {@code null} and the destination buffer is too small to hold the requested string, the
* string is truncated.
* </p>
* <p>
* If either {@code lpAppName} or {@code lpKeyName} is {@code null} and the destination buffer is too small to hold all the strings, the last string
* is truncated and followed by two {@code null} characters.
* </p>
* <p>
* In the event the initialization file specified by {@code lpFileName} is not found, or contains invalid values, this function will set errorno
* with a value of '0x2' (File Not Found). To retrieve extended error information, call {@link Kernel32#GetLastError}.
* </p>
*/
public static final String getPrivateProfileString(final String lpAppName, final String lpKeyName, final String lpDefault, final String lpFileName) {
final char buffer[] = new char[1024];
Kernel32.INSTANCE.GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buffer, new DWORD(buffer.length), lpFileName);
return Native.toString(buffer);
}
public static final void writePrivateProfileString(final String appName, final String keyName, final String string, final String fileName) {
if (!Kernel32.INSTANCE.WritePrivateProfileString(appName, keyName, string, fileName))
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
/**
* Convenience method to get the processor information. Takes care of auto-growing the array.
*
* @return the array of processor information.
*/
public static final WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] getLogicalProcessorInformation()
{
int sizePerStruct = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION().size();
WinDef.DWORDByReference bufferSize = new WinDef.DWORDByReference(new WinDef.DWORD(sizePerStruct));
Memory memory;
while (true)
{
memory = new Memory(bufferSize.getValue().intValue());
if (! Kernel32.INSTANCE.GetLogicalProcessorInformation(memory, bufferSize))
{
int err = Kernel32.INSTANCE.GetLastError();
if (err != WinError.ERROR_INSUFFICIENT_BUFFER)
throw new Win32Exception(err);
}
else
{
break;
}
}
WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION firstInformation = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION(memory);
int returnedStructCount = bufferSize.getValue().intValue() / sizePerStruct;
return (WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]) firstInformation.toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[returnedStructCount]);
}
}
@@ -1,426 +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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMAccess.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMAccess extends StdCallLibrary {
public static class LOCALGROUP_INFO_0 extends Structure {
public LOCALGROUP_INFO_0() {
super();
}
public LOCALGROUP_INFO_0(Pointer memory) {
super(memory);
read();
}
public WString lgrui0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lgrui0_name" });
}
}
public static class LOCALGROUP_INFO_1 extends Structure {
public LOCALGROUP_INFO_1() {
super();
}
public LOCALGROUP_INFO_1(Pointer memory) {
super(memory);
read();
}
public WString lgrui1_name;
public WString lgrui1_comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "lgrui1_name", "lgrui1_comment" });
}
}
//
// bit masks for the NetUserEnum filter parameter.
//
int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
int FILTER_NORMAL_ACCOUNT = 0x0002;
// int FILTER_PROXY_ACCOUNT = 0x0004;
int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
/**
* The USER_INFO_0 structure contains a user account name.
*/
public static class USER_INFO_0 extends Structure {
public USER_INFO_0() {
super();
}
public USER_INFO_0(Pointer memory) {
super(memory);
read();
}
/**
* 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" });
}
}
/**
* The USER_INFO_1 structure contains information about a user account, including
* account name, password data, privilege level, and the path to the user's home
* directory.
*/
public static class USER_INFO_1 extends Structure {
public USER_INFO_1() {
super();
}
public USER_INFO_1(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a Unicode string that specifies the name of the user
* account.
*/
public WString usri1_name;
/**
* Pointer to a Unicode string that specifies the password of the user
* indicated by the usri1_name member.
*/
public WString usri1_password;
/**
* Specifies a DWORD value that indicates the number of seconds that have
* elapsed since the usri1_password member was last changed.
*/
public int usri1_password_age;
/**
* Specifies a DWORD value that indicates the level of privilege assigned
* to the usri1_name member.
*/
public int usri1_priv;
/**
* Pointer to a Unicode string specifying the path of the home directory
* for the user specified in the usri1_name member.
*/
public WString usri1_home_dir;
/**
* Pointer to a Unicode string that contains a comment to associate with
* the user account.
*/
public WString usri1_comment;
/**
* Specifies a DWORD value that determines several features.
*/
public int usri1_flags;
/**
* Pointer to a Unicode string specifying the path for the user's
* logon script file.
*/
public WString usri1_script_path;
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" });
}
}
/**
* The USER_INFO_23 structure contains information about a user account,
* including the account name, the user's full name, a comment associated with the account,
* and the user's security identifier (SID).
*
* Note :
* The USER_INFO_23 structure supersedes the USER_INFO_20 structure.
* It is recommended that applications use the USER_INFO_23 structure instead of the USER_INFO_20 structure.
*/
public static class USER_INFO_23 extends Structure {
public USER_INFO_23() {
super();
}
public USER_INFO_23(Pointer memory) {
useMemory(memory);
read();
}
/**
* A pointer to a Unicode string that specifies the name of the user account.
* Calls to the NetUserSetInfo function ignore this member.
*/
public WString usri23_name;
/**
* A pointer to a Unicode string that contains the full name of the user.
* This string can be a null string, or it can have any number of characters before the terminating null character.
*/
public WString usri23_full_name;
/**
* A pointer to a Unicode string that contains a comment associated with the user account.
* This string can be a null string, or it can have any number of characters before the terminating null character.
*/
public WString usri23_comment;
/**
* This member can be one or more of the following values.
* Note that setting user account control flags may require certain privileges and control access rights.
* For more information, see the Remarks section of the NetUserSetInfo function.
* Value Meaning
* UF_SCRIPT The logon script executed. This value must be set.
* UF_ACCOUNTDISABLE The user's account is disabled.
* UF_HOMEDIR_REQUIRED The home directory is required. This value is ignored.
* UF_PASSWD_NOTREQD No password is required.
* UF_PASSWD_CANT_CHANGE The user cannot change the password.
* UF_LOCKOUT The account is currently locked out. You can call the NetUserSetInfo function to clear this value and unlock a previously locked account. You cannot use this value to lock a previously unlocked account.
* UF_DONT_EXPIRE_PASSWD The password should never expire on the account.
* UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED The user's password is stored under reversible encryption in the Active Directory.
* UF_NOT_DELEGATED Marks the account as "sensitive"; other users cannot act as delegates of this user account.
* UF_SMARTCARD_REQUIRED Requires the user to log on to the user account with a smart card.
* UF_USE_DES_KEY_ONLY Restrict this principal to use only Data Encryption Standard (DES) encryption types for keys.
* UF_DONT_REQUIRE_PREAUTH This account does not require Kerberos preauthentication for logon.
* UF_TRUSTED_FOR_DELEGATION The account is enabled for delegation. This is a security-sensitive setting; accounts with this option enabled should be tightly controlled. This setting allows a service running under the account to assume a client's identity and authenticate as that user to other remote servers on the network.
* UF_PASSWORD_EXPIRED The user's password has expired. Windows 2000: This value is not supported.
* UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION The account is trusted to authenticate a user outside of the Kerberos security package and delegate that user through constrained delegation. This is a security-sensitive setting; accounts with this option enabled should be tightly controlled. This setting allows a service running under the account to assert a client's identity and authenticate as that user to specifically configured services on the network. Windows XP/2000: This value is not supported.
*
* The following values describe the account type. Only one value can be set. You cannot change the account type using the NetUserSetInfo function.
* Value Meaning
* UF_NORMAL_ACCOUNT This is a default account type that represents a typical user.
* UF_TEMP_DUPLICATE_ACCOUNT This is an account for users whose primary account is in another domain. This account provides user access to this domain, but not to any domain that trusts this domain. The User Manager refers to this account type as a local user account.
* UF_WORKSTATION_TRUST_ACCOUNT This is a computer account for a computer that is a member of this domain.
* UF_SERVER_TRUST_ACCOUNT This is a computer account for a backup domain controller that is a member of this domain.
* UF_INTERDOMAIN_TRUST_ACCOUNT This is a permit to trust account for a domain that trusts other domains.
*/
public int usri23_flags;
/**
* 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;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "usri23_name", "usri23_full_name", "usri23_comment", "usri23_flags", "usri23_user_sid" });
}
}
/**
* The GROUP_USERS_INFO_0 structure contains global group member information.
*/
public static class GROUP_USERS_INFO_0 extends Structure {
public GROUP_USERS_INFO_0() {
super();
}
public GROUP_USERS_INFO_0(Pointer memory) {
super(memory);
read();
}
/**
* 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" });
}
}
/**
* The LOCALGROUP_USERS_INFO_0 structure contains local group member information.
*/
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
public LOCALGROUP_USERS_INFO_0() {
super();
}
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
super(memory);
read();
}
/**
* 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" });
}
}
/**
* The GROUP_INFO_0 structure contains the name of a global group in the security
* database, which is the security accounts manager (SAM) database or, in the case
* of domain controllers, the Active Directory.
*/
public static class GROUP_INFO_0 extends Structure {
public GROUP_INFO_0() {
super();
}
public GROUP_INFO_0(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that specifies
* the name of the global group.
*/
public WString grpi0_name;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi0_name" });
}
}
/**
* The GROUP_INFO_1 structure contains a global group name and a comment to
* associate with the group.
*/
public static class GROUP_INFO_1 extends Structure {
public GROUP_INFO_1() {
super();
}
public GROUP_INFO_1(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that specifies
* the name of the global group.
*/
public WString grpi1_name;
/**
* Pointer to a null-terminated Unicode character string that specifies
* a remark associated with the global group. This member can be a null
* string. The comment can contain MAXCOMMENTSZ characters.
*/
public WString grpi1_comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi1_name", "grpi1_comment" });
}
}
/**
* The GROUP_INFO_2 structure contains information about a global group, including
* name, identifier, and resource attributes.
*/
public static class GROUP_INFO_2 extends Structure {
public GROUP_INFO_2() {
super();
}
public GROUP_INFO_2(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that
* specifies the name of the global group.
*/
public WString grpi2_name;
/**
* Pointer to a null-terminated Unicode character string that contains a
* remark associated with the global group. This member can be a null string.
* The comment can contain MAXCOMMENTSZ characters.
*/
public WString grpi2_comment;
/**
* Specifies a DWORD value that contains the relative identifier (RID) of
* the global group.
*/
public int grpi2_group_id;
/**
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED,
* and SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi2_attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi2_name", "grpi2_comment", "grpi2_group_id", "grpi2_attributes" });
}
}
/**
* The GROUP_INFO_3 structure contains information about a global group, including
* name, security identifier (SID), and resource attributes.
*/
public static class GROUP_INFO_3 extends Structure {
public GROUP_INFO_3() {
super();
}
public GROUP_INFO_3(Pointer memory) {
super(memory);
read();
}
/**
* Pointer to a null-terminated Unicode character string that
* specifies the name of the global group.
*/
public WString grpi3_name;
/**
* Pointer to a null-terminated Unicode character string that
* contains a remark associated with the global group. This member can be
* a null string. The comment can contain MAXCOMMENTSZ characters.
*/
public WString grpi3_comment;
/**
* Pointer to a SID structure that contains the security identifier (SID) that
* uniquely identifies the global group.
*/
public PSID.ByReference grpi3_group_sid;
/**
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and
* SE_GROUP_ENABLED_BY_DEFAULT.
*/
public int grpi3_attributes;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "grpi3_name", "grpi3_comment", "grpi3_group_sid", "grpi3_attributes" });
}
}
//
// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
//
int USER_PRIV_MASK = 3;
int USER_PRIV_GUEST = 0;
int USER_PRIV_USER = 1;
int USER_PRIV_ADMIN = 2;
}
@@ -1,30 +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 com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMCons.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMCons extends StdCallLibrary {
int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
/**
* Value to be used with APIs which have a "preferred maximum length" parameter.
* This value indicates that the API should just allocate "as much as it takes."
*/
int MAX_PREFERRED_LENGTH = -1;
}
@@ -1,567 +0,0 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMErr.h.
* @author dblock[at]dblock.org
* Windows SDK 6.0A
*/
public interface LMErr extends StdCallLibrary {
int NERR_Success = 0;
int NERR_BASE = 2100;
int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */
int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */
int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */
int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */
int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */
int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */
/* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
/* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
/* UNUSED BASE + 10 */
/* UNUSED BASE + 11 */
/* UNUSED BASE + 12 */
/* UNUSED BASE + 13 */
int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */
int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */
int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */
int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */
int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */
int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */
/* UNUSED BASE + 20 */
int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */
int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */
int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */
/* UNUSED BASE + 24 */
/* UNUSED BASE + 25 */
/* UNUSED BASE + 26 */
int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */
/* UNUSED BASE + 28 */
/* UNUSED BASE + 29 */
/* UNUSED BASE + 30 */
int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */
/* UNUSED BASE + 32 */
/* UNUSED BASE + 33 */
/* UNUSED BASE + 34 */
/* UNUSED BASE + 35 */
int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */
int NERR_WkstaInconsistentState = NERR_BASE + 37;
/* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */
int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */
int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */
int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/
int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */
int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */
int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */
int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */
/*
* Config API related
* Error codes from BASE + 45 to BASE + 49
*/
/* UNUSED BASE + 45 */
int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */
int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */
int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */
/*
* Spooler API related
* Error codes from BASE + 50 to BASE + 79
*/
int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */
int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */
int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */
int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */
int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */
int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */
int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */
int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */
int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */
int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */
int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */
int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */
int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */
int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */
int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */
int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */
int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */
int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */
int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */
/*
* Service API related
* Error codes from BASE + 80 to BASE + 99
*/
int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */
int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */
int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */
int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */
int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */
int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */
int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */
int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */
int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */
int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */
int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */
int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */
int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */
int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */
int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */
/*
* Wksta and Logon API related
* Error codes from BASE + 100 to BASE + 118
*/
int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */
int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */
int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */
int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */
int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */
int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */
int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */
int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */
/* UNUSED BASE + 108 */
int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */
int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */
int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */
int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */
/* UNUSED BASE + 113 */
int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */
int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */
int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */
int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */
/*
* ACF API related = access, user, group;
* Error codes from BASE + 119 to BASE + 149
*/
int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */
int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */
int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */
int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */
int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */
int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */
int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */
int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */
int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */
int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */
int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/
int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */
int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */
int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */
int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */
int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */
int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */
int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */
int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */
int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */
int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */
int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */
int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */
int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */
int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */
int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */
int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */
int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */
int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */
int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */
int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */
/*
* Use API related
* Error codes from BASE + 150 to BASE + 169
*/
int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */
int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */
int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */
int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */
/*
* Message Server related
* Error codes BASE + 170 to BASE + 209
*/
int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */
int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */
int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */
int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */
int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */
int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */
int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */
int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */
int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/
int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */
int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */
int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */
int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */
int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */
int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */
int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */
int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */
int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */
int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */
int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */
int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */
int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */
/* UNUSED BASE + 196 */
int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */
int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */
int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */
int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */
/*
* Server API related
* Error codes BASE + 210 to BASE + 229
*/
int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/
int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */
int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */
int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */
int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */
int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */
int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */
int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */
int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */
int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */
int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */
/*
* CharDev API related
* Error codes BASE + 230 to BASE + 249
*/
/* UNUSED BASE + 230 */
int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */
int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */
int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */
int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */
int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */
int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */
int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */
int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */
int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */
int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */
int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */
/*
* NetICanonicalize and NetIType and NetIMakeLMFileName
* NetIListCanon and NetINameCheck
* Error codes BASE + 250 to BASE + 269
*/
int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */
/* UNUSED BASE + 252 */
/* UNUSED BASE + 253 */
int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */
/* UNUSED BASE + 255 */
int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */
int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */
/* UNUSED BASE + 258 */
/* UNUSED BASE + 259 */
int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */
/*
* NetProfile
* Error codes BASE + 270 to BASE + 276
*/
int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */
int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */
int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */
int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/
int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */
int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */
/*
* NetAudit and NetErrorLog
* Error codes BASE + 277 to BASE + 279
*/
int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */
int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */
int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */
/*
* NetRemote
* Error codes BASE + 280 to BASE + 299
*/
int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */
int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */
int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */
int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */
/* UNUSED BASE + 284 */
int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */
/* UNUSED BASE + 286 */
/* UNUSED BASE + 287 */
/* UNUSED BASE + 288 */
int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */
/* UNUSED BASE + 290 */
int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */
int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/
/* UNUSED BASE + 293 */
/* UNUSED BASE + 294 */
/*
* NetWksta.sys = redir; returned error codes.
*
* NERR_BASE + = 300-329;
*/
int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */
int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */
int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */
int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */
int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */
int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */
/*
* Alert error codes.
*
* NERR_BASE + = 330-339;
*/
int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */
int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */
int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */
int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/
int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted
* because the user's logon hours are no longer valid. */
/*
* Additional Error and Audit log codes.
*
* NERR_BASE + (340-343;
*/
int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */
/* UNUSED BASE + 341 */
/* UNUSED BASE + 342 */
/* UNUSED BASE + 343 */
/*
* Additional UAS and NETLOGON codes
*
* NERR_BASE + (350-359;
*/
int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */
int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */
int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */
int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */
int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */
int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */
int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */
int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */
int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */
/*
* Server Integration error codes.
*
* NERR_BASE + (360-369;
*/
int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */
int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */
int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */
int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */
int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */
int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */
int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */
int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */
/* UNUSED BASE + 368 */
/* UNUSED BASE + 369 */
int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */
/*
* UPS error codes.
*
* NERR_BASE + = 380-384;
*/
int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */
int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */
int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */
int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */
int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */
/*
* Remoteboot error codes.
*
* NERR_BASE + = 400-419;
* Error codes 400 - 405 are used by RPLBOOT.SYS.
* Error codes 403, 407 - 416 are used by RPLLOADR.COM,
* Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;.
* Error code 418 is for when REMOTEBOOT can't start
* Error code 419 is for a disallowed 2nd rpl connection
*
*/
int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/
int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/
int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/
int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/
int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/
int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/
int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/
int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/
int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/
int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/
int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/
int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/
int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/
int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/
int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/
int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/
int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/
int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/
int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/
int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/
/*
* FTADMIN API error codes
*
* NERR_BASE + = 425-434;
*
* = Currently not used in NT;
*
*/
/*
* Browser service API error codes
*
* NERR_BASE + = 450-475;
*
*/
int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */
/*
* Additional Remoteboot error codes.
*
* NERR_BASE + = 510-550;
*/
int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/
int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/
int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/
int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/
int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/
int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/
int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/
int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/
int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/
int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/
int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/
int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/
int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/
int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/
int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/
int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/
int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/
int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/
int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/
int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/
int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/
int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/
int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/
int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/
int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/
int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/
int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/
int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/
int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/
int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/
int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/
int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/
/**INTERNAL_ONLY**/
/*
* Dfs API error codes.
*
* NERR_BASE + = 560-590;
*/
int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/
int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/
int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/
int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/
int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/
int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/
int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/
int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/
int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/
int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/
int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/
int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/
int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/
int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/
int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/
int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/
int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/
int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/
int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/
int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/
int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/
int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/
int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/
int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/
int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/
/*
* Net setup error codes.
*
* NERR_BASE + = 591-600;
*/
int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/
int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/
int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/
int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/
int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/
int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/
int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/
int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/
int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/
/*
* Some Password and account error results
*
* NERR_BASE + = 601 - 608;
*/
int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */
int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */
int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */
int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */
int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */
/***********WARNING ****************
*The range 2750-2799 has been *
*allocated to the IBM LAN Server *
***********************************/
/***********WARNING ****************
*The range 2900-2999 has been *
*reserved for Microsoft OEMs *
***********************************/
int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */
}
@@ -1,34 +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 com.sun.jna.win32.StdCallLibrary;
/**
* Ported from LMJoin.h.
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface LMJoin extends StdCallLibrary {
/**
* Status of a workstation.
*/
public abstract class NETSETUP_JOIN_STATUS {
public static final int NetSetupUnknownStatus = 0;
public static final int NetSetupUnjoined = 1;
public static final int NetSetupWorkgroupName = 2;
public static final int NetSetupDomainName = 3;
};
}
@@ -1,210 +0,0 @@
/* 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.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Provides access to the w32 MSI installer library.
*/
public interface Msi extends StdCallLibrary {
Msi INSTANCE = (Msi)
Native.loadLibrary("msi", Msi.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The component being requested is disabled on the computer.
*/
static int INSTALLSTATE_NOTUSED = -7;
/**
* The configuration data is corrupt.
*/
static int INSTALLSTATE_BADCONFIG = -6;
/**
* The installation is suspended or in progress.
*/
static int INSTALLSTATE_INCOMPLETE = -5;
/**
* The feature must run from the source, and the source is unavailable.
*/
static int INSTALLSTATE_SOURCEABSENT = -4;
/**
* The return buffer is full.
*/
static int INSTALLSTATE_MOREDATA = -3;
/**
* An invalid parameter was passed to the function.
*/
static int INSTALLSTATE_INVALIDARG = -2;
/**
* An unrecognized product or feature was specified.
*/
static int INSTALLSTATE_UNKNOWN = -1;
/**
* The feature is broken.
*/
static int INSTALLSTATE_BROKEN = 0;
/**
* The advertised feature.
*/
static int INSTALLSTATE_ADVERTISED = 1;
/**
* The component is being removed.
*/
static int INSTALLSTATE_REMOVED = 1;
/**
* The feature was uninstalled.
*/
static int INSTALLSTATE_ABSENT = 2;
/**
* The feature was installed on the local drive.
*/
static int INSTALLSTATE_LOCAL = 3;
/**
* The feature must run from the source, CD-ROM, or network.
*/
static int INSTALLSTATE_SOURCE = 4;
/**
* The feature is installed in the default location: local or source.
*/
static int INSTALLSTATE_DEFAULT = 5;
/**
* The MsiGetComponentPath function returns the full path to an installed component. If the key path for the
* component is a registry key then the registry key is returned.
*
* @param szProduct
* Specifies the product code for the client product.
*
* @param szComponent
* Specifies the component ID of the component to be located.
*
* @param lpPathBuf
* Pointer to a variable that receives the path to the component. This parameter can be null. If the component is
* a registry key, the registry roots are represented numerically. If this is a registry subkey path, there is a
* backslash at the end of the Key Path. If this is a registry value key path, there is no backslash at the end.
* For example, a registry path on a 32-bit operating system of HKEY_CURRENT_USER\SOFTWARE\Microsoft is returned
* as "01:\SOFTWARE\Microsoft\".
*
* @param pcchBuf
* Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf
* parameter. On input, this is the full size of the buffer, including a space for a terminating null character.
* If the buffer passed in is too small, the count returned does not include the terminating null character.
*
* If lpPathBuf is null, pcchBuf can be null.
*
* @return
* The MsiGetComponentPath function returns the following values.
* INSTALLSTATE_NOTUSED - The component being requested is disabled on the computer.
* INSTALLSTATE_ABSENT - The component is not installed.
* INSTALLSTATE_INVALIDARG - One of the function parameters is invalid.
* INSTALLSTATE_LOCAL - The component is installed locally.
* INSTALLSTATE_SOURCE - The component is installed to run from source.
* INSTALLSTATE_SOURCEABSENT - The component source is inaccessible.
* INSTALLSTATE_UNKNOWN - The product code or component ID is unknown.
*/
int MsiGetComponentPath(String szProduct, String szComponent, char[] lpPathBuf, IntByReference pcchBuf);
/**
* The MsiLocateComponent function returns the full path to an installed component without a product code. This
* function attempts to determine the product using MsiGetProductCode, but is not guaranteed to find the correct
* product for the caller. MsiGetComponentPath should always be called when possible.
*
* @param szComponent
* Specifies the component ID of the component to be located.
*
* @param lpPathBuf
* Pointer to a variable that receives the path to the component. The variable includes the terminating null
* character.
*
* @param pcchBuf
* Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf
* parameter. On input, this is the full size of the buffer, including a space for a terminating null character.
* Upon success of the MsiLocateComponent function, the variable pointed to by pcchBuf contains the count of
* characters not including the terminating null character. If the size of the buffer passed in is too small, the
* function returns INSTALLSTATE_MOREDATA.
*
* If lpPathBuf is null, pcchBuf can be null.
*
* @return
* The MsiGetComponentPath function returns the following values.
* INSTALLSTATE_NOTUSED - The component being requested is disabled on the computer.
* INSTALLSTATE_ABSENT - The component is not installed.
* INSTALLSTATE_INVALIDARG - One of the function parameters is invalid.
* INSTALLSTATE_LOCAL - The component is installed locally.
* INSTALLSTATE_MOREDATA - The buffer provided was too small.
* INSTALLSTATE_SOURCE - The component is installed to run from source.
* INSTALLSTATE_SOURCEABSENT - The component source is inaccessible.
* INSTALLSTATE_UNKNOWN - The product code or component ID is unknown.
*/
int MsiLocateComponent(String szComponent, char[] lpPathBuf, IntByReference pcchBuf);
/**
* The MsiGetProductCode function returns the product code of an application by using the component code of an
* installed or advertised component of the application. During initialization, an application must determine under
* which product code it has been installed or advertised.
*
* @param szComponent
* This parameter specifies the component code of a component that has been installed by the application. This
* will be typically the component code of the component containing the executable file of the application.
*
* @param lpProductBuf
* Pointer to a buffer that receives the product code. This buffer must be 39 characters long. The first 38
* characters are for the GUID, and the last character is for the terminating null character.
*
* @return
* ERROR_BAD_CONFIGURATION - The configuration data is corrupt.
* ERROR_INSTALL_FAILURE - The product code could not be determined.
* ERROR_INVALID_PARAMETER - An invalid parameter was passed to the function.
* ERROR_SUCCESS - The function completed successfully.
* ERROR_UNKNOWN_COMPONENT - The specified component is unknown.
*/
int MsiGetProductCode(String szComponent, char[] lpProductBuf);
/**
* The MsiEnumComponents function enumerates the installed components for all products. This function retrieves one
* component code each time it is called.
*
* @param iComponentIndex
* Specifies the index of the component to retrieve. This parameter should be zero for the first call to the
* MsiEnumComponents function and then incremented for subsequent calls. Because components are not ordered, any
* new component has an arbitrary index. This means that the function can return components in any order.
*
* @param lpComponentBuf
* Pointer to a buffer that receives the component code. This buffer must be 39 characters long. The first 38
* characters are for the GUID, and the last character is for the terminating null character.
*
* @return
* ERROR_BAD_CONFIGURATION - The configuration data is corrupt.
* ERROR_INVALID_PARAMETER - An invalid parameter was passed to the function.
* ERROR_NO_MORE_ITEMS - There are no components to return.
* ERROR_NOT_ENOUGH_MEMORY - The system does not have enough memory to complete the operation. Available with
* Windows Server 2003.
* ERROR_SUCCESS - A value was enumerated.
*/
int MsiEnumComponents(WinDef.DWORD iComponentIndex, char[] lpComponentBuf);
}
@@ -1,244 +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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from NTSecApi.h
* Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface NTSecApi extends StdCallLibrary {
/**
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
* functions to specify a Unicode string.
*/
public static class LSA_UNICODE_STRING extends Structure {
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
}
/**
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
* not including the terminating null character, if any.
*/
public short Length;
/**
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
* MaximumLength bytes can be written into the buffer without trampling memory.
*/
public short MaximumLength;
/**
* Pointer to a wide character string. Note that the strings returned by the
* various LSA functions might not be null terminated.
*/
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "MaximumLength", "Buffer" });
}
/**
* String representation of the buffer.
* @return
* Unicode string.
*/
public String getString() {
byte[] data = Buffer.getByteArray(0, Length);
if (data.length < 2 || data[data.length - 1] != 0) {
Memory newdata = new Memory(data.length + 2);
newdata.write(0, data, 0, data.length);
return newdata.getString(0, true);
}
return Buffer.getString(0, true);
}
}
/**
* Pointer to an LSA_UNICODE_STRING.
*/
public static class PLSA_UNICODE_STRING {
public static class ByReference extends PLSA_UNICODE_STRING
implements Structure.ByReference {
}
public LSA_UNICODE_STRING.ByReference s;
}
/**
* Record contains an included top-level name.
*/
int ForestTrustTopLevelName = 0;
/**
* Record contains an excluded top-level name.
*/
int ForestTrustTopLevelNameEx = 1;
/**
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
*/
int ForestTrustDomainInfo = 2;
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
public PSID.ByReference Sid;
public LSA_UNICODE_STRING DnsName;
public LSA_UNICODE_STRING NetbiosName;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Sid", "DnsName", "NetbiosName" });
}
}
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
public int Length;
public Pointer Buffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Length", "Buffer" });
}
}
public static class LSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public static class UNION extends Union {
public static class ByReference extends UNION implements Structure.ByReference {
}
public LSA_UNICODE_STRING TopLevelName;
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
public LSA_FOREST_TRUST_BINARY_DATA Data;
}
/**
* Flags that control the behavior of the operation.
*/
public int Flags;
/**
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
* The following table shows the possible values.
* ForestTrustTopLevelName
* Record contains an included top-level name.
* ForestTrustTopLevelNameEx
* Record contains an excluded top-level name.
* ForestTrustDomainInfo
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
* ForestTrustRecordTypeLast
* Marks the end of an enumeration.
*/
public int ForestTrustType;
public LARGE_INTEGER Time;
/**
* Data type depending on ForestTrustType.
*/
public UNION u;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "Flags", "ForestTrustType", "Time", "u" });
}
public void read() {
super.read();
switch(ForestTrustType) {
case NTSecApi.ForestTrustTopLevelName:
case NTSecApi.ForestTrustTopLevelNameEx:
u.setType(LSA_UNICODE_STRING.class);
break;
case NTSecApi.ForestTrustDomainInfo:
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
break;
default:
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
break;
}
u.read();
}
}
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
}
public LSA_FOREST_TRUST_RECORD.ByReference tr;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "tr" });
}
}
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
/**
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
* Entries member.
*/
public int RecordCount;
/**
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
* each of which contains one piece of forest trust information.
*/
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "RecordCount", "Entries" });
}
/**
* Get an array of LSA_FOREST_TRUST_RECORD entries.
* @return
* An array of forest trust records.
*/
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount);
}
}
/**
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
* forest trust information.
*/
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
}
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fti" });
}
}
}
@@ -1,89 +0,0 @@
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
public interface NTStatus {
int STATUS_SUCCESS = 0x00000000; // ntsubauth
int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
//
// MessageId: STATUS_WAIT_0
//
// MessageText:
//
// STATUS_WAIT_0
//
int STATUS_WAIT_0 = 0x00000000; // winnt
//
// MessageId: STATUS_WAIT_1
//
// MessageText:
//
// STATUS_WAIT_1
//
int STATUS_WAIT_1 = 0x00000001;
//
// MessageId: STATUS_WAIT_2
//
// MessageText:
//
// STATUS_WAIT_2
//
int STATUS_WAIT_2 = 0x00000002;
//
// MessageId: STATUS_WAIT_3
//
// MessageText:
//
// STATUS_WAIT_3
//
int STATUS_WAIT_3 = 0x00000003;
//
// MessageId: STATUS_WAIT_63
//
// MessageText:
//
// STATUS_WAIT_63
//
int STATUS_WAIT_63 = 0x0000003F;
//
// The success status codes 128 - 191 are reserved for wait completion
// status with an abandoned mutant object.
//
int STATUS_ABANDONED = 0x00000080;
//
// MessageId: STATUS_ABANDONED_WAIT_0
//
// MessageText:
//
// STATUS_ABANDONED_WAIT_0
//
int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt
//
// MessageId: STATUS_ABANDONED_WAIT_63
//
// MessageText:
//
// STATUS_ABANDONED_WAIT_63
//
int STATUS_ABANDONED_WAIT_63 = 0x000000BF;
}
@@ -1,431 +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 com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Netapi32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Netapi32 extends StdCallLibrary {
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Retrieves join status information for the specified computer.
*
* @param lpServer
* Specifies the DNS or NetBIOS name of the computer on which to
* call the function.
* @param lpNameBuffer
* Receives the NetBIOS name of the domain or workgroup to which
* the computer is joined.
* @param BufferType
* Join status of the specified computer.
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetGetJoinInformation(String lpServer,
PointerByReference lpNameBuffer, IntByReference BufferType);
/**
* Frees the memory that the NetApiBufferAllocate function allocates.
*
* @param buffer
* @return If the function succeeds, the return value is NERR_Success. If
* the function fails, the return value is a system error code.
*/
public int NetApiBufferFree(Pointer buffer);
/**
* Returns information about each local group account on the specified
* server.
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the address of the buffer that receives the
* information structure.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in
* bytes.
* @param entriesread
* Pointer to a value that receives the count of elements
* actually enumerated.
* @param totalentries
* Pointer to a value that receives the approximate total number
* of entries that could have been enumerated from the current
* resume position.
* @param resume_handle
* Pointer to a value that contains a resume handle that is used
* to continue an existing local group search.
* @return If the function succeeds, the return value is NERR_Success.
*/
public int NetLocalGroupEnum(String serverName, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* Returns the name of the primary domain controller (PDC).
*
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute. If this parameter is NULL, the local computer is used.
* @param domainName
* Specifies the name of the domain.
* @param bufptr
* Receives a string that specifies the server name of the PDC of the domain.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGetDCName(String serverName, String domainName,
PointerByReference bufptr);
/**
* The NetGroupEnum function retrieves information about each global group
* in the security database, which is the security accounts manager (SAM) database or,
* in the case of domain controllers, the Active Directory.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer to receive the global group information structure.
* The format of this data depends on the value of the level parameter.
* @param prefmaxlen
* Specifies the preferred maximum length of the returned data, in bytes.
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
* memory required to hold the data. If you specify another value in this
* parameter, it can restrict the number of bytes that the function returns.
* If the buffer size is insufficient to hold all entries, the function
* returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. The total number of entries
* is only a hint.
* @param resume_handle
* Pointer to a variable that contains a resume handle that is used to continue
* the global group enumeration. The handle should be zero on the first call and
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
* is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserEnum function provides information about all user accounts on a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param level
* Specifies the information level of the data.
* @param filter
* Specifies a value that filters the account types for enumeration.
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends
* on the value of the level parameter. This buffer is allocated by the system and
* must be freed using the NetApiBufferFree function. Note that you must free the
* buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
* required for the data. If you specify another value in this parameter, it can
* restrict the number of bytes that the function returns. If the buffer size is
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have
* been enumerated from the current resume position. Note that applications should
* consider this value only as a hint.
* @param resume_handle
* Pointer to a value that contains a resume handle which is used to continue an
* existing user search. The handle should be zero on the first call and left
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
* handle is stored.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
IntByReference resume_handle);
/**
* The NetUserGetGroups function retrieves a list of global groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
* remote server on which the function is to execute. If this parameter is NULL,
* the local computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user to search for
* in each group account. For more information, see the following Remarks section.
* @param level
* Specifies the information level of the data.
* @param bufptr
* Pointer to the buffer that receives the data. This buffer is allocated by the
* system and must be freed using the NetApiBufferFree function. Note that you must
* free the buffer even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number
* of bytes that the function returns. If the buffer size is insufficient to hold
* all entries, the function returns ERROR_MORE_DATA.
* @param entriesread
* Pointer to a value that receives the count of elements actually retrieved.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been retrieved.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetGroups(String servername, String username, int level,
PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
* specified user belongs.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user for which to return
* local group membership information. If the string is of the form DomainName\UserName
* the user name is expected to be found on that domain. If the string is of the form
* UserName, the user name is expected to be found on the server specified by the
* servername parameter.
* @param level
* Specifies the information level of the data.
* @param flags
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
* defined. If this bit is set, the function also returns the names of the local
* groups in which the user is indirectly a member (that is, the user has membership
* in a global group that is itself a member of one or more local groups).
* @param bufptr
* Pointer to the buffer that receives the data. The format of this data depends on
* the value of the level parameter. This buffer is allocated by the system and must
* be freed using the NetApiBufferFree function. Note that you must free the buffer
* even if the function fails with ERROR_MORE_DATA.
* @param prefmaxlen
* Specifies the preferred maximum length of returned data, in bytes. If you specify
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
* data. If you specify another value in this parameter, it can restrict the number of
* bytes that the function returns. If the buffer size is insufficient to hold all
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
* Management Function Buffers and Network Management Function Buffer Lengths.
* @param entriesread
* Pointer to a value that receives the count of elements actually enumerated.
* @param totalentries
* Pointer to a value that receives the total number of entries that could have been enumerated.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetLocalGroups(String servername, String username, int level,
int flags, PointerByReference bufptr, int prefmaxlen,
IntByReference entriesread, IntByReference totalentries);
/**
* The NetUserAdd function adds a user account and assigns a password and privilege level.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
* on which the function is to execute.
* @param level
* Specifies the information level of the data.
* @param buf
* Pointer to the buffer that specifies the data. The format of this data depends on the
* value of the level parameter.
* @param parm_err
* Pointer to a value that receives the index of the first member of the user information
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
* not returned on error.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserAdd(String servername, int level,
Structure buf, IntByReference parm_err);
/**
* The NetUserDel function deletes a user account from a server.
* @param servername
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
* server on which the function is to execute. If this parameter is NULL, the local
* computer is used.
* @param username
* Pointer to a constant string that specifies the name of the user account to delete.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserDel(String servername, String username);
/**
* The NetUserChangePassword function changes a user's password for a specified
* network server or domain.
* @param domainname
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
* server or domain on which the function is to execute. If this parameter is NULL,
* the logon domain of the caller is used.
* @param username
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
* function changes the password for the specified user. If this parameter is NULL,
* the logon name of the caller is used.
* @param oldpassword
* Pointer to a constant string that specifies the user's old password.
* @param newpassword
* Pointer to a constant string that specifies the user's new password.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserChangePassword(String domainname, String username,
String oldpassword, String newpassword);
/**
* The DsGetDcName function returns the name of a domain controller in a specified domain.
* This function accepts additional domain controller selection criteria to indicate
* preference for a domain controller with particular characteristics.
* @param ComputerName
* Pointer to a null-terminated string that specifies the name of the server to process
* this function. Typically, this parameter is NULL, which indicates that the local
* computer is used.
* @param DomainName
* Pointer to a null-terminated string that specifies the name of the domain or application
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
* may be specified with or without a trailing period.
* @param DomainGuid
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
* by DomainGuid.
* @param SiteName
* Pointer to a null-terminated string that specifies the name of the site where the returned
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
* to return a domain controller in the site closest to the site of the computer specified by
* ComputerName. This parameter should be NULL, by default.
* @param Flags
* Contains a set of flags that provide additional data used to process the request.
* @param DomainControllerInfo
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
* This structure is allocated by DsGetDcName. The caller must free the structure using
* the NetApiBufferFree function when it is no longer required.
* @return
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
* If the function fails, the return code is one of ERROR_* values.
*/
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO DomainControllerInfo);
/**
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
* @param serverName
* Contains the name of the domain controller that DsGetForestTrustInformationW
* is connected to remotely. The caller must be an authenticated user on this server.
* If this parameter is NULL, the local server is used.
* @param trustedDomainName
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
* trust attribute. If this parameter is NULL, the forest trust data for the domain
* hosted by ServerName is retrieved.
* @param Flags
* Contains a set of flags that modify the behavior of this function.
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
* @param ForestTrustInfo
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
* trust data that describes the namespaces claimed by the domain specified by
* TrustedDomainName. The Time member of all returned records will be zero.
* @return
* Returns NO_ERROR if successful or a Win32 error code otherwise.
*/
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo);
/**
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
* @param serverName
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
* obtain the trust information for. This computer must be running the Windows 2000 or later
* operating system. If this parameter is NULL, the name of the local computer is used.
* The caller must be an authenticated user in this domain.
* @param Flags
* Contains a set of flags that determines which domain trusts to enumerate.
* @param Domains
* Receives a pointer which points to an array of DS_DOMAIN_TRUSTS structures.
* Each structure in this array contains trust data about a domain. The caller must free this
* memory when it is no longer required by calling NetApiBufferFree.
* @param DomainCount
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
* @return
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
*/
public int DsEnumerateDomainTrusts(String serverName, int Flags,
PointerByReference Domains, IntByReference DomainCount);
/**
* The NetUserGetInfo function retrieves information about a particular user account on a server.
* @param servername
* A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on
* which the function is to execute. If this parameter is NULL, the local computer is used.
* @param username
* A pointer to a constant string that specifies the name of the user account for which to return information.
* For more information, see the following Remarks section.
* @param level
* The information level of the data. This parameter can be one of the following values.
* Value Meaning
* 0 Return the user account name. The bufptr parameter points to a USER_INFO_0 structure.
* 1 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure.
* 2 Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure.
* 3 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead.
* 4 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_4 structure. Windows 2000: This level is not supported.
* 10 Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure.
* 11 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure.
* 20 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_20 structure. Note that on Windows XP and later, it is recommended that you use USER_INFO_23 instead.
* 23 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_23 structure. Windows 2000: This level is not supported.
* @param bufptr
* A pointer to the buffer that receives the data.
* The format of this data depends on the value of the level parameter.
* This buffer is allocated by the system and must be freed using the NetApiBufferFree function.
* For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
* @return
* If the function succeeds, the return value is NERR_Success.
*/
public int NetUserGetInfo( String servername, String username, int level, PointerByReference bufptr );
}
@@ -1,695 +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 java.util.ArrayList;
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.Guid.GUID;
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
import com.sun.jna.platform.win32.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.PointerByReference;
/**
* Netapi32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Netapi32Util {
/**
* A group.
*/
public static class Group {
/**
* Group name.
*/
public String name;
}
/**
* A user.
*/
public static class User {
/**
* The name of the user account.
*/
public String name;
/**
* Contains a comment associated with the user account.
*/
public String comment;
}
public static class UserInfo extends User {
/**
* The full name belonging to the user account
*/
public String fullName;
/**
* The SID of the user account
*/
public String sidString;
/**
* The SID of the user account
*/
public PSID sid;
/**
* The flags of the user account
*/
public int flags;
}
/**
* A local group.
*/
public static class LocalGroup extends Group {
/**
* Group comment.
*/
public String comment;
}
/**
* Returns the name of the primary domain controller (PDC) on the current computer.
* @return The name of the primary domain controller.
*/
public static String getDCName() {
return getDCName(null, null);
}
/**
* Returns the name of the primary domain controller (PDC).
* @param serverName
* Specifies the DNS or NetBIOS name of the remote server on which the function is
* to execute.
* @param domainName
* Specifies the name of the domain.
* @return
* Name of the primary domain controller.
*/
public static String getDCName(String serverName, String domainName) {
PointerByReference bufptr = new PointerByReference();
try {
int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
return bufptr.getValue().getString(0, true);
} finally {
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
}
}
/**
* Return the domain/workgroup join status for a computer.
* @return Join status.
*/
public static int getJoinStatus() {
return getJoinStatus(null);
}
/**
* Return the domain/workgroup join status for a computer.
* @param computerName Computer name.
* @return Join status.
*/
public static int getJoinStatus(String computerName) {
PointerByReference lpNameBuffer = new PointerByReference();
IntByReference bufferType = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
return bufferType.getValue();
} finally {
if (lpNameBuffer.getPointer() != null) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get information about a computer.
* @param computerName
* @return Domain or workgroup name.
*/
public static String getDomainName(String computerName) {
PointerByReference lpNameBuffer = new PointerByReference();
IntByReference bufferType = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
// type of domain: bufferType.getValue()
return lpNameBuffer.getValue().getString(0, true);
} finally {
if (lpNameBuffer.getPointer() != null) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of local groups on the current computer.
* @return An array of local group names.
*/
public static LocalGroup[] getLocalGroups() {
return getLocalGroups(null);
}
/**
* Get the names of local groups on a computer.
* @param serverName Name of the computer.
* @return An array of local group names.
*/
public static LocalGroup[] getLocalGroups(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LOCALGROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
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]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of global groups on a computer.
* @return An array of group names.
*/
public static Group[] getGlobalGroups() {
return getGlobalGroups(null);
}
/**
* Get the names of global groups on a computer.
* @param serverName Name of the computer.
* @return An array of group names.
*/
public static Group[] getGlobalGroups(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
LocalGroup lgp = new LocalGroup();
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]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get the names of users on a local computer.
* @return Users.
*/
public static User[] getUsers() {
return getUsers(null);
}
/**
* Get the names of users on a computer.
* @param serverName Name of the computer.
* @return An array of users.
*/
public static User[] getUsers(String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesRead = new IntByReference();
IntByReference totalEntries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserEnum(
serverName, 1, 0, bufptr,
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
totalEntries, null);
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
throw new Win32Exception(rc);
}
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
ArrayList<User> result = new ArrayList<User>();
for(LMAccess.USER_INFO_1 lu : users) {
User auser = new User();
if (lu.usri1_name != null) {
auser.name = lu.usri1_name.toString();
}
result.add(auser);
}
return result.toArray(new User[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get local groups of the current user.
* @return Local groups.
*/
public static Group[] getCurrentUserLocalGroups() {
return getUserLocalGroups(Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible));
}
/**
* Get local groups of a given user.
* @param userName User name.
* @return Local groups.
*/
public static Group[] getUserLocalGroups(String userName) {
return getUserLocalGroups(userName, null);
}
/**
* Get local groups of a given user on a given system.
* @param userName User name.
* @param serverName Server name.
* @return Local groups.
*/
public static Group[] getUserLocalGroups(String userName, String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(
serverName, userName,
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
ArrayList<Group> result = new ArrayList<Group>();
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
LocalGroup lgp = new LocalGroup();
if (lgpi.lgrui0_name != null) {
lgp.name = lgpi.lgrui0_name.toString();
}
result.add(lgp);
}
return result.toArray(new Group[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* Get groups of a given user.
* @param userName User name.
* @return Groups.
*/
public static Group[] getUserGroups(String userName) {
return getUserGroups(userName, null);
}
/**
* Get groups of a given user on a given system.
* @param userName User name.
* @param serverName Server name.
* @return Groups.
*/
public static Group[] getUserGroups(String userName, String serverName) {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
try {
int rc = Netapi32.INSTANCE.NetUserGetGroups(
serverName, userName,
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
if (rc != LMErr.NERR_Success) {
throw new Win32Exception(rc);
}
GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
ArrayList<Group> result = new ArrayList<Group>();
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
Group lgp = new Group();
if (lgpi.grui0_name != null) {
lgp.name = lgpi.grui0_name.toString();
}
result.add(lgp);
}
return result.toArray(new Group[0]);
} finally {
if (bufptr.getValue() != Pointer.NULL) {
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
if (LMErr.NERR_Success != rc) {
throw new Win32Exception(rc);
}
}
}
}
/**
* A domain controller.
*/
public static class DomainController {
/**
* Specifies the computer name of the discovered domain controller.
*/
public String name;
/**
* Specifies the address of the discovered domain controller.
*/
public String address;
/**
* Indicates the type of string that is contained in the
* DomainControllerAddress member.
*/
public int addressType;
/**
* The GUID of the domain.
*/
public GUID domainGuid;
/**
* Pointer to a null-terminated string that specifies the name of the domain.
*/
public String domainName;
/**
* Pointer to a null-terminated string that specifies the name of the domain at the root
* of the DS tree.
*/
public String dnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int flags;
/**
* The name of the site that the computer belongs to.
*/
public String clientSiteName;
}
/**
* Return the domain controller for a current computer.
* @return
* Domain controller information.
*/
public static DomainController getDC() {
PDOMAIN_CONTROLLER_INFO pdci = new PDOMAIN_CONTROLLER_INFO();
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
if (W32Errors.ERROR_SUCCESS != rc) {
throw new Win32Exception(rc);
}
DomainController dc = new DomainController();
if (pdci.dci.DomainControllerAddress != null) {
dc.address = pdci.dci.DomainControllerAddress.toString();
}
dc.addressType = pdci.dci.DomainControllerAddressType;
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;
if (pdci.dci.DomainName != null) {
dc.domainName = pdci.dci.DomainName.toString();
}
dc.flags = pdci.dci.Flags;
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);
}
return dc;
}
/**
* A domain trust relationship.
*/
public static class DomainTrust {
/**
* NetBIOS name of the domain.
*/
public String NetbiosDomainName;
/**
* DNS name of the domain.
*/
public String DnsDomainName;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID DomainSid;
/**
* Contains the string representation of the security identifier of the domain
* represented by this structure.
*/
public String DomainSidString;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
/**
* Contains the string representation of the GUID of the domain represented by
* this structure.
*/
public String DomainGuidString;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
private int flags;
/**
* The domain represented by this structure is a member of the same forest
* as the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isInForest() {
return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0;
}
/**
* The domain represented by this structure is directly trusted by the domain
* that the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function is a member of.
* @return
* True or false.
*/
public boolean isOutbound() {
return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0;
}
/**
* The domain represented by this structure is the root of a tree and a member
* of the same forest as the server specified in the ServerName parameter of the
* DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isRoot() {
return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0;
}
/**
* The domain represented by this structure is the primary domain of the server
* specified in the ServerName parameter of the DsEnumerateDomainTrusts function.
* @return
* True or false.
*/
public boolean isPrimary() {
return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0;
}
/**
* The domain represented by this structure is running in the Windows 2000 native mode.
* @return
* True or false.
*/
public boolean isNativeMode() {
return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0;
}
/**
* The domain represented by this structure directly trusts the domain that
* the server specified in the ServerName parameter of the DsEnumerateDomainTrusts
* function is a member of.
* @return
* True or false.
*/
public boolean isInbound() {
return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0;
}
}
/**
* Retrieve all domain trusts.
* @return
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts() {
return getDomainTrusts(null);
}
/**
* Retrieve all domain trusts for a given server.
* @param serverName
* Server name.
* @return
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts(String serverName) {
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 {
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();
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(domainsPointerRef.getValue());
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
}
}
public static UserInfo getUserInfo(String accountName) {
return getUserInfo(accountName, Netapi32Util.getDCName());
}
public static UserInfo getUserInfo(String accountName, String domainName) {
PointerByReference bufptr = new PointerByReference();
int rc = -1;
try {
rc = Netapi32.INSTANCE.NetUserGetInfo(domainName, accountName, (short)23, bufptr);
if (rc == LMErr.NERR_Success) {
USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue());
UserInfo userInfo = new UserInfo();
if (info_23.usri23_comment != null) {
userInfo.comment = info_23.usri23_comment.toString();
}
userInfo.flags = info_23.usri23_flags;
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 {
throw new Win32Exception(rc);
}
} finally {
if (bufptr.getValue() != Pointer.NULL) {
Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
}
}
}
}
@@ -1,55 +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 com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* ntdll.dll Interface.
* @author dblock[at]dblock.org
*/
public interface NtDll extends StdCallLibrary {
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
/**
* The ZwQueryKey routine provides information about the class of a registry key,
* and the number and sizes of its subkeys.
* @param KeyHandle
* Handle to the registry key to obtain information about. This handle is created by
* a successful call to ZwCreateKey or ZwOpenKey.
* @param KeyInformationClass
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
* returned in the KeyInformation buffer.
* @param KeyInformation
* Pointer to a caller-allocated buffer that receives the requested information.
* @param Length
* Specifies the size, in bytes, of the KeyInformation buffer.
* @param ResultLength
* Pointer to a variable that receives the size, in bytes, of the requested key
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
* required buffer size.
* @return
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
*/
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
Structure KeyInformation, int Length, IntByReference ResultLength);
}
@@ -1,47 +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 com.sun.jna.platform.win32.Wdm.KEY_BASIC_INFORMATION;
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
import com.sun.jna.platform.win32.WinReg.HKEY;
import com.sun.jna.ptr.IntByReference;
/**
* NtDll Utility API.
* @author dblock[at]dblock.org
*/
public abstract class NtDllUtil {
/**
* Retrieve the name of an opened registry key.
* @param hkey Opened registry key.
* @return Basic key name, not including node information.
*/
public static String getKeyName(HKEY hkey) {
IntByReference resultLength = new IntByReference();
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
null, 0, resultLength);
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
throw new Win32Exception(rc);
}
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
resultLength.getValue());
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
keyInformation, resultLength.getValue(), resultLength);
if (rc != NTStatus.STATUS_SUCCESS) {
throw new Win32Exception(rc);
}
return keyInformation.getName();
}
}
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
@@ -1,58 +0,0 @@
/*
* 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 {
/** The clsctx inproc. */
int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
// With DCOM, CLSCTX_REMOTE_SERVER should be included
/** The clsctx all. */
int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_INPROC_HANDLER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
/** The clsctx server. */
int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
| WTypes.CLSCTX_LOCAL_SERVER
| WTypes.CLSCTX_REMOTE_SERVER);
}
@@ -1,217 +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 com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinDef.LPVOID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Ole32.dll Interface.
*
* @author dblock[at]dblock.org
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public interface Ole32 extends StdCallLibrary {
/** The instance. */
Ole32 INSTANCE = (Ole32) Native.loadLibrary("Ole32", Ole32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface
* identifiers.
*
* @param pguid
* A pointer to the requested GUID.
* @return S_OK if the GUID was successfully created.
*/
HRESULT CoCreateGuid(GUID pguid);
/** @deprecated use {@link #CoCreateGuid(Guid.GUID)}. */
HRESULT CoCreateGuid(GUID.ByReference pguid);
/**
* Converts a globally unique identifier (GUID) into a string of printable
* characters.
*
* @param rguid
* The GUID to be converted.
* @param lpsz
* A pointer to a caller-allocated string variable to receive the
* resulting string.
* @param cchMax
* The number of characters available in the lpsz buffer.
* @return If the function succeeds, the return value is the number of
* characters in the returned string, including the null terminator.
* If the buffer is too small to contain the string, the return
* value is 0.
*/
int StringFromGUID2(GUID rguid, char[] lpsz, int cchMax);
/**
* Converts a string generated by the StringFromIID function back into the
* original interface identifier (IID).
*
* @param lpsz
* A pointer to the string representation of the IID.
* @param lpiid
* A pointer to the requested IID on return.
* @return This function can return the standard return values E_INVALIDARG,
* E_OUTOFMEMORY, and S_OK.
*/
HRESULT IIDFromString(String lpsz, GUID lpiid);
/**
* Initializes the COM library on the current thread and identifies the
* concurrency model as single-thread apartment (STA).
*
* New applications should call CoInitializeEx instead of CoInitialize.
*
* pvReserved [in, optional] This parameter is reserved and must be NULL.
*
* @param pvReserved
* the pv reserved
* @return S_OK The COM library was initialized successfully on this thread.
*
* S_FALSE The COM library is already initialized on this thread.
*
* RPC_E_CHANGED_MODE A previous call to CoInitializeEx specified
* the concurrency model for this thread as multithread apartment
* (MTA). This could also indicate that a change from
* neutral-threaded apartment to single-threaded apartment has
* occurred.
*/
HRESULT CoInitialize(LPVOID pvReserved);
int COINIT_APARTMENTTHREADED = 0x2;
int COINIT_MULTITHREADED = 0x0;
int COINIT_DISABLE_OLE1DDE = 0x4;
int COINIT_SPEED_OVER_MEMORY = 0x8;
/**
* Initializes the COM library for use by the calling thread, sets the
* thread's concurrency model, and creates a new apartment for the thread if
* one is required.
*
* @param reserved
* This parameter is reserved and must be NULL.
* @param dwCoInit
* The concurrency model and initialization options for the
* thread. Values for this parameter are taken from the COINIT
* enumeration. Any combination of values from COINIT can be
* used, except that the {@link #COINIT_APARTMENTTHREADED} and
* {@link #COINIT_MULTITHREADED} flags cannot both be set. The
* default (and only sane choice) is
* {@link #COINIT_MULTITHREADED}.
* @return This function can return the standard return values E_INVALIDARG,
* E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values.
* S_OK, S_FALSE, RPC_E_CHANGED_MODE
*/
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
/**
* Closes the COM library on the current thread, unloads all DLLs loaded by
* the thread, frees any other resources that the thread maintains, and
* forces all RPC connections on the thread to close.
*
*/
void CoUninitialize();
/**
* Creates a single uninitialized object of the class associated with a
* specified CLSID.
*
* @param rclsid
* The CLSID associated with the data and code that will be used
* to create the object.
* @param pUnkOuter
* If NULL, indicates that the object is not being created as
* part of an aggregate. If non-NULL, pointer to the aggregate
* object's IUnknown interface (the controlling IUnknown).
* @param dwClsContext
* Context in which the code that manages the newly created
* object will run. The values are taken from the enumeration
* CLSCTX defined in WTypes.
* @param riid
* A reference to the identifier of the interface to be used to
* communicate with the object.
* @param ppv
* Address of pointer variable that receives the interface
* pointer requested in riid. Upon successful return, *ppv
* contains the requested interface pointer. Upon failure, *ppv
* contains NULL.
* @return an HRESULT
*/
HRESULT CoCreateInstance(GUID rclsid, Pointer pUnkOuter, int dwClsContext,
GUID riid, PointerByReference ppv);
/**
* Looks up a CLSID in the registry, given a ProgID.
*
* @param lpszProgID
* [in] A pointer to the ProgID whose CLSID is requested.
* @param lpclsid
* [out] Receives a pointer to the retrieved CLSID on return.
*
* @return S_OK The CLSID was retrieved successfully.
*
* CO_E_CLASSSTRING The registered CLSID for the ProgID is invalid.
*
* REGDB_E_WRITEREGDB An error occurred writing the CLSID to the
* registry. See Remarks below.
*
* Remarks Given a ProgID, CLSIDFromProgID looks up its associated
* CLSID in the registry. If the ProgID cannot be found in the
* registry, CLSIDFromProgID creates an OLE 1 CLSID for the ProgID
* and a CLSID entry in the registry. Because of the restrictions
* placed on OLE 1 CLSID values, CLSIDFromProgID and CLSIDFromString
* are the only two functions that can be used to generate a CLSID
* for an OLE 1 object.
*/
HRESULT CLSIDFromProgID(String lpszProgID, CLSID lpclsid);
/**
* Converts a string generated by the StringFromCLSID function back into the
* original CLSID.
*
* @param lpsz
* [in] The string representation of the CLSID.
*
* @param pclsid
* [out] A pointer to the CLSID.
*
* @return Return value
*
* This function can return the standard return value E_INVALIDARG,
* as well as the following values.
*
* NOERROR The CLSID was obtained successfully.
*
* CO_E_CLASSSTRING The class string was improperly formatted.
*
* REGDB_E_CLASSNOTREG The CLSID corresponding to the class string
* was not found in the registry.
*
* REGDB_E_READREGDB The registry could not be opened for reading.
*/
HRESULT CLSIDFromString(WString lpsz, CLSID pclsid);
}
@@ -1,73 +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 com.sun.jna.Native;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Ole32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Ole32Util {
/**
* Convert a string to a GUID.
* @param guidString
* String representation of a GUID, including { }.
* @return
* A GUID.
*/
public static GUID getGUIDFromString(String guidString) {
GUID lpiid = new GUID();
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return lpiid;
}
/**
* Convert a GUID into a string.
* @param guid
* GUID.
* @return
* String representation of a GUID.
*/
public static String getStringFromGUID(GUID guid) {
GUID pguid = new GUID(guid.getPointer());
int max = 39;
char[] lpsz = new char[max];
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
if (len == 0) {
throw new RuntimeException("StringFromGUID2");
}
lpsz[len - 1] = 0;
return Native.toString(lpsz);
}
/**
* Generate a new GUID.
* @return
* New GUID.
*/
public static GUID generateGUID() {
GUID pguid = new GUID();
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
if (! hr.equals(W32Errors.S_OK)) {
throw new RuntimeException(hr.toString());
}
return pguid;
}
}
@@ -1,477 +0,0 @@
/* copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.OaIdl.DISPIDByReference;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.Variant.VariantArg;
import com.sun.jna.platform.win32.WTypes.BSTR;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinBase.SYSTEMTIME;
import com.sun.jna.platform.win32.WinDef.LCID;
import com.sun.jna.platform.win32.WinDef.PVOID;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.ITypeLib;
import com.sun.jna.ptr.DoubleByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Oleaut32.dll Interface.
*
* @author scott.palmer
*/
public interface OleAuto extends StdCallLibrary {
/* Flags for IDispatch::Invoke */
/** The Constant DISPATCH_METHOD. */
public final static int DISPATCH_METHOD = 0x1;
/** The Constant DISPATCH_PROPERTYGET. */
public final static int DISPATCH_PROPERTYGET = 0x2;
/** The Constant DISPATCH_PROPERTYPUT. */
public final static int DISPATCH_PROPERTYPUT = 0x4;
/** The Constant DISPATCH_PROPERTYPUTREF. */
public final static int DISPATCH_PROPERTYPUTREF = 0x8;
/** An array that is allocated on the stac. */
public final static int FADF_AUTO = 0x0001;
/** An array that is statically allocated. */
public final static int FADF_STATIC = 0x0002;
/** An array that is embedded in a structure. */
public final static int FADF_EMBEDDED = 0x0004;
/** An array that is embedded in a structure. */
public final static int FADF_FIXEDSIZE = 0x0010;
/** An array that is embedded in a structure. */
public final static int FADF_RECORD = 0x0020;
/** An array that is embedded in a structure. */
public final static int FADF_HAVEIID = 0x0040;
/**
* An array that has a variant type. The variant type can be retrieved with
* SafeArrayGetVartype.
*/
public final static int FADF_HAVEVARTYPE = 0x0080;
/** An array of BSTRs. */
public final static int FADF_BSTR = 0x0100;
/** An array of IUnknown*. */
public final static int FADF_UNKNOWN = 0x0200;
/** An array of IDispatch*. */
public final static int FADF_DISPATCH = 0x0400;
/** An array of VARIANTs. */
public final static int FADF_VARIANT = 0x0800;
/** Bits reserved for future use. */
public final static int FADF_RESERVED = 0xF008;
/** The instance. */
OleAuto INSTANCE = (OleAuto) Native.loadLibrary("OleAut32", OleAuto.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* This function allocates a new string and copies the passed string into
* it.
*
* @param sz
* Null-terminated UNICODE string to copy.
* @return Null if there is insufficient memory or if a null pointer is
* passed in.
*/
public BSTR SysAllocString(String sz);
/**
* This function frees a string allocated previously by SysAllocString,
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
* SysReAllocStringLen.
*
* @param bstr
* Unicode string that was allocated previously, or NULL. Setting
* this parameter to NULL causes the function to simply return.
*/
public void SysFreeString(BSTR bstr);
/**
* The VariantInit function initializes the VARIANTARG by setting the vt
* field to VT_EMPTY. Unlike VariantClear, this function does not interpret
* the current contents of the VARIANTARG. Use VariantInit to initialize new
* local variables of type VARIANTARG (or VARIANT).
*
* @param pvarg
* The variant to initialize.
*/
public void VariantInit(VARIANT pvarg);
/**
* First, free any memory that is owned by pvargDest, such as VariantClear
* (pvargDest must point to a valid initialized variant, and not simply to
* an uninitialized memory location). Then pvargDest receives an exact copy
* of the contents of pvargSrc.
*
* If pvargSrc is a VT_BSTR, a copy of the string is made. If pvargSrcis a
* VT_ARRAY, the entire array is copied. If pvargSrc is a VT_DISPATCH or
* VT_UNKNOWN, AddRef is called to increment the object's reference count.
*
* If the variant to be copied is a COM object that is passed by reference,
* the vtfield of the pvargSrcparameter is VT_DISPATCH | VT_BYREF or
* VT_UNKNOWN | VT_BYREF. In this case, VariantCopy does not increment the
* reference count on the referenced object. Because the variant being
* copied is a pointer to a reference to an object, VariantCopy has no way
* to determine if it is necessary to increment the reference count of the
* object. It is therefore the responsibility of the caller to call
* IUnknown::AddRef on the object or not, as appropriate.
*
* Note The VariantCopy method is not threadsafe.
*
* @param pvargDest
* [out] The destination variant.
* @param pvargSrc
* [in] The source variant.
* @return the hresult
*/
public HRESULT VariantCopy(Pointer pvargDest, VARIANT pvargSrc);
/**
* Use this function to clear variables of type VARIANTARG (or VARIANT)
* before the memory containing the VARIANTARG is freed (as when a local
* variable goes out of scope).
*
* The function clears a VARIANTARG by setting the vt field to VT_EMPTY. The
* current contents of the VARIANTARG are released first. If the vtfield is
* VT_BSTR, the string is freed. If the vtfield is VT_DISPATCH, the object
* is released. If the vt field has the VT_ARRAY bit set, the array is
* freed.
*
* If the variant to be cleared is a COM object that is passed by reference,
* the vtfield of the pvargparameter is VT_DISPATCH | VT_BYREF or VT_UNKNOWN
* | VT_BYREF. In this case, VariantClear does not release the object.
* Because the variant being cleared is a pointer to a reference to an
* object, VariantClear has no way to determine if it is necessary to
* release the object. It is therefore the responsibility of the caller to
* release the object or not, as appropriate.
*
* In certain cases, it may be preferable to clear a variant in code without
* calling VariantClear. For example, you can change the type of a VT_I4
* variant to another type without calling this function. Safearrays of BSTR
* will have SysFreeString called on each element not VariantClear. However,
* you must call VariantClear if a VT_type is received but cannot be
* handled. Safearrays of variant will also have VariantClear called on each
* member. Using VariantClear in these cases ensures that code will continue
* to work if Automation adds new variant types in the future.
*
* Do not use VariantClear on unitialized variants; use VariantInit to
* initialize a new VARIANTARG or VARIANT.
*
* Variants containing arrays with outstanding references cannot be cleared.
* Attempts to do so will return an HRESULT containing DISP_E_ARRAYISLOCKED.
*
* @param pvarg
* [in, out] The variant to clear.
* @return the hresult
*/
HRESULT VariantClear(Pointer pvarg);
/**
* Creates a new array descriptor, allocates and initializes the data for
* the array, and returns a pointer to the new array descriptor.
*
* @param vt
* [in] The base type of the array (the VARTYPE of each element
* of the array). The VARTYPE is restricted to a subset of the
* variant types. Neither the VT_ARRAY nor the VT_BYREF flag can
* be set. VT_EMPTY and VT_NULL are not valid base types for the
* array. All other types are legal. cDims
*
* @param cDims
* the c dims
* @param rgsabound
* the rgsabound
*
* @return Return value
*
* A safe array descriptor, or null if the array could not be
* created.
*/
public SAFEARRAY SafeArrayCreate(VARTYPE vt, int cDims,
SAFEARRAYBOUND[] rgsabound);
/**
* Stores the data element at the specified location in the array.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
* @param idx
* the idx
* @param pv
* [in] The data to assign to the array. The variant types
* VT_DISPATCH, VT_UNKNOWN, and VT_BSTR are pointers, and do not
* require another level of indirection.
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* DISP_E_BADINDEX The specified index is not valid.
*
* E_INVALIDARG One of the arguments is not valid.
*
* E_OUTOFMEMORY Memory could not be allocated for the element.
*/
public HRESULT SafeArrayPutElement(SAFEARRAY psa, long[] idx, VARIANT pv);
/**
* Retrieves a single element of the array.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
* @param rgIndices
* [in] A vector of indexes for each dimension of the array. The
* right-most (least significant) dimension is rgIndices[0]. The
* left-most dimension is stored at rgIndices[psa->cDims - 1].
* @param pv
* [out] The element of the array.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* DISP_E_BADINDEX The specified index is not valid.
*
* E_INVALIDARG One of the arguments is not valid.
*
* E_OUTOFMEMORY Memory could not be allocated for the element.
*/
public HRESULT SafeArrayGetElement(SAFEARRAY psa, long[] rgIndices,
Pointer pv);
/**
* Increments the lock count of an array, and places a pointer to the array
* data in pvData of the array descriptor.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG The argument psa is not valid.
*
* E_UNEXPECTED The array could not be locked.
*/
public HRESULT SafeArrayLock(SAFEARRAY psa);
/**
* Decrements the lock count of an array so it can be freed or resized.
*
* @param psa
* [in] An array descriptor created by SafeArrayCreate.
*
* @return Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG The argument psa is not valid.
*
* E_UNEXPECTED The array could not be locked.
*/
public HRESULT SafeArrayUnLock(SAFEARRAY psa);
/**
* Retrieves a pointer to a running object that has been registered with
* OLE.
*
* @param rclsid
* [in] The class identifier (CLSID) of the active object from
* the OLE registration database.
* @param pvReserved
* Reserved for future use. Must be null.
* @param ppunk
* [out] The requested active object.
*
* @return Return value
*
* If this function succeeds, it returns S_OK. Otherwise, it returns
* an HRESULT error code.
*/
HRESULT GetActiveObject(GUID rclsid, PVOID pvReserved,
PointerByReference ppunk);
/**
* The Class DISPPARAMS.
*/
public class DISPPARAMS extends Structure {
/**
* The Class ByReference.
*/
public static class ByReference extends DISPPARAMS implements
Structure.ByReference {
}
/** The rgvarg. */
public VariantArg.ByReference rgvarg;
/** The rgdispid named args. */
public DISPIDByReference rgdispidNamedArgs;
/** The c args. */
public UINT cArgs;
/** The c named args. */
public UINT cNamedArgs;
/**
* Instantiates a new dispparams.
*/
public DISPPARAMS() {
super();
}
/**
* Instantiates a new dispparams.
*
* @param memory
* the memory
*/
public DISPPARAMS(Pointer memory) {
super(memory);
this.read();
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.Structure#getFieldOrder()
*/
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[] { "rgvarg", "rgdispidNamedArgs",
"cArgs", "cNamedArgs" });
}
}
/**
* Uses registry information to load a type library.
*
* @param rguid
* The GUID of the library.
* @param wVerMajor
* The major version of the library.
* @param wVerMinor
* The minor version of the library.
* @param lcid
* The national language code of the library.
* @param pptlib
* The loaded type library.
*
* This function can return one of these values: S_OK Success.
*
* E_INVALIDARG One or more of the arguments is not valid.
*
* E_OUTOFMEMORY Insufficient memory to complete the operation.
*
* TYPE_E_IOERROR The function could not write to the file.
*
* TYPE_E_INVALIDSTATE The type library could not be opened.
*
* TYPE_E_INVDATAREAD The function could not read from the file.
*
* TYPE_E_UNSUPFORMAT The type library has an older format.
*
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
* OLE-supported DLLs.
*
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
* loaded.
*/
public HRESULT LoadRegTypeLib(GUID rguid, int wVerMajor, int wVerMinor,
LCID lcid, PointerByReference pptlib);
/**
* Loads and registers a type library.
*
* @param szFile
* The name of the file from which the method should attempt to
* load a type library.
*
* @param pptlib
* The loaded type library. Return value
*
* This function can return one of these values.
*
* S_OK Success.
*
* E_INVALIDARG One or more of the arguments is not valid.
*
* E_OUTOFMEMORY Insufficient memory to complete the operation.
*
* TYPE_E_IOERROR The function could not write to the file.
*
* TYPE_E_INVALIDSTATE The type library could not be opened.
*
* TYPE_E_INVDATAREAD The function could not read from the file.
*
* TYPE_E_UNSUPFORMAT The type library has an older format.
*
* TYPE_E_UNKNOWNLCID The LCID could not be found in the
* OLE-supported DLLs.
*
* TYPE_E_CANTLOADLIBRARY The type library or DLL could not be
* loaded.
*/
HRESULT LoadTypeLib(WString szFile, ITypeLib pptlib);
/**
* Converts a system time to a variant representation.
*
* @param lpSystemTime
* [in] The system time.
*
* @param pvtime
* [out] The variant time.
*
* @return The function returns TRUE on success and FALSE otherwise.
*/
int SystemTimeToVariantTime(SYSTEMTIME lpSystemTime,
DoubleByReference pvtime);
}
@@ -1,77 +0,0 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.OaIdl.SAFEARRAYBOUND;
import com.sun.jna.platform.win32.Variant.VARIANT;
import com.sun.jna.platform.win32.WTypes.VARTYPE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.platform.win32.COM.COMUtils;
/**
* The Class OleAut32Util.
*
* @author Tobias Wolf, wolf.tobias@gmx.net
*/
public abstract class OleAutoUtil {
/**
* Creates a new the variant array.
*
* @param size the size
* @return the sAFEARRA y. by reference
*/
public static SAFEARRAY createVarArray(int size) {
SAFEARRAY psa;
SAFEARRAYBOUND[] rgsabound = new SAFEARRAYBOUND[1];
rgsabound[0] = new SAFEARRAYBOUND(size, 0);
psa = OleAuto.INSTANCE.SafeArrayCreate(
new VARTYPE(Variant.VT_VARIANT), 1, rgsabound);
return psa;
}
/**
* Safe array put element.
*
* @param array the array
* @param index the index
* @param arg the arg
*/
public static void SafeArrayPutElement(SAFEARRAY array, long index,
VARIANT arg) {
long[] idx = new long[1];
idx[0] = index;
HRESULT hr = OleAuto.INSTANCE.SafeArrayPutElement(array, idx, arg);
COMUtils.SUCCEEDED(hr);
}
/**
* Safe array get element.
*
* @param array the array
* @param index the index
* @return the variant
*/
public static VARIANT SafeArrayGetElement(SAFEARRAY array, long index) {
long[] idx = new long[1];
idx[0] = index;
VARIANT result = new VARIANT();
HRESULT hr = OleAuto.INSTANCE.SafeArrayGetElement(array, idx,
result.getPointer());
COMUtils.SUCCEEDED(hr);
return result;
}
}
@@ -1,313 +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 com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.Sspi.CredHandle;
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
import com.sun.jna.platform.win32.Sspi.TimeStamp;
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
import com.sun.jna.platform.win32.WinNT.LUID;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Secur32.dll Interface.
* @author dblock[at]dblock.org
*/
public interface Secur32 extends StdCallLibrary {
Secur32 INSTANCE = (Secur32) Native.loadLibrary("Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
/**
* Specifies a format for a directory service object name.
* http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx
*/
public abstract class EXTENDED_NAME_FORMAT {
public static final int NameUnknown = 0;
public static final int NameFullyQualifiedDN = 1;
public static final int NameSamCompatible = 2;
public static final int NameDisplay = 3;
public static final int NameUniqueId = 6;
public static final int NameCanonical = 7;
public static final int NameUserPrincipal = 8;
public static final int NameCanonicalEx = 9;
public static final int NameServicePrincipal = 10;
public static final int NameDnsDomain = 12;
};
/**
* Retrieves the name of the user or other security principal associated with
* the calling thread. You can specify the format of the returned name.
* @param nameFormat The format of the name.
* @param lpNameBuffer A pointer to a buffer that receives the name in the specified format.
* @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character.
* @return True if the function succeeds. False otherwise.
*/
public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len);
/**
* The AcquireCredentialsHandle function acquires a handle to preexisting credentials
* of a security principal. This handle is required by the AcceptSecurityContext
* and InitializeSecurityContext functions. These can be either preexisting credentials,
* which are established through a system logon that is not described here, or the
* caller can provide alternative credentials.
* @param pszPrincipal
* A pointer to a null-terminated string that specifies the name of the principal whose
* credentials the handle will reference.
* @param pszPackage
* A pointer to a null-terminated string that specifies the name of the security package
* with which these credentials will be used.
* @param fCredentialUse
* A flag that indicates how these credentials will be used.
* @param pvLogonID
* A pointer to a locally unique identifier (LUID) that identifies the user.
* @param pAuthData
* A pointer to package-specific data. This parameter can be NULL, which indicates
* that the default credentials for that package must be used. To use supplied
* credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials
* in this parameter.
* @param pGetKeyFn
* This parameter is not used and should be set to NULL.
* @param pvGetKeyArgument
* This parameter is not used and should be set to NULL.
* @param phCredential
* A pointer to a CredHandle structure to receive the credential handle.
* @param ptsExpiry
* A pointer to a TimeStamp structure that receives the time at which the returned
* credentials expire. The value returned in this TimeStamp structure depends on
* the security package. The security package must return this value in local time.
* @return
* If the function succeeds, the function returns one of the SEC_I_ success codes.
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
int fCredentialUse, LUID pvLogonID,
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
Pointer pvGetKeyArgument, CredHandle phCredential,
TimeStamp ptsExpiry);
/**
* The InitializeSecurityContext function initiates the client side, outbound security
* context from a credential handle. The function is used to build a security context
* between the client application and a remote peer. InitializeSecurityContext returns
* a token that the client must pass to the remote peer, which the peer in turn submits
* to the local security implementation through the AcceptSecurityContext call. The
* token generated should be considered opaque by all callers.
*
* Typically, the InitializeSecurityContext function is called in a loop until a
* sufficient security context is established.
*
* @param phCredential
* A handle to the credentials returned by AcquireCredentialsHandle. This handle is
* used to build the security context. The InitializeSecurityContext function requires
* at least OUTBOUND credentials.
* @param phContext
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
* this pointer is NULL. On the second call, this parameter is a pointer to the handle
* to the partially formed context returned in the phNewContext parameter by the first
* call.
* @param pszTargetName
* A pointer to a null-terminated string that indicates the target of the context.
* The string contents are security-package specific.
* @param fContextReq
* Bit flags that indicate requests for the context. Not all packages can support all
* requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example,
* ISC_REQ_DELEGATE.
* @param Reserved1
* This parameter is reserved and must be set to zero.
* @param TargetDataRep
* The data representation, such as byte ordering, on the target. This parameter can be
* either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
* @param pInput
* A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied
* as input to the package. The pointer must be NULL on the first call to the function.
* On subsequent calls to the function, it is a pointer to a buffer allocated with enough
* memory to hold the token returned by the remote peer.
* @param Reserved2
* This parameter is reserved and must be set to zero.
* @param phNewContext
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
* this pointer receives the new context handle. On the second call, phNewContext can be
* the same as the handle specified in the phContext parameter.
* @param pOutput
* A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure
* that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it
* will be there on output. The system will allocate a buffer for the security token if
* requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer
* descriptor for the security token.
* @param pfContextAttr
* A pointer to a variable to receive a set of bit flags that indicate the attributes of
* the established context. Flags used for this parameter are prefixed with ISC_RET,
* such as ISC_RET_DELEGATE.
* @param ptsExpiry
* A pointer to a TimeStamp structure that receives the expiration time of the context.
* It is recommended that the security package always return this value in local time.
* This parameter is optional and NULL should be passed for short-lived clients.
* @return
* If the function succeeds, the function returns one of the SEC_I_ success codes.
* If the function fails, the function returns one of the SEC_E_ error codes.
*/
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
String pszTargetName, int fContextReq, int Reserved1,
int TargetDataRep, SecBufferDesc pInput, int Reserved2,
CtxtHandle phNewContext, SecBufferDesc pOutput, IntByReference pfContextAttr,
TimeStamp ptsExpiry);
/**
* The DeleteSecurityContext function deletes the local data structures associated
* with the specified security context.
* @param phContext
* Handle of the security context to delete.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
*/
public int DeleteSecurityContext(CtxtHandle phContext);
/**
* The FreeCredentialsHandle function notifies the security system that the
* credentials are no longer needed. An application calls this function to free
* the credential handle acquired in the call to the AcquireCredentialsHandle
* function. When all references to this credential set have been removed, the
* credentials themselves can be removed.
* @param phCredential
* A pointer to the credential handle obtained by using the AcquireCredentialsHandle
* function.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
*/
public int FreeCredentialsHandle(CredHandle phCredential);
/**
* The AcceptSecurityContext function enables the server component of a transport
* application to establish a security context between the server and a remote client.
* The remote client uses the InitializeSecurityContext function to start the process
* of establishing a security context. The server can require one or more reply tokens
* from the remote client to complete establishing the security context.
* @param phCredential
* A handle to the credentials of the server. The server calls the AcquireCredentialsHandle
* function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve
* this handle.
* @param phContext
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
* this pointer is NULL. On subsequent calls, phContext is the handle to the partially
* formed context that was returned in the phNewContext parameter by the first call.
* @param pInput
* A pointer to a SecBufferDesc structure generated by a client call to
* InitializeSecurityContext that contains the input buffer descriptor.
* @param fContextReq
* Bit flags that specify the attributes required by the server to establish the
* context. Bit flags can be combined by using bitwise-OR operations.
* @param TargetDataRep
* The data representation, such as byte ordering, on the target. This parameter can
* be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
* @param phNewContext
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
* this pointer receives the new context handle. On subsequent calls, phNewContext
* can be the same as the handle specified in the phContext parameter.
* @param pOutput
* A pointer to a SecBufferDesc structure that contains the output buffer descriptor.
* This buffer is sent to the client for input into additional calls to
* InitializeSecurityContext. An output buffer may be generated even if the function
* returns SEC_E_OK. Any buffer generated must be sent back to the client application.
* @param pfContextAttr
* A pointer to a variable that receives a set of bit flags that indicate the
* attributes of the established context. For a description of the various attributes,
* see Context Requirements. Flags used for this parameter are prefixed with ASC_RET,
* for example, ASC_RET_DELEGATE.
* @param ptsTimeStamp
* A pointer to a TimeStamp structure that receives the expiration time of the context.
* @return
* This function returns one of SEC_* values.
*/
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
SecBufferDesc pInput, 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 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
* describes a security package that is available within that SSP.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code.
*/
public int EnumerateSecurityPackages(IntByReference pcPackages,
PSecPkgInfo ppPackageInfo);
/**
* The FreeContextBuffer function enables callers of security package functions to free a memory
* buffer that was allocated by the security package as a result of calls to InitializeSecurityContext
* and AcceptSecurityContext.
* @param buffer
* A pointer to memory allocated by the security package.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code.
*/
public int FreeContextBuffer(Pointer buffer);
/**
* The QuerySecurityContextToken function obtains the access token for a client security context
* and uses it directly.
* @param phContext
* Handle of the context to query.
* @param phToken
* Returned handle to the access token.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a nonzero error code. One possible error code return is
* SEC_E_INVALID_HANDLE.
*/
public int QuerySecurityContextToken(CtxtHandle phContext,
HANDLEByReference phToken);
/**
* The ImpersonateSecurityContext function allows a server to impersonate a client by using
* a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken.
* This function allows the application server to act as the client, and thus all necessary
* access controls are enforced.
* @param phContext
* The handle of the context to impersonate. This handle must have been obtained by a call
* to the AcceptSecurityContext function.
* @return
* If the function succeeds, the function returns SEC_E_OK.
* If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or
* SEC_E_UNSUPPORTED_FUNCTION error code.
*/
public int ImpersonateSecurityContext(CtxtHandle phContext);
/**
* Allows a security package to discontinue the impersonation of the caller and restore its
* own security context.
* @param phContext
* Handle of the security context being impersonated. This handle must have been obtained in
* the call to the AcceptSecurityContext function and used in the call to the
* ImpersonateSecurityContext function.
* @return
* If the function succeeds, the return value is SEC_E_OK.
* If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION.
*/
public int RevertSecurityContext(CtxtHandle phContext);
}
@@ -1,102 +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 java.util.ArrayList;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
import com.sun.jna.ptr.IntByReference;
/**
* Secur32 Utility API.
* @author dblock[at]dblock.org
*/
public abstract class Secur32Util {
/**
* An SSPI package.
*/
public static class SecurityPackage {
/**
* Package name.
*/
public String name;
/**
* Package comment.
*/
public String comment;
}
/**
* Retrieves the name of the user or other security principal associated
* with the calling thread.
*
* @param format User name format.
* @return User name in a given format.
*/
public static String getUserNameEx(int format) {
char[] buffer = new char[128];
IntByReference len = new IntByReference(buffer.length);
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
if (! result) {
int rc = Kernel32.INSTANCE.GetLastError();
switch(rc) {
case W32Errors.ERROR_MORE_DATA:
buffer = new char[len.getValue() + 1];
break;
default:
throw new Win32Exception(Native.getLastError());
}
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
}
if (! result) {
throw new Win32Exception(Native.getLastError());
}
return Native.toString(buffer);
}
/**
* Get the security packages installed on the current computer.
* @return
* An array of SSPI security packages.
*/
public static SecurityPackage[] getSecurityPackages() {
IntByReference pcPackages = new IntByReference();
PSecPkgInfo pPackageInfo = new PSecPkgInfo();
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
for(SecPkgInfo packageInfo : packagesInfo) {
SecurityPackage securityPackage = new SecurityPackage();
securityPackage.name = packageInfo.Name.toString();
securityPackage.comment = packageInfo.Comment.toString();
packages.add(securityPackage);
}
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer());
if(W32Errors.SEC_E_OK != rc) {
throw new Win32Exception(rc);
}
return packages.toArray(new SecurityPackage[0]);
}
}
@@ -1,345 +0,0 @@
/* 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.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* The interface for the w32 setup API.
*/
public interface SetupApi extends StdCallLibrary {
SetupApi INSTANCE = (SetupApi)
Native.loadLibrary("setupapi", SetupApi.class, W32APIOptions.DEFAULT_OPTIONS);
/**
* The GUID_DEVINTERFACE_DISK device interface class is defined for hard disk storage devices.
*/
public static Guid.GUID GUID_DEVINTERFACE_DISK = new Guid.GUID(new byte[]
{
0x07, 0x63, (byte) 0xf5, 0x53, (byte) 0xbf, (byte) 0xb6, (byte) 0xd0, 0x11,
(byte) 0x94, (byte) 0xf2, 0x00, (byte) 0xa0, (byte) 0xc9, (byte) 0x1e, (byte) 0xfb, (byte) 0x8b
});
/**
* Return only the device that is associated with the system default device interface, if one is set, for the
* specified device interface classes.
*/
public int DIGCF_DEFAULT = 0x1;
/**
* Return only devices that are currently present in a system.
*/
public int DIGCF_PRESENT = 0x2;
/**
* Return a list of installed devices for all device setup classes or all device interface classes.
*/
public int DIGCF_ALLCLASSES = 0x4;
/**
* Return only devices that are a part of the current hardware profile.
*/
public int DIGCF_PROFILE = 0x8;
/**
* Return devices that support device interfaces for the specified device interface classes. This flag must be set
* in the Flags parameter if the Enumerator parameter specifies a device instance ID.
*/
public int DIGCF_DEVICEINTERFACE = 0x10;
/**
* (Windows XP and later) The function retrieves the device's current removal policy as a DWORD that contains one of
* the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
*/
public int SPDRP_REMOVAL_POLICY = 0x0000001F;
/**
* Removable.
*/
public int CM_DEVCAP_REMOVABLE = 0x00000004;
/**
* The SetupDiGetClassDevs function returns a handle to a device information set that contains requested device
* information elements for a local computer.
*
* @param classGuid
* A pointer to the GUID for a device setup class or a device interface class. This pointer is optional and can be
* NULL. For more information about how to set ClassGuid, see the following Remarks section.
*
* @param enumerator
* A pointer to a NULL-terminated string that specifies:
*
* An identifier (ID) of a Plug and Play (PnP) enumerator. This ID can either be the value's globally unique
* identifier (GUID) or symbolic name. For example, "PCI" can be used to specify the PCI PnP value. Other examples
* of symbolic names for PnP values include "USB," "PCMCIA," and "SCSI".
*
* A PnP device instance ID. When specifying a PnP device instance ID, DIGCF_DEVICEINTERFACE must be set in the
* Flags parameter.
*
* This pointer is optional and can be NULL. If an enumeration value is not used to select devices, set Enumerator
* to NULL.
*
* @param hwndParent
* A handle to the top-level window to be used for a user interface that is associated with installing a device
* instance in the device information set. This handle is optional and can be NULL.
*
* @param flags
* A variable of type DWORD that specifies control options that filter the device information elements that are
* added to the device information set.
*
* @return
* If the operation succeeds, SetupDiGetClassDevs returns a handle to a device information set that contains all
* installed devices that matched the supplied parameters. If the operation fails, the function returns
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
*/
WinNT.HANDLE SetupDiGetClassDevs(Guid.GUID classGuid, Pointer enumerator, Pointer hwndParent, int flags);
/**
* The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory.
*
* @param hDevInfo A handle to the device information set to delete.
* @return The function returns TRUE if it is successful. Otherwise, it returns FALSE and the logged error can be
* retrieved with a call to GetLastError.
*/
boolean SetupDiDestroyDeviceInfoList(WinNT.HANDLE hDevInfo);
/**
* The SetupDiEnumDeviceInterfaces function enumerates the device interfaces that are contained in a device
* information set.
*
* @param hDevInfo
* A pointer to a device information set that contains the device interfaces for which to return information. This
* handle is typically returned by SetupDiGetClassDevs.
*
* @param devInfo
* A pointer to an SP_DEVINFO_DATA structure that specifies a device information element in DeviceInfoSet. This
* parameter is optional and can be NULL. If this parameter is specified, SetupDiEnumDeviceInterfaces constrains
* the enumeration to the interfaces that are supported by the specified device. If this parameter is NULL,
* repeated calls to SetupDiEnumDeviceInterfaces return information about the interfaces that are associated with
* all the device information elements in DeviceInfoSet. This pointer is typically returned by
* SetupDiEnumDeviceInfo.
*
* @param interfaceClassGuid
* A pointer to a GUID that specifies the device interface class for the requested interface.
*
* @param memberIndex
* A zero-based index into the list of interfaces in the device information set. The caller should call this
* function first with MemberIndex set to zero to obtain the first interface. Then, repeatedly increment
* MemberIndex and retrieve an interface until this function fails and GetLastError returns ERROR_NO_MORE_ITEMS.
*
* If DeviceInfoData specifies a particular device, the MemberIndex is relative to only the interfaces exposed by
* that device.
*
* @param deviceInterfaceData
* A pointer to a caller-allocated buffer that contains, on successful return, a completed
* SP_DEVICE_INTERFACE_DATA structure that identifies an interface that meets the search parameters. The caller
* must set DeviceInterfaceData.cbSize to sizeof(SP_DEVICE_INTERFACE_DATA) before calling this function.
*
* @return
* SetupDiEnumDeviceInterfaces returns TRUE if the function completed without error. If the function completed
* with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
*/
boolean SetupDiEnumDeviceInterfaces(WinNT.HANDLE hDevInfo, Pointer devInfo,
Guid.GUID interfaceClassGuid, int memberIndex,
SP_DEVICE_INTERFACE_DATA deviceInterfaceData);
/**
* The SetupDiGetDeviceInterfaceDetail function returns details about a device interface.
*
* @param hDevInfo
* A pointer to the device information set that contains the interface for which to retrieve details. This handle
* is typically returned by SetupDiGetClassDevs.
*
* @param deviceInterfaceData
* A pointer to an SP_DEVICE_INTERFACE_DATA structure that specifies the interface in DeviceInfoSet for which to
* retrieve details. A pointer of this type is typically returned by SetupDiEnumDeviceInterfaces.
*
* @param deviceInterfaceDetailData
* A pointer to an SP_DEVICE_INTERFACE_DETAIL_DATA structure to receive information about the specified interface.
* This parameter is optional and can be NULL. This parameter must be NULL if DeviceInterfaceDetailSize is zero.
* If this parameter is specified, the caller must set DeviceInterfaceDetailData.cbSize to
* sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) before calling this function. The cbSize member always contains the
* size of the fixed part of the data structure, not a size reflecting the variable-length string at the end.
*
* @param deviceInterfaceDetailDataSize
* The size of the DeviceInterfaceDetailData buffer. The buffer must be at least
* (offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA, DevicePath) + sizeof(TCHAR)) bytes, to contain the fixed part of the
* structure and a single NULL to terminate an empty MULTI_SZ string.
*
* This parameter must be zero if DeviceInterfaceDetailData is NULL.
*
* @param requiredSize
* A pointer to a variable of type DWORD that receives the required size of the DeviceInterfaceDetailData buffer.
* This size includes the size of the fixed part of the structure plus the number of bytes required for the
* variable-length device path string. This parameter is optional and can be NULL.
*
* @param deviceInfoData
* A pointer to a buffer that receives information about the device that supports the requested interface. The
* caller must set DeviceInfoData.cbSize to sizeof(SP_DEVINFO_DATA). This parameter is optional and can be NULL.
*
* @return
* SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. If the function completed
* with an error, FALSE is returned and the error code for the failure can be retrieved by calling GetLastError.
*/
boolean SetupDiGetDeviceInterfaceDetail(WinNT.HANDLE hDevInfo,
SP_DEVICE_INTERFACE_DATA deviceInterfaceData, Pointer deviceInterfaceDetailData,
int deviceInterfaceDetailDataSize, IntByReference requiredSize, SP_DEVINFO_DATA deviceInfoData);
/**
* The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property.
*
* @param DeviceInfoSet
* A handle to a device information set that contains a device information element that represents the device for
* which to retrieve a Plug and Play property.
*
* @param DeviceInfoData
* A pointer to an SP_DEVINFO_DATA structure that specifies the device information element in DeviceInfoSet.
*
* @param Property
* Specifies the property to be retrieved.
*
* @param PropertyRegDataType
* A pointer to a variable that receives the data type of the property that is being retrieved. This is one of the
* standard registry data types. This parameter is optional and can be NULL.
*
* @param PropertyBuffer
* A pointer to a buffer that receives the property that is being retrieved. If this parameter is set to NULL, and
* PropertyBufferSize is also set to zero, the function returns the required size for the buffer in RequiredSize.
*
* @param PropertyBufferSize
* The size, in bytes, of the PropertyBuffer buffer.
*
* @param RequiredSize
* A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer
* that is required to hold the data for the requested property. This parameter is optional and can be NULL.
*
* @return
* SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the
* logged error can be retrieved by making a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the
* ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is
* not valid.
*/
boolean SetupDiGetDeviceRegistryProperty(WinNT.HANDLE DeviceInfoSet, SP_DEVINFO_DATA DeviceInfoData,
int Property, IntByReference PropertyRegDataType, Pointer PropertyBuffer, int PropertyBufferSize,
IntByReference RequiredSize);
/**
* An SP_DEVICE_INTERFACE_DATA structure defines a device interface in a device information set.
*/
public static class SP_DEVICE_INTERFACE_DATA extends Structure {
public static class ByReference extends SP_DEVINFO_DATA implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public SP_DEVICE_INTERFACE_DATA() {
cbSize = size();
}
public SP_DEVICE_INTERFACE_DATA(Pointer memory) {
super(memory);
read();
}
/**
* The size, in bytes, of the SP_DEVICE_INTERFACE_DATA structure.
*/
public int cbSize;
/**
* The GUID for the class to which the device interface belongs.
*/
public Guid.GUID InterfaceClassGuid;
/**
* Can be one or more of the following:
* SPINT_ACTIVE - The interface is active (enabled).
* SPINT_DEFAULT - The interface is the default interface for the device class.
* SPINT_REMOVED - The interface is removed.
*/
public int Flags;
/**
* Reserved. Do not use.
*/
public Pointer Reserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "Flags", "Reserved" });
}
}
/**
* An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set.
*/
public static class SP_DEVINFO_DATA extends Structure {
public static class ByReference extends SP_DEVINFO_DATA implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public SP_DEVINFO_DATA() {
cbSize = size();
}
public SP_DEVINFO_DATA(Pointer memory) {
super(memory);
read();
}
/**
* The size, in bytes, of the SP_DEVINFO_DATA structure.
*/
public int cbSize;
/**
* The GUID of the device's setup class.
*/
public Guid.GUID InterfaceClassGuid;
/**
* An opaque handle to the device instance (also known as a handle to the devnode).
*
* Some functions, such as SetupDiXxx functions, take the whole SP_DEVINFO_DATA structure as input to identify a
* device in a device information set. Other functions, such as CM_Xxx functions like CM_Get_DevNode_Status,
* take this DevInst handle as input.
*/
public int DevInst;
/**
* Reserved. For internal use only.
*/
public Pointer Reserved;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbSize", "InterfaceClassGuid", "DevInst", "Reserved" });
}
}
}
@@ -1,210 +0,0 @@
/* 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.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.WinDef.UINT_PTR;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.HRESULT;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Shell32.dll Interface.
*/
public interface Shell32 extends ShellAPI, StdCallLibrary {
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
W32APIOptions.UNICODE_OPTIONS);
/**
* This function can be used to copy, move, rename, or delete a file system object.
* @param fileop
* Address of an SHFILEOPSTRUCT structure that contains information this function
* needs to carry out the specified operation.
* @return
* Returns zero if successful, or nonzero otherwise.
*/
int SHFileOperation(SHFILEOPSTRUCT fileop);
/**
* Takes the CSIDL of a folder and returns the path.
* @param hwndOwner
* Handle to an owner window. This parameter is typically set to NULL. If it is not NULL,
* and a dial-up connection needs to be made to access the folder, a user interface (UI)
* prompt will appear in this window.
* @param nFolder
* A CSIDL value that identifies the folder whose path is to be retrieved. Only real
* folders are valid. If a virtual folder is specified, this function will fail. You can
* force creation of a folder with SHGetFolderPath by combining the folder's CSIDL with
* CSIDL_FLAG_CREATE.
* @param hToken
* An access token that can be used to represent a particular user.
* @param dwFlags
* Flags to specify which path is to be returned.
* @param pszPath
* Pointer to a null-terminated string of length MAX_PATH which will receive the path.
* If an error occurs or S_FALSE is returned, this string will be empty.
* @return
* Returns standard HRESULT codes.
*/
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
char[] pszPath);
/**
* Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
* The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call
* given a suitable interface definition for IShellFolder
* @param ppshf A place to put the IShellFolder interface pointer
* @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
*/
HRESULT SHGetDesktopFolder( PointerByReference ppshf );
/**
* Performs an operation on a specified file.
*
* @param hwnd
* A handle to the owner window used for displaying a UI or error messages. This value can be NULL if the
* operation is not associated with a window.
*
* @param lpOperation
* A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be
* performed. The set of available verbs depends on the particular file or folder. Generally, the actions
* available from an object's shortcut menu are available verbs. The following verbs are commonly used:
*
* edit
* Launches an editor and opens the document for editing. If lpFile is not a document file, the function will
* fail.
* explore
* Explores a folder specified by lpFile.
* find
* Initiates a search beginning in the directory specified by lpDirectory.
* open
* Opens the item specified by the lpFile parameter. The item can be a file or folder.
* print
* Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
* NULL
* In systems prior to Windows 2000, the default verb is used if it is valid and available in the registry. If
* not, the "open" verb is used.
* In Windows 2000 and later, the default verb is used if available. If not, the "open" verb is used. If neither
* verb is available, the system uses the first verb listed in the registry.
*
* @param lpFile
* A pointer to a null-terminated string that specifies the file or object on which to execute the specified verb.
* To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported
* on all objects. For example, not all document types support the "print" verb. If a relative path is used for
* the lpDirectory parameter do not use a relative path for lpFile.
*
* @param lpParameters
* If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies
* the parameters to be passed to the application. The format of this string is determined by the verb that is to
* be invoked. If lpFile specifies a document file, lpParameters should be NULL.
*
* @param lpDirectory
* A pointer to a null-terminated string that specifies the default (working) directory for the action. If this
* value is NULL, the current working directory is used. If a relative path is provided at lpFile, do not use a
* relative path for lpDirectory.
*
* @param nShowCmd
* The flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document
* file, the flag is simply passed to the associated application. It is up to the application to decide how to
* handle it.
*
* @return
* If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value
* 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.
* ERROR_PATH_NOT_FOUND The specified path was not found.
* ERROR_BAD_FORMAT The .exe file is invalid (non-Win32 .exe or error in .exe image).
* SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
* SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
* SE_ERR_DDEBUSY The DDE transaction could not be completed because other DDE transactions were being processed.
* SE_ERR_DDEFAIL The DDE transaction failed.
* SE_ERR_DDETIMEOUT The DDE transaction could not be completed because the request timed out.
* SE_ERR_DLLNOTFOUND The specified DLL was not found.
* SE_ERR_FNF The specified file was not found.
* SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be
* returned if you attempt to print a file that is not printable.
* SE_ERR_OOM There was not enough memory to complete the operation.
* SE_ERR_PNF The specified path was not found.
* SE_ERR_SHARE A sharing violation occurred.
*/
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);
/**
* SHAppBarMessage function
*
* @param dwMessage
* Appbar message value to send. This parameter can be one of the following values.
* {@link ShellAPI#ABM_NEW} Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar.
* {@link ShellAPI#ABM_REMOVE} Unregisters an appbar, removing the bar from the system's internal list.
* {@link ShellAPI#ABM_QUERYPOS} Requests a size and screen position for an appbar.
* {@link ShellAPI#ABM_SETPOS} Sets the size and screen position of an appbar.
* {@link ShellAPI#ABM_GETSTATE} Retrieves the autohide and always-on-top states of the Windows taskbar.
* {@link ShellAPI#ABM_GETTASKBARPOS} Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app barsÑthe working area available to your applicationÑ, use the GetMonitorInfo function.
* {@link ShellAPI#ABM_ACTIVATE} Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate.
* {@link ShellAPI#ABM_GETAUTOHIDEBAR} Retrieves the handle to the autohide appbar associated with a particular edge of the screen.
* {@link ShellAPI#ABM_SETAUTOHIDEBAR} Registers or unregisters an autohide appbar for an edge of the screen.
* {@link ShellAPI#ABM_WINDOWPOSCHANGED} Notifies the system when an appbar's position has changed.
* {@link ShellAPI#ABM_SETSTATE} Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes.
*
* @param pData
* A pointer to an APPBARDATA structure. The content of the structure on entry and on exit depends on the value set in the dwMessage parameter. See the individual message pages for specifics.
*
* @return This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar message sent.
*
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787951(v=vs.85).aspx">ABM_NEW</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787955(v=vs.85).aspx">ABM_REMOVE</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787953(v=vs.85).aspx">ABM_QUERYPOS</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787959(v=vs.85).aspx">ABM_SETPOS</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787947(v=vs.85).aspx">ABM_GETSTATE</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787949(v=vs.85).aspx">ABM_GETTASKBARPOS</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787943(v=vs.85).aspx">ABM_ACTIVATE</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787945(v=vs.85).aspx">ABM_GETAUTOHIDEBAR</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787957(v=vs.85).aspx">ABM_SETAUTOHIDEBAR</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787963(v=vs.85).aspx">ABM_WINDOWPOSCHANGED</a>
* @see <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787961(v=vs.85).aspx">ABM_SETSTATE</a>
*
*/
UINT_PTR SHAppBarMessage( DWORD dwMessage, APPBARDATA pData );
}
@@ -1,76 +0,0 @@
/* Copyright (c) 2010, 2013 Daniel Doubrovkine, Markus Karg, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinNT.HRESULT;
/**
* Shell32 Utility API.
* @author dblock[at]dblock.org
* @author markus[at]headcrashing[dot]eu
*/
public abstract class Shell32Util {
/**
* Get a special folder path.
* @param hwnd
* Parent window.
* @param nFolder
* Folder CSLID.
* @param dwFlags
* Flags.
* @return
* Special folder.
*/
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
nFolder, null, dwFlags,
pszPath);
if (! hr.equals(W32Errors.S_OK)) {
throw new Win32Exception(hr);
}
return Native.toString(pszPath);
}
/**
* Get a special folder path.
* @param nFolder
* Folder CSLID.
* @return
* Special folder path.
*/
public static String getFolderPath(int nFolder) {
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
}
/**
* Retrieves the path of a special folder, identified by its CSIDL.
*
* @param csidl
* A CSIDL that identifies the folder of interest. If a virtual folder is specified, this function will fail.
* @param create
* Indicates whether the folder should be created if it does not already exist. If this value is nonzero, the folder is created. If this value is
* zero, the folder is not created.
* @return The drive and path of the specified folder
*/
public static final String getSpecialFolderPath(final int csidl, final boolean create) {
final char[] pszPath = new char[WinDef.MAX_PATH];
if (!Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, csidl, create))
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
return Native.toString(pszPath);
}
}
@@ -1,209 +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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.WinDef.DWORD;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.RECT;
import com.sun.jna.platform.win32.WinDef.UINT;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from ShellAPI.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShellAPI extends StdCallLibrary {
int STRUCTURE_ALIGNMENT = Platform.is64Bit() ? Structure.ALIGN_DEFAULT : Structure.ALIGN_NONE;
int FO_MOVE = 0x0001;
int FO_COPY = 0x0002;
int FO_DELETE = 0x0003;
int FO_RENAME = 0x0004;
int FOF_MULTIDESTFILES = 0x0001;
int FOF_CONFIRMMOUSE = 0x0002;
int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
int PO_DELETE = 0x0013; // printer is being deleted
int PO_RENAME = 0x0014; // printer is being renamed
int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
/**
* Contains information that the SHFileOperation function uses to perform file operations.
*/
public static class SHFILEOPSTRUCT extends Structure {
/**
* A window handle to the dialog box to display information about
* the status of the file operation.
*/
public HANDLE hwnd;
/**
* An FO_* value that indicates which operation to perform.
*/
public int wFunc;
/**
* A pointer to one or more source file names, double null-terminated.
*/
public WString pFrom;
/**
* A pointer to the destination file or directory name.
*/
public WString pTo;
/**
* Flags that control the file operation.
*/
public short fFlags;
/**
* When the function returns, this member contains TRUE if any file operations
* were aborted before they were completed; otherwise, FALSE. An operation can
* be manually aborted by the user through UI or it can be silently aborted by
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
*/
public boolean fAnyOperationsAborted;
/**
* When the function returns, this member contains a handle to a name mapping
* object that contains the old and new names of the renamed files. This member
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
*/
public Pointer pNameMappings;
/**
* A pointer to the title of a progress dialog box. This is a null-terminated string.
*/
public WString lpszProgressTitle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "hwnd", "wFunc", "pFrom", "pTo", "fFlags", "fAnyOperationsAborted", "pNameMappings", "lpszProgressTitle" });
}
/** Use this to encode <code>pFrom/pTo</code> paths. */
public String encodePaths(String[] paths) {
String encoded = "";
for (int i=0; i < paths.length;i++) {
encoded += paths[i];
encoded += "\0";
}
return encoded + "\0";
}
}
/**
* Appbar message value to send. This parameter can be one of the following
* values.
*/
int ABM_NEW = 0x00000000;
/**
* Registers a new appbar and specifies the message identifier that the
* system should use to send notification messages to the appbar.
*/
int ABM_REMOVE = 0x00000001;
/** Unregisters an appbar, removing the bar from the system's internal list.*/
int ABM_QUERYPOS = 0x00000002;
/** Requests a size and screen position for an appbar. */
int ABM_SETPOS = 0x00000003;
/** Sets the size and screen position of an appbar. */
int ABM_GETSTATE = 0x00000004;
/** Retrieves the autohide and always-on-top states of the Windows taskbar. */
int ABM_GETTASKBARPOS = 0x00000005;
/**
* Retrieves the bounding rectangle of the Windows taskbar. Note that this
* applies only to the system taskbar. Other objects, particularly toolbars
* supplied with third-party software, also can be present. As a result,
* some of the screen area not covered by the Windows taskbar might not be
* visible to the user. To retrieve the area of the screen not covered by
* both the taskbar and other app barsÑthe working area available to your
* applicationÑ, use the GetMonitorInfo function.
*/
int ABM_ACTIVATE = 0x00000006;
/**
* Notifies the system to activate or deactivate an appbar. The lParam
* member of the APPBARDATA pointed to by pData is set to TRUE to activate
* or FALSE to deactivate.
*/
int ABM_GETAUTOHIDEBAR = 0x00000007;
/**
* Retrieves the handle to the autohide appbar associated with a particular
* edge of the screen.
*/
int ABM_SETAUTOHIDEBAR = 0x00000008;
/** Registers or unregisters an autohide appbar for an edge of the screen. */
int ABM_WINDOWPOSCHANGED = 0x00000009;
/** Notifies the system when an appbar's position has changed. */
int ABM_SETSTATE = 0x0000000A;
/** Left edge. */
int ABE_LEFT = 0;
/** Top edge. */
int ABE_TOP = 1;
/** Right edge. */
int ABE_RIGHT = 2;
/** Bottom edge. */
int ABE_BOTTOM = 3;
/**
* Contains information about a system appbar message.
*/
public static class APPBARDATA extends Structure {
public static class ByReference extends APPBARDATA implements Structure.ByReference {
}
public DWORD cbSize;
public HWND hWnd;
public UINT uCallbackMessage;
public UINT uEdge;
public RECT rc;
public LPARAM lParam;
public APPBARDATA() {
super();
}
public APPBARDATA(Pointer p) {
super(p);
}
@Override
protected List getFieldOrder() {
return Arrays.asList("cbSize", "hWnd", "uCallbackMessage", "uEdge", "rc", "lParam");
}
}
}
@@ -1,84 +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 com.sun.jna.platform.win32.WinDef.DWORD;
/**
* Ported from ShlObj.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface ShlObj {
DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
int CSIDL_DESKTOP = 0x0000; // <desktop>
int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
int CSIDL_PERSONAL = 0x0005; // My Documents
int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
int CSIDL_RECENT = 0x0008; // <user name>\Recent
int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
int CSIDL_DRIVES = 0x0011; // My Computer
int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
int CSIDL_FONTS = 0x0014; // windows\fonts
int CSIDL_TEMPLATES = 0x0015;
int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
int CSIDL_COMMON_FAVORITES = 0x001f;
int CSIDL_INTERNET_CACHE = 0x0020;
int CSIDL_COOKIES = 0x0021;
int CSIDL_HISTORY = 0x0022;
int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
int CSIDL_PROFILE = 0x0028; // USERPROFILE
int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
}
@@ -1,451 +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 java.util.Arrays;
import java.util.List;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from Sspi.h.
* Microsoft Windows SDK 6.0A.
* @author dblock[at]dblock.org
*/
public interface Sspi extends StdCallLibrary {
/**
* Maximum size in bytes of a security token.
*/
int MAX_TOKEN_SIZE = 12288;
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
/**
* Validate an incoming server credential. Inbound credentials might be validated
* by using an authenticating authority when InitializeSecurityContext or
* AcceptSecurityContext is called. If such an authority is not available, the function will
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
*/
int SECPKG_CRED_INBOUND = 1;
/**
* Allow a local client credential to prepare an outgoing token.
*/
int SECPKG_CRED_OUTBOUND = 2;
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
/**
* Specifies Native data representation.
*/
int SECURITY_NATIVE_DREP = 0x10;
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
/**
* The security package allocates output buffers for you.
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
*/
int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
/**
* Encrypt messages by using the EncryptMessage function.
*/
int ISC_REQ_CONFIDENTIALITY = 0x00000010;
/**
* The security context will not handle formatting messages. This value is the default.
*/
int ISC_REQ_CONNECTION = 0x00000800;
/**
* The server can use the context to authenticate to other servers as the client.
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
* Ignore this flag for constrained delegation.
*/
int ISC_REQ_DELEGATE = 0x00000001;
/**
* When errors occur, the remote party will be notified.
*/
int ISC_REQ_EXTENDED_ERROR = 0x00004000;
/**
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
*/
int ISC_REQ_INTEGRITY = 0x00010000;
/**
* The mutual authentication policy of the service will be satisfied.
*/
int ISC_REQ_MUTUAL_AUTH = 0x00000002;
/**
* Detect replayed messages that have been encoded by using the
* EncryptMessage or MakeSignature functions.
*/
int ISC_REQ_REPLAY_DETECT = 0x00000004;
/**
* Detect messages received out of sequence.
*/
int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
/**
* Support a stream-oriented connection.
*/
int ISC_REQ_STREAM = 0x00008000;
/**
* Version of the SecBuffer struct.
*/
int SECBUFFER_VERSION = 0;
/**
* This is a placeholder in the buffer array.
*/
int SECBUFFER_EMPTY = 0;
/**
* This buffer type is used for common data. The security package can read
* and write this data.
*/
int SECBUFFER_DATA = 1;
/**
* This buffer type is used to indicate the security token portion of the message.
* This is read-only for input parameters or read/write for output parameters.
*/
int SECBUFFER_TOKEN = 2;
/**
* Security handle.
*/
public static class SecHandle extends Structure {
public Pointer dwLower;
public Pointer dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
public static class ByReference extends SecHandle implements Structure.ByReference {
}
/**
* An empty SecHandle.
*/
public SecHandle() {
}
/**
* Returns true if the handle is NULL.
* @return
* True if NULL, False otherwise.
*/
public boolean isNull() {
return dwLower == null && dwUpper == null;
}
}
/**
* A pointer to a SecHandle
*/
public static class PSecHandle extends Structure {
public static class ByReference extends PSecHandle implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecHandle.ByReference secHandle;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "secHandle" });
}
public PSecHandle() {
}
public PSecHandle(SecHandle h) {
super(h.getPointer());
read();
}
}
/**
* Credentials handle.
*/
public static class CredHandle extends SecHandle {
}
/**
* Security context handle.
*/
public static class CtxtHandle extends SecHandle {
}
/**
* The SecBuffer structure describes a buffer allocated by a transport application
* to pass to a security package.
*/
public static class SecBuffer extends Structure {
/**
* A ByReference SecBuffer.
*/
public static class ByReference extends SecBuffer implements Structure.ByReference {
/**
* Create a SECBUFFER_EMPTY SecBuffer.
*/
public ByReference() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public ByReference(int type, int size) {
super(type, size);
}
public ByReference(int type, byte[] token) {
super(type, token);
}
}
/**
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
*/
public int cbBuffer;
/**
* Bit flags that indicate the type of buffer. Must be one of the values of
* the SecBufferType enumeration.
*/
public int BufferType = SECBUFFER_EMPTY;
/**
* A pointer to a buffer.
*/
public Pointer pvBuffer;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "cbBuffer", "BufferType", "pvBuffer" });
}
/**
* Create a new SECBUFFER_EMPTY buffer.
*/
public SecBuffer() {
}
/**
* Create a SecBuffer of a given type and size.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param size
* Buffer size, eg. MAX_TOKEN_SIZE.
*/
public SecBuffer(int type, int size) {
cbBuffer = size;
pvBuffer = new Memory(size);
BufferType = type;
}
/**
* Create a SecBuffer of a given type with initial data.
* @param type
* Buffer type, one of SECBUFFER_EMTPY, etc.
* @param token
* Existing token.
*/
public SecBuffer(int type, byte[] token) {
cbBuffer = token.length;
pvBuffer = new Memory(token.length);
pvBuffer.write(0, token, 0, token.length);
BufferType = type;
}
/**
* Get buffer bytes.
* @return
* Raw buffer bytes.
*/
public byte[] getBytes() {
return pvBuffer == null ? null : pvBuffer.getByteArray(0, cbBuffer);
}
}
public static class SecBufferDesc extends Structure {
/**
* Version number.
*/
public int ulVersion = SECBUFFER_VERSION;
/**
* Number of buffers.
*/
public int cBuffers = 1;
/**
* Pointer to array of buffers.
*/
public SecBuffer.ByReference[] pBuffers = new SecBuffer.ByReference[] {
new SecBuffer.ByReference()
};
protected List getFieldOrder() {
return Arrays.asList(new String[] { "ulVersion", "cBuffers", "pBuffers" });
}
/**
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
*/
public SecBufferDesc() {
}
/**
* Create a new SecBufferDesc with initial data.
* @param type
* Token type.
* @param token
* Initial token data.
*/
public SecBufferDesc(int type, byte[] token) {
pBuffers[0] = new SecBuffer.ByReference(type, token);
}
/**
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
* @param type
* @param tokenSize
*/
public SecBufferDesc(int type, int tokenSize) {
pBuffers[0] = new SecBuffer.ByReference(type, tokenSize);
}
public byte[] getBytes() {
return pBuffers[0].getBytes();
}
}
/**
* A security integer.
*/
public static class SECURITY_INTEGER extends Structure {
public int dwLower;
public int dwUpper;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "dwLower", "dwUpper" });
}
/**
* An security integer of 0.
*/
public SECURITY_INTEGER() {
}
}
/**
* A timestamp.
*/
public static class TimeStamp extends SECURITY_INTEGER {
}
/**
* A pointer to an array of SecPkgInfo structures.
*/
public static class PSecPkgInfo extends Structure {
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
}
/**
* The first entry in an array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference pPkgInfo;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "pPkgInfo" });
}
public PSecPkgInfo() {
}
/**
* An array of SecPkgInfo structures.
*/
public SecPkgInfo.ByReference[] toArray(int size) {
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
}
}
/**
* The SecPkgInfo structure provides general information about a security package,
* such as its name and capabilities.
*/
public static class SecPkgInfo extends Structure {
/**
* A reference pointer to a SecPkgInfo structure.
*/
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
}
/**
* Set of bit flags that describes the capabilities of the security package.
*/
public int fCapabilities;
/**
* Specifies the version of the package protocol. Must be 1.
*/
public short wVersion = 1;
/**
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
*/
public short wRPCID;
/**
* Specifies the maximum size, in bytes, of the token.
*/
public int cbMaxToken;
/**
* Pointer to a null-terminated string that contains the name of the security package.
*/
public WString Name;
/**
* Pointer to a null-terminated string. This can be any additional string passed
* back by the package.
*/
public WString Comment;
protected List getFieldOrder() {
return Arrays.asList(new String[] { "fCapabilities", "wVersion", "wRPCID", "cbMaxToken", "Name", "Comment" });
}
/**
* Create a new package info.
*/
public SecPkgInfo() {
}
}
}
@@ -1,146 +0,0 @@
/* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
/**
* Interface for the Tlhelp32.h header file.
*/
public interface Tlhelp32 extends StdCallLibrary {
/**
* Includes all heaps of the process specified in th32ProcessID in the snapshot. To enumerate the heaps, see
* Heap32ListFirst.
*/
WinDef.DWORD TH32CS_SNAPHEAPLIST = new WinDef.DWORD(0x00000001);
/**
* Includes all processes in the system in the snapshot. To enumerate the processes, see Process32First.
*/
WinDef.DWORD TH32CS_SNAPPROCESS = new WinDef.DWORD(0x00000002);
/**
* Includes all threads in the system in the snapshot. To enumerate the threads, see Thread32First.
*/
WinDef.DWORD TH32CS_SNAPTHREAD = new WinDef.DWORD(0x00000004);
/**
* Includes all modules of the process specified in th32ProcessID in the snapshot. To enumerate the modules, see
* Module32First. If the function fails with ERROR_BAD_LENGTH, retry the function until it succeeds.
*/
WinDef.DWORD TH32CS_SNAPMODULE = new WinDef.DWORD(0x00000008);
/**
* Includes all 32-bit modules of the process specified in th32ProcessID in the snapshot when called from a 64-bit
* process. This flag can be combined with TH32CS_SNAPMODULE or TH32CS_SNAPALL. If the function fails with
* ERROR_BAD_LENGTH, retry the function until it succeeds.
*/
WinDef.DWORD TH32CS_SNAPMODULE32 = new WinDef.DWORD(0x00000010);
/**
* Includes all processes and threads in the system, plus the heaps and modules of the process specified in th32ProcessID.
*/
WinDef.DWORD TH32CS_SNAPALL = new WinDef.DWORD((TH32CS_SNAPHEAPLIST.intValue() |
TH32CS_SNAPPROCESS.intValue() | TH32CS_SNAPTHREAD.intValue() | TH32CS_SNAPMODULE.intValue()));
/**
* Indicates that the snapshot handle is to be inheritable.
*/
WinDef.DWORD TH32CS_INHERIT = new WinDef.DWORD(0x80000000);
/**
* Describes an entry from a list of the processes residing in the system address space when a snapshot was taken.
*/
public static class PROCESSENTRY32 extends Structure {
public static class ByReference extends PROCESSENTRY32 implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public PROCESSENTRY32() {
dwSize = new WinDef.DWORD(size());
}
public PROCESSENTRY32(Pointer memory) {
super(memory);
read();
}
/**
* The size of the structure, in bytes. Before calling the Process32First function, set this member to
* sizeof(PROCESSENTRY32). If you do not initialize dwSize, Process32First fails.
*/
public WinDef.DWORD dwSize;
/**
* This member is no longer used and is always set to zero.
*/
public WinDef.DWORD cntUsage;
/**
* The process identifier.
*/
public WinDef.DWORD th32ProcessID;
/**
* This member is no longer used and is always set to zero.
*/
public BaseTSD.ULONG_PTR th32DefaultHeapID;
/**
* This member is no longer used and is always set to zero.
*/
public WinDef.DWORD th32ModuleID;
/**
* The number of execution threads started by the process.
*/
public WinDef.DWORD cntThreads;
/**
* The identifier of the process that created this process (its parent process).
*/
public WinDef.DWORD th32ParentProcessID;
/**
* The base priority of any threads created by this process.
*/
public WinDef.LONG pcPriClassBase;
/**
* This member is no longer used, and is always set to zero.
*/
public WinDef.DWORD dwFlags;
/**
* The name of the executable file for the process. To retrieve the full path to the executable file, call the
* Module32First function and check the szExePath member of the MODULEENTRY32 structure that is returned.
* However, if the calling process is a 32-bit process, you must call the QueryFullProcessImageName function to
* 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
@@ -1,51 +0,0 @@
/*
* 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());
}
}
@@ -1,412 +0,0 @@
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" });
}
}
}
@@ -1,124 +0,0 @@
/* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import java.util.Arrays;
import java.util.List;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
/**
* Interface for the VerRsrc.h header file.
*/
public interface VerRsrc extends StdCallLibrary {
/**
* Contains version information for a file. This information is language and code page independent.
*/
public static class VS_FIXEDFILEINFO extends Structure {
public static class ByReference extends VS_FIXEDFILEINFO implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public VS_FIXEDFILEINFO() {
}
public VS_FIXEDFILEINFO(Pointer memory) {
super(memory);
read();
}
/**
* Contains the value 0xFEEF04BD. This is used with the szKey member of the VS_VERSIONINFO structure when
* searching a file for the VS_FIXEDFILEINFO structure.
*/
public WinDef.DWORD dwSignature;
/**
* The binary version number of this structure. The high-order word of this member contains the major version
* number, and the low-order word contains the minor version number.
*/
public WinDef.DWORD dwStrucVersion;
/**
* The most significant 32 bits of the file's binary version number. This member is used with dwFileVersionLS to
* form a 64-bit value used for numeric comparisons.
*/
public WinDef.DWORD dwFileVersionMS;
/**
* The least significant 32 bits of the file's binary version number. This member is used with dwFileVersionMS
* to form a 64-bit value used for numeric comparisons.
*/
public WinDef.DWORD dwFileVersionLS;
/**
* The most significant 32 bits of the binary version number of the product with which this file was
* distributed. This member is used with dwProductVersionLS to form a 64-bit value used for numeric comparisons.
*/
public WinDef.DWORD dwProductVersionMS;
/**
* The least significant 32 bits of the binary version number of the product with which this file was
* distributed. This member is used with dwProductVersionMS to form a 64-bit value used for numeric comparisons.
*/
public WinDef.DWORD dwProductVersionLS;
/**
* Contains a bitmask that specifies the valid bits in dwFileFlags. A bit is valid only if it was defined when
* the file was created.
*/
public WinDef.DWORD dwFileFlagsMask;
/**
* Contains a bitmask that specifies the Boolean attributes of the file. This member can include one or more of
* the following values.
*/
public WinDef.DWORD dwFileFlags;
/**
* The operating system for which this file was designed.
*/
public WinDef.DWORD dwFileOS;
/**
* The general type of file.
*/
public WinDef.DWORD dwFileType;
/**
* The function of the file. The possible values depend on the value of dwFileType.
*/
public WinDef.DWORD dwFileSubtype;
/**
* The most significant 32 bits of the file's 64-bit binary creation date and time stamp.
*/
public WinDef.DWORD dwFileDateMS;
/**
* 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 +0,0 @@
/* 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.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
/**
* Provides access to the w32 version library.
*/
public interface Version extends StdCallLibrary {
Version INSTANCE = (Version)
Native.loadLibrary("version", Version.class, W32APIOptions.DEFAULT_OPTIONS);
/**
* Determines whether the operating system can retrieve version information for a specified file. If version
* information is available, GetFileVersionInfoSize returns the size, in bytes, of that information.
*
* @param lptstrFilename
* The name of the file of interest. The function uses the search sequence specified by the LoadLibrary function.
*
* @param lpdwHandle
* A pointer to a variable that the function sets to zero.
*
* @return
* If the function succeeds, the return value is the size, in bytes, of the file's version information.
*
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
*/
int GetFileVersionInfoSize(String lptstrFilename, IntByReference lpdwHandle);
/**
* Retrieves version information for the specified file.
*
* @param lptstrFilename
* The name of the file. If a full path is not specified, the function uses the search sequence specified by the
* LoadLibrary function.
*
* @param dwHandle
* This parameter is ignored.
*
* @param dwLen
* The size, in bytes, of the buffer pointed to by the lpData parameter.
*
* Call the GetFileVersionInfoSize function first to determine the size, in bytes, of a file's version
* information. The dwLen member should be equal to or greater than that value.
*
* If the buffer pointed to by lpData is not large enough, the function truncates the file's version information
* to the size of the buffer.
*
* @param lpData
* Pointer to a buffer that receives the file-version information.
*
* You can use this value in a subsequent call to the VerQueryValue function to retrieve data from the buffer.
*
* @return
* If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
*/
boolean GetFileVersionInfo(String lptstrFilename, int dwHandle, int dwLen, Pointer lpData);
/**
* Retrieves specified version information from the specified version-information resource. To retrieve the
* appropriate resource, before you call VerQueryValue, you must first call the GetFileVersionInfoSize function, and
* then the GetFileVersionInfo function.
*
* @param pBlock
* The version-information resource returned by the GetFileVersionInfo function.
*
* @param lpSubBlock
* The version-information value to be retrieved.
*
* @param lplpBuffer
* When this method returns, contains the address of a pointer to the requested version information in the buffer
* pointed to by pBlock. The memory pointed to by lplpBuffer is freed when the associated pBlock memory is freed.
*
* @param puLen
* When this method returns, contains a pointer to the size of the requested data pointed to by lplpBuffer: for
* version information values, the length in characters of the string stored at lplpBuffer; for translation array
* values, the size in bytes of the array stored at lplpBuffer; and for root block, the size in bytes of the
* structure.
*
* @return
* If the specified version-information structure exists, and version information is available, the return value
* is nonzero. If the address of the length buffer is zero, no value is available for the specified
* version-information name.
*
* If the specified name does not exist or the specified resource is not valid, the return value is zero.
*/
boolean VerQueryValue(Pointer pBlock, String lpSubBlock, PointerByReference lplpBuffer, IntByReference puLen);
}

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